repeat_option.ts 895 B

12345678910111213141516171819202122232425262728293031323334
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import {coreModule} from 'app/core/core';
  3. var template = `
  4. <div class="gf-form-select-wrapper max-width-13">
  5. <select class="gf-form-input" ng-model="model.repeat" ng-options="f.value as f.text for f in variables">
  6. <option value=""></option>
  7. </div>
  8. `;
  9. coreModule.directive('dashRepeatOption', function(variableSrv) {
  10. return {
  11. restrict: 'E',
  12. template: template,
  13. scope: {
  14. model: "=",
  15. },
  16. link: function(scope, element) {
  17. element.css({display: 'block', width: '100%'});
  18. scope.variables = variableSrv.variables.map(item => {
  19. return {text: item.name, value: item.name};
  20. });
  21. if (scope.variables.length === 0) {
  22. scope.variables.unshift({text: 'No template variables found', value: null});
  23. }
  24. scope.variables.unshift({text: 'Disabled', value: null});
  25. }
  26. };
  27. });