mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ds: minor fix that resets data source model when switching data source type
This commit is contained in:
parent
c2b05341e5
commit
546f903141
@ -58,7 +58,7 @@ export class DataSourceEditCtrl {
|
||||
}
|
||||
|
||||
initNewDatasourceModel() {
|
||||
this.current = angular.copy(defaults);
|
||||
this.current = _.cloneDeep(defaults);
|
||||
|
||||
// We are coming from getting started
|
||||
if (this.$location.search().gettingstarted) {
|
||||
@ -93,11 +93,21 @@ export class DataSourceEditCtrl {
|
||||
});
|
||||
}
|
||||
|
||||
userChangedType() {
|
||||
// reset model but keep name & default flag
|
||||
this.current = _.defaults({
|
||||
id: this.current.id,
|
||||
name: this.current.name,
|
||||
isDefault: this.current.isDefault,
|
||||
type: this.current.type,
|
||||
}, _.cloneDeep(defaults));
|
||||
this.typeChanged();
|
||||
}
|
||||
|
||||
typeChanged() {
|
||||
this.hasDashboards = false;
|
||||
return this.backendSrv.get('/api/plugins/' + this.current.type + '/settings').then(pluginInfo => {
|
||||
this.datasourceMeta = pluginInfo;
|
||||
console.log(this.datasourceMeta) ;
|
||||
this.hasDashboards = _.find(pluginInfo.includes, {type: 'dashboard'});
|
||||
});
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">Type</span>
|
||||
<div class="gf-form-select-wrapper max-width-23">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.type" ng-options="v.id as v.name for v in ctrl.types" ng-change="ctrl.typeChanged()"></select>
|
||||
<select class="gf-form-input" ng-model="ctrl.current.type" ng-options="v.id as v.name for v in ctrl.types" ng-change="ctrl.userChangedType()"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user