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.

315 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', :class='$vuetify.theme.dark ? `grey darken-4` : ``')
  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='$vuetify.theme.dark ? `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='$vuetify.theme.dark ? `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='$vuetify.theme.dark ? `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='$vuetify.theme.dark ? `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='/security', v-if='hasPermission(`manage:system`)')
  93. v-list-item-avatar(size='24', tile): v-icon mdi-lock-check
  94. v-list-item-title {{ $t('admin:security.title') }}
  95. v-list-item(to='/ssl', v-if='hasPermission(`manage:system`)')
  96. v-list-item-avatar(size='24', tile): v-icon mdi-cloud-lock-outline
  97. v-list-item-title {{ $t('admin:ssl.title') }}
  98. v-list-item(to='/system', color='primary', v-if='hasPermission(`manage:system`)')
  99. v-list-item-avatar(size='24', tile): v-icon mdi-tune
  100. v-list-item-title {{ $t('admin:system.title') }}
  101. v-list-item(to='/utilities', color='primary', v-if='hasPermission(`manage:system`)')
  102. v-list-item-avatar(size='24', tile): v-icon mdi-wrench-outline
  103. v-list-item-title {{ $t('admin:utilities.title') }}
  104. v-list-item(to='/webhooks', v-if='hasPermission(`manage:system`)', disabled)
  105. v-list-item-avatar(size='24', tile): v-icon(color='grey lighten-2') mdi-webhook
  106. v-list-item-title {{ $t('admin:webhooks.title') }}
  107. v-list-group(
  108. to='/dev'
  109. no-action
  110. v-if='hasPermission([`manage:system`, `manage:api`])'
  111. )
  112. v-list-item(slot='activator')
  113. v-list-item-avatar(size='24', tile): v-icon mdi-dev-to
  114. v-list-item-title {{ $t('admin:dev.title') }}
  115. v-list-item(to='/dev-flags', color='primary')
  116. v-list-item-title {{ $t('admin:dev.flags.title') }}
  117. v-list-item(href='/graphql', color='primary')
  118. v-list-item-title GraphQL
  119. //- v-list-item(to='/dev-graphiql')
  120. //- v-list-item-title {{ $t('admin:dev.graphiql.title') }}
  121. //- v-list-item(to='/dev-voyager')
  122. //- v-list-item-title {{ $t('admin:dev.voyager.title') }}
  123. v-divider.my-2
  124. v-list-item(to='/contribute', color='primary')
  125. v-list-item-avatar(size='24', tile): v-icon mdi-heart-outline
  126. v-list-item-title {{ $t('admin:contribute.title') }}
  127. v-content(:class='$vuetify.theme.dark ? "grey darken-5" : "grey lighten-5"')
  128. transition(name='admin-router')
  129. router-view
  130. nav-footer
  131. notify
  132. search-results
  133. </template>
  134. <script>
  135. import _ from 'lodash'
  136. import VueRouter from 'vue-router'
  137. import { get, sync } from 'vuex-pathify'
  138. import statsQuery from 'gql/admin/dashboard/dashboard-query-stats.gql'
  139. import adminStore from '../store/admin'
  140. /* global WIKI */
  141. WIKI.$store.registerModule('admin', adminStore)
  142. const router = new VueRouter({
  143. mode: 'history',
  144. base: '/a',
  145. routes: [
  146. { path: '/', redirect: '/dashboard' },
  147. { path: '/dashboard', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-dashboard.vue') },
  148. { path: '/general', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-general.vue') },
  149. { path: '/locale', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-locale.vue') },
  150. { path: '/navigation', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-navigation.vue') },
  151. { path: '/pages', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages.vue') },
  152. { path: '/pages/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages-edit.vue') },
  153. { path: '/pages/visualize', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-pages-visualize.vue') },
  154. { path: '/tags', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-tags.vue') },
  155. { path: '/theme', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-theme.vue') },
  156. { path: '/groups', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups.vue') },
  157. { path: '/groups/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-groups-edit.vue') },
  158. { path: '/users', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users.vue') },
  159. { path: '/users/:id(\\d+)', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-users-edit.vue') },
  160. { path: '/analytics', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-analytics.vue') },
  161. { path: '/auth', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-auth.vue') },
  162. { path: '/rendering', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-rendering.vue') },
  163. { path: '/editor', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-editor.vue') },
  164. { path: '/logging', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-logging.vue') },
  165. { path: '/search', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-search.vue') },
  166. { path: '/storage', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-storage.vue') },
  167. { path: '/api', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-api.vue') },
  168. { path: '/mail', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-mail.vue') },
  169. { path: '/security', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-security.vue') },
  170. { path: '/ssl', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-ssl.vue') },
  171. { path: '/system', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-system.vue') },
  172. { path: '/utilities', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-utilities.vue') },
  173. { path: '/webhooks', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-webhooks.vue') },
  174. { path: '/dev-flags', component: () => import(/* webpackChunkName: "admin-dev" */ './admin/admin-dev-flags.vue') },
  175. { path: '/contribute', component: () => import(/* webpackChunkName: "admin" */ './admin/admin-contribute.vue') }
  176. ]
  177. })
  178. export default {
  179. i18nOptions: { namespaces: 'admin' },
  180. data() {
  181. return {
  182. adminDrawerShown: true,
  183. scrollStyle: {
  184. vuescroll: {},
  185. scrollPanel: {
  186. initialScrollY: 0,
  187. initialScrollX: 0,
  188. scrollingX: false,
  189. easing: 'easeOutQuad',
  190. speed: 1000,
  191. verticalNativeBarPos: this.$vuetify.rtl ? `left` : `right`
  192. },
  193. rail: {
  194. gutterOfEnds: '2px'
  195. },
  196. bar: {
  197. onlyShowBarOnScroll: false,
  198. background: '#CCC',
  199. hoverStyle: {
  200. background: '#999'
  201. }
  202. }
  203. }
  204. }
  205. },
  206. computed: {
  207. info: sync('admin/info'),
  208. permissions: get('user/permissions')
  209. },
  210. router,
  211. created() {
  212. this.$store.commit('page/SET_MODE', 'admin')
  213. },
  214. methods: {
  215. hasPermission(prm) {
  216. if (_.isArray(prm)) {
  217. return _.some(prm, p => {
  218. return _.includes(this.permissions, p)
  219. })
  220. } else {
  221. return _.includes(this.permissions, prm)
  222. }
  223. }
  224. },
  225. apollo: {
  226. info: {
  227. query: statsQuery,
  228. fetchPolicy: 'network-only',
  229. manual: true,
  230. result({ data, loading, networkStatus }) {
  231. this.info = data.system.info
  232. },
  233. watchLoading (isLoading) {
  234. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-stats-refresh')
  235. }
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang='scss'>
  241. .admin {
  242. &.theme--light .application--wrap {
  243. background-color: lighten(mc('grey', '200'), 2%);
  244. }
  245. }
  246. .admin-router {
  247. &-enter-active, &-leave-active {
  248. transition: opacity .25s ease;
  249. opacity: 1;
  250. }
  251. &-enter-active {
  252. transition-delay: .25s;
  253. }
  254. &-enter, &-leave-to {
  255. opacity: 0;
  256. }
  257. }
  258. .admin-sidebar {
  259. .v-list__tile--active {
  260. background-color: rgba(mc('theme', 'primary'), .1);
  261. .v-icon {
  262. color: mc('theme', 'primary');
  263. }
  264. }
  265. .v-list-group > .v-list-item {
  266. padding-left: 0;
  267. }
  268. }
  269. .theme--dark {
  270. .admin-sidebar .v-list__tile--active {
  271. background-color: rgba(0,0,0, .2);
  272. color: mc('blue', '500') !important;
  273. .v-icon {
  274. color: mc('blue', '500');
  275. }
  276. }
  277. }
  278. .admin-header {
  279. display: flex;
  280. justify-content: flex-start;
  281. align-items: center;
  282. &-title {
  283. margin-left: 1rem;
  284. }
  285. }
  286. .v-application.admin {
  287. code {
  288. box-shadow: none;
  289. font-family: 'Roboto Mono', monospace;
  290. color: mc('pink', '500');
  291. }
  292. }
  293. </style>