GUI -- reworking code to eliminate unnecessary 'ONOS' global.
- re-package fn and keys factories into util module.
Change-Id: I3d9f50b9a91468140845e862aff3fdb518948774
diff --git a/web/gui/src/main/webapp/app/fw/README.txt b/web/gui/src/main/webapp/app/fw/README.txt
index 712f055..2fc39ab 100644
--- a/web/gui/src/main/webapp/app/fw/README.txt
+++ b/web/gui/src/main/webapp/app/fw/README.txt
@@ -1,9 +1,26 @@
# Framework related code
-- Masthead
-- Float Panels
-- Alerts
-- Flash (transient messages)
-- Quick Help (key bindings, mouse gestures)
-- Death Mask (server connection lost)
+- Util
+ - General Functions
+ - Key Handler
+ - Theme Service
+ - Alert Service
+- Mast
+ - Masthead
+
+- Svg
+ - Glyph Service
+ - Icon Service
+ - Map Service
+ - Zoom Service
+
+- Layers
+ - Flash Service (transient messages)
+ - Panel Service (floating panels)
+ - Quick Help Service (key bindings, mouse gestures)
+ - Death Mask Service (loss of server connection)
+
+- Remote
+ - Login Service
+ - Web Socket Service
diff --git a/web/gui/src/main/webapp/app/fw/mast/mast.js b/web/gui/src/main/webapp/app/fw/mast/mast.js
index f8c4fc3..4a8b1cd 100644
--- a/web/gui/src/main/webapp/app/fw/mast/mast.js
+++ b/web/gui/src/main/webapp/app/fw/mast/mast.js
@@ -15,7 +15,7 @@
*/
/*
- ONOS GUI -- Masthead
+ ONOS GUI -- Masthead Module
@author Simon Hunt
*/
@@ -23,9 +23,14 @@
'use strict';
angular.module('onosMast', [])
- .controller('MastCtrl', [function () {
- // controller logic here
- console.log('MastCtrl has been created');
+ .controller('MastCtrl', ['$log', function (_$log_) {
+ var $log = _$log_,
+ self = this;
+
+ // initialize mast controller here...
+ self.radio = null;
+
+ $log.log('MastCtrl has been created');
}]);
}());
diff --git a/web/gui/src/main/webapp/app/fw/lib/fn.js b/web/gui/src/main/webapp/app/fw/util/fn.js
similarity index 76%
rename from web/gui/src/main/webapp/app/fw/lib/fn.js
rename to web/gui/src/main/webapp/app/fw/util/fn.js
index 5269d4d..4cdd0f0 100644
--- a/web/gui/src/main/webapp/app/fw/lib/fn.js
+++ b/web/gui/src/main/webapp/app/fw/util/fn.js
@@ -15,11 +15,11 @@
*/
/*
- ONOS GUI -- General Purpose Functions
+ ONOS GUI -- Util -- General Purpose Functions
@author Simon Hunt
*/
-(function (onos) {
+(function () {
'use strict';
function isF(f) {
@@ -42,14 +42,15 @@
return isA(a) && a.indexOf(x) > -1;
}
- onos.factory('FnService', [function () {
- return {
- isF: isF,
- isA: isA,
- isS: isS,
- isO: isO,
- contains: contains
- };
+ angular.module('onosUtil')
+ .factory('FnService', [function () {
+ return {
+ isF: isF,
+ isA: isA,
+ isS: isS,
+ isO: isO,
+ contains: contains
+ };
}]);
-}(ONOS));
+}());
diff --git a/web/gui/src/main/webapp/app/fw/lib/keys.js b/web/gui/src/main/webapp/app/fw/util/keys.js
similarity index 84%
rename from web/gui/src/main/webapp/app/fw/lib/keys.js
rename to web/gui/src/main/webapp/app/fw/util/keys.js
index 87dc21d..5cae514 100644
--- a/web/gui/src/main/webapp/app/fw/lib/keys.js
+++ b/web/gui/src/main/webapp/app/fw/util/keys.js
@@ -15,11 +15,11 @@
*/
/*
- ONOS GUI -- Key Handler Service
+ ONOS GUI -- Util -- Key Handler Service
@author Simon Hunt
*/
-(function (onos) {
+(function () {
'use strict';
// references to injected services
@@ -81,6 +81,8 @@
vcb = f.isF(vk) || (f.isA(vk) && f.isF(vk[0])) || f.isF(kh.viewFn),
token = getViewToken();
+ d3.event.stopPropagation();
+
// global callback?
if (gcb && gcb(token, key, keyCode, event)) {
// if the event was 'handled', we are done
@@ -181,32 +183,33 @@
};
}
- onos.factory('KeyService', ['$log', 'FnService', function ($l, fs) {
- $log = $l;
- f = fs;
- return {
- installOn: function (elem) {
- elem.on('keydown', keyIn);
- setupGlobalKeys();
- },
- theme: function () {
- return theme;
- },
- keyBindings: function (x) {
- if (x === undefined) {
- return getKeyBindings();
- } else {
- setKeyBindings(x);
+ angular.module('onosUtil')
+ .factory('KeyService', ['$log', 'FnService', function ($l, fs) {
+ $log = $l;
+ f = fs;
+ return {
+ installOn: function (elem) {
+ elem.on('keydown', keyIn);
+ setupGlobalKeys();
+ },
+ theme: function () {
+ return theme;
+ },
+ keyBindings: function (x) {
+ if (x === undefined) {
+ return getKeyBindings();
+ } else {
+ setKeyBindings(x);
+ }
+ },
+ gestureNotes: function (g) {
+ if (g === undefined) {
+ return keyHandler.viewGestures;
+ } else {
+ keyHandler.viewGestures = f.isA(g) || [];
+ }
}
- },
- gestureNotes: function (g) {
- if (g === undefined) {
- return keyHandler.viewGestures;
- } else {
- keyHandler.viewGestures = f.isA(g) || [];
- }
- }
- };
+ };
}]);
-}(ONOS));
+}());
diff --git a/web/gui/src/main/webapp/app/fw/util/util.js b/web/gui/src/main/webapp/app/fw/util/util.js
new file mode 100644
index 0000000..2ccc8fa
--- /dev/null
+++ b/web/gui/src/main/webapp/app/fw/util/util.js
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ ONOS GUI -- Utilities Module
+
+ @author Simon Hunt
+ */
+(function () {
+ 'use strict';
+
+ angular.module('onosUtil', []);
+
+}());
diff --git a/web/gui/src/main/webapp/app/index.html b/web/gui/src/main/webapp/app/index.html
index 6084854..14a029f 100644
--- a/web/gui/src/main/webapp/app/index.html
+++ b/web/gui/src/main/webapp/app/index.html
@@ -32,8 +32,11 @@
<!-- ONOS UI Framework included here -->
<!-- TODO: use a single catenated-minified file here -->
<script src="onos.js"></script>
- <script src="fw/lib/fn.js"></script>
- <script src="fw/lib/keys.js"></script>
+
+ <script src="fw/util/util.js"></script>
+ <script src="fw/util/fn.js"></script>
+ <script src="fw/util/keys.js"></script>
+
<script src="fw/mast/mast.js"></script>
<!-- Framework and library stylesheets included here -->
diff --git a/web/gui/src/main/webapp/app/onos.js b/web/gui/src/main/webapp/app/onos.js
index db104dd..1fece59 100644
--- a/web/gui/src/main/webapp/app/onos.js
+++ b/web/gui/src/main/webapp/app/onos.js
@@ -15,21 +15,25 @@
*/
/*
- ONOS GUI -- Base Framework
+ ONOS GUI -- Main Application Module
@author Simon Hunt
*/
-// our one global variable
-var ONOS;
-
(function () {
'use strict';
- ONOS = angular.module('onosApp', ['onosMast'])
- .controller('OnosCtrl', ['KeyService', function (ks) {
- console.log('OnosCtrl has been created');
+ angular.module('onosApp', ['onosUtil', 'onosMast'])
+ .controller('OnosCtrl', ['$log', 'KeyService', function (_$log_, ks) {
+ var $log = _$log_,
+ self = this;
+
+ self.version = '1.1.0';
+
+ // initialize onos (main app) controller here...
ks.installOn(d3.select('body'));
+
+ $log.log('OnosCtrl has been created');
}]);
}());