[ONOS-6375] Support topology overlay for mapping managemant app

Change-Id: I25cad3ebf450bc2658edf80e2085ec99f29f6aa6
diff --git a/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.html b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.html
new file mode 100644
index 0000000..9f78cac
--- /dev/null
+++ b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.html
@@ -0,0 +1,4 @@
+<!-- partial HTML -->
+<div id="ov-mapping-topo">
+    <p>This is a hidden view .. just a placeholder to house the javascript</p>
+</div>
diff --git a/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.js b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.js
new file mode 100644
index 0000000..af4bf23
--- /dev/null
+++ b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopo.js
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017-present 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.
+ */
+
+ (function () {
+     'use strict';
+
+     // injected refs
+     var $log, fs, flash, wss;
+
+     // constants
+     var displayStart = 'mappingsTopoDisplayStart',
+         displayStop = 'mappingsTopoDisplayStop';
+
+
+     // === ---------------------------
+     // === Helper functions
+
+     function sendDisplayStart() {
+         wss.sendEvent(displayStart);
+     }
+
+     function sendDisplayStop() {
+         wss.sendEvent(displayStop);
+     }
+
+     // === ---------------------------
+     // === Main API functions
+
+     function startDisplay() {
+         sendDisplayStart();
+         flash.flash('Showing mappings on devices');
+     }
+
+     function stopDisplay() {
+         sendDisplayStop();
+         flash.flash('Canceling mappings on devices');
+         return true;
+     }
+
+     angular.module('ovMappingTopo', [])
+         .factory('MappingTopoService',
+         ['$log', 'FnService', 'FlashService', 'WebSocketService',
+
+         function (_$log_, _fs_, _flash_, _wss_) {
+             $log = _$log_;
+             fs = _fs_;
+             flash = _flash_;
+             wss = _wss_;
+
+             return {
+                 startDisplay: startDisplay,
+                 stopDisplay: stopDisplay
+             };
+         }]);
+}());
\ No newline at end of file
diff --git a/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopoOverlay.js b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopoOverlay.js
new file mode 100644
index 0000000..2562860
--- /dev/null
+++ b/apps/mappingmanagement/web/src/main/resources/app/view/mapping/mappingTopoOverlay.js
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017-present 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 -- Mapping Management Topology Overlay
+ */
+(function () {
+    'use strict';
+
+    // injected references
+    var $log, tov, mts, ns;
+
+    var viewbox = '-1 -1 19 19';
+
+    // mapping glyph (view box 20x20)
+    var mapping = 'M8,0C4.687,0,2,2.687,2,6c0,3.854,4.321,8.663,5,9.398C7.281,' +
+    '15.703,7.516,16,8,16s0.719-0.297,1-0.602  C9.679,14.663,14,9.854,14,6C14,' +
+    '2.687,11.313,0,8,0z M8,10c-2.209,0-4-1.791-4-4s1.791-4,4-4s4,1.791,4,' +
+    '4S10.209,10,8,10z M8,4  C6.896,4,6,4.896,6,6s0.896,2,2,2s2-0.896,2-2S9.104,4,8,4z';
+
+    // overlay definition
+    var overlay = {
+        overlayId: 'mapping-overlay',
+        glyphId: '*mapping',
+        tooltip: 'Mappings Overlay',
+        glyphs: {
+            mapping: {
+                vb: viewbox,
+                d: mapping
+            }
+        },
+        activate: function () {
+            $log.debug("Mapping topology overlay ACTIVATED");
+            mts.startDisplay();
+        },
+        deactivate: function () {
+            mts.stopDisplay();
+            $log.debug("Mapping topology overlay DEACTIVATED");
+        },
+        buttons: {
+            mappings: {
+                gid: '*mapping',
+                tt: 'Show mappings for this device',
+                cb: function (data) {
+                    $log.debug('Show mappings for this device. data:', data);
+                    ns.navTo("mapping", {devId: data.id});
+                }
+            }
+        },
+        hooks: {
+            // hooks for when the selection changes...
+            empty: function () {
+                selectionCallback('empty');
+            },
+            single: function (data) {
+                selectionCallback('single', data);
+            },
+            multi: function (selectOrder) {
+                selectionCallback('multi', selectOrder);
+                tov.addDetailButton('mappings');
+            }
+        }
+    };
+
+    function selectionCallback(x, d) {
+        $log.debug('Selection callback', x, d);
+    }
+
+    // invoke code to register with the overlay service
+    angular.module('ovMappingTopo')
+        .run(['$log', 'TopoOverlayService', 'MappingTopoService', 'NavService',
+
+        function (_$log_, _tov_, _mts_, _ns_) {
+            $log = _$log_;
+            tov = _tov_;
+            mts = _mts_;
+            ns = _ns_;
+            tov.register(overlay);
+        }]);
+
+}());
diff --git a/apps/mappingmanagement/web/src/main/resources/gui/js.html b/apps/mappingmanagement/web/src/main/resources/gui/js.html
index 23df18f..b22fb0e 100644
--- a/apps/mappingmanagement/web/src/main/resources/gui/js.html
+++ b/apps/mappingmanagement/web/src/main/resources/gui/js.html
@@ -1 +1,3 @@
-<script src="app/view/mapping/mapping.js"></script>
\ No newline at end of file
+<script src="app/view/mapping/mapping.js"></script>
+<script src="app/view/mapping/mappingTopo.js"></script>
+<script src="app/view/mapping/mappingTopoOverlay.js"></script>
\ No newline at end of file