Merge pull request 'Webview: migrate create clan form to async api' (#1757) from hsjobeki/clan-core:hsjobeki-main into main
All checks were successful
buildbot/nix-build .#checks.aarch64-darwin.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-bash Build done.
buildbot/nix-build .#checks.x86_64-linux.check-for-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-archlinux Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-deb Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-apk Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-rpm Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-git Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-e2fsprogs Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-mypy Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-nix Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-age Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-openssh Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-rsync Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-no-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sops Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sshpass Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-tor Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-qemu Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-zbar Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-with-core Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-pytest Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-default Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.borgbackup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-without-core Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-inventory-eval Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-example-valid Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-inventory-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.module-clan-vars-eval Build done.
buildbot/nix-build .#checks.x86_64-linux.container Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-inventory-examples-cue Build done.
buildbot/nix-build .#checks.x86_64-linux.deltachat Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.matrix-synapse Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-full Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-ts-api Build done.
buildbot/nix-build .#checks.x86_64-linux.package-default Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.package-editor Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.x86_64-linux.module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-merge-after-ci Build done.
buildbot/nix-build .#checks.x86_64-linux.package-impure-checks Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-nix-unit-tests Build done.
buildbot/nix-build .#checks.x86_64-linux.package-moonlight-sunshine-accept Build done.
buildbot/nix-build .#checks.x86_64-linux.package-pending-reviews Build done.
buildbot/nix-build .#checks.x86_64-linux.package-tea-create-pr Build done.
buildbot/nix-build .#checks.x86_64-linux.package-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotier-members Build done.
buildbot/nix-build .#checks.x86_64-linux.package-inventory-schema-pretty Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotierone Build done.
buildbot/nix-build .#checks.x86_64-linux.flash Build done.
buildbot/nix-build .#checks.x86_64-linux.package-deploy-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-inventory-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.renderClanOptions Build done.
buildbot/nix-build .#checks.x86_64-linux.postgresql Build done.
buildbot/nix-build .#checks.x86_64-linux.secrets Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-function-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.test-backups Build done.
buildbot/nix-build .#checks.x86_64-linux.template-minimal Build done.
buildbot/nix-build .#checks.x86_64-linux.treefmt Build done.
buildbot/nix-build .#checks.x86_64-linux.zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.wayland-proxy-virtwl Build done.
buildbot/nix-build .#checks.x86_64-linux.syncthing Build done.
buildbot/nix-build .#checks.x86_64-linux.test-installation Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-install-test-ubuntu-22-04 Build done.
buildbot/nix-eval Build done.
checks / checks-impure (push) Successful in 3m6s
deploy / deploy-docs (push) Successful in 19s
All checks were successful
buildbot/nix-build .#checks.aarch64-darwin.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-bash Build done.
buildbot/nix-build .#checks.x86_64-linux.check-for-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-archlinux Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-deb Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-apk Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-rpm Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-git Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-e2fsprogs Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-mypy Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-nix Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-age Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-openssh Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-rsync Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-no-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sops Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sshpass Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-tor Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-qemu Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-zbar Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-with-core Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-pytest Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-default Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.borgbackup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-without-core Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-inventory-eval Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-example-valid Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-inventory-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.module-clan-vars-eval Build done.
buildbot/nix-build .#checks.x86_64-linux.container Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-inventory-examples-cue Build done.
buildbot/nix-build .#checks.x86_64-linux.deltachat Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.matrix-synapse Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-full Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-ts-api Build done.
buildbot/nix-build .#checks.x86_64-linux.package-default Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.package-editor Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-minimal-inventory-machine Build done.
buildbot/nix-build .#checks.x86_64-linux.module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-merge-after-ci Build done.
buildbot/nix-build .#checks.x86_64-linux.package-impure-checks Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-nix-unit-tests Build done.
buildbot/nix-build .#checks.x86_64-linux.package-moonlight-sunshine-accept Build done.
buildbot/nix-build .#checks.x86_64-linux.package-pending-reviews Build done.
buildbot/nix-build .#checks.x86_64-linux.package-tea-create-pr Build done.
buildbot/nix-build .#checks.x86_64-linux.package-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotier-members Build done.
buildbot/nix-build .#checks.x86_64-linux.package-inventory-schema-pretty Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotierone Build done.
buildbot/nix-build .#checks.x86_64-linux.flash Build done.
buildbot/nix-build .#checks.x86_64-linux.package-deploy-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-inventory-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.renderClanOptions Build done.
buildbot/nix-build .#checks.x86_64-linux.postgresql Build done.
buildbot/nix-build .#checks.x86_64-linux.secrets Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-function-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.test-backups Build done.
buildbot/nix-build .#checks.x86_64-linux.template-minimal Build done.
buildbot/nix-build .#checks.x86_64-linux.treefmt Build done.
buildbot/nix-build .#checks.x86_64-linux.zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.wayland-proxy-virtwl Build done.
buildbot/nix-build .#checks.x86_64-linux.syncthing Build done.
buildbot/nix-build .#checks.x86_64-linux.test-installation Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-install-test-ubuntu-22-04 Build done.
buildbot/nix-eval Build done.
checks / checks-impure (push) Successful in 3m6s
deploy / deploy-docs (push) Successful in 19s
This commit is contained in:
commit
495a7a4289
@ -7,6 +7,7 @@ import { BlockDevicesView } from "./routes/blockdevices/view";
|
||||
import { Flash } from "./routes/flash/view";
|
||||
import { Settings } from "./routes/settings";
|
||||
import { Welcome } from "./routes/welcome";
|
||||
import { Deploy } from "./routes/deploy";
|
||||
|
||||
export type Route = keyof typeof routes;
|
||||
|
||||
@ -51,6 +52,11 @@ export const routes = {
|
||||
label: "welcome",
|
||||
icon: "settings",
|
||||
},
|
||||
deploy: {
|
||||
child: Deploy,
|
||||
label: "deploy",
|
||||
icon: "content_copy",
|
||||
},
|
||||
};
|
||||
|
||||
interface RouterProps {
|
||||
|
@ -1,6 +1,21 @@
|
||||
import { createQuery } from "@tanstack/solid-query";
|
||||
import { activeURI, setRoute } from "../App";
|
||||
import { callApi } from "../api";
|
||||
import { Show } from "solid-js";
|
||||
|
||||
export const Header = () => {
|
||||
const { isLoading, data } = createQuery(() => ({
|
||||
queryKey: [`${activeURI()}:meta`],
|
||||
queryFn: async () => {
|
||||
const currUri = activeURI();
|
||||
if (currUri) {
|
||||
const result = await callApi("show_clan_meta", { uri: currUri });
|
||||
if (result.status === "error") throw new Error("Failed to fetch data");
|
||||
return result.data;
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
return (
|
||||
<div class="navbar bg-base-100">
|
||||
<div class="flex-none">
|
||||
@ -14,7 +29,16 @@ export const Header = () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<a class="text-xl">{activeURI()}</a>
|
||||
<div class="tooltip tooltip-right" data-tip={data?.name || activeURI()}>
|
||||
<div class="avatar placeholder online mx-4">
|
||||
<div class="w-10 rounded-full bg-slate-700 text-neutral-content">
|
||||
<span class="text-xl">C</span>
|
||||
<Show when={data?.name}>
|
||||
{(name) => <span class="text-xl">{name()}</span>}
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-none">
|
||||
<span class="tooltip tooltip-bottom" data-tip="Settings">
|
||||
|
@ -1,26 +1,14 @@
|
||||
import { OperationResponse, pyApi } from "@/src/api";
|
||||
import {
|
||||
For,
|
||||
JSX,
|
||||
Match,
|
||||
Show,
|
||||
Switch,
|
||||
createEffect,
|
||||
createSignal,
|
||||
} from "solid-js";
|
||||
import { OperationResponse, callApi, pyApi } from "@/src/api";
|
||||
import { Show } from "solid-js";
|
||||
import {
|
||||
SubmitHandler,
|
||||
createForm,
|
||||
required,
|
||||
custom,
|
||||
reset,
|
||||
} from "@modular-forms/solid";
|
||||
import toast from "solid-toast";
|
||||
import { setActiveURI, setRoute } from "@/src/App";
|
||||
|
||||
interface ClanDetailsProps {
|
||||
directory: string;
|
||||
}
|
||||
|
||||
type CreateForm = Meta & {
|
||||
template_url: string;
|
||||
};
|
||||
@ -28,69 +16,44 @@ type CreateForm = Meta & {
|
||||
export const ClanForm = () => {
|
||||
const [formStore, { Form, Field }] = createForm<CreateForm>({
|
||||
initialValues: {
|
||||
name: "",
|
||||
description: "",
|
||||
template_url: "git+https://git.clan.lol/clan/clan-core#templates.minimal",
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit: SubmitHandler<CreateForm> = async (values, event) => {
|
||||
const { template_url, ...meta } = values;
|
||||
pyApi.open_file.dispatch({
|
||||
file_request: {
|
||||
mode: "save",
|
||||
},
|
||||
|
||||
op_key: "create_clan",
|
||||
const response = await callApi("open_file", {
|
||||
file_request: { mode: "save" },
|
||||
});
|
||||
|
||||
// await new Promise<void>((done) => {
|
||||
// pyApi.open_file.receive((r) => {
|
||||
// if (r.op_key !== "create_clan") {
|
||||
// done();
|
||||
// return;
|
||||
// }
|
||||
// if (r.status !== "success") {
|
||||
// toast.error("Cannot select clan directory");
|
||||
// done();
|
||||
// return;
|
||||
// }
|
||||
// const target_dir = r?.data;
|
||||
// if (!target_dir) {
|
||||
// toast.error("Cannot select clan directory");
|
||||
// done();
|
||||
// return;
|
||||
// }
|
||||
if (response.status !== "success") {
|
||||
toast.error("Cannot select clan directory");
|
||||
return;
|
||||
}
|
||||
const target_dir = response?.data;
|
||||
if (!target_dir) {
|
||||
toast.error("Cannot select clan directory");
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log({ formStore });
|
||||
|
||||
// toast.promise(
|
||||
// new Promise<void>((resolve, reject) => {
|
||||
// pyApi.create_clan.receive((r) => {
|
||||
// done();
|
||||
// if (r.status === "error") {
|
||||
// reject();
|
||||
// console.error(r.errors);
|
||||
// return;
|
||||
// }
|
||||
// resolve();
|
||||
|
||||
// // Navigate to the new clan
|
||||
// setCurrClanURI(target_dir);
|
||||
// setRoute("machines");
|
||||
// });
|
||||
|
||||
// pyApi.create_clan.dispatch({
|
||||
// options: { directory: target_dir, meta, template_url },
|
||||
// op_key: "create_clan",
|
||||
// });
|
||||
// }),
|
||||
// {
|
||||
// loading: "Creating clan...",
|
||||
// success: "Clan Successfully Created",
|
||||
// error: "Failed to create clan",
|
||||
// }
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
await toast.promise(
|
||||
(async () => {
|
||||
await callApi("create_clan", {
|
||||
options: { directory: target_dir, meta, template_url },
|
||||
});
|
||||
setActiveURI(target_dir);
|
||||
setRoute("machines");
|
||||
})(),
|
||||
{
|
||||
loading: "Creating clan...",
|
||||
success: "Clan Successfully Created",
|
||||
error: "Failed to create clan",
|
||||
}
|
||||
);
|
||||
reset(formStore);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -135,6 +98,7 @@ export const ClanForm = () => {
|
||||
|
||||
<input
|
||||
{...props}
|
||||
disabled={formStore.submitting}
|
||||
required
|
||||
placeholder="Clan Name"
|
||||
class="input input-bordered"
|
||||
@ -158,6 +122,7 @@ export const ClanForm = () => {
|
||||
|
||||
<input
|
||||
{...props}
|
||||
disabled={formStore.submitting}
|
||||
required
|
||||
type="text"
|
||||
placeholder="Some words about your clan"
|
||||
@ -188,6 +153,7 @@ export const ClanForm = () => {
|
||||
<input
|
||||
{...props}
|
||||
required
|
||||
disabled={formStore.submitting}
|
||||
type="text"
|
||||
placeholder="Template to use"
|
||||
class="input input-bordered"
|
||||
|
6
pkgs/webview-ui/app/src/routes/deploy/index.tsx
Normal file
6
pkgs/webview-ui/app/src/routes/deploy/index.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import { callApi } from "@/src/api";
|
||||
import { createQuery } from "@tanstack/solid-query";
|
||||
|
||||
export const Deploy = () => {
|
||||
return <div>Deloy view</div>;
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
import { route } from "@/src/App";
|
||||
import { OperationArgs, OperationResponse, pyApi } from "@/src/api";
|
||||
import { OperationArgs, OperationResponse, callApi, pyApi } from "@/src/api";
|
||||
import { SubmitHandler, createForm, required } from "@modular-forms/solid";
|
||||
import { createQuery } from "@tanstack/solid-query";
|
||||
import { For, createSignal } from "solid-js";
|
||||
import { effect } from "solid-js/web";
|
||||
|
||||
@ -28,36 +29,35 @@ type BlockDevices = Extract<
|
||||
export const Flash = () => {
|
||||
const [formStore, { Form, Field }] = createForm<FlashFormValues>({});
|
||||
|
||||
const [devices, setDevices] = createSignal<BlockDevices>([]);
|
||||
// pyApi.show_block_devices.receive((r) => {
|
||||
// console.log("block devices", r);
|
||||
// if (r.status === "success") {
|
||||
// setDevices(r.data.blockdevices);
|
||||
// }
|
||||
// });
|
||||
const {
|
||||
data: devices,
|
||||
refetch: loadDevices,
|
||||
isFetching,
|
||||
} = createQuery(() => ({
|
||||
queryKey: ["TanStack Query"],
|
||||
queryFn: async () => {
|
||||
const result = await callApi("show_block_devices", {});
|
||||
if (result.status === "error") throw new Error("Failed to fetch data");
|
||||
return result.data;
|
||||
},
|
||||
staleTime: 1000 * 60 * 1, // 1 minutes
|
||||
}));
|
||||
|
||||
const handleSubmit: SubmitHandler<FlashFormValues> = (values, event) => {
|
||||
// pyApi.open_file.dispatch({ file_request: { mode: "save" } });
|
||||
// pyApi.open_file.receive((r) => {
|
||||
// if (r.status === "success") {
|
||||
// if (r.data) {
|
||||
// pyApi.create_clan.dispatch({
|
||||
// options: { directory: r.data, meta: values },
|
||||
// });
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
const handleSubmit = async (values: FlashFormValues) => {
|
||||
// TODO: Rework Flash machine API
|
||||
// Its unusable in its current state
|
||||
// await callApi("flash_machine", {
|
||||
// machine: {
|
||||
// name: "",
|
||||
// },
|
||||
// disks: {values.disk },
|
||||
// dry_run: true,
|
||||
// });
|
||||
console.log("submit", values);
|
||||
};
|
||||
|
||||
// effect(() => {
|
||||
// if (route() === "flash") {
|
||||
// pyApi.show_block_devices.dispatch({});
|
||||
// }
|
||||
// });
|
||||
return (
|
||||
<div class="">
|
||||
<div class="px-2">
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Field
|
||||
name="machine.flake"
|
||||
@ -70,7 +70,7 @@ export const Flash = () => {
|
||||
<input
|
||||
type="text"
|
||||
class="grow"
|
||||
placeholder="Clan URI"
|
||||
placeholder="machine.flake"
|
||||
required
|
||||
{...props}
|
||||
/>
|
||||
@ -96,7 +96,7 @@ export const Flash = () => {
|
||||
<input
|
||||
type="text"
|
||||
class="grow"
|
||||
placeholder="Machine Name"
|
||||
placeholder="machine.name"
|
||||
required
|
||||
{...props}
|
||||
/>
|
||||
@ -115,9 +115,15 @@ export const Flash = () => {
|
||||
{(field, props) => (
|
||||
<>
|
||||
<label class="form-control input-bordered flex w-full items-center gap-2">
|
||||
<select required class="select w-full" {...props}>
|
||||
<select
|
||||
required
|
||||
class="select select-bordered w-full"
|
||||
{...props}
|
||||
>
|
||||
{/* <span class="material-icons">devices</span> */}
|
||||
<For each={devices()}>
|
||||
<option disabled>Select a disk</option>
|
||||
|
||||
<For each={devices?.blockdevices}>
|
||||
{(device) => (
|
||||
<option value={device.name}>
|
||||
{device.name} / {device.size} bytes
|
||||
@ -126,6 +132,11 @@ export const Flash = () => {
|
||||
</For>
|
||||
</select>
|
||||
<div class="label">
|
||||
{isFetching && (
|
||||
<span class="label-text-alt">
|
||||
<span class="loading loading-bars"></span>
|
||||
</span>
|
||||
)}
|
||||
{field.error && (
|
||||
<span class="label-text-alt font-bold text-error">
|
||||
{field.error}
|
||||
|
Loading…
Reference in New Issue
Block a user