Add frontend support for settings

This commit is contained in:
Sami Abuzakuk
2025-10-12 10:22:20 +02:00
parent 288a40952e
commit c8aa5e9917
4 changed files with 145 additions and 4 deletions

View File

@@ -1,5 +1,12 @@
<script lang="ts">
import { updateScript, deleteScript, addLog, deleteLog, executeScript } from '$lib/api';
import {
updateScript,
deleteScript,
addLog,
deleteLog,
executeScript,
fetchLogs
} from '$lib/api';
import type { Script, Log } from '$lib/api';
import CodeMirror from 'svelte-codemirror-editor';
import { python } from '@codemirror/lang-python';
@@ -29,12 +36,14 @@
selectedLog = null;
}
// Notifications are now handled globally via the layout
async function handleExecuteScript() {
try {
await executeScript(script.id);
window.showNotification('success', 'Script executed successfully!');
// Reload the list of logs after execution
logs = (await fetchLogs(script.id)).sort(
(a, b) => new Date(b.created_at!).getTime() - new Date(a.created_at!).getTime()
);
} catch (err) {
window.showNotification('error', 'Failed to execute script. ' + err);
}
@@ -252,7 +261,7 @@
<div
class="fixed inset-0 bg-opacity-30 backdrop-blur-sm flex items-center justify-center z-50"
>
<div class="bg-white p-6 rounded shadow-lg w-3/4 max-w-2xl">
<div class="bg-white p-6 rounded shadow-lg w-3/4 max-w-2xl max-h-[80vh] overflow-y-auto">
<h3 class="text-lg font-bold mb-4">Log Details</h3>
<div class="mb-4">
<p class="font-semibold">Message:</p>