mirror of
https://github.com/directus/directus.git
synced 2026-02-01 09:05:01 -05:00
Add insights store
This commit is contained in:
@@ -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[];
|
||||
|
||||
@@ -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';
|
||||
|
||||
19
app/src/stores/insights.ts
Normal file
19
app/src/stores/insights.ts
Normal file
@@ -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();
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -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';
|
||||
|
||||
25
app/src/types/insights.ts
Normal file
25
app/src/types/insights.ts
Normal file
@@ -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<string, any>;
|
||||
date_created: string;
|
||||
user_created: string;
|
||||
};
|
||||
Reference in New Issue
Block a user