From c78f309f673023a73ce794d2c5865123d03797b0 Mon Sep 17 00:00:00 2001 From: rama-huawei Date: Thu, 19 May 2016 18:09:29 +0530 Subject: [PATCH] [onos-4531, onos-4532] SFC web gui implementation Change-Id: If7a515d4f3fac9736e98570e8e78af6003c5bef8 --- apps/vtn/app/app.xml | 1 + apps/vtn/app/features.xml | 1 + apps/vtn/app/pom.xml | 5 + apps/vtn/pom.xml | 7 +- apps/vtn/sfcweb/pom.xml | 59 +++++ .../sfcweb/SfcwebUiTopovComponent.java | 86 ++++++ .../sfcweb/SfcwebUiTopovMessageHandler.java | 245 ++++++++++++++++++ .../sfcweb/SfcwebUiTopovOverlay.java | 52 ++++ .../org/onosproject/sfcweb/package-info.java | 20 ++ .../app/view/sfcwebTopov/sfcwebTopov.css | 1 + .../app/view/sfcwebTopov/sfcwebTopov.html | 4 + .../app/view/sfcwebTopov/sfcwebTopovDemo.js | 154 +++++++++++ .../view/sfcwebTopov/sfcwebTopovOverlay.js | 83 ++++++ .../src/main/resources/sfcwebTopov/css.html | 1 + .../src/main/resources/sfcwebTopov/js.html | 61 +++++ 15 files changed, 777 insertions(+), 3 deletions(-) create mode 100755 apps/vtn/sfcweb/pom.xml create mode 100755 apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java create mode 100755 apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java create mode 100755 apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java create mode 100755 apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java create mode 100755 apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css create mode 100755 apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html create mode 100755 apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js create mode 100755 apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js create mode 100755 apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html create mode 100755 apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html diff --git a/apps/vtn/app/app.xml b/apps/vtn/app/app.xml index 67092f8b6c..10bd68131b 100644 --- a/apps/vtn/app/app.xml +++ b/apps/vtn/app/app.xml @@ -23,4 +23,5 @@ mvn:${project.groupId}/onos-app-sfc-mgr/${project.version} mvn:${project.groupId}/onos-app-vtn-web/${project.version} mvn:${project.groupId}/onos-app-vtn-rsc/${project.version} + mvn:${project.groupId}/onos-app-sfc-web/${project.version} diff --git a/apps/vtn/app/features.xml b/apps/vtn/app/features.xml index be45842ca4..c9407900ef 100644 --- a/apps/vtn/app/features.xml +++ b/apps/vtn/app/features.xml @@ -23,5 +23,6 @@ mvn:${project.groupId}/onos-app-sfc-mgr/${project.version} mvn:${project.groupId}/onos-app-vtn-web/${project.version} mvn:${project.groupId}/onos-app-vtn-rsc/${project.version} + mvn:${project.groupId}/onos-app-sfc-web/${project.version} diff --git a/apps/vtn/app/pom.xml b/apps/vtn/app/pom.xml index f60edb8c7c..5fb9065bc4 100644 --- a/apps/vtn/app/pom.xml +++ b/apps/vtn/app/pom.xml @@ -41,6 +41,11 @@ onos-app-vtn-web ${project.version} + + org.onosproject + onos-app-sfc-web + ${project.version} + org.onosproject onos-app-vtn-mgr diff --git a/apps/vtn/pom.xml b/apps/vtn/pom.xml index b28a47cbe4..dddf8028e2 100644 --- a/apps/vtn/pom.xml +++ b/apps/vtn/pom.xml @@ -36,10 +36,11 @@ vtnrsc vtnmgr vtnweb + sfcweb app - - - + + + org.onosproject onlab-junit test diff --git a/apps/vtn/sfcweb/pom.xml b/apps/vtn/sfcweb/pom.xml new file mode 100755 index 0000000000..5484061c78 --- /dev/null +++ b/apps/vtn/sfcweb/pom.xml @@ -0,0 +1,59 @@ + + + + + 4.0.0 + + + org.onosproject + onos-app-vtn + 1.6.0-SNAPSHOT + ../pom.xml + + + onos-app-sfc-web + bundle + + SFC web application + + + org.onosproject.sfcweb + SFC web application + Utility + https://wiki.onosproject.org/display/ONOS/ + /onos/vtn + + Allows the user to visualize different types of paths between + network entities such as switches and hosts. + SF and SFF. + + + + + + javax.ws.rs + javax.ws.rs-api + 2.0.1 + + + org.onosproject + onos-app-vtn-rsc + ${project.version} + + + + diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java new file mode 100755 index 0000000000..76ce18dec0 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java @@ -0,0 +1,86 @@ +/* + * Copyright 2016-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. + */ +package org.onosproject.sfcweb; + +import com.google.common.collect.ImmutableList; +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onosproject.ui.UiExtension; +import org.onosproject.ui.UiExtensionService; +import org.onosproject.ui.UiMessageHandlerFactory; +import org.onosproject.ui.UiTopoOverlayFactory; +import org.onosproject.ui.UiView; +import org.onosproject.ui.UiViewHidden; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * Skeletal ONOS UI Topology-Overlay application component. + */ +@Component(immediate = true) +public class SfcwebUiTopovComponent { + + private static final ClassLoader CL = SfcwebUiTopovComponent.class.getClassLoader(); + private static final String VIEW_ID = "sfcwebTopov"; + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected UiExtensionService uiExtensionService; + + // List of application views + private final List uiViews = ImmutableList.of( + new UiViewHidden(VIEW_ID) + ); + + // Factory for UI message handlers + private final UiMessageHandlerFactory messageHandlerFactory = + () -> ImmutableList.of( + new SfcwebUiTopovMessageHandler() + ); + + // Factory for UI topology overlays + private final UiTopoOverlayFactory topoOverlayFactory = + () -> ImmutableList.of( + new SfcwebUiTopovOverlay() + ); + + // Application UI extension + protected UiExtension extension = + new UiExtension.Builder(CL, uiViews) + .resourcePath(VIEW_ID) + .messageHandlerFactory(messageHandlerFactory) + .topoOverlayFactory(topoOverlayFactory) + .build(); + + @Activate + protected void activate() { + uiExtensionService.register(extension); + log.info("Started"); + } + + @Deactivate + protected void deactivate() { + uiExtensionService.unregister(extension); + log.info("Stopped"); + } + +} diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java new file mode 100755 index 0000000000..df541b38f5 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java @@ -0,0 +1,245 @@ +/* + * Copyright 2016-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. + */ +package org.onosproject.sfcweb; + +import org.onlab.osgi.DefaultServiceDirectory; +import org.onlab.osgi.ServiceDirectory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.google.common.collect.ImmutableSet; + +import org.onlab.packet.MacAddress; +import org.onosproject.net.Device; +import org.onosproject.net.Element; +import org.onosproject.net.Link; +import org.onosproject.net.device.DeviceService; +import org.onosproject.net.host.HostService; +import org.onosproject.net.link.LinkService; +import org.onosproject.ui.topo.HostHighlight; +import org.onosproject.ui.RequestHandler; +import org.onosproject.ui.UiConnection; +import org.onosproject.ui.UiMessageHandler; +import org.onosproject.ui.topo.Highlights; +import org.onosproject.ui.topo.NodeBadge; +import org.onosproject.ui.topo.TopoJson; +import org.onosproject.ui.topo.DeviceHighlight; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.portchain.PortChainService; +import org.onosproject.vtnrsc.portpair.PortPairService; +import org.onosproject.vtnrsc.PortChainId; +import org.onosproject.net.DeviceId; +import org.onosproject.net.Host; +import org.onosproject.net.HostId; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.VirtualPortId; +import org.onosproject.vtnrsc.service.VtnRscService; +import org.onosproject.vtnrsc.virtualport.VirtualPortService; +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; +import org.onosproject.vtnrsc.PortPairGroupId; +import org.onosproject.vtnrsc.PortPairGroup; + +import java.util.Collection; +import java.util.Timer; +import java.util.TimerTask; +import java.util.List; +import java.util.ListIterator; + +/** + * SFC web gui topology-overlay message handler. + */ +public class SfcwebUiTopovMessageHandler extends UiMessageHandler { + + private static final String SAMPLE_TOPOV_DISPLAY_START = "sfcwebTopovDisplayStart"; + private static final String SAMPLE_TOPOV_DISPLAY_SFC = "showSfcInfo"; + private static final String SAMPLE_TOPOV_DISPLAY_STOP = "sfcTopovClear"; + private static final String CONFIG_SFP_MSG = "configSfpMessage"; + + private static final String ID = "id"; + private static final String MODE = "mode"; + private static final String SFC_ID = "SFC"; + + private static final long UPDATE_PERIOD_MS = 1000; + + private static final Link[] EMPTY_LINK_SET = new Link[0]; + + private enum Mode { IDLE, MOUSE, LINK } + + private final Logger log = LoggerFactory.getLogger(getClass()); + + private DeviceService deviceService; + private HostService hostService; + private LinkService linkService; + + private final Timer timer = new Timer("sfcweb-overlay"); + private TimerTask demoTask = null; + private Mode currentMode = Mode.IDLE; + private Element elementOfNote; + private Link[] linkSet = EMPTY_LINK_SET; + private int linkIndex; + + private long someNumber = 1; + private long someIncrement = 1; + protected PortPairService portPairService; + protected VtnRscService vtnRscService; + protected VirtualPortService virtualPortService; + protected PortChainService portChainService; + protected PortPairGroupService portPairGroupService; + + @Override + public void init(UiConnection connection, ServiceDirectory directory) { + super.init(connection, directory); + deviceService = directory.get(DeviceService.class); + hostService = directory.get(HostService.class); + linkService = directory.get(LinkService.class); + portChainService = directory.get(PortChainService.class); + portPairService = directory.get(PortPairService.class); + portPairGroupService = directory.get(PortPairGroupService.class); + } + + @Override + protected Collection createRequestHandlers() { + return ImmutableSet.of( + new DisplayStartHandler(), + new DisplayStopHandler(), + new ConfigSfpMsg() + ); + } + + /** + * Handler classes. + */ + private final class DisplayStartHandler extends RequestHandler { + public DisplayStartHandler() { + super(SAMPLE_TOPOV_DISPLAY_START); + } + @Override + public void process(long sid, ObjectNode payload) { + String mode = string(payload, MODE); + PortChainService pcs = get(PortChainService.class); + Iterable portChains = pcs.getPortChains(); + ObjectNode result = objectNode(); + + ArrayNode arrayNode = arrayNode(); + + for (final PortChain portChain : portChains) { + arrayNode.add(portChain.portChainId().value().toString()); + } + result.putArray("a").addAll(arrayNode); + + sendMessage(SAMPLE_TOPOV_DISPLAY_SFC, sid, result); + } + } + + private final class DisplayStopHandler extends RequestHandler { + public DisplayStopHandler() { + super(SAMPLE_TOPOV_DISPLAY_STOP); + } + + @Override + public void process(long sid, ObjectNode payload) { + log.debug("Stop Display"); + clearState(); + clearForMode(); + cancelTask(); + } + } + + private final class ConfigSfpMsg extends RequestHandler { + public ConfigSfpMsg() { + super(CONFIG_SFP_MSG); + } + + @Override + public void process(long sid, ObjectNode payload) { + String id = string(payload, ID); + ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); + vtnRscService = serviceDirectory.get(VtnRscService.class); + virtualPortService = serviceDirectory.get(VirtualPortService.class); + + Highlights highlights = new Highlights(); + + PortChainId portChainId = PortChainId.of(id); + boolean portChainIdExist = portChainService.exists(portChainId); + if (!portChainIdExist) { + log.info("portchain id doesn't exist"); + return; + } + + PortChain portChain = portChainService.getPortChain(portChainId); + + List llPortPairGroupIdList = portChain.portPairGroups(); + ListIterator portPairGroupIdListIterator = llPortPairGroupIdList.listIterator(); + while (portPairGroupIdListIterator.hasNext()) { + PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next(); + PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId); + List llPortPairIdList = portPairGroup.portPairs(); + ListIterator portPairListIterator = llPortPairIdList.listIterator(); + + while (portPairListIterator.hasNext()) { + PortPairId portPairId = portPairListIterator.next(); + PortPair portPair = portPairService.getPortPair(portPairId); + DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress())); + Device device = deviceService.getDevice(deviceId); + DeviceHighlight dh = new DeviceHighlight(device.id().toString()); + dh.setBadge(NodeBadge.text(SFC_ID)); + + MacAddress dstMacAddress = virtualPortService.getPort(VirtualPortId + .portId(portPair.egress())).macAddress(); + Host host = hostService.getHost(HostId.hostId(dstMacAddress)); + HostHighlight hhDst = new HostHighlight(host.id().toString()); + hhDst.setBadge(NodeBadge.text(SFC_ID)); + + MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId + .portId(portPair.ingress())).macAddress(); + Host hostSrc = hostService.getHost(HostId.hostId(srcMacAddress)); + HostHighlight hhSrc = new HostHighlight(hostSrc.id().toString()); + hhSrc.setBadge(NodeBadge.text(SFC_ID)); + + highlights.add(dh); + highlights.add(hhSrc); + highlights.add(hhDst); + } + } + + sendHighlights(highlights); + } + } + + private synchronized void cancelTask() { + if (demoTask != null) { + demoTask.cancel(); + demoTask = null; + } + } + + private void clearState() { + currentMode = Mode.IDLE; + elementOfNote = null; + linkSet = EMPTY_LINK_SET; + } + + private void clearForMode() { + sendHighlights(new Highlights()); + } + + private void sendHighlights(Highlights highlights) { + sendMessage(TopoJson.highlightsMessage(highlights)); + } + +} diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java new file mode 100755 index 0000000000..6ee1b0222b --- /dev/null +++ b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016-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. + */ +package org.onosproject.sfcweb; + +import org.onosproject.net.DeviceId; +import org.onosproject.net.HostId; +import org.onosproject.ui.UiTopoOverlay; +import org.onosproject.ui.topo.PropertyPanel; + + +/** + * Our sfcweb topology overlay. + */ +public class SfcwebUiTopovOverlay extends UiTopoOverlay { + + // NOTE: this must match the ID defined in sfcwebTopov.js + private static final String OVERLAY_ID = "SFC-Service-overlay"; + private static final String MY_DEVICE_TITLE = "SFF specific device details"; + private static final String MY_HOST_TITLE = "SF specific host details"; + + public SfcwebUiTopovOverlay() { + super(OVERLAY_ID); + } + + @Override + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { + pp.title(MY_DEVICE_TITLE); + pp.removeAllProps(); + pp.addProp("SFF Device Id", deviceId.toString()); + } + + @Override + public void modifyHostDetails(PropertyPanel pp, HostId hostId) { + pp.title(MY_HOST_TITLE); + pp.removeAllProps(); + pp.addProp("SF host Address", hostId.toString()); + } + +} diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java new file mode 100755 index 0000000000..f779dae6a3 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2016-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. + */ + +/** + * SFC service topology view overlay. + */ +package org.onosproject.sfcweb; diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css new file mode 100755 index 0000000000..8729afee65 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css @@ -0,0 +1 @@ +/* css for sfcweb app topology overlay */ diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html new file mode 100755 index 0000000000..4a420ea9aa --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html @@ -0,0 +1,4 @@ + +
+

