adding new dashboard view. Muchas wow

This commit is contained in:
orangecoding
2025-12-14 12:23:59 +01:00
parent 87b5673bf0
commit 87771655a8
31 changed files with 688 additions and 1047 deletions

View File

@@ -33,6 +33,16 @@ export const useFredyState = create(
(set) => {
// Async actions that directly set state (no separate reducer concept)
const effects = {
dashboard: {
async getDashboard() {
try {
const response = await xhrGet('/api/dashboard');
set((state) => ({ dashboard: { ...state.dashboard, data: response.json } }));
} catch (Exception) {
console.error('Error while trying to get resource for /api/dashboard. Error:', Exception);
}
},
},
notificationAdapter: {
async getAdapter() {
try {
@@ -90,27 +100,6 @@ export const useFredyState = create(
console.error(`Error while trying to get resource for api/jobs. Error:`, Exception);
}
},
async getProcessingTimes() {
try {
const response = await xhrGet('/api/jobs/processingTimes');
set((state) => ({ jobs: { ...state.jobs, processingTimes: Object.freeze(response.json) } }));
} catch (Exception) {
console.error(`Error while trying to get resource for api/processingTimes. Error:`, Exception);
}
},
async getInsightDataForJob(jobId) {
try {
const response = await xhrGet(`/api/jobs/insights/${jobId}`);
set((state) => ({
jobs: {
...state.jobs,
insights: { ...state.jobs.insights, [jobId]: Object.freeze(response.json) },
},
}));
} catch (Exception) {
console.error(`Error while trying to get resource for api/jobs/insights. Error:`, Exception);
}
},
},
user: {
async getUsers() {
@@ -185,6 +174,7 @@ export const useFredyState = create(
// Initial state
const initial = {
dashboard: { data: null },
notificationAdapter: [],
listingsTable: {
totalNumber: 0,
@@ -196,12 +186,13 @@ export const useFredyState = create(
demoMode: { demoMode: false },
versionUpdate: {},
provider: [],
jobs: { jobs: [], insights: {}, processingTimes: {}, shareableUserList: [] },
jobs: { jobs: [], shareableUserList: [] },
user: { users: [], currentUser: null },
};
// Expose actions by grouping them per slice
const actions = {
dashboard: { ...effects.dashboard },
notificationAdapter: { ...effects.notificationAdapter },
generalSettings: { ...effects.generalSettings },
demoMode: { ...effects.demoMode },