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.

271 lines
11 KiB

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