config_ctrl.ts 964 B

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