From 3fdd08e327f75a7111d3aec02da8a20d5394393f Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 15 Apr 2022 14:47:38 +0200 Subject: [PATCH] fix(ui) - json fix --- .../Dashboard/components/DashboardModal/DashboardModal.tsx | 4 +++- frontend/app/mstore/types/dashboard.ts | 1 - frontend/app/mstore/types/filterItem.ts | 3 ++- frontend/app/mstore/types/widget.ts | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/Dashboard/components/DashboardModal/DashboardModal.tsx b/frontend/app/components/Dashboard/components/DashboardModal/DashboardModal.tsx index 35277dc74..15b26c809 100644 --- a/frontend/app/components/Dashboard/components/DashboardModal/DashboardModal.tsx +++ b/frontend/app/components/Dashboard/components/DashboardModal/DashboardModal.tsx @@ -22,7 +22,9 @@ function DashboardModal(props) { const loading = useObserver(() => dashboardStore.isSaving); const onSave = () => { - dashboardStore.save(dashboard).then(hideModal) + dashboardStore.save(dashboard).then(hideModal).then(() => { + dashboardStore.fetch(dashboard.dashboardId) + }) } const handleCreateNew = () => { diff --git a/frontend/app/mstore/types/dashboard.ts b/frontend/app/mstore/types/dashboard.ts index 25cfa7a05..57b191252 100644 --- a/frontend/app/mstore/types/dashboard.ts +++ b/frontend/app/mstore/types/dashboard.ts @@ -95,7 +95,6 @@ export default class Dashboard implements IDashboard { this.name = json.name this.isPublic = json.isPublic this.isPinned = json.isPinned - // this.config = json.config this.widgets = json.widgets ? json.widgets.map(w => new Widget().fromJson(w)).sort((a, b) => a.position - b.position) : [] }) return this diff --git a/frontend/app/mstore/types/filterItem.ts b/frontend/app/mstore/types/filterItem.ts index 606767b2b..7b7e4999a 100644 --- a/frontend/app/mstore/types/filterItem.ts +++ b/frontend/app/mstore/types/filterItem.ts @@ -36,7 +36,8 @@ export default class FilterItem { } fromJson(json, mainFilterKey = '') { - let _filter = filtersMap[json.type] + console.log('fromJson', json.type) + let _filter = filtersMap[json.type] || {} if (mainFilterKey) { const mainFilter = filtersMap[mainFilterKey]; const subFilterMap = {} diff --git a/frontend/app/mstore/types/widget.ts b/frontend/app/mstore/types/widget.ts index 0a465f5cf..adff4e390 100644 --- a/frontend/app/mstore/types/widget.ts +++ b/frontend/app/mstore/types/widget.ts @@ -139,8 +139,7 @@ export default class Widget implements IWidget { this.series = json.series ? json.series.map((series: any) => new FilterSeries().fromJson(series)) : [], this.dashboards = json.dashboards this.owner = json.ownerEmail - // this.lastModified = json.editedAt || json.createdAt ? DateTime.fromMillis(json.editedAt || json.createdAt) : null - this.lastModified = DateTime.fromMillis(1649319074) + this.lastModified = json.editedAt || json.createdAt ? DateTime.fromMillis(json.editedAt || json.createdAt) : null this.config = json.config this.position = json.config.position this.predefinedKey = json.predefinedKey