@ssa-ui-kit/infra-dash 0.0.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,8 @@ export type TimeseriesPanelProps = {
4
4
  panelData: PanelData;
5
5
  /** Optional title for the panel, defaults to panel.title */
6
6
  title?: string;
7
+ /** Optional hover format for the x axis */
8
+ xAxisHoverFormat?: string;
7
9
  };
8
- export declare const TimeseriesPanel: ({ panel, panelData, title: providedTitle, }: TimeseriesPanelProps) => import("@emotion/react/jsx-runtime").JSX.Element;
10
+ export declare const TimeseriesPanel: ({ panel, panelData, title: providedTitle, xAxisHoverFormat, }: TimeseriesPanelProps) => import("@emotion/react/jsx-runtime").JSX.Element;
9
11
  export declare const panelConfig: PanelConfig<TimeseriesPanelProps>;
@@ -0,0 +1,2 @@
1
+ export * from './root';
2
+ export * from './panelDataPeriod';
@@ -0,0 +1,24 @@
1
+ import { PanelDataPeriod } from '../panel';
2
+ export interface UseInfraDashPanelDataPeriodOptions {
3
+ defaultPeriod?: PanelDataPeriod;
4
+ period?: PanelDataPeriod;
5
+ onPeriodChange?: (period: PanelDataPeriod) => void;
6
+ }
7
+ export declare const useInfraDashPanelDataPeriod: ({ defaultPeriod, period: providedPeriod, onPeriodChange, }?: UseInfraDashPanelDataPeriodOptions) => {
8
+ period: 0 | 2 | 1 | 3 | 4;
9
+ changePeriod: (value: 0 | 2 | 1 | 3 | 4) => void;
10
+ };
11
+ export type InfraDashPanelDataPeriodStore = ReturnType<typeof useInfraDashPanelDataPeriod>;
12
+ export declare const InfraDashPanelDataPeriodProvider: ({ children, value, }: {
13
+ value: {
14
+ period: 0 | 2 | 1 | 3 | 4;
15
+ changePeriod: (value: 0 | 2 | 1 | 3 | 4) => void;
16
+ };
17
+ children: React.ReactNode;
18
+ }) => import("react").FunctionComponentElement<import("react").ProviderProps<{
19
+ period: 0 | 2 | 1 | 3 | 4;
20
+ changePeriod: (value: 0 | 2 | 1 | 3 | 4) => void;
21
+ } | null>>, useInfraDashPanelDataPeriodContext: () => {
22
+ period: 0 | 2 | 1 | 3 | 4;
23
+ changePeriod: (value: 0 | 2 | 1 | 3 | 4) => void;
24
+ };
@@ -1,6 +1,6 @@
1
- import { InfraDashTransport } from './transport';
2
- import { MutationClient, QueryClient } from './query';
3
- import { PanelRegistry } from './panelRegistry';
1
+ import { PanelRegistry } from '../panelRegistry';
2
+ import { MutationClient, QueryClient } from '../query';
3
+ import { InfraDashTransport } from '../transport';
4
4
  export interface InfraDashContextValue {
5
5
  transport: InfraDashTransport;
6
6
  queryClient: QueryClient;
@@ -15,6 +15,8 @@ export type Dashboard = {
15
15
  id: number;
16
16
  /** Display title of the dashboard shown in the UI */
17
17
  title: string;
18
+ /** Indicates if the dashboard is published and available to users */
19
+ published: boolean;
18
20
  /** Dashboard-specific configuration and settings */
19
21
  dashboardDefinition: DashboardDefinition;
20
22
  /** Array of panels that belong to this dashboard */
@@ -5,13 +5,6 @@ import { GrafanaPanelData, GrafanaPanelSchema } from './grafana';
5
5
  * Contains both the component configuration and grid layout positioning.
6
6
  */
7
7
  export type PanelDefinition = {
8
- source: {
9
- type: typeof PANEL_DATA_SOURCE.GRAFANA;
10
- /** Unique identifier for the Grafana dashboard */
11
- dashboardUid: string;
12
- /** Unique identifier for the Grafana panel within the dashboard */
13
- panelId: number;
14
- };
15
8
  component: {
16
9
  /** Unique identifier for the component type */
17
10
  id: string;
@@ -36,6 +29,11 @@ export type Panel = {
36
29
  panelSchema: GrafanaPanelSchema;
37
30
  /** Component and layout definition for the panel */
38
31
  panelDefinition: PanelDefinition;
32
+ source: {
33
+ type: typeof PANEL_DATA_SOURCE.GRAFANA;
34
+ dashboardUid: string;
35
+ panelId: number;
36
+ };
39
37
  };
40
38
  /**
41
39
  * Optional schema defining the structure of props this component expects.
@@ -93,4 +91,12 @@ export type PanelData = {
93
91
  /** The actual panel data from Grafana */
94
92
  data: GrafanaPanelData;
95
93
  };
94
+ export declare const PANEL_DATA_PERIOD: {
95
+ readonly LAST_HOUR: 0;
96
+ readonly LAST_6_HOURS: 1;
97
+ readonly LAST_24_HOURS: 2;
98
+ readonly LAST_7_DAYS: 3;
99
+ readonly LAST_30_DAYS: 4;
100
+ };
101
+ export type PanelDataPeriod = (typeof PANEL_DATA_PERIOD)[keyof typeof PANEL_DATA_PERIOD];
96
102
  export {};
@@ -30,6 +30,7 @@ export declare class QueryEntry<T> {
30
30
  private controller;
31
31
  constructor(key: QueryKey, fetcher: Fetcher<T>, options?: QueryOptions);
32
32
  private notify;
33
+ isActive(): boolean | 0 | undefined;
33
34
  updateEntity(fetcher: Fetcher<T>, options?: QueryOptions): QueryEntry<T>;
34
35
  fetch(): Promise<T | undefined>;
35
36
  subscribe(sub: Subscriber<T>): () => void;
@@ -41,10 +42,11 @@ export declare class QueryClient {
41
42
  private cache;
42
43
  get<T>(key: QueryKey): QueryEntry<T> | undefined;
43
44
  fetchQuery<T>(key: QueryKey, fetcher: Fetcher<T>, options?: QueryOptions): QueryEntry<T>;
44
- invalidateQueries({ key, exact, reset, }: {
45
+ invalidateQueries({ key, exact, reset, type, }: {
45
46
  key: QueryKey;
46
47
  exact?: boolean;
47
48
  reset?: boolean;
49
+ type?: 'active' | 'inactive' | 'all';
48
50
  }): void;
49
51
  setQueryData<T>(key: QueryKey, data: T): void;
50
52
  }
@@ -1,33 +1,32 @@
1
1
  import { Dashboard, DashboardDefinition } from '../dashboard';
2
2
  import { GrafanaDashboard, GrafanaPanel, GrafanaPanelData } from '../grafana';
3
- import { PanelDefinition } from '../panel';
3
+ import { PANEL_DATA_SOURCE, PanelDefinition } from '../panel';
4
4
  export type CreateDashboardPayload = {
5
5
  title: string;
6
- dashboardUid: string;
7
6
  dashboardDefinition: DashboardDefinition;
7
+ published: boolean;
8
8
  panels: {
9
- id: number;
9
+ source: {
10
+ type: typeof PANEL_DATA_SOURCE.GRAFANA;
11
+ dashboardUid: string;
12
+ panelId: number;
13
+ };
10
14
  panelDefinition: PanelDefinition;
11
15
  }[];
12
16
  };
13
17
  export type UpdateDashboardPayload = {
14
18
  dashboardId: number;
15
- title: string;
16
- dashboardDefinition: DashboardDefinition;
17
- panels: {
18
- id: number;
19
- panelDefinition: PanelDefinition;
20
- }[];
21
- };
19
+ } & CreateDashboardPayload;
22
20
  export interface InfraDashTransport {
23
21
  getGrafanaDashboards: (signal?: AbortSignal) => Promise<GrafanaDashboard[]>;
24
22
  getGrafanaPanels: (grafanaDashboardUid: string, signal?: AbortSignal) => Promise<GrafanaPanel[]>;
25
- getGrafanaPanelData: ({ dashboardUid, panelId, }: {
23
+ getGrafanaPanelData: ({ dashboardUid, panelId, period, }: {
26
24
  dashboardUid: string;
27
25
  panelId: number;
26
+ period?: number;
28
27
  }, signal?: AbortSignal) => Promise<GrafanaPanelData>;
29
- getPanelData: (panelId: number, signal?: AbortSignal) => Promise<GrafanaPanelData>;
30
28
  getDashboards: (signal?: AbortSignal) => Promise<Pick<Dashboard, 'id' | 'title'>[]>;
29
+ getPublishedDashboards: (signal?: AbortSignal) => Promise<Pick<Dashboard, 'id' | 'title'>[]>;
31
30
  getDashboard: (dashboardUid: number, signal?: AbortSignal) => Promise<Dashboard>;
32
31
  createDashboard: (payload: CreateDashboardPayload, signal?: AbortSignal) => Promise<unknown>;
33
32
  updateDashboard: (payload: UpdateDashboardPayload, signal?: AbortSignal) => Promise<unknown>;
@@ -16,12 +16,13 @@ export declare class RestInfraDashTransport implements InfraDashTransport {
16
16
  protected makeRequest<T = unknown>(request: Request, parseResponse?: boolean): Promise<T>;
17
17
  getGrafanaDashboards(signal?: AbortSignal): Promise<GrafanaDashboard[]>;
18
18
  getGrafanaPanels(grafanaDashboardUid: string, signal?: AbortSignal): Promise<GrafanaPanel[]>;
19
- getGrafanaPanelData({ dashboardUid, panelId, }: {
19
+ getGrafanaPanelData({ dashboardUid, panelId, period, }: {
20
20
  dashboardUid: string;
21
21
  panelId: number;
22
+ period?: number;
22
23
  }, signal?: AbortSignal): Promise<GrafanaPanelData>;
23
- getPanelData(panelId: number, signal?: AbortSignal): Promise<GrafanaPanelData>;
24
24
  getDashboards(signal?: AbortSignal): Promise<Pick<Dashboard, "title" | "id">[]>;
25
+ getPublishedDashboards(signal?: AbortSignal): Promise<Pick<Dashboard, "title" | "id">[]>;
25
26
  getDashboard(dashboardUid: number, signal?: AbortSignal): Promise<Dashboard>;
26
27
  createDashboard(payload: CreateDashboardPayload, signal?: AbortSignal): Promise<unknown>;
27
28
  updateDashboard(payload: UpdateDashboardPayload, signal?: AbortSignal): Promise<unknown>;
@@ -1,5 +1,6 @@
1
1
  import { DashboardPanelGridProps } from '../../features/DashboardPanelGrid';
2
2
  import { Dashboard } from '../../shared/dashboard';
3
+ import { UseInfraDashPanelDataPeriodOptions } from '../../shared/context';
3
4
  export type DashboardEditorProps = {
4
5
  dashboard?: Dashboard;
5
6
  defaultDashboard?: Dashboard;
@@ -12,4 +13,4 @@ export type DashboardEditorProps = {
12
13
  export declare const DashboardEditorInternal: ({ dashboard: controlledDashboard, defaultDashboard, gridProps, onChange, onSaved, onCreate, onError, ...divProps }: DashboardEditorProps) => import("@emotion/react/jsx-runtime").JSX.Element;
13
14
  export declare const DashboardEditor: ({ dashboardId, ...props }: DashboardEditorProps & {
14
15
  dashboardId?: number;
15
- }) => import("@emotion/react/jsx-runtime").JSX.Element;
16
+ } & UseInfraDashPanelDataPeriodOptions) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -20,6 +20,7 @@ export declare const updatePanel: ({ dashboard, panel }: UpdatePanelParams) => {
20
20
  panels: Panel[];
21
21
  id: number;
22
22
  title: string;
23
+ published: boolean;
23
24
  dashboardDefinition: import("../../shared/dashboard").DashboardDefinition;
24
25
  };
25
26
  export type RemovePanelParams = {
@@ -30,10 +31,39 @@ export declare const removePanel: ({ dashboard, panel }: RemovePanelParams) => {
30
31
  panels: Panel[];
31
32
  id: number;
32
33
  title: string;
34
+ published: boolean;
33
35
  dashboardDefinition: import("../../shared/dashboard").DashboardDefinition;
34
36
  };
35
37
  export type ApplyNewLayoutParams = {
36
38
  dashboard: Dashboard;
37
39
  newLayout: ReactGridLayout.Layout[];
38
40
  };
39
- export declare const applyNewLayout: ({ dashboard, newLayout, }: ApplyNewLayoutParams) => Dashboard;
41
+ export declare const applyNewLayout: ({ dashboard, newLayout, }: ApplyNewLayoutParams) => {
42
+ panels: {
43
+ panelDefinition: {
44
+ gridPos: Omit<import("react-grid-layout").Layout, "i"> | {
45
+ x: number;
46
+ y: number;
47
+ w: number;
48
+ h: number;
49
+ };
50
+ component: {
51
+ id: string;
52
+ props: Record<string, unknown>;
53
+ };
54
+ version: 1;
55
+ };
56
+ id: number;
57
+ title: string;
58
+ panelSchema: import("../../shared/grafana").GrafanaPanelSchema;
59
+ source: {
60
+ type: "grafana";
61
+ dashboardUid: string;
62
+ panelId: number;
63
+ };
64
+ }[];
65
+ id: number;
66
+ title: string;
67
+ published: boolean;
68
+ dashboardDefinition: import("../../shared/dashboard").DashboardDefinition;
69
+ };
@@ -1,7 +1,8 @@
1
1
  import { Dashboard } from '../../shared/dashboard';
2
+ import { UseInfraDashPanelDataPeriodOptions } from '../../shared/context';
2
3
  import { DashboardPanelGridProps } from '../../features/DashboardPanelGrid';
3
4
  export type DashboardViewerProps = {
4
5
  dashboardId?: number;
5
6
  dashboard?: Dashboard;
6
- } & Omit<DashboardPanelGridProps, 'dashboard'>;
7
+ } & Omit<DashboardPanelGridProps, 'dashboard'> & UseInfraDashPanelDataPeriodOptions;
7
8
  export declare const DashboardViewer: ({ dashboard, dashboardId, ...props }: DashboardViewerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/infra-dash",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -34,8 +34,8 @@
34
34
  "react-resizable": "^3.0.5",
35
35
  "@rjsf/validator-ajv8": "^5.24.11",
36
36
  "@rjsf/utils": "^5.24.11",
37
- "@ssa-ui-kit/core": "^2.23.2",
38
- "@ssa-ui-kit/hooks": "^2.23.2"
37
+ "@ssa-ui-kit/core": "^2.27.0",
38
+ "@ssa-ui-kit/hooks": "^2.27.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@emotion/css": "^11.13.5",