config_ctrl.ts 990 B

12345678910111213141516171819202122232425262728293031323334353637
  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. if (!this.current.id) {
  15. return;
  16. }
  17. this.datasourceSrv.loadDatasource(this.current.name)
  18. .then((ds) => {
  19. return ds.getVersion();
  20. }).then((version) => {
  21. this.graphiteVersions.push({name: version, value: version});
  22. this.current.jsonData.graphiteVersion = version;
  23. });
  24. }
  25. graphiteVersions = [
  26. {name: '0.9.x', value: '0.9'},
  27. {name: '1.0.x', value: '1.0'},
  28. {name: '1.1.x', value: '1.1'},
  29. ];
  30. }