admin.vue 14 KB

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