From bb8b828ad7d2a7e395271d502bb9c41a68185f3d Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Sat, 30 Mar 2024 00:51:57 +0800 Subject: [PATCH] feat(website): add more filters to hosts tabulation --- website/src/components/app/-app.tsx | 181 +++++++++++++++++++++++++--- 1 file changed, 164 insertions(+), 17 deletions(-) diff --git a/website/src/components/app/-app.tsx b/website/src/components/app/-app.tsx index 35f5070..d93746f 100644 --- a/website/src/components/app/-app.tsx +++ b/website/src/components/app/-app.tsx @@ -1,7 +1,7 @@ import { Card, CardBody, CardHeader } from '@nextui-org/card'; import { Chip } from '@nextui-org/chip'; import { Listbox, ListboxItem, ListboxSection } from '@nextui-org/listbox'; -import { Select, SelectItem, Selection } from '@nextui-org/react'; +import { Radio, RadioGroup, Select, SelectItem, Selection, Slider } from '@nextui-org/react'; import { Table, TableBody, TableCell, TableColumn, TableHeader, TableRow } from '@nextui-org/table'; import Image from 'next/image'; import Link from 'next/link'; @@ -111,11 +111,11 @@ export function TabulateHosts({ hosts, onHostSelect }: { hosts: LhpData[]; onHos return (
-
+
-
+
-
+
+ +
+ +
-
+
-
+
+ +
+ +
+ x.hardware.cpuCount))} + maxValue={Math.max(...hosts.map((x) => x.hardware.cpuCount))} + defaultValue={[ + Math.min(...hosts.map((x) => x.hardware.cpuCount)), + Math.max(...hosts.map((x) => x.hardware.cpuCount)), + ]} + className="max-w-md" + onChange={(x) => { + if (Array.isArray(x)) { + const [mi, ma] = x; + setFilters({ + ...filters, + cpu: (h) => mi <= h.hardware.cpuCount && h.hardware.cpuCount <= ma, + }); + } + }} + /> +
+ +
+ x.hardware.ramTotal)))} + defaultValue={[0, Math.ceil(Math.max(...hosts.map((x) => x.hardware.ramTotal)))]} + className="max-w-md" + onChange={(x) => { + if (Array.isArray(x)) { + const [mi, ma] = x; + setFilters({ + ...filters, + ram: (h) => mi <= h.hardware.ramTotal && h.hardware.ramTotal <= ma, + }); + } + }} + /> +
+ +
+ x.hardware.diskRoot)))} + defaultValue={[0, Math.ceil(Math.max(...hosts.map((x) => x.hardware.diskRoot)))]} + className="max-w-md" + onChange={(x) => { + if (Array.isArray(x)) { + const [mi, ma] = x; + setFilters({ + ...filters, + disk: (h) => mi <= h.hardware.diskRoot && h.hardware.diskRoot <= ma, + }); + } + }} + /> +
+ +
+ { + setFilters({ + ...filters, + docker: + x === 'yes' + ? (h) => h.dockerContainers != null + : x === 'no' + ? (h) => h.dockerContainers == null + : () => true, + }); + }} + > + All + Yes + No + +
+ +