blob: 37ebda3c355f416be92bbb25868e069020a83799 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001// alarm topology overlay - client side
2//
3// This is the glue that binds our business logic (in alarmTopovDemo.js)
4// to the overlay framework.
5
6(function () {
7 'use strict';
8
9 // injected refs
10 var $log, tov, stds, ns;
11
12 // internal state should be kept in the service module (not here)
13
14 // our overlay definition
15 var overlay = {
16 // NOTE: this must match the ID defined in AppUiTopovOverlay
17 overlayId: 'alarmsTopo-overlay',
18 glyphId: '*star4',
19 tooltip: 'Alarms Overlay',
20 // These glyphs get installed using the overlayId as a prefix.
21 // e.g. 'star4' is installed as 'alarmsTopo-overlay-star4'
22 // They can be referenced (from this overlay) as '*star4'
23 // That is, the '*' prefix stands in for 'alarmsTopo-overlay-'
24 glyphs: {
25 star4: {
26 vb: '0 0 8 8',
27 // TODO new icon needed
28 d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
29 },
30 banner: {
31 vb: '0 0 6 6',
32 // TODO new icon needed
33 d: 'M1,1v4l2,-2l2,2v-4z'
34 }
35 },
36 activate: function () {
37 $log.debug("Alarm topology overlay ACTIVATED");
38 },
39 deactivate: function () {
40 stds.stopDisplay();
41 $log.debug("Alarm topology overlay DEACTIVATED");
42 },
43 // detail panel button definitions
44 buttons: {
45 alarm1button: {
46 gid: 'chain',
47 tt: 'Show alarms for this device',
48 cb: function (data) {
49 $log.debug('Show alarms for selected device. data:', data);
50 ns.navTo("alarmTable", {devId: data.id});
51
52 }
53 },
54 alarm2button: {
55 gid: '*banner',
56 tt: 'Show alarms for all devices',
57 cb: function (data) {
58 $log.debug('Show alarms for all devices. data:', data);
59 ns.navTo("alarmTable");
60
61 }
62 }
63 },
64 // Key bindings for traffic overlay buttons
65 // NOTE: fully qual. button ID is derived from overlay-id and key-name
66 keyBindings: {
67 0: {
68 cb: function () {
69 stds.stopDisplay();
70 },
71 tt: 'Cancel Alarm Count on Device',
72 gid: 'xMark'
73 },
74 V: {
75 cb: function () {
76 stds.startDisplay('mouse');
77 },
78 tt: 'Start Alarm Count on Device',
79 gid: '*banner'
80 },
81 _keyOrder: [
82 '0', 'V'
83 ]
84 },
85 hooks: {
86 // hook for handling escape key
87 // Must return true to consume ESC, false otherwise.
88 escape: function () {
89 // Must return true to consume ESC, false otherwise.
90 return stds.stopDisplay();
91 },
92 // hooks for when the selection changes...
93 empty: function () {
94 selectionCallback('empty');
95 },
96 single: function (data) {
97 selectionCallback('single', data);
98 },
99 multi: function (selectOrder) {
100 selectionCallback('multi', selectOrder);
101 tov.addDetailButton('alarm1button');
102 tov.addDetailButton('alarm2button');
103 },
104 mouseover: function (m) {
105 // m has id, class, and type properties
106 $log.debug('mouseover:', m);
107 stds.updateDisplay(m);
108 },
109 mouseout: function () {
110 $log.debug('mouseout');
111 stds.updateDisplay();
112 }
113 }
114 };
115
116
117 function buttonCallback(x) {
118 $log.debug('Toolbar-button callback', x);
119 }
120
121 function selectionCallback(x, d) {
122 $log.debug('Selection callback', x, d);
123 }
124
125 // invoke code to register with the overlay service
126 angular.module('ovAlarmTopov')
127 .run(['$log', 'TopoOverlayService', 'AlarmTopovDemoService', 'NavService',
128 function (_$log_, _tov_, _stds_, _ns_) {
129 $log = _$log_;
130 tov = _tov_;
131 stds = _stds_;
132 ns = _ns_;
133 tov.register(overlay);
134 }]);
135
136}());