module.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. define([
  2. 'app/plugins/sdk',
  3. 'lodash'
  4. ], function(sdk, _) {
  5. var BoilerPlatePanelCtrl = (function(_super) {
  6. var self;
  7. function BoilerPlatePanelCtrl($scope, $injector) {
  8. _super.call(this, $scope, $injector);
  9. this.results = []
  10. self = this;
  11. }
  12. // you do not need a templateUrl, you can use a inline template here
  13. // BoilerPlatePanelCtrl.template = '<h2>boilerplate</h2>';
  14. // all panel static assets can be accessed via 'public/plugins/<plugin-id>/<file>
  15. BoilerPlatePanelCtrl.templateUrl = 'panel.html';
  16. BoilerPlatePanelCtrl.prototype = Object.create(_super.prototype);
  17. BoilerPlatePanelCtrl.prototype.constructor = BoilerPlatePanelCtrl;
  18. BoilerPlatePanelCtrl.prototype.refreshData = function(datasource) {
  19. this.issueQueries(datasource)
  20. .then(function(result) {
  21. self.results = [];
  22. _.each(result.data, function(target) {
  23. var last = _.last(target.datapoints)
  24. self.results.push(last[0]);
  25. });
  26. self.render();
  27. });
  28. }
  29. BoilerPlatePanelCtrl.prototype.render = function() {
  30. this.values = this.results.join(',');
  31. }
  32. return BoilerPlatePanelCtrl;
  33. })(sdk.MetricsPanelCtrl);
  34. return {
  35. PanelCtrl: BoilerPlatePanelCtrl
  36. };
  37. });