diff --git a/public/app/features/plugins/ds_edit_ctrl.ts b/public/app/features/plugins/ds_edit_ctrl.ts index b76407a90e8..e7e8014ed10 100644 --- a/public/app/features/plugins/ds_edit_ctrl.ts +++ b/public/app/features/plugins/ds_edit_ctrl.ts @@ -16,6 +16,8 @@ var defaults = { jsonData: {} }; +var datasourceCreated = false; + export class DataSourceEditCtrl { isNew: boolean; datasources: any[]; @@ -66,6 +68,11 @@ export class DataSourceEditCtrl { this.backendSrv.get('/api/datasources/' + id).then(ds => { this.isNew = false; this.current = ds; + + if (datasourceCreated) { + datasourceCreated = false; + this.testDatasource(); + } return this.typeChanged(); }); } @@ -123,14 +130,14 @@ export class DataSourceEditCtrl { if (this.current.id) { return this.backendSrv.put('/api/datasources/' + this.current.id, this.current).then(() => { this.updateFrontendSettings().then(() => { - if (test) { - this.testDatasource(); - } + this.testDatasource(); }); }); } else { return this.backendSrv.post('/api/datasources', this.current).then(result => { this.updateFrontendSettings(); + + datasourceCreated = true; this.$location.path('datasources/edit/' + result.id); }); } diff --git a/public/app/features/plugins/partials/ds_edit.html b/public/app/features/plugins/partials/ds_edit.html index 9ff82027abf..54254169b0b 100644 --- a/public/app/features/plugins/partials/ds_edit.html +++ b/public/app/features/plugins/partials/ds_edit.html @@ -25,7 +25,7 @@