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.

215 lines
7.5 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row, wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img.animated.fadeInUp(src='/svg/icon-browse-page.svg', alt='Dashboard', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text.animated.fadeInLeft {{ $t('admin:dashboard.title') }}
  9. .subtitle-1.grey--text.animated.fadeInLeft.wait-p2s {{ $t('admin:dashboard.subtitle') }}
  10. v-flex(xs12 md6 lg4 xl3 d-flex)
  11. v-card.primary.dashboard-card.animated.fadeInUp(dark)
  12. v-card-text
  13. v-icon.dashboard-icon mdi-file-document-outline
  14. .overline {{$t('admin:dashboard.pages')}}
  15. animated-number.display-1(
  16. :value='info.pagesTotal'
  17. :duration='2000'
  18. :formatValue='round'
  19. easing='easeOutQuint'
  20. )
  21. v-flex(xs12 md6 lg4 xl3 d-flex)
  22. v-card.green.lighten-1.dashboard-card.animated.fadeInUp.wait-p2s(dark)
  23. v-card-text
  24. v-icon.dashboard-icon mdi-account
  25. .overline {{$t('admin:dashboard.users')}}
  26. animated-number.display-1(
  27. :value='info.usersTotal'
  28. :duration='2000'
  29. :formatValue='round'
  30. easing='easeOutQuint'
  31. )
  32. v-flex(xs12 md6 lg4 xl3 d-flex)
  33. v-card.indigo.lighten-1.dashboard-card.animated.fadeInUp.wait-p4s(dark)
  34. v-card-text
  35. v-icon.dashboard-icon mdi-account-group
  36. .overline {{$t('admin:dashboard.groups')}}
  37. animated-number.display-1(
  38. :value='info.groupsTotal'
  39. :duration='2000'
  40. :formatValue='round'
  41. easing='easeOutQuint'
  42. )
  43. v-flex(xs12 md6 lg12 xl3 d-flex)
  44. v-card.dashboard-card.animated.fadeInUp.wait-p6s(
  45. :class='isLatestVersion ? "teal lighten-2" : "red lighten-2"'
  46. dark
  47. )
  48. v-btn.btn-animate-wrench(fab, absolute, :right='!$vuetify.rtl', :left='$vuetify.rtl', top, small, light, to='system', v-if='hasPermission(`manage:system`)')
  49. v-icon(:color='isLatestVersion ? `teal` : `red darken-4`', small) mdi-wrench
  50. v-card-text
  51. v-icon.dashboard-icon mdi-blur
  52. .subtitle-1 Wiki.js {{info.currentVersion}}
  53. .body-2(v-if='isLatestVersion') {{$t('admin:dashboard.versionLatest')}}
  54. .body-2(v-else) {{$t('admin:dashboard.versionNew', { version: info.latestVersion })}}
  55. v-flex(xs12, xl6)
  56. v-card.radius-7.animated.fadeInUp.wait-p2s
  57. v-toolbar(:color='$vuetify.theme.dark ? `grey darken-2` : `grey lighten-5`', dense, flat)
  58. v-spacer
  59. .overline {{$t('admin:dashboard.recentPages')}}
  60. v-spacer
  61. v-data-table.pb-2(
  62. :items='recentPages'
  63. :headers='headers'
  64. :loading='recentPagesLoading'
  65. hide-default-footer
  66. hide-default-header
  67. )
  68. template(slot='item', slot-scope='props')
  69. tr.is-clickable(:active='props.selected', @click='$router.push(`/pages/` + props.item.id)')
  70. td
  71. .body-2: strong {{ props.item.title }}
  72. td.admin-pages-path
  73. v-chip(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  74. span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
  75. td.text-right.caption(width='250') {{ props.item.updatedAt | moment('calendar') }}
  76. v-flex(xs12, xl6)
  77. v-card.radius-7.animated.fadeInUp.wait-p4s
  78. v-toolbar(:color='$vuetify.theme.dark ? `grey darken-2` : `grey lighten-5`', dense, flat)
  79. v-spacer
  80. .overline {{$t('admin:dashboard.mostPopularPages')}}
  81. v-spacer
  82. v-data-table.pb-2(
  83. :items='popularPages'
  84. :headers='headers'
  85. :loading='popularPagesLoading'
  86. hide-default-footer
  87. hide-default-header
  88. )
  89. template(slot='item', slot-scope='props')
  90. tr.is-clickable(:active='props.selected', @click='$router.push(`/pages/` + props.item.id)')
  91. td
  92. .body-2: strong {{ props.item.title }}
  93. td.admin-pages-path
  94. v-chip(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  95. span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
  96. td.text-right.caption(width='250') {{ props.item.updatedAt | moment('calendar') }}
  97. v-flex(xs12)
  98. v-card.dashboard-contribute.animated.fadeInUp.wait-p4s
  99. v-card-text
  100. img(src='/svg/icon-heart-health.svg', alt='Contribute', style='height: 80px;')
  101. .pl-5
  102. .subtitle-1 {{$t('admin:contribute.title')}}
  103. .body-2.mt-3: strong {{$t('admin:dashboard.contributeSubtitle')}}
  104. .body-2 {{$t('admin:dashboard.contributeHelp')}}
  105. v-btn.mx-0.mt-4(:color='$vuetify.theme.dark ? `indigo lighten-3` : `indigo`', outlined, small, to='/contribute')
  106. .caption: strong {{$t('admin:dashboard.contributeLearnMore')}}
  107. </template>
  108. <script>
  109. import _ from 'lodash'
  110. import AnimatedNumber from 'animated-number-vue'
  111. import { get } from 'vuex-pathify'
  112. import recentPagesQuery from 'gql/admin/dashboard/dashboard-query-recentpages.gql'
  113. export default {
  114. components: {
  115. AnimatedNumber
  116. },
  117. data() {
  118. return {
  119. recentPages: [],
  120. recentPagesLoading: false,
  121. popularPages: [],
  122. popularPagesLoading: false,
  123. headers: [
  124. { text: 'ID', value: 'id', width: 80 },
  125. { text: 'Title', value: 'title' },
  126. { text: 'Path', value: 'path' },
  127. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  128. ]
  129. }
  130. },
  131. computed: {
  132. isLatestVersion() {
  133. return this.info.currentVersion === this.info.latestVersion
  134. },
  135. info: get('admin/info'),
  136. permissions: get('user/permissions')
  137. },
  138. methods: {
  139. round(val) { return Math.round(val) },
  140. hasPermission(prm) {
  141. if (_.isArray(prm)) {
  142. return _.some(prm, p => {
  143. return _.includes(this.permissions, p)
  144. })
  145. } else {
  146. return _.includes(this.permissions, prm)
  147. }
  148. }
  149. },
  150. apollo: {
  151. recentPages: {
  152. query: recentPagesQuery,
  153. update: (data) => data.pages.list,
  154. watchLoading (isLoading) {
  155. this.recentPagesLoading = isLoading
  156. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-dashboard-recentpages')
  157. }
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang='scss'>
  163. .dashboard-card {
  164. display: flex;
  165. width: 100%;
  166. border-radius: 7px;
  167. .v-card__text {
  168. overflow: hidden;
  169. position: relative;
  170. }
  171. }
  172. .dashboard-contribute {
  173. background-color: #FFF;
  174. background-image: linear-gradient(to bottom, #FFF 0%, lighten(mc('indigo', '50'), 3%) 100%);
  175. border-radius: 7px;
  176. @at-root .theme--dark & {
  177. background-color: mc('grey', '800');
  178. background-image: linear-gradient(to bottom, mc('grey', '800') 0%, darken(mc('grey', '800'), 6%) 100%);
  179. }
  180. .v-card__text {
  181. display: flex;
  182. align-items: center;
  183. color: mc('indigo', '500') !important;
  184. @at-root .theme--dark & {
  185. color: mc('grey', '300') !important;
  186. }
  187. }
  188. }
  189. .dashboard-icon {
  190. position: absolute;
  191. right: 0;
  192. top: 12px;
  193. font-size: 100px !important;
  194. opacity: .25;
  195. @at-root .v-application--is-rtl & {
  196. left: 0;
  197. right: initial;
  198. }
  199. }
  200. </style>