module.js 1.3 KB

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