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.

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