You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
14 KiB

5 years ago
  1. <template lang='pug'>
  2. v-app.admin
  3. nav-header(hide-search)
  4. template(slot='mid')
  5. v-spacer
  6. .overline.grey--text {{$t('admin:adminArea')}}
  7. v-spacer
  8. v-navigation-drawer.pb-0.admin-sidebar(v-model='adminDrawerShown', app, fixed, clipped, :right='$vuetify.rtl', permanent, width='300')
  9. vue-scroll(:ops='scrollStyle')
  10. v-list(dense, nav)
  11. v-list-item(to='/dashboard', color='primary')
  12. v-list-item-avatar(size='24'): v-icon mdi-view-dashboard-variant
  13. v-list-item-title {{ $t('admin:dashboard.title') }}
  14. template(v-if='hasPermission([`manage:system`, `manage:navigation`, `write:pages`, `manage:pages`, `delete:pages`])')
  15. v-divider.my-2
  16. v-subheader.pl-4 {{ $t('admin:nav.site') }}
  17. v-list-item(to='/general', color='primary', v-if='hasPermission(`manage:system`)')
  18. v-list-item-avatar(size='24'): v-icon mdi-widgets
  19. v-list-item-title {{ $t('admin:general.title') }}
  20. v-list-item(to='/locale', color='primary', v-if='hasPermission(`manage:system`)')
  21. v-list-item-avatar(size='24'): v-icon mdi-web
  22. v-list-item-title {{ $t('admin:locale.title') }}
  23. v-list-item(to='/navigation', color='primary', v-if='hasPermission([`manage:system`, `manage:navigation`])')
  24. v-list-item-avatar(size='24'): v-icon mdi-near-me
  25. v-list-item-title {{ $t('admin:navigation.title') }}
  26. v-list-item(to='/pages', color='primary', v-if='hasPermission([`manage:system`, `write:pages`, `manage:pages`, `delete:pages`])')
  27. v-list-item-avatar(size='24'): v-icon mdi-file-document-outline
  28. v-list-item-title {{ $t('admin:pages.title') }}
  29. v-list-item-action(style='min-width:auto;')
  30. v-chip(x-small, :color='darkMode ? `grey darken-3-d4` : `grey lighten-5`')
  31. .caption.grey--text {{ info.pagesTotal }}
  32. v-list-item(to='/tags', v-if='hasPermission([`manage:system`])', disabled)
  33. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-tag-multiple
  34. v-list-item-title {{ $t('admin:tags.title') }}
  35. v-list-item(to='/theme', color='primary', v-if='hasPermission([`manage:system`, `manage:theme`])')
  36. v-list-item-avatar(size='24'): v-icon mdi-palette-outline
  37. v-list-item-title {{ $t('admin:theme.title') }}
  38. template(v-if='hasPermission([`manage:system`, `manage:groups`, `write:groups`, `manage:users`, `write:users`])')
  39. v-divider.my-2
  40. v-subheader.pl-4 {{ $t('admin:nav.users') }}
  41. v-list-item(to='/groups', color='primary', v-if='hasPermission([`manage:system`, `manage:groups`, `write:groups`])')
  42. v-list-item-avatar(size='24'): v-icon mdi-account-group
  43. v-list-item-title {{ $t('admin:groups.title') }}
  44. v-list-item-action(style='min-width:auto;')
  45. v-chip(x-small, :color='darkMode ? `grey darken-3-d4` : `grey lighten-4`')
  46. .caption.grey--text {{ info.groupsTotal }}
  47. v-list-item(to='/users', color='primary', v-if='hasPermission([`manage:system`, `manage:groups`, `write:groups`, `manage:users`, `write:users`])')
  48. v-list-item-avatar(size='24'): v-icon mdi-account-box
  49. v-list-item-title {{ $t('admin:users.title') }}
  50. v-list-item-action(style='min-width:auto;')
  51. v-chip(x-small, :color='darkMode ? `grey darken-3-d4` : `grey lighten-4`')
  52. .caption.grey--text {{ info.usersTotal }}
  53. template(v-if='hasPermission(`manage:system`)')
  54. v-divider.my-2
  55. v-subheader.pl-4 {{ $t('admin:nav.modules') }}
  56. v-list-item(to='/analytics', color='primary')
  57. v-list-item-avatar(size='24'): v-icon mdi-chart-timeline-variant
  58. v-list-item-title {{ $t('admin:analytics.title') }}
  59. v-list-item(to='/auth', color='primary')
  60. v-list-item-avatar(size='24'): v-icon mdi-lock-outline
  61. v-list-item-title {{ $t('admin:auth.title') }}
  62. v-list-item(to='/comments', disabled)
  63. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-comment-text-outline
  64. v-list-item-title {{ $t('admin:comments.title') }}
  65. v-list-item(to='/editor', disabled)
  66. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-playlist-edit
  67. v-list-item-title {{ $t('admin:editor.title') }}
  68. v-list-item(to='/logging', disabled)
  69. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-script-text-outline
  70. v-list-item-title {{ $t('admin:logging.title') }}
  71. v-list-item(to='/rendering', color='primary')
  72. v-list-item-avatar(size='24'): v-icon mdi-cogs
  73. v-list-item-title {{ $t('admin:rendering.title') }}
  74. v-list-item(to='/search', color='primary')
  75. v-list-item-avatar(size='24'): v-icon mdi-cloud-search-outline
  76. v-list-item-title {{ $t('admin:search.title') }}
  77. v-list-item(to='/storage', color='primary')
  78. v-list-item-avatar(size='24'): v-icon mdi-harddisk
  79. v-list-item-title {{ $t('admin:storage.title') }}
  80. template(v-if='hasPermission([`manage:system`, `manage:api`])')
  81. v-divider.my-2
  82. v-subheader.pl-4 {{ $t('admin:nav.system') }}
  83. v-list-item(to='/api', v-if='hasPermission([`manage:system`, `manage:api`])', disabled)
  84. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-call-split
  85. v-list-item-title {{ $t('admin:api.title') }}
  86. v-list-item(to='/mail', color='primary', v-if='hasPermission(`manage:system`)')
  87. v-list-item-avatar(size='24'): v-icon mdi-email-multiple-outline
  88. v-list-item-title {{ $t('admin:mail.title') }}
  89. v-list-item(to='/ssl', v-if='hasPermission(`manage:system`)', disabled)
  90. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-cloud-lock-outline
  91. v-list-item-title {{ $t('admin:ssl.title') }}
  92. v-list-item(to='/system', color='primary', v-if='hasPermission(`manage:system`)')
  93. v-list-item-avatar(size='24'): v-icon mdi-tune
  94. v-list-item-title {{ $t('admin:system.title') }}
  95. v-list-item(to='/utilities', color='primary', v-if='hasPermission(`manage:system`)')
  96. v-list-item-avatar(size='24'): v-icon mdi-wrench-outline
  97. v-list-item-title {{ $t('admin:utilities.title') }}
  98. v-list-item(to='/webhooks', v-if='hasPermission(`manage:system`)', disabled)
  99. v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-webhook
  100. v-list-item-title {{ $t('admin:webhooks.title') }}
  101. v-list-group(
  102. to='/dev'
  103. no-action
  104. v-if='hasPermission([`manage:system`, `manage:api`])'
  105. )
  106. v-list-item(slot='activator')
  107. v-list-item-avatar(size='24'): v-icon mdi-dev-to
  108. v-list-item-title {{ $t('admin:dev.title') }}
  109. v-list-item(to='/dev-flags', color='primary')
  110. v-list-item-title {{ $t('admin:dev.flags.title') }}
  111. v-list-item(href='/graphql', color='primary')
  112. v-list-item-title GraphQL
  113. //- v-list-item(to='/dev-graphiql')
  114. //- v-list-item-title {{ $t('admin:dev.graphiql.title') }}
  115. //- v-list-item(to='/dev-voyager')
  116. //- v-list-item-title {{ $t('admin:dev.voyager.title') }}
  117. v-divider.my-2
  118. v-list-item(to='/contribute', color='primary')
  119. v-list-item-avatar(size='24'): v-icon mdi-heart-outline
  120. v-list-item-title {{ $t('admin:contribute.title') }}
  121. v-content(:class='darkMode ? "grey darken-4" : ""')
  122. transition(name='admin-router')
  123. router-view
  124. nav-footer
  125. notify
  126. search-results
  127. </template>
  128. <script>
  129. import _ from 'lodash'
  130. import VueRouter from 'vue-router'
  131. import { get, sync } from 'vuex-pathify'
  132. import statsQuery from 'gql/admin/dashboard/dashboard-query-stats.gql'
  133. import adminStore from '../store/admin'
  134. /* global WIKI */
  135. WIKI.$store.registerModule('admin', adminStore)
  136. const router = new VueRouter({
  137. mode: 'history',
  138. base: '/a',
  139. routes: [
  140. { path: '/', redirect: '/dashboard' },
  141. { path: '/dashboard', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-dashboard.vue') },
  142. { path: '/general', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-general.vue') },
  143. { path: '/locale', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-locale.vue') },
  144. { path: '/navigation', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-navigation.vue') },
  145. { path: '/pages', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages.vue') },
  146. { path: '/pages/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages-edit.vue') },
  147. { path: '/pages/visualize', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages-visualize.vue') },
  148. { path: '/theme', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-theme.vue') },
  149. { path: '/groups', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups.vue') },
  150. { path: '/groups/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups-edit.vue') },
  151. { path: '/users', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users.vue') },
  152. { path: '/users/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users-edit.vue') },
  153. { path: '/analytics', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-analytics.vue') },
  154. { path: '/auth', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-auth.vue') },
  155. { path: '/rendering', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-rendering.vue') },
  156. { path: '/editor', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-editor.vue') },
  157. { path: '/logging', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-logging.vue') },
  158. { path: '/search', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-search.vue') },
  159. { path: '/storage', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-storage.vue') },
  160. { path: '/api', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-api.vue') },
  161. { path: '/mail', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-mail.vue') },
  162. { path: '/ssl', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-ssl.vue') },
  163. { path: '/system', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-system.vue') },
  164. { path: '/utilities', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-utilities.vue') },
  165. { path: '/webhooks', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-webhooks.vue') },
  166. { path: '/dev-flags', component: () => import(/* webpackChunkName: "admin-dev" */ './admin/admin-dev-flags.vue') },
  167. { path: '/contribute', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-contribute.vue') }
  168. ]
  169. })
  170. export default {
  171. i18nOptions: { namespaces: 'admin' },
  172. data() {
  173. return {
  174. adminDrawerShown: true,
  175. scrollStyle: {
  176. vuescroll: {},
  177. scrollPanel: {
  178. initialScrollY: 0,
  179. initialScrollX: 0,
  180. scrollingX: false,
  181. easing: 'easeOutQuad',
  182. speed: 1000,
  183. verticalNativeBarPos: this.$vuetify.rtl ? `left` : `right`
  184. },
  185. rail: {
  186. gutterOfEnds: '2px'
  187. },
  188. bar: {
  189. onlyShowBarOnScroll: false,
  190. background: '#CCC',
  191. hoverStyle: {
  192. background: '#999'
  193. }
  194. }
  195. }
  196. }
  197. },
  198. computed: {
  199. darkMode: get('site/dark'),
  200. info: sync('admin/info'),
  201. permissions: get('user/permissions')
  202. },
  203. router,
  204. created() {
  205. this.$store.commit('page/SET_MODE', 'admin')
  206. },
  207. methods: {
  208. hasPermission(prm) {
  209. if (_.isArray(prm)) {
  210. return _.some(prm, p => {
  211. return _.includes(this.permissions, p)
  212. })
  213. } else {
  214. return _.includes(this.permissions, prm)
  215. }
  216. }
  217. },
  218. apollo: {
  219. info: {
  220. query: statsQuery,
  221. fetchPolicy: 'network-only',
  222. manual: true,
  223. result({ data, loading, networkStatus }) {
  224. this.info = data.system.info
  225. },
  226. watchLoading (isLoading) {
  227. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-stats-refresh')
  228. }
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang='scss'>
  234. .admin {
  235. &.theme--light .application--wrap {
  236. background-color: lighten(mc('grey', '200'), 2%);
  237. }
  238. }
  239. .admin-router {
  240. &-enter-active, &-leave-active {
  241. transition: opacity .25s ease;
  242. opacity: 1;
  243. }
  244. &-enter-active {
  245. transition-delay: .25s;
  246. }
  247. &-enter, &-leave-to {
  248. opacity: 0;
  249. }
  250. }
  251. .admin-sidebar {
  252. .v-list__tile--active {
  253. background-color: rgba(mc('theme', 'primary'), .1);
  254. .v-icon {
  255. color: mc('theme', 'primary');
  256. }
  257. }
  258. }
  259. .theme--dark {
  260. .admin-sidebar .v-list__tile--active {
  261. background-color: rgba(0,0,0, .2);
  262. color: mc('blue', '500') !important;
  263. .v-icon {
  264. color: mc('blue', '500');
  265. }
  266. }
  267. }
  268. .admin-header {
  269. display: flex;
  270. justify-content: flex-start;
  271. align-items: center;
  272. &-title {
  273. margin-left: 1rem;
  274. }
  275. }
  276. .v-application.admin {
  277. code {
  278. box-shadow: none;
  279. font-family: 'Roboto Mono', monospace;
  280. color: mc('pink', '500');
  281. }
  282. }
  283. </style>