config_ctrl.ts 941 B

123456789101112131415161718192021222324252627282930313233
  1. ///<reference path="../../../headers/common.d.ts" />
  2. export class GraphiteConfigCtrl {
  3. static templateUrl = 'public/app/plugins/datasource/graphite/partials/config.html';
  4. datasourceSrv: any;
  5. current: any;
  6. /** @ngInject */
  7. constructor($scope, datasourceSrv) {
  8. this.datasourceSrv = datasourceSrv;
  9. this.current.jsonData = this.current.jsonData || {};
  10. this.current.jsonData.graphiteVersion = this.current.jsonData.graphiteVersion || '0.9';
  11. this.autoDetectGraphiteVersion();
  12. }
  13. autoDetectGraphiteVersion() {
  14. this.datasourceSrv.loadDatasource(this.current.name)
  15. .then((ds) => {
  16. return ds.getVersion();
  17. }).then((version) => {
  18. this.graphiteVersions.push({name: version, value: version});
  19. this.current.jsonData.graphiteVersion = version;
  20. });
  21. }
  22. graphiteVersions = [
  23. {name: '0.9.x', value: '0.9'},
  24. {name: '1.0.x', value: '1.0'},
  25. {name: '1.1.x', value: '1.1'},
  26. ];
  27. }