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.

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