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.

255 lines
10 KiB

  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')
  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-tile(to='/dev', v-if='hasPermission([`manage:system`, `manage:api`])')
  83. v-list-tile-avatar: v-icon weekend
  84. v-list-tile-title {{ $t('admin:dev.title') }}
  85. v-divider.my-2
  86. v-list-tile(to='/contribute')
  87. v-list-tile-avatar: v-icon favorite
  88. v-list-tile-title {{ $t('admin:contribute.title') }}
  89. v-content(:class='darkMode ? "grey darken-4" : ""')
  90. transition(name='admin-router')
  91. router-view
  92. nav-footer
  93. </template>
  94. <script>
  95. import _ from 'lodash'
  96. import VueRouter from 'vue-router'
  97. import { get, sync } from 'vuex-pathify'
  98. import statsQuery from 'gql/admin/dashboard/dashboard-query-stats.gql'
  99. import adminStore from '@/store/admin'
  100. /* global WIKI */
  101. WIKI.$store.registerModule('admin', adminStore)
  102. const router = new VueRouter({
  103. mode: 'history',
  104. base: '/a',
  105. routes: [
  106. { path: '/', redirect: '/dashboard' },
  107. { path: '/dashboard', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-dashboard.vue') },
  108. { path: '/general', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-general.vue') },
  109. { path: '/locale', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-locale.vue') },
  110. { path: '/navigation', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-navigation.vue') },
  111. { path: '/pages', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages.vue') },
  112. { path: '/theme', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-theme.vue') },
  113. { path: '/groups', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups.vue') },
  114. { path: '/groups/:id', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups-edit.vue') },
  115. { path: '/users', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users.vue') },
  116. { path: '/users/:id', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users-edit.vue') },
  117. { path: '/auth', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-auth.vue') },
  118. { path: '/rendering', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-rendering.vue') },
  119. { path: '/editor', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-editor.vue') },
  120. { path: '/logging', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-logging.vue') },
  121. { path: '/search', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-search.vue') },
  122. { path: '/storage', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-storage.vue') },
  123. { path: '/api', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-api.vue') },
  124. { path: '/mail', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-mail.vue') },
  125. { path: '/system', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-system.vue') },
  126. { path: '/utilities', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-utilities.vue') },
  127. { path: '/dev', component: () => import(/* webpackChunkName: "admin-dev" */ './admin/admin-dev.vue') },
  128. { path: '/contribute', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-contribute.vue') }
  129. ]
  130. })
  131. export default {
  132. i18nOptions: { namespaces: 'admin' },
  133. data() {
  134. return {
  135. adminDrawerShown: true,
  136. scrollStyle: {
  137. vuescroll: {},
  138. scrollPanel: {
  139. initialScrollY: 0,
  140. initialScrollX: 0,
  141. scrollingX: false,
  142. easing: 'easeOutQuad',
  143. speed: 1000
  144. },
  145. rail: {
  146. gutterOfEnds: '2px'
  147. },
  148. bar: {
  149. onlyShowBarOnScroll: false,
  150. background: '#CCC',
  151. hoverStyle: {
  152. background: '#999'
  153. }
  154. }
  155. }
  156. }
  157. },
  158. computed: {
  159. darkMode: get('site/dark'),
  160. info: sync('admin/info'),
  161. permissions: get('user/permissions')
  162. },
  163. router,
  164. created() {
  165. this.$store.commit('page/SET_MODE', 'admin')
  166. },
  167. methods: {
  168. hasPermission(prm) {
  169. if (_.isArray(prm)) {
  170. return _.some(prm, p => {
  171. return _.includes(this.permissions, p)
  172. })
  173. } else {
  174. return _.includes(this.permissions, prm)
  175. }
  176. }
  177. },
  178. apollo: {
  179. info: {
  180. query: statsQuery,
  181. fetchPolicy: 'network-only',
  182. manual: true,
  183. result({ data, loading, networkStatus }) {
  184. this.info = data.system.info
  185. },
  186. watchLoading (isLoading) {
  187. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-stats-refresh')
  188. }
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang='scss'>
  194. .admin {
  195. &.theme--light {
  196. background-color: lighten(mc('grey', '200'), 2%);
  197. }
  198. }
  199. .admin-router {
  200. &-enter-active, &-leave-active {
  201. transition: opacity .25s ease;
  202. opacity: 1;
  203. }
  204. &-enter-active {
  205. transition-delay: .25s;
  206. }
  207. &-enter, &-leave-to {
  208. opacity: 0;
  209. }
  210. }
  211. .admin-sidebar {
  212. .v-list__tile--active {
  213. background-color: rgba(mc('theme', 'primary'), .1);
  214. .v-icon {
  215. color: mc('theme', 'primary');
  216. }
  217. }
  218. }
  219. .theme--dark {
  220. .admin-sidebar .v-list__tile--active {
  221. background-color: rgba(0,0,0, .2);
  222. color: mc('blue', '500') !important;
  223. .v-icon {
  224. color: mc('blue', '500');
  225. }
  226. }
  227. }
  228. .admin-header {
  229. display: flex;
  230. justify-content: flex-start;
  231. align-items: center;
  232. &-title {
  233. margin-left: 1rem;
  234. }
  235. }
  236. </style>