Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: add types to dashboard #1015

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/packages/evidently-ui-lib/src/api/LocalApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class LocalApi implements Api {
return Promise.resolve({
id: 'project1',
name: 'Project #1',
dashboard: { tabs: [], tab_id_to_panel_ids: {} }
dashboard: { tabs: [], tab_id_to_panel_ids: {}, panels: [], name: '' }
})
}

Expand All @@ -104,7 +104,7 @@ export default class LocalApi implements Api {
return Promise.resolve({
id: 'new-project-id',
name: 'name',
dashboard: { tab_id_to_panel_ids: {}, tabs: [] }
dashboard: { tab_id_to_panel_ids: {}, tabs: [], panels: [], name: '' }
})
}

Expand Down
62 changes: 61 additions & 1 deletion ui/packages/evidently-ui-lib/src/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,68 @@ export interface ProjectInfo {
team_id?: string
}

type PanelTestFilter =
| { test_hash: string }
| {
test_id: string
test_args: Record<string, string>
}

type PanelValueBase = { field_path: string; legend: string }
type PanelValue = PanelValueBase &
(
| { metric_hash: string }
| {
metric_id: string
metric_args: Record<string, string>
}
)

type DashboardPanelBase = {
id: string
title: string
size: 1 | 2
filter: {
metadata_values: MetadataValueType
include_test_suites: boolean
tag_values: string[]
}
}

export type DashboardPanel = DashboardPanelBase &
(
| {
type: 'evidently.ui.dashboards.reports.DashboardPanelCounter'
agg: 'last' | 'sum' | 'none'
text: string
value: PanelValue | null
}
| {
type: 'evidently.ui.dashboards.reports.DashboardPanelPlot'
plot_type: 'line' | 'bar' | 'histogram' | 'scatter'
values: PanelValue[]
}
| {
type: 'evidently.ui.dashboards.test_suites.DashboardPanelTestSuite'
panel_type: 'aggregate' | 'detailed'
time_agg: string
test_filters: PanelTestFilter[]
}
| {
type: 'evidently.ui.dashboards.test_suites.DashboardPanelTestSuiteCounter'
agg: 'none' | 'last'
statuses: ('SUCCESS' | 'ERROR' | 'FAIL' | 'SKIPPED' | 'WARNING')[]
test_filters: PanelTestFilter[]
}
)

export interface ProjectDetails extends ProjectInfo {
dashboard: { tabs: DashboardTab[]; tab_id_to_panel_ids: Record<string, string[]> }
dashboard: {
name: string
tabs: DashboardTab[]
tab_id_to_panel_ids: Record<string, string[]>
panels: DashboardPanel[]
}
}

export type MetadataValueType = Record<string, string | string[] | Record<string, string>>
Expand Down
Loading