diff --git a/website/src/components/app/-app.tsx b/website/src/components/app/-app.tsx index a39fb64..d93746f 100644 --- a/website/src/components/app/-app.tsx +++ b/website/src/components/app/-app.tsx @@ -1,11 +1,12 @@ import { Card, CardBody, CardHeader } from '@nextui-org/card'; import { Chip } from '@nextui-org/chip'; import { Listbox, ListboxItem, ListboxSection } from '@nextui-org/listbox'; +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'; import { Just, Maybe, Nothing } from 'purify-ts/Maybe'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import { LhpData } from './-data'; import { KVBox } from './-ui'; @@ -100,8 +101,281 @@ export function cloudIcon(x: string) { } export function TabulateHosts({ hosts, onHostSelect }: { hosts: LhpData[]; onHostSelect: (host: LhpData) => void }) { + const [filters, setFilters] = useState boolean>>({}); + const [filteredHosts, setFilteredHosts] = useState(hosts); + + useEffect(() => { + setFilteredHosts(hosts.filter((host) => Object.values(filters).reduce((acc, f) => acc && f(host), true))); + }, [filters, hosts]); + 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 + +
+ +
+ +
+
+ Tags - + {(host) => (