Simon Hunt
Committed by Brian O'Connor

GUI -- added 'debug' query param and cut out noisy debug console messages by default.

Change-Id: I8b3eff58677a3882c62c7f2267a5258ba2cd2593
1 # Framework related code 1 # Framework related code
2 2
3 -- Util 3 +- layer
4 - - General Functions 4 + - Flash Service (transient messages)
5 - - Key Handler 5 + - Panel Service (floating panels)
6 - - Theme Service 6 + - Quick Help Service (key bindings, mouse gestures)
7 - - Alert Service 7 + - Veil Service (loss of server connection)
8 - - Preference Service 8 +
9 +- mast
10 + - Masthead Service
11 +
12 +- nav
13 + - Navigation Service (navigation menu)
14 +
15 +- remote
16 + - REST Service
17 + - URL functin Service
18 + - Web Socket Service
19 + - Web Socket Event Service
20 + - Web Socket encapsulation
9 21
10 -- Mast 22 + - (Login Service) << planned
11 - - Masthead
12 23
13 -- Svg 24 +- svg
25 + - GeoData Service (TopoJSON map functions)
14 - Glyph Service 26 - Glyph Service
15 - Icon Service 27 - Icon Service
16 - Map Service 28 - Map Service
29 + - SVG Utilities Service
17 - Zoom Service 30 - Zoom Service
18 31
19 -- Layers 32 +- util
20 - - Flash Service (transient messages) 33 + - General Functions
21 - - Panel Service (floating panels) 34 + - Key Handler
22 - - Quick Help Service (key bindings, mouse gestures) 35 + - User Preference Service
23 - - Death Mask Service (loss of server connection) 36 + - Randomization Service
24 - 37 + - Theme Service
25 -- Remote
26 - - Login Service
27 - - Web Socket Service
28 38
29 -- Widget 39 +- widget
30 - - Table Styling Directives 40 + - Button Service
41 + - Table Service (table styling directives)
31 - Table Builder Service 42 - Table Builder Service
32 - Toolbar Service 43 - Toolbar Service
33 - - Button Service 44 + - Tooltip Service
......
...@@ -185,16 +185,22 @@ ...@@ -185,16 +185,22 @@
185 $log.warn('Panel with ID "' + id + '" already exists'); 185 $log.warn('Panel with ID "' + id + '" already exists');
186 return null; 186 return null;
187 } 187 }
188 - $log.debug('creating panel:', id, settings); 188 + if (fs.debugOn('widget')) {
189 + $log.debug('creating panel:', id, settings);
190 + }
189 return makePanel(id, settings); 191 return makePanel(id, settings);
190 } 192 }
191 193
192 function destroyPanel(id) { 194 function destroyPanel(id) {
193 if (panels[id]) { 195 if (panels[id]) {
194 - $log.debug('destroying panel:', id); 196 + if (fs.debugOn('widget')) {
197 + $log.debug('destroying panel:', id);
198 + }
195 removePanel(id); 199 removePanel(id);
196 } else { 200 } else {
197 - $log.debug('no panel to destroy:', id); 201 + if (fs.debugOn('widget')) {
202 + $log.debug('no panel to destroy:', id);
203 + }
198 } 204 }
199 } 205 }
200 206
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
67 } 67 }
68 68
69 // function that only invokes the veil if the caller is the current view 69 // function that only invokes the veil if the caller is the current view
70 + // TODO: review - is this deprecated ?
70 function lostServer(ctrlName, msg) { 71 function lostServer(ctrlName, msg) {
71 if ($route.current.$$route.controller === ctrlName) { 72 if ($route.current.$$route.controller === ctrlName) {
72 $log.debug('VEIL-service: ', ctrlName); 73 $log.debug('VEIL-service: ', ctrlName);
......
...@@ -61,7 +61,9 @@ ...@@ -61,7 +61,9 @@
61 $log.info('Web socket open - ', url); 61 $log.info('Web socket open - ', url);
62 vs.hide(); 62 vs.hide();
63 63
64 - $log.debug('Sending ' + pendingEvents.length + ' pending event(s)...'); 64 + if (fs.debugOn('txrx')) {
65 + $log.debug('Sending ' + pendingEvents.length + ' pending event(s)...');
66 + }
65 pendingEvents.forEach(function (ev) { 67 pendingEvents.forEach(function (ev) {
66 _send(ev); 68 _send(ev);
67 }); 69 });
...@@ -82,7 +84,9 @@ ...@@ -82,7 +84,9 @@
82 $log.error('Message.data is not valid JSON', msgEvent.data, e); 84 $log.error('Message.data is not valid JSON', msgEvent.data, e);
83 return null; 85 return null;
84 } 86 }
85 - $log.debug(' << *Rx* ', ev.event, ev.payload); 87 + if (fs.debugOn('txrx')) {
88 + $log.debug(' << *Rx* ', ev.event, ev.payload);
89 + }
86 90
87 if (h = handlers[ev.event]) { 91 if (h = handlers[ev.event]) {
88 try { 92 try {
...@@ -140,7 +144,9 @@ ...@@ -140,7 +144,9 @@
140 } 144 }
141 145
142 function _send(ev) { 146 function _send(ev) {
143 - $log.debug(' *Tx* >> ', ev.event, ev.payload); 147 + if (fs.debugOn('txrx')) {
148 + $log.debug(' *Tx* >> ', ev.event, ev.payload);
149 + }
144 ws.send(JSON.stringify(ev)); 150 ws.send(JSON.stringify(ev));
145 } 151 }
146 152
......
...@@ -20,7 +20,20 @@ ...@@ -20,7 +20,20 @@
20 (function () { 20 (function () {
21 'use strict'; 21 'use strict';
22 22
23 - var $window; 23 + // injected services
24 + var $window, $log;
25 +
26 + // internal state
27 + var debugFlags = {};
28 +
29 +
30 + function _parseDebugFlags(dbgstr) {
31 + var bits = dbgstr ? dbgstr.split(",") : [];
32 + bits.forEach(function (key) {
33 + debugFlags[key] = true;
34 + });
35 + $log.debug('Debug flags:', dbgstr);
36 + }
24 37
25 function isF(f) { 38 function isF(f) {
26 return typeof f === 'function' ? f : null; 39 return typeof f === 'function' ? f : null;
...@@ -186,10 +199,18 @@ ...@@ -186,10 +199,18 @@
186 .replace(/\.\d*/, '')); 199 .replace(/\.\d*/, ''));
187 } 200 }
188 201
202 + // return true if the given debug flag was specified in the query params
203 + function debugOn(tag) {
204 + return debugFlags[tag];
205 + }
189 206
190 angular.module('onosUtil') 207 angular.module('onosUtil')
191 - .factory('FnService', ['$window', function (_$window_) { 208 + .factory('FnService',
209 + ['$window', '$location', '$log', function (_$window_, $loc, _$log_) {
192 $window = _$window_; 210 $window = _$window_;
211 + $log = _$log_;
212 +
213 + _parseDebugFlags($loc.search().debug);
193 214
194 return { 215 return {
195 isF: isF, 216 isF: isF,
...@@ -201,6 +222,7 @@ ...@@ -201,6 +222,7 @@
201 areFunctionsNonStrict: areFunctionsNonStrict, 222 areFunctionsNonStrict: areFunctionsNonStrict,
202 windowSize: windowSize, 223 windowSize: windowSize,
203 isMobile: isMobile, 224 isMobile: isMobile,
225 + debugOn: debugOn,
204 find: find, 226 find: find,
205 inArray: inArray, 227 inArray: inArray,
206 removeFromArray: removeFromArray, 228 removeFromArray: removeFromArray,
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 'use strict'; 21 'use strict';
22 22
23 // injected refs 23 // injected refs
24 - var $log, $cookies; 24 + var $log, $cookies, fs;
25 25
26 // internal state 26 // internal state
27 var cache = {}; 27 var cache = {};
...@@ -106,14 +106,17 @@ ...@@ -106,14 +106,17 @@
106 106
107 // FORCE cookie to be set by writing directly to document.cookie... 107 // FORCE cookie to be set by writing directly to document.cookie...
108 document.cookie = name + '=' + encodeURIComponent(str); 108 document.cookie = name + '=' + encodeURIComponent(str);
109 - $log.debug('<<>> Wrote cookie <'+name+'>:', str); 109 + if (fs.debugOn('prefs')) {
110 + $log.debug('<<>> Wrote cookie <'+name+'>:', str);
111 + }
110 } 112 }
111 113
112 angular.module('onosUtil') 114 angular.module('onosUtil')
113 - .factory('PrefsService', ['$log', '$cookies', 115 + .factory('PrefsService', ['$log', '$cookies', 'FnService',
114 - function (_$log_, _$cookies_) { 116 + function (_$log_, _$cookies_, _fs_) {
115 $log = _$log_; 117 $log = _$log_;
116 $cookies = _$cookies_; 118 $cookies = _$cookies_;
119 + fs = _fs_;
117 120
118 return { 121 return {
119 getPrefs: getPrefs, 122 getPrefs: getPrefs,
......
...@@ -70,7 +70,9 @@ ...@@ -70,7 +70,9 @@
70 cstmWidths[index] = h.attr(colWidth); 70 cstmWidths[index] = h.attr(colWidth);
71 } 71 }
72 }); 72 });
73 - $log.debug('Headers with custom widths: ', cstmWidths); 73 + if (fs.debugOn('widget')) {
74 + $log.debug('Headers with custom widths: ', cstmWidths);
75 + }
74 } 76 }
75 77
76 function setTdWidths(elem) { 78 function setTdWidths(elem) {
......
...@@ -69,7 +69,9 @@ ...@@ -69,7 +69,9 @@
69 69
70 function startRefresh() { 70 function startRefresh() {
71 promise = $interval(function () { 71 promise = $interval(function () {
72 - $log.debug('Refreshing ' + root + ' page'); 72 + if (fs.debugOn('widget')) {
73 + $log.debug('Refreshing ' + root + ' page');
74 + }
73 sortCb(o.scope.sortParams); 75 sortCb(o.scope.sortParams);
74 }, refreshInterval); 76 }, refreshInterval);
75 } 77 }
......