2017-08-07 16:10:59 +03:00
|
|
|
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;
|
2017-08-07 16:10:59 +03:00
|
|
|
current: any;
|
|
|
|
|
|
|
|
|
|
/** @ngInject */
|
2017-10-20 16:25:19 +03:00
|
|
|
constructor($scope, datasourceSrv) {
|
|
|
|
|
this.datasourceSrv = datasourceSrv;
|
2017-09-04 10:28:48 +02:00
|
|
|
this.current.jsonData = this.current.jsonData || {};
|
2017-12-21 08:39:31 +01:00
|
|
|
this.current.jsonData.graphiteVersion = this.current.jsonData.graphiteVersion || '0.9';
|
2017-10-20 16:25:19 +03:00
|
|
|
this.autoDetectGraphiteVersion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
autoDetectGraphiteVersion() {
|
2017-12-12 15:28:41 +01:00
|
|
|
if (!this.current.id) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 16:06:54 +01:00
|
|
|
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;
|
|
|
|
|
});
|
2017-08-07 16:10:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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' },
|
2017-08-07 16:10:59 +03:00
|
|
|
];
|
|
|
|
|
}
|