GUI -- Completed implementation of Instance events (add, update, remove)
- fixed instance color selection (using cat7() function)
- miscellaneous additions to utility functions.
- etc. and so on...

Change-Id: I61895489ccc60fa17beda9e920e65742e0f2c526
diff --git a/web/gui/src/main/webapp/app/view/topo/topoInst.js b/web/gui/src/main/webapp/app/view/topo/topoInst.js
index 12e47c6..7bd74f9 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoInst.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoInst.js
@@ -23,7 +23,7 @@
     'use strict';
 
     // injected refs
-    var $log, ps, sus, gs;
+    var $log, ps, sus, gs, ts, fs;
 
     // configuration
     var instCfg = {
@@ -79,6 +79,23 @@
         }
     }
 
+    function removeInstance(data) {
+        var id = data.id,
+            d = onosInstances[id];
+        if (d) {
+            var idx = fs.find(id, onosOrder);
+            if (idx >= 0) {
+                onosOrder.splice(idx, 1);
+            }
+            delete onosInstances[id];
+            updateInstances();
+        } else {
+            logicError('removeInstance lookup fail. ID = "' + id + '"');
+        }
+    }
+
+    // ==========================
+
     function computeDim(self) {
         var css = window.getComputedStyle(self);
         return {
@@ -143,9 +160,7 @@
     }
 
     function instColor(id, online) {
-        // TODO: fix this..
-        //return cat7.get(id, !online, network.view.getTheme());
-        return '#3E5780';
+        return sus.cat7().getColor(id, !online, ts.theme());
     }
 
     // ==============================
@@ -288,17 +303,22 @@
     angular.module('ovTopo')
     .factory('TopoInstService',
         ['$log', 'PanelService', 'SvgUtilService', 'GlyphService',
+            'ThemeService', 'FnService',
 
-        function (_$log_, _ps_, _sus_, _gs_) {
+        function (_$log_, _ps_, _sus_, _gs_, _ts_, _fs_) {
             $log = _$log_;
             ps = _ps_;
             sus = _sus_;
             gs = _gs_;
+            ts = _ts_;
+            fs = _fs_;
 
             return {
                 initInst: initInst,
                 destroyInst: destroyInst,
-                addInstance: addInstance
+                addInstance: addInstance,
+                updateInstance: updateInstance,
+                removeInstance: removeInstance
             };
         }]);
 }());