feat: implement plugin architecture and application settings with Svelte UI
- Added plugin base and loader for backend extensibility - Implemented application settings management with config persistence - Created Svelte-based frontend with Dashboard and Settings pages - Added API routes for plugins, tasks, and settings - Updated documentation and specifications - Improved project structure and developer tools
This commit is contained in:
100
frontend/src/lib/stores.js
Normal file → Executable file
100
frontend/src/lib/stores.js
Normal file → Executable file
@@ -1,40 +1,60 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { api } from './api.js';
|
||||
|
||||
// Store for the list of available plugins
|
||||
export const plugins = writable([]);
|
||||
|
||||
// Store for the list of tasks
|
||||
export const tasks = writable([]);
|
||||
|
||||
// Store for the currently selected plugin
|
||||
export const selectedPlugin = writable(null);
|
||||
|
||||
// Store for the currently selected task
|
||||
export const selectedTask = writable(null);
|
||||
|
||||
// Store for the logs of the currently selected task
|
||||
export const taskLogs = writable([]);
|
||||
|
||||
// Function to fetch plugins from the API
|
||||
export async function fetchPlugins() {
|
||||
try {
|
||||
const data = await api.getPlugins();
|
||||
console.log('Fetched plugins:', data); // Add console log
|
||||
plugins.set(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching plugins:', error);
|
||||
// Handle error appropriately in the UI
|
||||
}
|
||||
}
|
||||
|
||||
// Function to fetch tasks from the API
|
||||
export async function fetchTasks() {
|
||||
try {
|
||||
const data = await api.getTasks();
|
||||
tasks.set(data);
|
||||
} catch (error) {
|
||||
console.error('Error fetching tasks:', error);
|
||||
// Handle error appropriately in the UI
|
||||
}
|
||||
}
|
||||
// [DEF:stores_module:Module]
|
||||
// @SEMANTICS: state, stores, svelte, plugins, tasks
|
||||
// @PURPOSE: Global state management using Svelte stores.
|
||||
// @LAYER: UI-State
|
||||
|
||||
import { writable } from 'svelte/store';
|
||||
import { api } from './api.js';
|
||||
|
||||
// [DEF:plugins:Data]
|
||||
// @PURPOSE: Store for the list of available plugins.
|
||||
export const plugins = writable([]);
|
||||
|
||||
// [DEF:tasks:Data]
|
||||
// @PURPOSE: Store for the list of tasks.
|
||||
export const tasks = writable([]);
|
||||
|
||||
// [DEF:selectedPlugin:Data]
|
||||
// @PURPOSE: Store for the currently selected plugin.
|
||||
export const selectedPlugin = writable(null);
|
||||
|
||||
// [DEF:selectedTask:Data]
|
||||
// @PURPOSE: Store for the currently selected task.
|
||||
export const selectedTask = writable(null);
|
||||
|
||||
// [DEF:currentPage:Data]
|
||||
// @PURPOSE: Store for the current page.
|
||||
export const currentPage = writable('dashboard');
|
||||
|
||||
// [DEF:taskLogs:Data]
|
||||
// @PURPOSE: Store for the logs of the currently selected task.
|
||||
export const taskLogs = writable([]);
|
||||
|
||||
// [DEF:fetchPlugins:Function]
|
||||
// @PURPOSE: Fetches plugins from the API and updates the plugins store.
|
||||
export async function fetchPlugins() {
|
||||
try {
|
||||
console.log("[stores.fetchPlugins][Action] Fetching plugins.");
|
||||
const data = await api.getPlugins();
|
||||
console.log("[stores.fetchPlugins][Coherence:OK] Plugins fetched context={{'count': " + data.length + "}}");
|
||||
plugins.set(data);
|
||||
} catch (error) {
|
||||
console.error(`[stores.fetchPlugins][Coherence:Failed] Error fetching plugins context={{'error': '${error}'}}`);
|
||||
}
|
||||
}
|
||||
// [/DEF:fetchPlugins]
|
||||
|
||||
// [DEF:fetchTasks:Function]
|
||||
// @PURPOSE: Fetches tasks from the API and updates the tasks store.
|
||||
export async function fetchTasks() {
|
||||
try {
|
||||
console.log("[stores.fetchTasks][Action] Fetching tasks.");
|
||||
const data = await api.getTasks();
|
||||
console.log("[stores.fetchTasks][Coherence:OK] Tasks fetched context={{'count': " + data.length + "}}");
|
||||
tasks.set(data);
|
||||
} catch (error) {
|
||||
console.error(`[stores.fetchTasks][Coherence:Failed] Error fetching tasks context={{'error': '${error}'}}`);
|
||||
}
|
||||
}
|
||||
// [/DEF:fetchTasks]
|
||||
// [/DEF:stores_module]
|
||||
Reference in New Issue
Block a user