rama-huawei
Committed by Ray Milkey

[onos-4531, onos-4532] SFC web gui implementation

Change-Id: If7a515d4f3fac9736e98570e8e78af6003c5bef8
...@@ -23,4 +23,5 @@ ...@@ -23,4 +23,5 @@
23 <artifact>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</artifact> 23 <artifact>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</artifact>
24 <artifact>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</artifact> 24 <artifact>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</artifact>
25 <artifact>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</artifact> 25 <artifact>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</artifact>
26 + <artifact>mvn:${project.groupId}/onos-app-sfc-web/${project.version}</artifact>
26 </app> 27 </app>
......
...@@ -23,5 +23,6 @@ ...@@ -23,5 +23,6 @@
23 <bundle>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</bundle> 23 <bundle>mvn:${project.groupId}/onos-app-sfc-mgr/${project.version}</bundle>
24 <bundle>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-app-vtn-web/${project.version}</bundle>
25 <bundle>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</bundle> 25 <bundle>mvn:${project.groupId}/onos-app-vtn-rsc/${project.version}</bundle>
26 + <bundle>mvn:${project.groupId}/onos-app-sfc-web/${project.version}</bundle>
26 </feature> 27 </feature>
27 </features> 28 </features>
......
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
43 </dependency> 43 </dependency>
44 <dependency> 44 <dependency>
45 <groupId>org.onosproject</groupId> 45 <groupId>org.onosproject</groupId>
46 + <artifactId>onos-app-sfc-web</artifactId>
47 + <version>${project.version}</version>
48 + </dependency>
49 + <dependency>
50 + <groupId>org.onosproject</groupId>
46 <artifactId>onos-app-vtn-mgr</artifactId> 51 <artifactId>onos-app-vtn-mgr</artifactId>
47 <version>${project.version}</version> 52 <version>${project.version}</version>
48 </dependency> 53 </dependency>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
36 <module>vtnrsc</module> 36 <module>vtnrsc</module>
37 <module>vtnmgr</module> 37 <module>vtnmgr</module>
38 <module>vtnweb</module> 38 <module>vtnweb</module>
39 + <module>sfcweb</module>
39 <module>app</module> 40 <module>app</module>
40 </modules> 41 </modules>
41 <dependencies> 42 <dependencies>
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +
3 +<!--
4 + ~ Copyright 2016-present Open Networking Laboratory
5 + ~
6 + ~ Licensed under the Apache License, Version 2.0 (the "License");
7 + ~ you may not use this file except in compliance with the License.
8 + ~ You may obtain a copy of the License at
9 + ~
10 + ~ http://www.apache.org/licenses/LICENSE-2.0
11 + ~
12 + ~ Unless required by applicable law or agreed to in writing, software
13 + ~ distributed under the License is distributed on an "AS IS" BASIS,
14 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + ~ See the License for the specific language governing permissions and
16 + ~ limitations under the License.
17 + -->
18 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19 + <modelVersion>4.0.0</modelVersion>
20 +
21 + <parent>
22 + <groupId>org.onosproject</groupId>
23 + <artifactId>onos-app-vtn</artifactId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + <relativePath>../pom.xml</relativePath>
26 + </parent>
27 +
28 + <artifactId>onos-app-sfc-web</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <description>SFC web application</description>
32 +
33 + <properties>
34 + <onos.app.name>org.onosproject.sfcweb</onos.app.name>
35 + <onos.app.title>SFC web application</onos.app.title>
36 + <onos.app.category>Utility</onos.app.category>
37 + <onos.app.url>https://wiki.onosproject.org/display/ONOS/</onos.app.url>
38 + <web.context>/onos/vtn</web.context>
39 + <onos.app.readme>
40 + Allows the user to visualize different types of paths between
41 + network entities such as switches and hosts.
42 + SF and SFF.
43 + </onos.app.readme>
44 + </properties>
45 +
46 + <dependencies>
47 + <dependency>
48 + <groupId>javax.ws.rs</groupId>
49 + <artifactId>javax.ws.rs-api</artifactId>
50 + <version>2.0.1</version>
51 + </dependency>
52 + <dependency>
53 + <groupId>org.onosproject</groupId>
54 + <artifactId>onos-app-vtn-rsc</artifactId>
55 + <version>${project.version}</version>
56 + </dependency>
57 + </dependencies>
58 +
59 +</project>
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.sfcweb;
17 +
18 +import com.google.common.collect.ImmutableList;
19 +import org.apache.felix.scr.annotations.Activate;
20 +import org.apache.felix.scr.annotations.Component;
21 +import org.apache.felix.scr.annotations.Deactivate;
22 +import org.apache.felix.scr.annotations.Reference;
23 +import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.onosproject.ui.UiExtension;
25 +import org.onosproject.ui.UiExtensionService;
26 +import org.onosproject.ui.UiMessageHandlerFactory;
27 +import org.onosproject.ui.UiTopoOverlayFactory;
28 +import org.onosproject.ui.UiView;
29 +import org.onosproject.ui.UiViewHidden;
30 +import org.slf4j.Logger;
31 +import org.slf4j.LoggerFactory;
32 +
33 +import java.util.List;
34 +
35 +/**
36 + * Skeletal ONOS UI Topology-Overlay application component.
37 + */
38 +@Component(immediate = true)
39 +public class SfcwebUiTopovComponent {
40 +
41 + private static final ClassLoader CL = SfcwebUiTopovComponent.class.getClassLoader();
42 + private static final String VIEW_ID = "sfcwebTopov";
43 +
44 + private final Logger log = LoggerFactory.getLogger(getClass());
45 +
46 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
47 + protected UiExtensionService uiExtensionService;
48 +
49 + // List of application views
50 + private final List<UiView> uiViews = ImmutableList.of(
51 + new UiViewHidden(VIEW_ID)
52 + );
53 +
54 + // Factory for UI message handlers
55 + private final UiMessageHandlerFactory messageHandlerFactory =
56 + () -> ImmutableList.of(
57 + new SfcwebUiTopovMessageHandler()
58 + );
59 +
60 + // Factory for UI topology overlays
61 + private final UiTopoOverlayFactory topoOverlayFactory =
62 + () -> ImmutableList.of(
63 + new SfcwebUiTopovOverlay()
64 + );
65 +
66 + // Application UI extension
67 + protected UiExtension extension =
68 + new UiExtension.Builder(CL, uiViews)
69 + .resourcePath(VIEW_ID)
70 + .messageHandlerFactory(messageHandlerFactory)
71 + .topoOverlayFactory(topoOverlayFactory)
72 + .build();
73 +
74 + @Activate
75 + protected void activate() {
76 + uiExtensionService.register(extension);
77 + log.info("Started");
78 + }
79 +
80 + @Deactivate
81 + protected void deactivate() {
82 + uiExtensionService.unregister(extension);
83 + log.info("Stopped");
84 + }
85 +
86 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.sfcweb;
17 +
18 +import org.onlab.osgi.DefaultServiceDirectory;
19 +import org.onlab.osgi.ServiceDirectory;
20 +import com.fasterxml.jackson.databind.node.ObjectNode;
21 +import com.fasterxml.jackson.databind.node.ArrayNode;
22 +import com.google.common.collect.ImmutableSet;
23 +
24 +import org.onlab.packet.MacAddress;
25 +import org.onosproject.net.Device;
26 +import org.onosproject.net.Element;
27 +import org.onosproject.net.Link;
28 +import org.onosproject.net.device.DeviceService;
29 +import org.onosproject.net.host.HostService;
30 +import org.onosproject.net.link.LinkService;
31 +import org.onosproject.ui.topo.HostHighlight;
32 +import org.onosproject.ui.RequestHandler;
33 +import org.onosproject.ui.UiConnection;
34 +import org.onosproject.ui.UiMessageHandler;
35 +import org.onosproject.ui.topo.Highlights;
36 +import org.onosproject.ui.topo.NodeBadge;
37 +import org.onosproject.ui.topo.TopoJson;
38 +import org.onosproject.ui.topo.DeviceHighlight;
39 +import org.slf4j.Logger;
40 +import org.slf4j.LoggerFactory;
41 +import org.onosproject.vtnrsc.PortChain;
42 +import org.onosproject.vtnrsc.portchain.PortChainService;
43 +import org.onosproject.vtnrsc.portpair.PortPairService;
44 +import org.onosproject.vtnrsc.PortChainId;
45 +import org.onosproject.net.DeviceId;
46 +import org.onosproject.net.Host;
47 +import org.onosproject.net.HostId;
48 +import org.onosproject.vtnrsc.PortPair;
49 +import org.onosproject.vtnrsc.PortPairId;
50 +import org.onosproject.vtnrsc.VirtualPortId;
51 +import org.onosproject.vtnrsc.service.VtnRscService;
52 +import org.onosproject.vtnrsc.virtualport.VirtualPortService;
53 +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
54 +import org.onosproject.vtnrsc.PortPairGroupId;
55 +import org.onosproject.vtnrsc.PortPairGroup;
56 +
57 +import java.util.Collection;
58 +import java.util.Timer;
59 +import java.util.TimerTask;
60 +import java.util.List;
61 +import java.util.ListIterator;
62 +
63 +/**
64 + * SFC web gui topology-overlay message handler.
65 + */
66 +public class SfcwebUiTopovMessageHandler extends UiMessageHandler {
67 +
68 + private static final String SAMPLE_TOPOV_DISPLAY_START = "sfcwebTopovDisplayStart";
69 + private static final String SAMPLE_TOPOV_DISPLAY_SFC = "showSfcInfo";
70 + private static final String SAMPLE_TOPOV_DISPLAY_STOP = "sfcTopovClear";
71 + private static final String CONFIG_SFP_MSG = "configSfpMessage";
72 +
73 + private static final String ID = "id";
74 + private static final String MODE = "mode";
75 + private static final String SFC_ID = "SFC";
76 +
77 + private static final long UPDATE_PERIOD_MS = 1000;
78 +
79 + private static final Link[] EMPTY_LINK_SET = new Link[0];
80 +
81 + private enum Mode { IDLE, MOUSE, LINK }
82 +
83 + private final Logger log = LoggerFactory.getLogger(getClass());
84 +
85 + private DeviceService deviceService;
86 + private HostService hostService;
87 + private LinkService linkService;
88 +
89 + private final Timer timer = new Timer("sfcweb-overlay");
90 + private TimerTask demoTask = null;
91 + private Mode currentMode = Mode.IDLE;
92 + private Element elementOfNote;
93 + private Link[] linkSet = EMPTY_LINK_SET;
94 + private int linkIndex;
95 +
96 + private long someNumber = 1;
97 + private long someIncrement = 1;
98 + protected PortPairService portPairService;
99 + protected VtnRscService vtnRscService;
100 + protected VirtualPortService virtualPortService;
101 + protected PortChainService portChainService;
102 + protected PortPairGroupService portPairGroupService;
103 +
104 + @Override
105 + public void init(UiConnection connection, ServiceDirectory directory) {
106 + super.init(connection, directory);
107 + deviceService = directory.get(DeviceService.class);
108 + hostService = directory.get(HostService.class);
109 + linkService = directory.get(LinkService.class);
110 + portChainService = directory.get(PortChainService.class);
111 + portPairService = directory.get(PortPairService.class);
112 + portPairGroupService = directory.get(PortPairGroupService.class);
113 + }
114 +
115 + @Override
116 + protected Collection<RequestHandler> createRequestHandlers() {
117 + return ImmutableSet.of(
118 + new DisplayStartHandler(),
119 + new DisplayStopHandler(),
120 + new ConfigSfpMsg()
121 + );
122 + }
123 +
124 + /**
125 + * Handler classes.
126 + */
127 + private final class DisplayStartHandler extends RequestHandler {
128 + public DisplayStartHandler() {
129 + super(SAMPLE_TOPOV_DISPLAY_START);
130 + }
131 + @Override
132 + public void process(long sid, ObjectNode payload) {
133 + String mode = string(payload, MODE);
134 + PortChainService pcs = get(PortChainService.class);
135 + Iterable<PortChain> portChains = pcs.getPortChains();
136 + ObjectNode result = objectNode();
137 +
138 + ArrayNode arrayNode = arrayNode();
139 +
140 + for (final PortChain portChain : portChains) {
141 + arrayNode.add(portChain.portChainId().value().toString());
142 + }
143 + result.putArray("a").addAll(arrayNode);
144 +
145 + sendMessage(SAMPLE_TOPOV_DISPLAY_SFC, sid, result);
146 + }
147 + }
148 +
149 + private final class DisplayStopHandler extends RequestHandler {
150 + public DisplayStopHandler() {
151 + super(SAMPLE_TOPOV_DISPLAY_STOP);
152 + }
153 +
154 + @Override
155 + public void process(long sid, ObjectNode payload) {
156 + log.debug("Stop Display");
157 + clearState();
158 + clearForMode();
159 + cancelTask();
160 + }
161 + }
162 +
163 + private final class ConfigSfpMsg extends RequestHandler {
164 + public ConfigSfpMsg() {
165 + super(CONFIG_SFP_MSG);
166 + }
167 +
168 + @Override
169 + public void process(long sid, ObjectNode payload) {
170 + String id = string(payload, ID);
171 + ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
172 + vtnRscService = serviceDirectory.get(VtnRscService.class);
173 + virtualPortService = serviceDirectory.get(VirtualPortService.class);
174 +
175 + Highlights highlights = new Highlights();
176 +
177 + PortChainId portChainId = PortChainId.of(id);
178 + boolean portChainIdExist = portChainService.exists(portChainId);
179 + if (!portChainIdExist) {
180 + log.info("portchain id doesn't exist");
181 + return;
182 + }
183 +
184 + PortChain portChain = portChainService.getPortChain(portChainId);
185 +
186 + List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups();
187 + ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator();
188 + while (portPairGroupIdListIterator.hasNext()) {
189 + PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next();
190 + PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
191 + List<PortPairId> llPortPairIdList = portPairGroup.portPairs();
192 + ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator();
193 +
194 + while (portPairListIterator.hasNext()) {
195 + PortPairId portPairId = portPairListIterator.next();
196 + PortPair portPair = portPairService.getPortPair(portPairId);
197 + DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress()));
198 + Device device = deviceService.getDevice(deviceId);
199 + DeviceHighlight dh = new DeviceHighlight(device.id().toString());
200 + dh.setBadge(NodeBadge.text(SFC_ID));
201 +
202 + MacAddress dstMacAddress = virtualPortService.getPort(VirtualPortId
203 + .portId(portPair.egress())).macAddress();
204 + Host host = hostService.getHost(HostId.hostId(dstMacAddress));
205 + HostHighlight hhDst = new HostHighlight(host.id().toString());
206 + hhDst.setBadge(NodeBadge.text(SFC_ID));
207 +
208 + MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId
209 + .portId(portPair.ingress())).macAddress();
210 + Host hostSrc = hostService.getHost(HostId.hostId(srcMacAddress));
211 + HostHighlight hhSrc = new HostHighlight(hostSrc.id().toString());
212 + hhSrc.setBadge(NodeBadge.text(SFC_ID));
213 +
214 + highlights.add(dh);
215 + highlights.add(hhSrc);
216 + highlights.add(hhDst);
217 + }
218 + }
219 +
220 + sendHighlights(highlights);
221 + }
222 + }
223 +
224 + private synchronized void cancelTask() {
225 + if (demoTask != null) {
226 + demoTask.cancel();
227 + demoTask = null;
228 + }
229 + }
230 +
231 + private void clearState() {
232 + currentMode = Mode.IDLE;
233 + elementOfNote = null;
234 + linkSet = EMPTY_LINK_SET;
235 + }
236 +
237 + private void clearForMode() {
238 + sendHighlights(new Highlights());
239 + }
240 +
241 + private void sendHighlights(Highlights highlights) {
242 + sendMessage(TopoJson.highlightsMessage(highlights));
243 + }
244 +
245 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.sfcweb;
17 +
18 +import org.onosproject.net.DeviceId;
19 +import org.onosproject.net.HostId;
20 +import org.onosproject.ui.UiTopoOverlay;
21 +import org.onosproject.ui.topo.PropertyPanel;
22 +
23 +
24 +/**
25 + * Our sfcweb topology overlay.
26 + */
27 +public class SfcwebUiTopovOverlay extends UiTopoOverlay {
28 +
29 + // NOTE: this must match the ID defined in sfcwebTopov.js
30 + private static final String OVERLAY_ID = "SFC-Service-overlay";
31 + private static final String MY_DEVICE_TITLE = "SFF specific device details";
32 + private static final String MY_HOST_TITLE = "SF specific host details";
33 +
34 + public SfcwebUiTopovOverlay() {
35 + super(OVERLAY_ID);
36 + }
37 +
38 + @Override
39 + public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
40 + pp.title(MY_DEVICE_TITLE);
41 + pp.removeAllProps();
42 + pp.addProp("SFF Device Id", deviceId.toString());
43 + }
44 +
45 + @Override
46 + public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
47 + pp.title(MY_HOST_TITLE);
48 + pp.removeAllProps();
49 + pp.addProp("SF host Address", hostId.toString());
50 + }
51 +
52 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * SFC service topology view overlay.
19 + */
20 +package org.onosproject.sfcweb;
1 +<!-- partial HTML -->
2 +<div id="ov-sfcweb-topov">
3 + <p>This is a hidden view .. just a placeholder to house the javascript</p>
4 +</div>
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + sfc web gui overlay implementation.
19 + */
20 +
21 +(function () {
22 + 'use strict';
23 +
24 + // injected refs
25 + var $log, fs, flash, wss, tds, ds, handlerMap = {};
26 +
27 + // constants
28 + var displayStart = 'sfcwebTopovDisplayStart',
29 + showSfcInf = 'showSfcInfo',
30 + clearMessage = 'sfcTopovClear',
31 + configSfpMessage = 'configSfpMessage' ;
32 +
33 + // internal state
34 + var currentMode = null;
35 +
36 + // === Main API functions
37 +
38 + function start() {
39 + handlerMap[showSfcInf] = showSfcInformation;
40 + wss.bindHandlers(handlerMap);
41 + wss.sendEvent(displayStart);
42 + }
43 +
44 + function dOk() {
45 + var sfcId = null;
46 + sfcId = d3.select('#sfp-value').property("value");
47 +
48 + if (sfcId) {
49 + console.log(sfcId);
50 + }
51 +
52 + $log.debug('Dialog OK button clicked');
53 +
54 + wss.sendEvent(configSfpMessage, {
55 + id: sfcId
56 + });
57 +
58 + flash.flash('SFP ID query:');
59 + }
60 +
61 + function dClose() {
62 + $log.debug('Dialog Close button clicked (or Esc pressed)');
63 + }
64 +
65 + function createUserText() {
66 + var content = ds.createDiv();
67 + var form = content.append('form');
68 + var p = form.append('p');
69 +
70 + p.append('input').attr({
71 + id: 'sfp-value',
72 + type: 'string',
73 + name: 'sfp-value-name'
74 + });
75 + p.append('span').text('ID');
76 + p.append('br');
77 +
78 + return content;
79 + }
80 +
81 + function configSfp() {
82 + tds.openDialog()
83 + .setTitle('SFP ID User Input')
84 + .addContent(createUserText())
85 + .addOk(dOk, 'OK')
86 + .addCancel(dClose, 'Close')
87 + .bindKeys();
88 + }
89 +
90 + function showSfcInformation(data) {
91 + console.log(data);
92 + wss.unbindHandlers(handlerMap);
93 +
94 + // Get the modal
95 + var modal = document.getElementById('myModal');
96 +
97 + // Get the button that opens the modal
98 + var btn = document.getElementById("myBtn");
99 +
100 + // Get the <span> element that closes the modal
101 + var span = document.getElementsByClassName("close")[0];
102 +
103 + modal.style.display = "block";
104 +
105 + var tBody = document.getElementById('sfc-info-body');
106 +
107 + var tdString = '' ;
108 +
109 + for (var i = 0; i < data.a.length; i++) {
110 + tdString += '<tr> <td>'+ data.a[i] +'</td></tr>';
111 + }
112 +
113 + tBody.innerHTML = tdString;
114 +
115 + // When the user clicks on <span> (x), close the modal
116 + span.onclick = function() {
117 + modal.style.display = "none";
118 + }
119 +
120 + // When the user clicks anywhere outside of the modal, close it
121 + window.onclick = function(event) {
122 + if (event.target == modal) {
123 + modal.style.display = "none";
124 + }
125 + }
126 +
127 + }
128 +
129 + function clear() {
130 + wss.sendEvent(clearMessage);
131 + flash.flash('Cleared SFC overlay');
132 + }
133 +
134 + // === ---------------------------
135 + // === Module Factory Definition
136 + angular.module('ovSfcwebTopov', [])
137 + .factory('SfcwebTopovDemoService',
138 + ['$log', 'FnService', 'FlashService', 'WebSocketService', 'TopoDialogService', 'DialogService',
139 + function (_$log_, _fs_, _flash_, _wss_, _tds_, _ds_) {
140 + $log = _$log_;
141 + fs = _fs_;
142 + flash = _flash_;
143 + wss = _wss_;
144 + tds = _tds_;
145 + ds = _ds_;
146 + return {
147 + start: start,
148 + showSfcInformation: showSfcInformation,
149 + clear: clear,
150 + configSfp: configSfp
151 + };
152 + }]);
153 +
154 +}());
1 +// sfcweb topology overlay - client side
2 +//
3 +// This is the glue that binds our business logic (in sfcwebTopovDemo.js)
4 +// to the overlay framework.
5 +
6 +(function () {
7 + 'use strict';
8 +
9 + // injected refs
10 + var $log, tov, pps;
11 + var longPrefix = 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1' +
12 + 'z M71.9,6.1H56.9v13h14.9V6.1z M53.2,6.1H38.3v13h14.9V6.1z M34.5,' +
13 + '6.1H19.6v13h14.9V6.1z M102.2,6.1h-8v13h8V6.1z' ;
14 +
15 + // our overlay definition
16 + var overlay = {
17 + // NOTE: this must match the ID defined in SfcWebUiTopovOverlay
18 + overlayId: 'SFC-Service-overlay',
19 + glyphId: '*star4',
20 + tooltip: 'SFC web service Topo Overlay',
21 +
22 + // These glyphs get installed using the overlayId as a prefix.
23 + // e.g. 'star4' is installed as 'meowster-overlay-star4'
24 + // They can be referenced (from this overlay) as '*star4'
25 + // That is, the '*' prefix stands in for 'meowster-overlay-'
26 + glyphs: {
27 + star4: {
28 + vb: '0 0 8 8',
29 + d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
30 + },
31 + jp: {
32 + vb: '0 0 110 110',
33 + d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' +
34 + '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'
35 + }
36 + },
37 + activate: function () {
38 + $log.debug("SFC service topology overlay ACTIVATED");
39 + },
40 + deactivate: function () {
41 + pps.clear();
42 + $log.debug("SFC service topology overlay DEACTIVATED");
43 + },
44 +
45 + // Key bindings for traffic overlay buttons
46 + // NOTE: fully qual. button ID is derived from overlay-id and key-name
47 + // FIXME: find better keys for shortest paths & disjoint paths modes
48 + keyBindings: {
49 + 4: {
50 + cb: function () {
51 + pps.start();
52 + },
53 + tt: 'Query SFP active list information',
54 + gid: 'summary'
55 + },
56 + 5: {
57 + cb: function () {
58 + pps.configSfp();
59 + },
60 + tt: 'Highlight SFP active list information',
61 + gid: '*jp'
62 + },
63 +
64 + _keyOrder: [
65 + '4' , '5'
66 + ]
67 + }
68 +
69 + };
70 +
71 + // invoke code to register with the overlay service
72 + angular.module('ovSfcwebTopov')
73 + .run(['$log', 'TopoOverlayService', 'SfcwebTopovDemoService',
74 +
75 + function (_$log_, _tov_, _pps_) {
76 + $log = _$log_;
77 + tov = _tov_;
78 + pps = _pps_;
79 + tov.register(overlay);
80 + $log.debug('ovSfcwebTopov run');
81 + }]);
82 +
83 +}());
1 +<link rel="stylesheet" href="app/view/sfcwebTopov/sfcwebTopov.css">
...\ No newline at end of file ...\ No newline at end of file
1 +<script src="app/view/sfcwebTopov/sfcwebTopovDemo.js"></script>
2 +<script src="app/view/sfcwebTopov/sfcwebTopovOverlay.js"></script>
3 +
4 +<style>
5 + /* The Modal (background) */
6 + .modal {
7 + display: none;
8 + position: fixed;
9 + z-index: 1;
10 + padding-top: 0px;
11 + left: 0px;
12 + top: 0;
13 + width: 37%;
14 + height: 25%;
15 + overflow: auto;
16 + background-color: none;
17 + margin: 178px 0px 0px -8px;
18 + }
19 +
20 + /* Modal Content */
21 + .modal-content {
22 + background-color: #fefefe;
23 + margin: auto;
24 + padding: 20px;
25 + border: 1px solid #888;
26 + width: 80%;
27 + }
28 +
29 + /* The Close Button */
30 + .close {
31 + color: #aaaaaa;
32 + float: right;
33 + font-size: 28px;
34 + font-weight: bold;
35 + }
36 +
37 + .close:hover,
38 + .close:focus {
39 + color: #000;
40 + text-decoration: none;
41 + cursor: pointer;
42 + }
43 +
44 +</style>
45 +
46 +<!-- The Modal -->
47 +<div id="myModal" class="modal">
48 +
49 + <!-- Modal content -->
50 + <div class="modal-content">
51 + <span class="close">×</span>
52 + <table id='sfc-info'>
53 + <thead>
54 + <td>SFP ID information</td>
55 + </thead>
56 + <tbody id='sfc-info-body'>
57 +
58 + </tbody>
59 + </table>
60 + </div>
61 +</div>