Files
grafana/public/app/plugins/datasource/graphite/config_ctrl.ts

36 lines
964 B
TypeScript
Raw Normal View History

export class GraphiteConfigCtrl {
2017-12-20 12:33:33 +01:00
static templateUrl = 'public/app/plugins/datasource/graphite/partials/config.html';
2017-10-20 16:25:19 +03:00
datasourceSrv: any;
current: any;
/** @ngInject */
2017-10-20 16:25:19 +03:00
constructor($scope, datasourceSrv) {
this.datasourceSrv = datasourceSrv;
this.current.jsonData = this.current.jsonData || {};
this.current.jsonData.graphiteVersion = this.current.jsonData.graphiteVersion || '0.9';
2017-10-20 16:25:19 +03:00
this.autoDetectGraphiteVersion();
}
autoDetectGraphiteVersion() {
if (!this.current.id) {
return;
}
this.datasourceSrv
.loadDatasource(this.current.name)
.then(ds => {
return ds.getVersion();
})
.then(version => {
this.graphiteVersions.push({ name: version, value: version });
this.current.jsonData.graphiteVersion = version;
});
}
graphiteVersions = [
2017-12-20 12:33:33 +01:00
{ name: '0.9.x', value: '0.9' },
{ name: '1.0.x', value: '1.0' },
{ name: '1.1.x', value: '1.1' },
];
}