Clan-app: show nixos machines and inventory machines

This commit is contained in:
Johannes Kirschbauer
2024-08-03 13:12:33 +02:00
parent af79d3e241
commit 66f69e50e8
2 changed files with 44 additions and 72 deletions

View File

@@ -5,7 +5,7 @@ type MachineDetails = SuccessData<"list_inventory_machines">["data"][string];
interface MachineListItemProps {
name: string;
info: MachineDetails;
info?: MachineDetails;
}
type HWInfo = Record<string, SuccessData<"show_machine_hardware_info">["data"]>;
@@ -53,21 +53,6 @@ const [errors, setErrors] = createSignal<MachineErrors>({});
export const MachineListItem = (props: MachineListItemProps) => {
const { name, info } = props;
// const clan_dir = currClanURI();
// if (clan_dir) {
// pyApi.show_machine_hardware_info.dispatch({
// op_key: name,
// clan_dir,
// machine_name: name,
// });
// pyApi.show_machine_deployment_target.dispatch({
// op_key: name,
// clan_dir,
// machine_name: name,
// });
// }
return (
<li>
<div class="card card-side m-2 bg-base-100 shadow-lg">
@@ -80,48 +65,9 @@ export const MachineListItem = (props: MachineListItemProps) => {
<div class="flex flex-col">
<h2 class="card-title">{name}</h2>
<div class="text-slate-600">
<Show
when={info}
fallback={
<Switch fallback={<div class="skeleton h-8 w-full"></div>}>
<Match when={!info.description}>No description</Match>
</Switch>
}
>
{(d) => d()?.description}
</Show>
</div>
<div class="flex flex-row flex-wrap gap-4 py-2">
<div class="badge badge-primary flex flex-row gap-1 py-4 align-middle">
<span>System:</span>
{hwInfo()[name]?.system ? (
<span class="text-primary">{hwInfo()[name]?.system}</span>
) : (
<span class="text-warning">Not set</span>
)}
</div>
<div class="badge badge-ghost flex flex-row gap-1 py-4 align-middle">
<span>Target Host:</span>
{deploymentInfo()[name] ? (
<span class="text-primary">{deploymentInfo()[name]}</span>
) : (
<span class="text-warning">Not set</span>
)}
{/* <Show
when={deploymentInfo()[name]}
fallback={
<Switch fallback={<div class="skeleton h-8 w-full"></div>}>
<Match when={deploymentInfo()[name] !== undefined}>
No deployment target detected
</Match>
</Switch>
}
>
{(i) => + i()}
</Show> */}
</div>
<Show when={info}>{(d) => d()?.description}</Show>
</div>
<div class="flex flex-row flex-wrap gap-4 py-2"></div>
{/* Show only the first error at the bottom */}
<Show when={errors()[name]?.[0]}>
{(error) => (