WIP: Staged all changes
This commit is contained in:
40
frontend/src/lib/stores.js
Normal file
40
frontend/src/lib/stores.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user