module.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. ## annotations
  3. */
  4. define([
  5. 'angular',
  6. 'app',
  7. 'underscore'
  8. ],
  9. function (angular, app, _) {
  10. 'use strict';
  11. var module = angular.module('kibana.panels.annotations', []);
  12. app.useModule(module);
  13. module.controller('AnnotationsCtrl', function($scope, dashboard, $rootScope) {
  14. $scope.panelMeta = {
  15. status : "Stable",
  16. description : "Annotations"
  17. };
  18. // Set and populate defaults
  19. var _d = {
  20. annotations: []
  21. };
  22. var annotationDefaults = {
  23. name: '',
  24. type: 'graphite metric'
  25. };
  26. _.defaults($scope.panel,_d);
  27. $scope.init = function() {
  28. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  29. $scope.currentIsNew = true;
  30. };
  31. $scope.getAnnotationInfo = function(annotation) {
  32. return annotation.target;
  33. };
  34. $scope.edit = function(annotation) {
  35. $scope.currentAnnnotation = annotation;
  36. $scope.currentIsNew = false;
  37. };
  38. $scope.getInfo = function(annotation) {
  39. return annotation.target;
  40. };
  41. $scope.update = function() {
  42. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  43. $scope.currentIsNew = true;
  44. };
  45. $scope.add = function() {
  46. $scope.panel.annotations.push($scope.currentAnnnotation);
  47. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  48. };
  49. $scope.hide = function (annotation) {
  50. annotation.enable = !annotation.enable;
  51. $rootScope.$broadcast('refresh');
  52. };
  53. });
  54. });