dashboard.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="flex flex-col">
  3. <h1 class="text-lg font-bold text-secondaryDark">
  4. {{ t('metrics.dashboard') }}
  5. </h1>
  6. <div v-if="fetching" class="flex justify-center py-6">
  7. <HoppSmartSpinner />
  8. </div>
  9. <div v-else-if="error || !metrics">
  10. <p class="text-xl">{{ t('metrics.no_metrics') }}</p>
  11. </div>
  12. <div v-else>
  13. <div class="py-10 grid lg:grid-cols-2 gap-6">
  14. <DashboardMetricsCard
  15. :count="metrics.usersCount"
  16. :label="t('metrics.total_users')"
  17. :icon="UserIcon"
  18. color="text-green-400"
  19. />
  20. <DashboardMetricsCard
  21. :count="metrics.teamsCount"
  22. :label="t('metrics.total_teams')"
  23. :icon="UsersIcon"
  24. color="text-pink-400"
  25. />
  26. <DashboardMetricsCard
  27. :count="metrics.teamRequestsCount"
  28. :label="t('metrics.total_requests')"
  29. :icon="LineChartIcon"
  30. color="text-cyan-400"
  31. />
  32. <DashboardMetricsCard
  33. :count="metrics.teamCollectionsCount"
  34. :label="t('metrics.total_collections')"
  35. :icon="FolderTreeIcon"
  36. color="text-orange-400"
  37. />
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script setup lang="ts">
  43. import { computed } from 'vue';
  44. import { useQuery } from '@urql/vue';
  45. import { MetricsDocument } from '../helpers/backend/graphql';
  46. import UserIcon from '~icons/lucide/user';
  47. import UsersIcon from '~icons/lucide/users';
  48. import LineChartIcon from '~icons/lucide/line-chart';
  49. import FolderTreeIcon from '~icons/lucide/folder-tree';
  50. import { useI18n } from '../composables/i18n';
  51. const t = useI18n();
  52. // Get Metrics Data
  53. const { fetching, error, data } = useQuery({ query: MetricsDocument });
  54. const metrics = computed(() => data?.value?.admin);
  55. </script>