diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 83c36c3..2a206df 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -12,6 +12,7 @@ import DraggableGrid, { type GridItemLayout } from './dashboard/DraggableGrid.svelte'; import { dashboardPreferences, dashboardData, GRID_COLS, GRID_ROW_HEIGHT, type TileItem } from '$lib/stores/dashboard'; import { currentEnvironment } from '$lib/stores/environment'; + import { IsMobile } from '$lib/hooks/is-mobile.svelte.js'; import type { EnvironmentStats } from './api/dashboard/stats/+server'; import { getLabelColor, getLabelBgColor } from '$lib/utils/label-colors'; @@ -43,6 +44,8 @@ let initialLoading = $state(true); let refreshing = $state(false); let prefsLoaded = $state(false); + const mobileWatcher = new IsMobile(); + const isMobile = $derived.by(() => mobileWatcher.current); // Label filtering - load from localStorage let filterLabels = $state([]); @@ -113,6 +116,9 @@ return tileLabels.some(label => filterLabels.includes(label)); }); }); + const orderedGridItems = $derived.by(() => { + return [...filteredGridItems].sort((a, b) => (a.y - b.y) || (a.x - b.x)); + }); // AbortController for SSE stream cleanup let abortController: AbortController | null = null; @@ -965,36 +971,67 @@ {:else} - - - {#snippet children({ item })} - {@const tile = getTileById(item.id)} - {#if tile} - {#if tile.loading && !tile.stats} - - - {:else if tile.stats} - - handleEventsClick(tile.stats!.id)} /> + {#if isMobile} +
+ {#each orderedGridItems as item (item.id)} + {@const tile = getTileById(item.id)} + {#if tile} + {#if tile.loading && !tile.stats} + +
+ +
+ {:else if tile.stats} + +
handleTileClick(tile.stats!.id)}> + handleEventsClick(tile.stats!.id)} + /> +
+ {/if} {/if} - {/if} - {/snippet} - + {/each} +
+ {:else} + + + {#snippet children({ item })} + {@const tile = getTileById(item.id)} + {#if tile} + {#if tile.loading && !tile.stats} + + + {:else if tile.stats} + + handleEventsClick(tile.stats!.id)} /> + {/if} + {/if} + {/snippet} + + {/if} {/if}