diff --git a/app/src/hydrate.ts b/app/src/hydrate.ts index 30cea1ff22..e5d6a53f1a 100644 --- a/app/src/hydrate.ts +++ b/app/src/hydrate.ts @@ -6,6 +6,7 @@ import { useCollectionsStore, useFieldsStore, useLatencyStore, + useInsightsStore, usePermissionsStore, usePresetsStore, useRelationsStore, @@ -35,6 +36,7 @@ export function useStores( useLatencyStore, useRelationsStore, usePermissionsStore, + useInsightsStore, ] ): GenericStore[] { return stores.map((useStore) => useStore()) as GenericStore[]; diff --git a/app/src/stores/index.ts b/app/src/stores/index.ts index d7fbf37892..4f4c6f4f07 100644 --- a/app/src/stores/index.ts +++ b/app/src/stores/index.ts @@ -1,6 +1,7 @@ export * from './app'; export * from './collections'; export * from './fields'; +export * from './insights'; export * from './latency'; export * from './notifications'; export * from './permissions'; diff --git a/app/src/stores/insights.ts b/app/src/stores/insights.ts new file mode 100644 index 0000000000..7535d4412b --- /dev/null +++ b/app/src/stores/insights.ts @@ -0,0 +1,19 @@ +import { Dashboard } from '../types'; +import api from '@/api'; +import { createStore } from 'pinia'; + +export const useInsightsStore = createStore({ + id: 'insightsStore', + state: () => ({ + dashboards: [] as Dashboard[], + }), + actions: { + async hydrate() { + const response = await api.get('/dashboards', { params: { limit: -1, fields: ['*', 'panels.*'] } }); + this.state.dashboards = response.data.data; + }, + dehydrate() { + this.reset(); + }, + }, +}); diff --git a/app/src/types/index.ts b/app/src/types/index.ts index d0f55b2850..a8f2be7f3f 100644 --- a/app/src/types/index.ts +++ b/app/src/types/index.ts @@ -1,6 +1,7 @@ export * from './collections'; export * from './error'; export * from './fields'; +export * from './insights'; export * from './items'; export * from './notifications'; export * from './permissions'; diff --git a/app/src/types/insights.ts b/app/src/types/insights.ts new file mode 100644 index 0000000000..0fbc0afea7 --- /dev/null +++ b/app/src/types/insights.ts @@ -0,0 +1,25 @@ +export type Dashboard = { + id: string; + name: string; + icon: string; + panels: Panel[]; + date_created: string; + user_created: string; +}; + +export type Panel = { + id: string; + dashboard: string; + name: string; + icon: string; + color: string; + note: string; + type: string; + position_x: number; + position_y: number; + width: number; + height: number; + options: Record; + date_created: string; + user_created: string; +};