config_ctrl.ts 1.0 KB

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