From 99dd437834ad800475912045e347f374495e2f0a Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 11 Dec 2024 11:32:51 +0100 Subject: [PATCH] UI: module list toggle {list,grid} view --- .../app/src/routes/modules/list.tsx | 173 +++++++++++++++--- 1 file changed, 152 insertions(+), 21 deletions(-) diff --git a/pkgs/webview-ui/app/src/routes/modules/list.tsx b/pkgs/webview-ui/app/src/routes/modules/list.tsx index 5bf699cdb..994333a01 100644 --- a/pkgs/webview-ui/app/src/routes/modules/list.tsx +++ b/pkgs/webview-ui/app/src/routes/modules/list.tsx @@ -1,48 +1,179 @@ -import { callApi, SuccessData } from "@/src/api"; +import { SuccessData } from "@/src/api"; import { activeURI } from "@/src/App"; +import { Button } from "@/src/components/button"; +import { Header } from "@/src/layout/header"; import { createModulesQuery } from "@/src/queries"; import { A, useNavigate } from "@solidjs/router"; -import { createQuery, useQueryClient } from "@tanstack/solid-query"; -import { createEffect, For, Match, Switch } from "solid-js"; -import { SolidMarkdown } from "solid-markdown"; +import { createSignal, For, Match, Switch } from "solid-js"; +import { Typography } from "@/src/components/Typography"; +import { Menu } from "@/src/components/Menu"; +import { makePersisted } from "@solid-primitives/storage"; +import { useQueryClient } from "@tanstack/solid-query"; +import cx from "classnames"; +import Icon from "@/src/components/icon"; export type ModuleInfo = SuccessData<"list_modules">[string]; -const ModuleListItem = (props: { name: string; info: ModuleInfo }) => { +interface CategoryProps { + categories: string[]; +} +const Categories = (props: CategoryProps) => { + return ( + + {props.categories.map((category) => ( + {category} + ))} + + ); +}; + +interface RolesProps { + roles: string[]; +} +const Roles = (props: RolesProps) => { + return ( +
+ + + Service Typography{" "} + + + {props.roles.map((role) => ( + {role} + ))} +
+ ); +}; + +const ModuleItem = (props: { + name: string; + info: ModuleInfo; + class?: string; +}) => { const { name, info } = props; const navigate = useNavigate(); return ( -
+
-
{name}
+
+ {name} + +
-
{info.description}
-
{JSON.stringify(info.constraints)}
+
+ + {info.description} + +
+
); }; export const ModuleList = () => { + const queryClient = useQueryClient(); const modulesQuery = createModulesQuery(activeURI(), { features: ["inventory"], }); + + const [view, setView] = makePersisted(createSignal<"list" | "grid">("list"), { + name: "modules_view", + storage: localStorage, + }); + + const refresh = async () => { + queryClient.invalidateQueries({ + // Invalidates the cache for of all types of machine list at once + queryKey: [activeURI(), "list_modules"], + }); + }; return ( - - Loading.... - -
- Show Modules - - {([k, v]) => } - -
-
-
+ <> +
+ + + + +
+ + + + + + +
+ + + + + } + /> + + Loading.... + +
+ + {([k, v]) => ( + + )} + +
+
+
+ ); };