A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: dashboard should be split by tabs rather than pulse cards
aminnausin8d1c094ed299
diff --git a/resources/js/components/dashboard/DashboardAnalytics.vue b/resources/js/components/dashboard/DashboardAnalytics.vueindex 33bea4c3..a1876b60 100644--- a/resources/js/components/dashboard/DashboardAnalytics.vue+++ b/resources/js/components/dashboard/DashboardAnalytics.vue@@ -2,43 +2,35 @@import type { BreadCrumbItem } from '@/types/types';import type { PulseResponse } from '@/types/pulseTypes';-import { computed, defineAsyncComponent, ref, useTemplateRef, watch } from 'vue';+import { computed, onMounted, ref, useTemplateRef } from 'vue';import { useGetPulse, useGetSiteAnalytics } from '@/service/queries';import { ButtonText, ButtonBase } from '@/components/cedar-ui/button';import { handleStartTask } from '@/service/taskService';import { periodForHumans } from '@/service/pulseUtil';import { BreadCrumbs } from '@/components/cedar-ui/breadcrumbs';import { BasePopover } from '@/components/cedar-ui/popover';+import { queryClient } from '@/service/vue-query';import { useAuth } from '@/composables/auth/useAuth';+import PulseSlowOutgoingRequests from '@/components/cards/pulse/PulseSlowOutgoingRequests.vue';import LucideChartNoAxesCombined from '~icons/lucide/chart-no-axes-combined';import DashboardTaskMenu from '@/components/menus/DashboardTaskMenu.vue';+import PulseSlowRequests from '@/components/cards/pulse/PulseSlowRequests.vue';+import PulseSlowQueries from '@/components/cards/pulse/PulseSlowQueries.vue';+import PulseExceptions from '@/components/cards/pulse/PulseExceptions.vue';import DashboardCard from '@/components/cards/layout/DashboardCard.vue';-import PulseSkeleton from '@/components/cards/pulse/PulseSkeleton.vue';+import PulseRequests from '@/components/cards/pulse/PulseRequests.vue';+import PulseSlowJobs from '@/components/cards/pulse/PulseSlowJobs.vue';import PulseServers from '@/components/cards/pulse/PulseServers.vue';+import PulseQueues from '@/components/cards/pulse/PulseQueues.vue';+import PulseUsage from '@/components/cards/pulse/PulseUsage.vue';+import PulseCache from '@/components/cards/pulse/PulseCache.vue';import ProiconsArrowSync from '~icons/proicons/arrow-sync';import ProiconsHome2 from '~icons/proicons/home-2';import ProiconsBolt from '~icons/proicons/bolt';import ProiconsAdd from '~icons/proicons/add';-const loadPulseCard = (loader: () => Promise<any>) =>- defineAsyncComponent({- loader,- loadingComponent: PulseSkeleton,- delay: 100,- });--const PulseUsage = loadPulseCard(() => import('@/components/cards/pulse/PulseUsage.vue'));-const PulseQueues = loadPulseCard(() => import('@/components/cards/pulse/PulseQueues.vue'));-const PulseRequests = loadPulseCard(() => import('@/components/cards/pulse/PulseRequests.vue'));-const PulseSlowRequests = loadPulseCard(() => import('@/components/cards/pulse/PulseSlowRequests.vue'));-const PulseSlowJobs = loadPulseCard(() => import('@/components/cards/pulse/PulseSlowJobs.vue'));-const PulseSlowQueries = loadPulseCard(() => import('@/components/cards/pulse/PulseSlowQueries.vue'));-const PulseCache = loadPulseCard(() => import('@/components/cards/pulse/PulseCache.vue'));-const PulseExceptions = loadPulseCard(() => import('@/components/cards/pulse/PulseExceptions.vue'));-const PulseSlowOutgoingRequests = loadPulseCard(() => import('@/components/cards/pulse/PulseSlowOutgoingRequests.vue'));-const validPeriods: { key: string; value: string }[] = [{ key: '1h', value: '1_hour' },{ key: '6h', value: '6_hours' },@@ -47,15 +39,16 @@ const validPeriods: { key: string; value: string }[] = [{ key: '30d', value: '30_days' },];-const period = ref<string>('1_hour');-const pulseData = ref<PulseResponse>();const taskPopover = useTemplateRef('taskPopover');+const period = ref<string>('1_hour');const { data: stats } = useGetSiteAnalytics(period);const { data: rawPulseData, isLoading: pulseLoading } = useGetPulse({ period });const { isAdmin } = useAuth();+const pulseData = computed<PulseResponse>(() => rawPulseData.value?.data as PulseResponse);+const breadCrumbs = computed(() => {const items: BreadCrumbItem[] = [{@@ -68,19 +61,13 @@ const breadCrumbs = computed(() => {return items;});-watch(- () => rawPulseData.value,- () => {- if (rawPulseData?.value?.data) {- pulseData.value = rawPulseData.value.data;- }- },-);+onMounted(() => {+ queryClient.invalidateQueries({ queryKey: ['pulse', period] });+});</script><template><div class="flex flex-wrap items-center justify-between gap-2"><BreadCrumbs :bread-crumbs="breadCrumbs" />-<div class="ml-auto flex flex-wrap items-center gap-2 text-sm font-medium *:leading-4"><h5>Time Period</h5><ButtonBasediff --git a/resources/js/components/dashboard/DashboardSkeleton.vue b/resources/js/components/dashboard/DashboardSkeleton.vuenew file mode 100644index 00000000..c40de2e5--- /dev/null+++ b/resources/js/components/dashboard/DashboardSkeleton.vue@@ -0,0 +1,50 @@+<template>+ <div class="animate-pulse space-y-6">+ <div class="flex flex-wrap items-center justify-between gap-4">+ <div class="flex items-center gap-2">+ <div class="bg-surface-2 h-5 w-24 rounded"></div>+ <div class="bg-surface-2 h-4 w-4 rounded-full"></div>+ <div class="bg-surface-2 h-5 w-20 rounded"></div>+ </div>+ <div class="flex gap-2">+ <div v-for="i in 5" :key="i" class="bg-surface-2 h-6 w-10 rounded"></div>+ </div>+ </div>++ <div class="flex gap-2">+ <div class="bg-surface-2 h-9 w-32 rounded-md"></div>+ <div class="bg-surface-2 h-9 w-28 rounded-md"></div>+ <div class="bg-surface-2 h-9 w-24 rounded-md"></div>+ </div>++ <div class="grid w-full grid-cols-2 gap-6 sm:grid-cols-4 lg:grid-cols-6">+ <div class="bg-surface-2 col-span-2 row-span-3 h-full min-h-30 rounded-xl lg:col-span-2"></div>+ <div class="bg-surface-2 col-span-2 h-40 rounded-xl lg:col-span-4"></div>+ <div class="bg-surface-2 col-span-2 row-span-2 hidden h-80 rounded-xl lg:col-span-4 lg:block"></div>++ <div+ v-for="i in 4"+ :key="i"+ class="bg-surface-2/50 border-surface-2 flex h-48 flex-col gap-3 rounded-xl border p-4 shadow-sm"+ :class="i % 2 === 0 ? 'col-span-2' : 'col-span-2 lg:col-span-4'"+ >+ <div class="flex items-center gap-2">+ <div class="bg-surface-4 h-5 w-5 rounded-md"></div>+ <div class="bg-surface-4 h-4 w-24 rounded"></div>+ </div>+ <div class="bg-surface-4 mt-auto h-8 w-1/2 rounded"></div>+ <div class="bg-surface-4 h-3 w-full rounded"></div>+ </div>+ </div>+ </div>+</template>++<style scoped>+/* Ensure your background colors match your theme's surface levels */+/* .bg-surface-1 {+ @apply bg-gray-100 dark:bg-[#1a1a1a];+}+.bg-surface-2 {+ @apply bg-gray-200 dark:bg-[#2a2a2a];+} */+</style>diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vueindex 1e3013c4..fbd99712 100644--- a/resources/js/views/DashboardView.vue+++ b/resources/js/views/DashboardView.vue@@ -1,20 +1,39 @@<script setup lang="ts">+import { computed, defineAsyncComponent, onMounted } from 'vue';import { useDashboardTabs } from '@/components/panels/DashboardTabs';import { getScreenSize } from '@/service/util';import { useAppStore } from '@/stores/AppStore';-import { onMounted } from 'vue';-import DashboardAnalytics from '@/components/dashboard/DashboardAnalytics.vue';-import DashboardLibraries from '@/components/dashboard/DashboardLibraries.vue';-import DashboardActivity from '@/components/dashboard/DashboardActivity.vue';+import DashboardSkeleton from '@/components/dashboard/DashboardSkeleton.vue';import DashboardSidebar from '@/components/panels/DashboardSidebar.vue';-import DashboardUsers from '@/components/dashboard/DashboardUsers.vue';-import DashboardTasks from '@/components/dashboard/DashboardTasks.vue';import LayoutBase from '@/layouts/LayoutBase.vue';const { activeDashboardTab } = useDashboardTabs();const { cycleSideBar } = useAppStore();+const DashboardAnalytics = defineAsyncComponent(() => import('@/components/dashboard/DashboardAnalytics.vue'));+const DashboardLibraries = defineAsyncComponent(() => import('@/components/dashboard/DashboardLibraries.vue'));+const DashboardActivity = defineAsyncComponent(() => import('@/components/dashboard/DashboardActivity.vue'));+const DashboardUsers = defineAsyncComponent(() => import('@/components/dashboard/DashboardUsers.vue'));+const DashboardTasks = defineAsyncComponent(() => import('@/components/dashboard/DashboardTasks.vue'));++const activeComponent = computed(() => {+ switch (activeDashboardTab.value?.name) {+ case 'overview':+ return DashboardAnalytics;+ case 'libraries':+ return DashboardLibraries;+ case 'activity':+ return DashboardActivity;+ case 'users':+ return DashboardUsers;+ case 'tasks':+ return DashboardTasks;+ default:+ return null;+ }+});+onMounted(async () => {const screenSize = getScreenSize();@@ -27,16 +46,36 @@ onMounted(async () => {<template><LayoutBase><template v-slot:content>- <section id="content-dashboard" class="page-height flex flex-col gap-4 text-sm">- <DashboardAnalytics v-if="activeDashboardTab?.name == 'overview'" />- <DashboardLibraries v-if="activeDashboardTab?.name == 'libraries'" />- <DashboardActivity v-if="activeDashboardTab?.name == 'activity'" />- <DashboardUsers v-if="activeDashboardTab?.name == 'users'" />- <DashboardTasks v-if="activeDashboardTab?.name == 'tasks'" />- </section>+ <Suspense :timeout="0" :key="activeDashboardTab?.name">+ <template #default>+ <Transition name="fade" mode="out-in" appear>+ <section id="content-dashboard" class="page-height flex flex-col gap-4 text-sm">+ <component :is="activeComponent" />+ </section>+ </Transition>+ </template>++ <template #fallback>+ <Transition name="fade" mode="out-in">+ <DashboardSkeleton />+ </Transition>+ </template>+ </Suspense></template><template v-slot:leftSidebar><DashboardSidebar /></template></LayoutBase></template>++<style scoped lang="css">+.fade-enter-active,+.fade-leave-active {+ transition: opacity 150ms ease;+}++.fade-enter-from,+.fade-leave-to {+ opacity: 0;+}+</style>