diff --git a/frontend/src/app/data/page.tsx b/frontend/src/app/data/page.tsx index 04943c991a..b4969e4ec9 100644 --- a/frontend/src/app/data/page.tsx +++ b/frontend/src/app/data/page.tsx @@ -11,18 +11,16 @@ import { Trophy, XCircle, } from "lucide-react"; -import { - Bar, - BarChart, - CartesianGrid, - Cell, - LabelList, - XAxis, -} from "recharts"; -import React, { useEffect, useMemo, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; +import { Bar, BarChart, CartesianGrid, Cell, LabelList, XAxis } from "recharts"; import type { ChartConfig } from "@/components/ui/chart"; +import { formattedBadge } from "@/components/command-menu"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"; import { Dialog, DialogContent, @@ -31,37 +29,10 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { - ChartContainer, - ChartTooltip, - ChartTooltipContent, -} from "@/components/ui/chart"; -import { formattedBadge } from "@/components/command-menu"; import { ScrollArea } from "@/components/ui/scroll-area"; -import { Button } from "@/components/ui/button"; -import { Badge } from "@/components/ui/badge"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; type DataModel = { id: number; @@ -141,7 +112,8 @@ export default function DataPage() { const [summaryRes, dataRes] = await Promise.all([ fetch("https://api.htl-braunau.at/data/summary"), fetch( - `https://api.htl-braunau.at/data/paginated?page=${currentPage}&limit=${itemsPerPage === 0 ? "" : itemsPerPage + `https://api.htl-braunau.at/data/paginated?page=${currentPage}&limit=${ + itemsPerPage === 0 ? "" : itemsPerPage }`, ), ]); @@ -158,11 +130,9 @@ export default function DataPage() { setSummary(summaryData); setData(pageData); - } - catch (err) { + } catch (err) { setError((err as Error).message); - } - finally { + } finally { setLoading(false); } }; @@ -171,8 +141,7 @@ export default function DataPage() { }, [currentPage, itemsPerPage]); const sortedData = useMemo(() => { - if (!sortConfig) - return data; + if (!sortConfig) return data; return [...data].sort((a, b) => { if (a[sortConfig.key] < b[sortConfig.key]) { return sortConfig.direction === "ascending" ? -1 : 1; @@ -186,11 +155,7 @@ export default function DataPage() { const requestSort = (key: string) => { let direction: "ascending" | "descending" = "ascending"; - if ( - sortConfig - && sortConfig.key === key - && sortConfig.direction === "ascending" - ) { + if (sortConfig && sortConfig.key === key && sortConfig.direction === "ascending") { direction = "descending"; } setSortConfig({ key, direction }); @@ -205,10 +170,8 @@ export default function DataPage() { }; const getTypeBadge = (type: string) => { - if (type === "lxc") - return formattedBadge("ct"); - if (type === "vm") - return formattedBadge("vm"); + if (type === "lxc") return formattedBadge("ct"); + if (type === "vm") return formattedBadge("vm"); return null; }; @@ -219,8 +182,7 @@ export default function DataPage() { const successRate = totalCount > 0 ? (successCount / totalCount) * 100 : 0; const allApps = useMemo(() => { - if (!summary?.nsapp_count) - return []; + if (!summary?.nsapp_count) return []; return Object.entries(summary.nsapp_count).sort(([, a], [, b]) => b - a); }, [summary]); @@ -255,9 +217,7 @@ export default function DataPage() { {/* Header */}
- Overview of container installations and system statistics. -
+Overview of container installations and system statistics.
- Total LXC/VM entries found -
+Total LXC/VM entries found
- {nf.format(successCount)} - {" "} - successful installations -
+{nf.format(successCount)} successful installations
- Installations encountered errors -
+Installations encountered errors
- {mostPopularApp ? nf.format(mostPopularApp[1]) : 0} - {" "} - installations + {mostPopularApp ? nf.format(mostPopularApp[1]) : 0} installations