blob: eeefa62c3cff6efd4786a31e4edb368a49064039 [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
Simon Hunt1c694bb2016-02-01 10:07:35 -080014 // alarm clock glyph (vbox 110x110)
15 var clock = 'M92.9,61.3a39,39,0,1,1-39-39,39,39,0,0,1,39,39h0Z' +
16 'M44,19.3c-4.4-7.4-14.8-9.3-23.2-4.2S9.1,30.2,13.5,37.6m80.8,0' +
17 'c4.4-7.4,1.2-17.5-7.3-22.5s-18.8-3.2-23.3,4.2m-8.4,1.8V16.5h4.4' +
18 'V11.9H48.2v4.6h4.6v4.6M51.6,56.4H51.5' +
19 'a5.4,5.4,0,0,0,2.4,10.3,4.7,4.7,0,0,0,4.9-3.1H74.5' +
20 'a2.2,2.2,0,0,0,2.4-2.2,2.4,2.4,0,0,0-2.4-2.3H58.8' +
21 'a5.3,5.3,0,0,0-2.5-2.6H56.2V32.9' +
22 'a2.3,2.3,0,0,0-.6-1.7,2.2,2.2,0,0,0-1.6-.7,2.4,2.4,0,0,0-2.4,2.4' +
23 'h0V56.4M82.2,91.1l-7.1,5.3-0.2.2-1.2,2.1a0.6,0.6,0,0,0,.2.8' +
24 'h0.2c2.6,0.4,10.7.9,10.3-1.2m-60.8,0c-0.4,2.1,7.7,1.6,10.3,1.2' +
25 'h0.2a0.6,0.6,0,0,0,.2-0.8l-1.2-2.1-0.2-.2-7.1-5.3';
26
kmcpeakeb172d5f2015-12-10 11:30:43 +000027 // our overlay definition
28 var overlay = {
29 // NOTE: this must match the ID defined in AppUiTopovOverlay
30 overlayId: 'alarmsTopo-overlay',
Simon Hunt1c694bb2016-02-01 10:07:35 -080031 glyphId: '*clock',
kmcpeakeb172d5f2015-12-10 11:30:43 +000032 tooltip: 'Alarms Overlay',
33 // These glyphs get installed using the overlayId as a prefix.
34 // e.g. 'star4' is installed as 'alarmsTopo-overlay-star4'
35 // They can be referenced (from this overlay) as '*star4'
36 // That is, the '*' prefix stands in for 'alarmsTopo-overlay-'
37 glyphs: {
Simon Hunt1c694bb2016-02-01 10:07:35 -080038 clock: {
39 vb: '0 0 110 110',
40 d: clock
41 },
kmcpeakeb172d5f2015-12-10 11:30:43 +000042 star4: {
43 vb: '0 0 8 8',
44 // TODO new icon needed
45 d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
46 },
47 banner: {
48 vb: '0 0 6 6',
49 // TODO new icon needed
50 d: 'M1,1v4l2,-2l2,2v-4z'
51 }
52 },
53 activate: function () {
54 $log.debug("Alarm topology overlay ACTIVATED");
55 },
56 deactivate: function () {
57 stds.stopDisplay();
58 $log.debug("Alarm topology overlay DEACTIVATED");
59 },
60 // detail panel button definitions
61 buttons: {
62 alarm1button: {
63 gid: 'chain',
64 tt: 'Show alarms for this device',
65 cb: function (data) {
66 $log.debug('Show alarms for selected device. data:', data);
67 ns.navTo("alarmTable", {devId: data.id});
68
69 }
70 },
71 alarm2button: {
72 gid: '*banner',
73 tt: 'Show alarms for all devices',
74 cb: function (data) {
75 $log.debug('Show alarms for all devices. data:', data);
76 ns.navTo("alarmTable");
77
78 }
79 }
80 },
81 // Key bindings for traffic overlay buttons
82 // NOTE: fully qual. button ID is derived from overlay-id and key-name
83 keyBindings: {
84 0: {
85 cb: function () {
86 stds.stopDisplay();
87 },
88 tt: 'Cancel Alarm Count on Device',
89 gid: 'xMark'
90 },
91 V: {
92 cb: function () {
93 stds.startDisplay('mouse');
94 },
95 tt: 'Start Alarm Count on Device',
96 gid: '*banner'
97 },
98 _keyOrder: [
99 '0', 'V'
100 ]
101 },
102 hooks: {
103 // hook for handling escape key
104 // Must return true to consume ESC, false otherwise.
105 escape: function () {
106 // Must return true to consume ESC, false otherwise.
107 return stds.stopDisplay();
108 },
109 // hooks for when the selection changes...
110 empty: function () {
111 selectionCallback('empty');
112 },
113 single: function (data) {
114 selectionCallback('single', data);
115 },
116 multi: function (selectOrder) {
117 selectionCallback('multi', selectOrder);
118 tov.addDetailButton('alarm1button');
119 tov.addDetailButton('alarm2button');
120 },
121 mouseover: function (m) {
122 // m has id, class, and type properties
123 $log.debug('mouseover:', m);
124 stds.updateDisplay(m);
125 },
126 mouseout: function () {
127 $log.debug('mouseout');
128 stds.updateDisplay();
129 }
130 }
131 };
132
133
134 function buttonCallback(x) {
135 $log.debug('Toolbar-button callback', x);
136 }
137
138 function selectionCallback(x, d) {
139 $log.debug('Selection callback', x, d);
140 }
141
142 // invoke code to register with the overlay service
143 angular.module('ovAlarmTopov')
144 .run(['$log', 'TopoOverlayService', 'AlarmTopovDemoService', 'NavService',
145 function (_$log_, _tov_, _stds_, _ns_) {
146 $log = _$log_;
147 tov = _tov_;
148 stds = _stds_;
149 ns = _ns_;
150 tov.register(overlay);
151 }]);
152
153}());