module.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. showLine: true,
  26. iconColor: '#C0C6BE',
  27. lineColor: 'rgba(255, 96, 96, 0.592157)',
  28. iconSize: 13,
  29. enable: true
  30. };
  31. _.defaults($scope.panel,_d);
  32. $scope.init = function() {
  33. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  34. $scope.currentIsNew = true;
  35. };
  36. $scope.edit = function(annotation) {
  37. $scope.currentAnnnotation = annotation;
  38. $scope.currentIsNew = false;
  39. };
  40. $scope.update = function() {
  41. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  42. $scope.currentIsNew = true;
  43. };
  44. $scope.add = function() {
  45. $scope.panel.annotations.push($scope.currentAnnnotation);
  46. $scope.currentAnnnotation = angular.copy(annotationDefaults);
  47. };
  48. $scope.hide = function (annotation) {
  49. annotation.enable = !annotation.enable;
  50. $rootScope.$broadcast('refresh');
  51. };
  52. });
  53. });