diff --git a/web/gui/src/main/webapp/app/fw/README.txt b/web/gui/src/main/webapp/app/fw/README.txt index 5ce4ebf2bd..626547b275 100644 --- a/web/gui/src/main/webapp/app/fw/README.txt +++ b/web/gui/src/main/webapp/app/fw/README.txt @@ -1,33 +1,44 @@ # Framework related code -- Util - - General Functions - - Key Handler - - Theme Service - - Alert Service - - Preference Service - -- Mast - - Masthead - -- Svg - - Glyph Service - - Icon Service - - Map Service - - Zoom Service - -- Layers +- layer - Flash Service (transient messages) - Panel Service (floating panels) - Quick Help Service (key bindings, mouse gestures) - - Death Mask Service (loss of server connection) + - Veil Service (loss of server connection) -- Remote - - Login Service +- mast + - Masthead Service + +- nav + - Navigation Service (navigation menu) + +- remote + - REST Service + - URL functin Service - Web Socket Service + - Web Socket Event Service + - Web Socket encapsulation -- Widget - - Table Styling Directives + - (Login Service) << planned + +- svg + - GeoData Service (TopoJSON map functions) + - Glyph Service + - Icon Service + - Map Service + - SVG Utilities Service + - Zoom Service + +- util + - General Functions + - Key Handler + - User Preference Service + - Randomization Service + - Theme Service + +- widget + - Button Service + - Table Service (table styling directives) - Table Builder Service - Toolbar Service - - Button Service + - Tooltip Service diff --git a/web/gui/src/main/webapp/app/fw/layer/panel.js b/web/gui/src/main/webapp/app/fw/layer/panel.js index 68899fb046..aef71eee8d 100644 --- a/web/gui/src/main/webapp/app/fw/layer/panel.js +++ b/web/gui/src/main/webapp/app/fw/layer/panel.js @@ -185,16 +185,22 @@ $log.warn('Panel with ID "' + id + '" already exists'); return null; } - $log.debug('creating panel:', id, settings); + if (fs.debugOn('widget')) { + $log.debug('creating panel:', id, settings); + } return makePanel(id, settings); } function destroyPanel(id) { if (panels[id]) { - $log.debug('destroying panel:', id); + if (fs.debugOn('widget')) { + $log.debug('destroying panel:', id); + } removePanel(id); } else { - $log.debug('no panel to destroy:', id); + if (fs.debugOn('widget')) { + $log.debug('no panel to destroy:', id); + } } } diff --git a/web/gui/src/main/webapp/app/fw/layer/veil.js b/web/gui/src/main/webapp/app/fw/layer/veil.js index 309b9f0bde..fc0530af58 100644 --- a/web/gui/src/main/webapp/app/fw/layer/veil.js +++ b/web/gui/src/main/webapp/app/fw/layer/veil.js @@ -67,6 +67,7 @@ } // function that only invokes the veil if the caller is the current view + // TODO: review - is this deprecated ? function lostServer(ctrlName, msg) { if ($route.current.$$route.controller === ctrlName) { $log.debug('VEIL-service: ', ctrlName); diff --git a/web/gui/src/main/webapp/app/fw/remote/websocket.js b/web/gui/src/main/webapp/app/fw/remote/websocket.js index 0ca10e9b7c..1c03d6fd6b 100644 --- a/web/gui/src/main/webapp/app/fw/remote/websocket.js +++ b/web/gui/src/main/webapp/app/fw/remote/websocket.js @@ -61,7 +61,9 @@ $log.info('Web socket open - ', url); vs.hide(); - $log.debug('Sending ' + pendingEvents.length + ' pending event(s)...'); + if (fs.debugOn('txrx')) { + $log.debug('Sending ' + pendingEvents.length + ' pending event(s)...'); + } pendingEvents.forEach(function (ev) { _send(ev); }); @@ -82,7 +84,9 @@ $log.error('Message.data is not valid JSON', msgEvent.data, e); return null; } - $log.debug(' << *Rx* ', ev.event, ev.payload); + if (fs.debugOn('txrx')) { + $log.debug(' << *Rx* ', ev.event, ev.payload); + } if (h = handlers[ev.event]) { try { @@ -140,7 +144,9 @@ } function _send(ev) { - $log.debug(' *Tx* >> ', ev.event, ev.payload); + if (fs.debugOn('txrx')) { + $log.debug(' *Tx* >> ', ev.event, ev.payload); + } ws.send(JSON.stringify(ev)); } diff --git a/web/gui/src/main/webapp/app/fw/util/fn.js b/web/gui/src/main/webapp/app/fw/util/fn.js index 6c7bb2a235..3e2fb298ed 100644 --- a/web/gui/src/main/webapp/app/fw/util/fn.js +++ b/web/gui/src/main/webapp/app/fw/util/fn.js @@ -20,7 +20,20 @@ (function () { 'use strict'; - var $window; + // injected services + var $window, $log; + + // internal state + var debugFlags = {}; + + + function _parseDebugFlags(dbgstr) { + var bits = dbgstr ? dbgstr.split(",") : []; + bits.forEach(function (key) { + debugFlags[key] = true; + }); + $log.debug('Debug flags:', dbgstr); + } function isF(f) { return typeof f === 'function' ? f : null; @@ -186,10 +199,18 @@ .replace(/\.\d*/, '')); } + // return true if the given debug flag was specified in the query params + function debugOn(tag) { + return debugFlags[tag]; + } angular.module('onosUtil') - .factory('FnService', ['$window', function (_$window_) { + .factory('FnService', + ['$window', '$location', '$log', function (_$window_, $loc, _$log_) { $window = _$window_; + $log = _$log_; + + _parseDebugFlags($loc.search().debug); return { isF: isF, @@ -201,6 +222,7 @@ areFunctionsNonStrict: areFunctionsNonStrict, windowSize: windowSize, isMobile: isMobile, + debugOn: debugOn, find: find, inArray: inArray, removeFromArray: removeFromArray, diff --git a/web/gui/src/main/webapp/app/fw/util/prefs.js b/web/gui/src/main/webapp/app/fw/util/prefs.js index 6138ca4d2d..02a23909f4 100644 --- a/web/gui/src/main/webapp/app/fw/util/prefs.js +++ b/web/gui/src/main/webapp/app/fw/util/prefs.js @@ -21,7 +21,7 @@ 'use strict'; // injected refs - var $log, $cookies; + var $log, $cookies, fs; // internal state var cache = {}; @@ -106,14 +106,17 @@ // FORCE cookie to be set by writing directly to document.cookie... document.cookie = name + '=' + encodeURIComponent(str); - $log.debug('<<>> Wrote cookie <'+name+'>:', str); + if (fs.debugOn('prefs')) { + $log.debug('<<>> Wrote cookie <'+name+'>:', str); + } } angular.module('onosUtil') - .factory('PrefsService', ['$log', '$cookies', - function (_$log_, _$cookies_) { + .factory('PrefsService', ['$log', '$cookies', 'FnService', + function (_$log_, _$cookies_, _fs_) { $log = _$log_; $cookies = _$cookies_; + fs = _fs_; return { getPrefs: getPrefs, diff --git a/web/gui/src/main/webapp/app/fw/widget/table.js b/web/gui/src/main/webapp/app/fw/widget/table.js index d8543fb532..adae2d02df 100644 --- a/web/gui/src/main/webapp/app/fw/widget/table.js +++ b/web/gui/src/main/webapp/app/fw/widget/table.js @@ -70,7 +70,9 @@ cstmWidths[index] = h.attr(colWidth); } }); - $log.debug('Headers with custom widths: ', cstmWidths); + if (fs.debugOn('widget')) { + $log.debug('Headers with custom widths: ', cstmWidths); + } } function setTdWidths(elem) { diff --git a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js index 3af8d60652..b3d759e29d 100644 --- a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js +++ b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js @@ -69,7 +69,9 @@ function startRefresh() { promise = $interval(function () { - $log.debug('Refreshing ' + root + ' page'); + if (fs.debugOn('widget')) { + $log.debug('Refreshing ' + root + ' page'); + } sortCb(o.scope.sortParams); }, refreshInterval); }