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.

283 lines
12 KiB

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