feat: integrate SvelteKit for seamless navigation and improved data loading
This commit is contained in:
132
frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js
Normal file
132
frontend/.svelte-kit/output/server/entries/pages/_page.svelte.js
Normal file
@@ -0,0 +1,132 @@
|
||||
import { a1 as ssr_context, X as store_get, _ as escape_html, Z as ensure_array_like, V as attr_class, Y as unsubscribe_stores, a2 as attr, a3 as bind_props } from "../../chunks/index2.js";
|
||||
import { w as writable } from "../../chunks/index.js";
|
||||
import "clsx";
|
||||
function onDestroy(fn) {
|
||||
/** @type {SSRContext} */
|
||||
ssr_context.r.on_destroy(fn);
|
||||
}
|
||||
const plugins = writable([]);
|
||||
const selectedPlugin = writable(null);
|
||||
const selectedTask = writable(null);
|
||||
const taskLogs = writable([]);
|
||||
function TaskRunner($$renderer, $$props) {
|
||||
$$renderer.component(($$renderer2) => {
|
||||
var $$store_subs;
|
||||
onDestroy(() => {
|
||||
});
|
||||
$$renderer2.push(`<div class="p-4 border rounded-lg bg-white shadow-md">`);
|
||||
if (store_get($$store_subs ??= {}, "$selectedTask", selectedTask)) {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<h2 class="text-xl font-semibold mb-2">Task: ${escape_html(store_get($$store_subs ??= {}, "$selectedTask", selectedTask).plugin_id)}</h2> <div class="bg-gray-900 text-white font-mono text-sm p-4 rounded-md h-96 overflow-y-auto"><!--[-->`);
|
||||
const each_array = ensure_array_like(store_get($$store_subs ??= {}, "$taskLogs", taskLogs));
|
||||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||||
let log = each_array[$$index];
|
||||
$$renderer2.push(`<div><span class="text-gray-400">${escape_html(new Date(log.timestamp).toLocaleTimeString())}</span> <span${attr_class(log.level === "ERROR" ? "text-red-500" : "text-green-400")}>[${escape_html(log.level)}]</span> <span>${escape_html(log.message)}</span></div>`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--></div>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
$$renderer2.push(`<p>No task selected.</p>`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--></div>`);
|
||||
if ($$store_subs) unsubscribe_stores($$store_subs);
|
||||
});
|
||||
}
|
||||
function DynamicForm($$renderer, $$props) {
|
||||
$$renderer.component(($$renderer2) => {
|
||||
let schema = $$props["schema"];
|
||||
let formData = {};
|
||||
function initializeForm() {
|
||||
if (schema && schema.properties) {
|
||||
for (const key in schema.properties) {
|
||||
formData[key] = schema.properties[key].default || "";
|
||||
}
|
||||
}
|
||||
}
|
||||
initializeForm();
|
||||
$$renderer2.push(`<form class="space-y-4">`);
|
||||
if (schema && schema.properties) {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<!--[-->`);
|
||||
const each_array = ensure_array_like(Object.entries(schema.properties));
|
||||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||||
let [key, prop] = each_array[$$index];
|
||||
$$renderer2.push(`<div class="flex flex-col"><label${attr("for", key)} class="mb-1 font-semibold text-gray-700">${escape_html(prop.title || key)}</label> `);
|
||||
if (prop.type === "string") {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<input type="text"${attr("id", key)}${attr("value", formData[key])}${attr("placeholder", prop.description || "")} class="p-2 border rounded-md"/>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
if (prop.type === "number" || prop.type === "integer") {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<input type="number"${attr("id", key)}${attr("value", formData[key])}${attr("placeholder", prop.description || "")} class="p-2 border rounded-md"/>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
if (prop.type === "boolean") {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<input type="checkbox"${attr("id", key)}${attr("checked", formData[key], true)} class="h-5 w-5"/>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
}
|
||||
$$renderer2.push(`<!--]-->`);
|
||||
}
|
||||
$$renderer2.push(`<!--]-->`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--></div>`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--> <button type="submit" class="w-full bg-green-500 text-white p-2 rounded-md hover:bg-green-600">Run Task</button>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
}
|
||||
$$renderer2.push(`<!--]--></form>`);
|
||||
bind_props($$props, { schema });
|
||||
});
|
||||
}
|
||||
function _page($$renderer, $$props) {
|
||||
$$renderer.component(($$renderer2) => {
|
||||
var $$store_subs;
|
||||
let data = $$props["data"];
|
||||
if (data.plugins) {
|
||||
plugins.set(data.plugins);
|
||||
}
|
||||
$$renderer2.push(`<div class="container mx-auto p-4">`);
|
||||
if (store_get($$store_subs ??= {}, "$selectedTask", selectedTask)) {
|
||||
$$renderer2.push("<!--[-->");
|
||||
TaskRunner($$renderer2);
|
||||
$$renderer2.push(`<!----> <button class="mt-4 bg-blue-500 text-white p-2 rounded">Back to Task List</button>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
if (store_get($$store_subs ??= {}, "$selectedPlugin", selectedPlugin)) {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<h2 class="text-2xl font-bold mb-4">${escape_html(store_get($$store_subs ??= {}, "$selectedPlugin", selectedPlugin).name)}</h2> `);
|
||||
DynamicForm($$renderer2, {
|
||||
schema: store_get($$store_subs ??= {}, "$selectedPlugin", selectedPlugin).schema
|
||||
});
|
||||
$$renderer2.push(`<!----> <button class="mt-4 bg-gray-500 text-white p-2 rounded">Back to Dashboard</button>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
$$renderer2.push(`<h1 class="text-2xl font-bold mb-4">Available Tools</h1> `);
|
||||
if (data.error) {
|
||||
$$renderer2.push("<!--[-->");
|
||||
$$renderer2.push(`<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">${escape_html(data.error)}</div>`);
|
||||
} else {
|
||||
$$renderer2.push("<!--[!-->");
|
||||
}
|
||||
$$renderer2.push(`<!--]--> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"><!--[-->`);
|
||||
const each_array = ensure_array_like(data.plugins);
|
||||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||||
let plugin = each_array[$$index];
|
||||
$$renderer2.push(`<div class="border rounded-lg p-4 cursor-pointer hover:bg-gray-100" role="button" tabindex="0"><h2 class="text-xl font-semibold">${escape_html(plugin.name)}</h2> <p class="text-gray-600">${escape_html(plugin.description)}</p> <span class="text-sm text-gray-400">v${escape_html(plugin.version)}</span></div>`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--></div>`);
|
||||
}
|
||||
$$renderer2.push(`<!--]-->`);
|
||||
}
|
||||
$$renderer2.push(`<!--]--></div>`);
|
||||
if ($$store_subs) unsubscribe_stores($$store_subs);
|
||||
bind_props($$props, { data });
|
||||
});
|
||||
}
|
||||
export {
|
||||
_page as default
|
||||
};
|
||||
Reference in New Issue
Block a user