Files
ss-tools/frontend/src/lib/stores.js
busya 2d8cae563f 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
2025-12-20 20:48:18 +03:00

60 lines
2.1 KiB
JavaScript
Executable File

// [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]