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.

252 lines
8.2 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='/_assets/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.blue.darken-3.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.blue.darken-4.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 ? "green" : "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 ? `green` : `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='recentPagesHeaders'
  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.lastLogins')}}
  81. v-spacer
  82. v-data-table.pb-2(
  83. :items='lastLogins'
  84. :headers='lastLoginsHeaders'
  85. :loading='lastLoginsLoading'
  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(`/users/` + props.item.id)')
  91. td
  92. .body-2: strong {{ props.item.name }}
  93. td.text-right.caption(width='250') {{ props.item.lastLoginAt | moment('calendar') }}
  94. v-flex(xs12)
  95. v-card.dashboard-contribute.animated.fadeInUp.wait-p4s
  96. v-card-text
  97. img(src='/_assets/svg/icon-heart-health.svg', alt='Contribute', style='height: 80px;')
  98. .pl-5
  99. .subtitle-1 {{$t('admin:contribute.title')}}
  100. .body-2.mt-3: strong {{$t('admin:dashboard.contributeSubtitle')}}
  101. .body-2 {{$t('admin:dashboard.contributeHelp')}}
  102. v-btn.mx-0.mt-4(:color='$vuetify.theme.dark ? `indigo lighten-3` : `indigo`', outlined, small, to='/contribute')
  103. .caption: strong {{$t('admin:dashboard.contributeLearnMore')}}
  104. </template>
  105. <script>
  106. import _ from 'lodash'
  107. import AnimatedNumber from 'animated-number-vue'
  108. import { get } from 'vuex-pathify'
  109. import gql from 'graphql-tag'
  110. import semverLte from 'semver/functions/lte'
  111. export default {
  112. components: {
  113. AnimatedNumber
  114. },
  115. data() {
  116. return {
  117. recentPages: [],
  118. recentPagesLoading: false,
  119. recentPagesHeaders: [
  120. { text: 'Title', value: 'title' },
  121. { text: 'Path', value: 'path' },
  122. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  123. ],
  124. lastLogins: [],
  125. lastLoginsLoading: false,
  126. lastLoginsHeaders: [
  127. { text: 'User', value: 'displayName' },
  128. { text: 'Last Login', value: 'lastLoginAt', width: 250 }
  129. ]
  130. }
  131. },
  132. computed: {
  133. isLatestVersion() {
  134. return semverLte(this.info.latestVersion, this.info.currentVersion)
  135. },
  136. info: get('admin/info'),
  137. permissions: get('user/permissions')
  138. },
  139. methods: {
  140. round(val) { return Math.round(val) },
  141. hasPermission(prm) {
  142. if (_.isArray(prm)) {
  143. return _.some(prm, p => {
  144. return _.includes(this.permissions, p)
  145. })
  146. } else {
  147. return _.includes(this.permissions, prm)
  148. }
  149. }
  150. },
  151. apollo: {
  152. recentPages: {
  153. query: gql`
  154. query {
  155. pages {
  156. list(limit: 10, orderBy: UPDATED, orderByDirection: DESC) {
  157. id
  158. locale
  159. path
  160. title
  161. description
  162. contentType
  163. isPublished
  164. isPrivate
  165. privateNS
  166. createdAt
  167. updatedAt
  168. }
  169. }
  170. }
  171. `,
  172. update: (data) => data.pages.list,
  173. watchLoading (isLoading) {
  174. this.recentPagesLoading = isLoading
  175. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-dashboard-recentpages')
  176. }
  177. },
  178. lastLogins: {
  179. query: gql`
  180. query {
  181. users {
  182. lastLogins {
  183. id
  184. name
  185. lastLoginAt
  186. }
  187. }
  188. }
  189. `,
  190. fetchPolicy: 'network-only',
  191. update: (data) => data.users.lastLogins,
  192. watchLoading (isLoading) {
  193. this.lastLoginsLoading = isLoading
  194. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-dashboard-lastlogins')
  195. }
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang='scss'>
  201. .dashboard-card {
  202. display: flex;
  203. width: 100%;
  204. border-radius: 7px;
  205. .v-card__text {
  206. overflow: hidden;
  207. position: relative;
  208. }
  209. }
  210. .dashboard-contribute {
  211. background-color: #FFF;
  212. background-image: linear-gradient(to bottom, #FFF 0%, lighten(mc('indigo', '50'), 3%) 100%);
  213. border-radius: 7px;
  214. @at-root .theme--dark & {
  215. background-color: mc('grey', '800');
  216. background-image: linear-gradient(to bottom, mc('grey', '800') 0%, darken(mc('grey', '800'), 6%) 100%);
  217. }
  218. .v-card__text {
  219. display: flex;
  220. align-items: center;
  221. color: mc('indigo', '500') !important;
  222. @at-root .theme--dark & {
  223. color: mc('grey', '300') !important;
  224. }
  225. }
  226. }
  227. .v-icon.dashboard-icon {
  228. position: absolute !important;
  229. right: 0;
  230. top: 12px;
  231. font-size: 100px !important;
  232. opacity: .25;
  233. @at-root .v-application--is-rtl & {
  234. left: 0;
  235. right: initial;
  236. }
  237. }
  238. </style>