change(ui): remove additional calls to api after dashb update
This commit is contained in:
parent
539b91a6e6
commit
0aa5dbb4ac
1 changed files with 11 additions and 3 deletions
|
|
@ -189,19 +189,19 @@ export default class DashboardStore {
|
|||
return new Promise((resolve, reject) => {
|
||||
dashboardService
|
||||
.saveDashboard(dashboard)
|
||||
.then((_dashboard) => {
|
||||
.then((_dashboard: any) => {
|
||||
runInAction(() => {
|
||||
if (isCreating) {
|
||||
toast.success('Dashboard created successfully');
|
||||
this.addDashboard(new Dashboard().fromJson(_dashboard));
|
||||
} else {
|
||||
toast.success('Dashboard successfully updated ');
|
||||
this.updateDashboard(new Dashboard().fromJson(_dashboard));
|
||||
this.syncDashboardInfo(_dashboard.dashboardId!, _dashboard);
|
||||
}
|
||||
resolve(_dashboard);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(() => {
|
||||
toast.error('Error saving dashboard');
|
||||
reject();
|
||||
})
|
||||
|
|
@ -213,6 +213,14 @@ export default class DashboardStore {
|
|||
});
|
||||
}
|
||||
|
||||
syncDashboardInfo(id: string, info: { name: string, description: string, isPublic: boolean, createdAt: number }) {
|
||||
if (this.selectedDashboard !== null) {
|
||||
this.selectedDashboard.update(info)
|
||||
const index = this.dashboards.findIndex((d) => d.dashboardId === id);
|
||||
Object.assign(this.dashboards[index], info)
|
||||
}
|
||||
}
|
||||
|
||||
saveMetric(metric: Widget, dashboardId: string): Promise<any> {
|
||||
const isCreating = !metric.widgetId;
|
||||
return dashboardService.saveMetric(metric, dashboardId).then((metric) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue