mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: fixes issue with UI not being re-rendered after moving dashboard
This commit is contained in:
parent
4e3ff19689
commit
1c0d022ac2
@ -2,6 +2,8 @@ import coreModule from 'app/core/core_module';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import { IScope } from 'angular';
|
||||
import { promiseToDigest } from 'app/core/utils/promiseToDigest';
|
||||
|
||||
export class MoveToFolderCtrl {
|
||||
dashboards: any;
|
||||
@ -10,27 +12,31 @@ export class MoveToFolderCtrl {
|
||||
afterSave: any;
|
||||
isValidFolderSelection = true;
|
||||
|
||||
constructor(private $scope: IScope) {}
|
||||
|
||||
onFolderChange(folder: any) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
save() {
|
||||
return backendSrv.moveDashboards(this.dashboards, this.folder).then((result: any) => {
|
||||
if (result.successCount > 0) {
|
||||
const header = `Dashboard${result.successCount === 1 ? '' : 's'} Moved`;
|
||||
const msg = `${result.successCount} dashboard${result.successCount === 1 ? '' : 's'} moved to ${
|
||||
this.folder.title
|
||||
}`;
|
||||
appEvents.emit(AppEvents.alertSuccess, [header, msg]);
|
||||
}
|
||||
return promiseToDigest(this.$scope)(
|
||||
backendSrv.moveDashboards(this.dashboards, this.folder).then((result: any) => {
|
||||
if (result.successCount > 0) {
|
||||
const header = `Dashboard${result.successCount === 1 ? '' : 's'} Moved`;
|
||||
const msg = `${result.successCount} dashboard${result.successCount === 1 ? '' : 's'} moved to ${
|
||||
this.folder.title
|
||||
}`;
|
||||
appEvents.emit(AppEvents.alertSuccess, [header, msg]);
|
||||
}
|
||||
|
||||
if (result.totalCount === result.alreadyInFolderCount) {
|
||||
appEvents.emit(AppEvents.alertError, ['Error', `Dashboards already belongs to folder ${this.folder.title}`]);
|
||||
}
|
||||
if (result.totalCount === result.alreadyInFolderCount) {
|
||||
appEvents.emit(AppEvents.alertError, ['Error', `Dashboards already belongs to folder ${this.folder.title}`]);
|
||||
}
|
||||
|
||||
this.dismiss();
|
||||
return this.afterSave();
|
||||
});
|
||||
this.dismiss();
|
||||
return this.afterSave();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
onEnterFolderCreation() {
|
||||
|
Loading…
Reference in New Issue
Block a user