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.

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