This is a hidden view .. just a placeholder to house the javascript

+
diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js new file mode 100755 index 0000000000..ebaf482745 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js @@ -0,0 +1,154 @@ +/* + * Copyright 2016-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. + */ + +/* + sfc web gui overlay implementation. + */ + +(function () { + 'use strict'; + + // injected refs + var $log, fs, flash, wss, tds, ds, handlerMap = {}; + + // constants + var displayStart = 'sfcwebTopovDisplayStart', + showSfcInf = 'showSfcInfo', + clearMessage = 'sfcTopovClear', + configSfpMessage = 'configSfpMessage' ; + + // internal state + var currentMode = null; + + // === Main API functions + + function start() { + handlerMap[showSfcInf] = showSfcInformation; + wss.bindHandlers(handlerMap); + wss.sendEvent(displayStart); + } + + function dOk() { + var sfcId = null; + sfcId = d3.select('#sfp-value').property("value"); + + if (sfcId) { + console.log(sfcId); + } + + $log.debug('Dialog OK button clicked'); + + wss.sendEvent(configSfpMessage, { + id: sfcId + }); + + flash.flash('SFP ID query:'); + } + + function dClose() { + $log.debug('Dialog Close button clicked (or Esc pressed)'); + } + + function createUserText() { + var content = ds.createDiv(); + var form = content.append('form'); + var p = form.append('p'); + + p.append('input').attr({ + id: 'sfp-value', + type: 'string', + name: 'sfp-value-name' + }); + p.append('span').text('ID'); + p.append('br'); + + return content; + } + + function configSfp() { + tds.openDialog() + .setTitle('SFP ID User Input') + .addContent(createUserText()) + .addOk(dOk, 'OK') + .addCancel(dClose, 'Close') + .bindKeys(); + } + + function showSfcInformation(data) { + console.log(data); + wss.unbindHandlers(handlerMap); + + // Get the modal + var modal = document.getElementById('myModal'); + + // Get the button that opens the modal + var btn = document.getElementById("myBtn"); + + // Get the element that closes the modal + var span = document.getElementsByClassName("close")[0]; + + modal.style.display = "block"; + + var tBody = document.getElementById('sfc-info-body'); + + var tdString = '' ; + + for (var i = 0; i < data.a.length; i++) { + tdString += ' '+ data.a[i] +''; + } + + tBody.innerHTML = tdString; + + // When the user clicks on (x), close the modal + span.onclick = function() { + modal.style.display = "none"; + } + + // When the user clicks anywhere outside of the modal, close it + window.onclick = function(event) { + if (event.target == modal) { + modal.style.display = "none"; + } + } + + } + + function clear() { + wss.sendEvent(clearMessage); + flash.flash('Cleared SFC overlay'); + } + + // === --------------------------- + // === Module Factory Definition + angular.module('ovSfcwebTopov', []) + .factory('SfcwebTopovDemoService', + ['$log', 'FnService', 'FlashService', 'WebSocketService', 'TopoDialogService', 'DialogService', + function (_$log_, _fs_, _flash_, _wss_, _tds_, _ds_) { + $log = _$log_; + fs = _fs_; + flash = _flash_; + wss = _wss_; + tds = _tds_; + ds = _ds_; + return { + start: start, + showSfcInformation: showSfcInformation, + clear: clear, + configSfp: configSfp + }; + }]); + +}()); diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js new file mode 100755 index 0000000000..75bccb15e4 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js @@ -0,0 +1,83 @@ +// sfcweb topology overlay - client side +// +// This is the glue that binds our business logic (in sfcwebTopovDemo.js) +// to the overlay framework. + +(function () { + 'use strict'; + + // injected refs + var $log, tov, pps; + var longPrefix = 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1' + + 'z M71.9,6.1H56.9v13h14.9V6.1z M53.2,6.1H38.3v13h14.9V6.1z M34.5,' + + '6.1H19.6v13h14.9V6.1z M102.2,6.1h-8v13h8V6.1z' ; + + // our overlay definition + var overlay = { + // NOTE: this must match the ID defined in SfcWebUiTopovOverlay + overlayId: 'SFC-Service-overlay', + glyphId: '*star4', + tooltip: 'SFC web service Topo Overlay', + + // These glyphs get installed using the overlayId as a prefix. + // e.g. 'star4' is installed as 'meowster-overlay-star4' + // They can be referenced (from this overlay) as '*star4' + // That is, the '*' prefix stands in for 'meowster-overlay-' + glyphs: { + star4: { + vb: '0 0 8 8', + d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z' + }, + jp: { + vb: '0 0 110 110', + d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' + + 'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z' + } + }, + activate: function () { + $log.debug("SFC service topology overlay ACTIVATED"); + }, + deactivate: function () { + pps.clear(); + $log.debug("SFC service topology overlay DEACTIVATED"); + }, + + // Key bindings for traffic overlay buttons + // NOTE: fully qual. button ID is derived from overlay-id and key-name + // FIXME: find better keys for shortest paths & disjoint paths modes + keyBindings: { + 4: { + cb: function () { + pps.start(); + }, + tt: 'Query SFP active list information', + gid: 'summary' + }, + 5: { + cb: function () { + pps.configSfp(); + }, + tt: 'Highlight SFP active list information', + gid: '*jp' + }, + + _keyOrder: [ + '4' , '5' + ] + } + + }; + + // invoke code to register with the overlay service + angular.module('ovSfcwebTopov') + .run(['$log', 'TopoOverlayService', 'SfcwebTopovDemoService', + + function (_$log_, _tov_, _pps_) { + $log = _$log_; + tov = _tov_; + pps = _pps_; + tov.register(overlay); + $log.debug('ovSfcwebTopov run'); + }]); + +}()); diff --git a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html new file mode 100755 index 0000000000..4e201d70a1 --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html new file mode 100755 index 0000000000..ea42c706ba --- /dev/null +++ b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html @@ -0,0 +1,61 @@ + + + + + + +