UI-Lion: Final piece to the POC puzzle !!!

Change-Id: If5348ca0f6bf91974f837cc08cca4eb30c186a52
diff --git a/web/gui/src/main/webapp/app/fw/util/lion.js b/web/gui/src/main/webapp/app/fw/util/lion.js
index 56c5db4..f30f157 100644
--- a/web/gui/src/main/webapp/app/fw/util/lion.js
+++ b/web/gui/src/main/webapp/app/fw/util/lion.js
@@ -21,65 +21,49 @@
 (function () {
     'use strict';
 
-    var $log, fs;
+    // injected services
+    var $log, fs, wss;
 
-    // returns a lion bundle (function) for the given bundle-key
-    function bundle(bundleKey) {
-        var bundle = {
-            computer: 'Calcolatore',
-            disk: 'Disco',
-            monitor: 'Schermo',
-            keyboard: 'Tastiera'
-        };
+    // private state
+    var handlers = {
+            uberlion: uberlion
+        },
+        ubercache = {};
 
-        if (bundleKey === 'core.view.cluster') {
-            bundle = {
-                // grouped to match core.view.cluster.lioncfg
-                title_cluster_nodes: 'Cluster Nodes',
-                k_esc_hint: 'Close the details panel',
-                k_click_hint: 'Select a row to show cluster node details',
-                k_scroll_down_hint: 'See available cluster nodes',
+    // handler for uberlion event..
+    function uberlion(data) {
+        $log.debug('LION service: uber-lion bundle received:', data);
+        ubercache = data.lion;
+    }
 
-                devices: 'Devices',
-                node_id: 'Node ID',
-                ip_address: 'IP Address',
-                tcp_port: 'TCP Port',
-                uri: 'URI',
-                protocol: 'Protocol',
+    function init() {
+        wss.bindHandlers(handlers);
+    }
 
-                type: 'Type',
-                chassis_id: 'Chassis ID',
-                vendor: 'Vendor',
-                hw_version: 'H/W Version',
-                sw_version: 'S/W Version',
-                serial_number: 'Serial #',
+    // returns a lion bundle (function) for the given bundle ID
+    function bundle(bundleId) {
+        var bundle = ubercache[bundleId];
 
-                total: 'Total',
-                active: 'Active',
-                started: 'Started',
-                last_updated: 'Last Updated',
-
-                click: 'click',
-                scroll_down: 'scroll down'
-            };
+        if (!bundle) {
+            $log.warn('No lion bundle registered:', bundleId);
+            bundle = {};
         }
 
-        // TODO: Use message handler mech. to get bundle from server
-        $log.warn('Using fake bundle', bundle);
-
         return function (key) {
             return bundle[key] || '%' + key + '%';
         };
     }
 
     angular.module('onosUtil')
-        .factory('LionService', ['$log', 'FnService',
+        .factory('LionService', ['$log', 'FnService', 'WebSocketService',
 
-        function (_$log_, _fs_) {
+        function (_$log_, _fs_, _wss_) {
             $log = _$log_;
             fs = _fs_;
+            wss = _wss_;
 
             return {
+                init: init,
                 bundle: bundle
             };
         }]);
diff --git a/web/gui/src/main/webapp/app/view/cluster/cluster.js b/web/gui/src/main/webapp/app/view/cluster/cluster.js
index f4d94f7..3732ab2 100644
--- a/web/gui/src/main/webapp/app/view/cluster/cluster.js
+++ b/web/gui/src/main/webapp/app/view/cluster/cluster.js
@@ -221,7 +221,7 @@
             is = _is_;
             wss = _wss_;
 
-            $scope.lion = lion.bundle('core.view.cluster');
+            $scope.lion = lion.bundle('core.view.Cluster');
             $scope.panelData = {};
 
             tbs.buildTable({
diff --git a/web/gui/src/main/webapp/onos.js b/web/gui/src/main/webapp/onos.js
index f7c8046..665bf26 100644
--- a/web/gui/src/main/webapp/onos.js
+++ b/web/gui/src/main/webapp/onos.js
@@ -89,12 +89,13 @@
 
         .controller('OnosCtrl', [
             '$log', '$scope', '$route', '$routeParams', '$location',
+            'LionService',
             'KeyService', 'ThemeService', 'GlyphService', 'VeilService',
             'PanelService', 'FlashService', 'QuickHelpService', 'EeService',
             'WebSocketService', 'SpriteService',
 
             function (_$log_, $scope, $route, $routeParams, $location,
-                      ks, ts, gs, vs, ps, flash, qhs, ee, wss, ss) {
+                      lion, ks, ts, gs, vs, ps, flash, qhs, ee, wss, ss) {
                 var self = this;
                 $log = _$log_;
 
@@ -108,6 +109,7 @@
                 $scope.onos['viewMap'] = viewMap;
 
                 // initialize services...
+                lion.init();
                 ts.init();
                 ks.installOn(d3.select('body'));
                 ks.bindQhs(qhs);