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.

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