clan-cli: Unify list_machines and use flake caching
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../clan-cli/clan_lib"
|
||||
},
|
||||
{
|
||||
"path": "../webview-ui"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
|
||||
10
pkgs/clan-app/ui/src/api/manual_types.tsx
Normal file
10
pkgs/clan-app/ui/src/api/manual_types.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface Machine {
|
||||
machine: {
|
||||
name: string;
|
||||
flake: {
|
||||
identifier: string;
|
||||
};
|
||||
override_target_host: string | null;
|
||||
private_key: string | null;
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { Filter } from "../../routes/machines";
|
||||
import { Typography } from "../Typography";
|
||||
import "./css/index.css";
|
||||
|
||||
type MachineDetails = SuccessQuery<"list_machines">["data"][string];
|
||||
type MachineDetails = SuccessQuery<"list_inv_machines">["data"][string];
|
||||
|
||||
interface MachineListItemProps {
|
||||
name: string;
|
||||
|
||||
@@ -61,7 +61,7 @@ export function CreateMachine() {
|
||||
reset(formStore);
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [activeURI(), "list_machines"],
|
||||
queryKey: [activeURI(), "list_inv_machines"],
|
||||
});
|
||||
navigate("/machines");
|
||||
} else {
|
||||
|
||||
@@ -391,12 +391,14 @@ const MachineForm = (props: MachineDetailsProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const machine_response = await callApi("set_machine", {
|
||||
flake: {
|
||||
identifier: curr_uri,
|
||||
},
|
||||
machine_name: props.initialData.machine.name || "My machine",
|
||||
const machine_response = await callApi("set_inv_machine", {
|
||||
machine: {
|
||||
name: props.initialData.machine.name || "My machine",
|
||||
flake: {
|
||||
identifier: curr_uri,
|
||||
},
|
||||
},
|
||||
inventory_machine: {
|
||||
...values.machine,
|
||||
// TODO: Remove this workaround
|
||||
tags: Array.from(
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Header } from "@/src/layout/header";
|
||||
import { makePersisted } from "@solid-primitives/storage";
|
||||
|
||||
type MachinesModel = Extract<
|
||||
OperationResponse<"list_machines">,
|
||||
OperationResponse<"list_inv_machines">,
|
||||
{ status: "success" }
|
||||
>["data"];
|
||||
|
||||
@@ -32,13 +32,13 @@ export const MachineListView: Component = () => {
|
||||
const [filter, setFilter] = createSignal<Filter>({ tags: [] });
|
||||
|
||||
const inventoryQuery = createQuery<MachinesModel>(() => ({
|
||||
queryKey: [activeURI(), "list_machines"],
|
||||
queryKey: [activeURI(), "list_inv_machines"],
|
||||
placeholderData: {},
|
||||
enabled: !!activeURI(),
|
||||
queryFn: async () => {
|
||||
const uri = activeURI();
|
||||
if (uri) {
|
||||
const response = await callApi("list_machines", {
|
||||
const response = await callApi("list_inv_machines", {
|
||||
flake: {
|
||||
identifier: uri,
|
||||
},
|
||||
@@ -56,7 +56,7 @@ export const MachineListView: Component = () => {
|
||||
const refresh = async () => {
|
||||
queryClient.invalidateQueries({
|
||||
// Invalidates the cache for of all types of machine list at once
|
||||
queryKey: [activeURI(), "list_machines"],
|
||||
queryKey: [activeURI(), "list_inv_machines"],
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user