From 5cdef35217176dc4e458e10b82bb99e3881be13d Mon Sep 17 00:00:00 2001 From: Alex Cabrera Date: Wed, 25 Oct 2023 14:38:48 -0700 Subject: [PATCH 1/2] fix: fetch instance view for report slices --- backend/zeno_backend/server.py | 4 ++++ .../src/lib/components/report/Element.svelte | 2 +- .../report/elements/SliceElement.svelte | 6 ++++-- .../models/Body_upload_dataset_schema.ts | 2 +- frontend/src/lib/zenoapi/models/Project.ts | 2 +- .../src/lib/zenoapi/services/ZenoService.ts | 19 +++++++++++++++++++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/backend/zeno_backend/server.py b/backend/zeno_backend/server.py index cfd2d461..7a936a99 100644 --- a/backend/zeno_backend/server.py +++ b/backend/zeno_backend/server.py @@ -590,6 +590,10 @@ def get_charts_for_projects(req: list[str]): def get_slices_for_projects(req: list[str]): return select.slices_for_projects(req) + @api_app.post("/match-instance-view/", response_model=str, tags=["zeno"]) + def match_instance_view(req: str): + return select.match_instance_view(req) + @api_app.post( "/slice-metrics/{project}", response_model=list[GroupMetric], diff --git a/frontend/src/lib/components/report/Element.svelte b/frontend/src/lib/components/report/Element.svelte index 717aea49..d5c91a7c 100644 --- a/frontend/src/lib/components/report/Element.svelte +++ b/frontend/src/lib/components/report/Element.svelte @@ -19,7 +19,7 @@ } -{#if element.data !== null && element.data !== undefined} +{#if element.data !== null && element.data !== undefined && chartOptions.length > 0}
{#if element.type === ReportElementType.TEXT} diff --git a/frontend/src/lib/components/report/elements/SliceElement.svelte b/frontend/src/lib/components/report/elements/SliceElement.svelte index e7e7779c..9dd5111f 100644 --- a/frontend/src/lib/components/report/elements/SliceElement.svelte +++ b/frontend/src/lib/components/report/elements/SliceElement.svelte @@ -21,10 +21,12 @@ let sliceElementOptions: SliceElementOptions | undefined; let table: Record[] | undefined = []; let page = 0; + let view = ''; $: updateSliceElementSpec(element.data as string); - $: if (sliceElementSpec) { + $: if (sliceElementSpec && sliceElementOptions) { + zenoClient.matchInstanceView(sliceElementOptions.project.view ?? '').then((r) => (view = r)); zenoClient .getSliceTable({ sliceId: sliceElementSpec.sliceId, @@ -101,7 +103,7 @@ {#each table as inst (inst[sliceElementOptions.idColumn])}
; ownerName: string; - view: string; + view?: string; editor: boolean; samplesPerPage?: number; public?: boolean; diff --git a/frontend/src/lib/zenoapi/services/ZenoService.ts b/frontend/src/lib/zenoapi/services/ZenoService.ts index eebc57bf..b3f5849f 100644 --- a/frontend/src/lib/zenoapi/services/ZenoService.ts +++ b/frontend/src/lib/zenoapi/services/ZenoService.ts @@ -850,6 +850,25 @@ export class ZenoService { }); } + /** + * Match Instance View + * @param req + * @returns string Successful Response + * @throws ApiError + */ + public matchInstanceView(req: string): CancelablePromise { + return this.httpRequest.request({ + method: 'POST', + url: '/match-instance-view/', + query: { + req: req + }, + errors: { + 422: `Validation Error` + } + }); + } + /** * Get Metrics For Slices * @param project From 029bc23598dcbd907515f2ccf3f22cd272ab273b Mon Sep 17 00:00:00 2001 From: Alex Cabrera Date: Wed, 25 Oct 2023 14:44:32 -0700 Subject: [PATCH 2/2] fix --- frontend/src/lib/components/instances/ComparisonView.svelte | 4 ++-- frontend/src/lib/components/instances/ListView.svelte | 2 +- frontend/src/lib/components/instances/TableView.svelte | 2 +- frontend/src/lib/components/project/Project.svelte | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/components/instances/ComparisonView.svelte b/frontend/src/lib/components/instances/ComparisonView.svelte index c02d42af..9c32fc21 100644 --- a/frontend/src/lib/components/instances/ComparisonView.svelte +++ b/frontend/src/lib/components/instances/ComparisonView.svelte @@ -268,7 +268,7 @@