Thomas Vachuska
Committed by Gerrit Code Review

Removed legacy GUI.

FIxed an NPE in the devices table.
Added cord-gui to obs.exclude

Change-Id: I18a53d2c44c6c97fb7f5d16b7446942a1a37ddca
Showing 34 changed files with 5 additions and 3133 deletions
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
3 .*/build/conf/.* 3 .*/build/conf/.*
4 .*/docs/.* 4 .*/docs/.*
5 .*/openflow/drivers/.* 5 .*/openflow/drivers/.*
6 +.*/cord-gui/.*
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -121,6 +121,8 @@ public class DeviceViewMessageHandler extends UiMessageHandler { ...@@ -121,6 +121,8 @@ public class DeviceViewMessageHandler extends UiMessageHandler {
121 boolean available = ds.isAvailable(id); 121 boolean available = ds.isAvailable(id);
122 String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE; 122 String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;
123 123
124 + String protocol = dev.annotations().value(PROTOCOL);
125 +
124 row.cell(ID, id) 126 row.cell(ID, id)
125 .cell(AVAILABLE, available) 127 .cell(AVAILABLE, available)
126 .cell(AVAILABLE_IID, iconId) 128 .cell(AVAILABLE_IID, iconId)
...@@ -128,7 +130,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler { ...@@ -128,7 +130,7 @@ public class DeviceViewMessageHandler extends UiMessageHandler {
128 .cell(MFR, dev.manufacturer()) 130 .cell(MFR, dev.manufacturer())
129 .cell(HW, dev.hwVersion()) 131 .cell(HW, dev.hwVersion())
130 .cell(SW, dev.swVersion()) 132 .cell(SW, dev.swVersion())
131 - .cell(PROTOCOL, dev.annotations().value(PROTOCOL)) 133 + .cell(PROTOCOL, protocol != null ? protocol : "")
132 .cell(NUM_PORTS, ds.getPorts(id).size()) 134 .cell(NUM_PORTS, ds.getPorts(id).size())
133 .cell(MASTER_ID, ms.getMasterFor(id)); 135 .cell(MASTER_ID, ms.getMasterFor(id));
134 } 136 }
......
1 -/*
2 - * Copyright 2014-2015 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.ui.impl;
17 -
18 -import org.eclipse.jetty.websocket.WebSocket;
19 -import org.eclipse.jetty.websocket.WebSocketServlet;
20 -import org.onlab.osgi.DefaultServiceDirectory;
21 -import org.onlab.osgi.ServiceDirectory;
22 -
23 -import javax.servlet.ServletException;
24 -import javax.servlet.http.HttpServletRequest;
25 -import java.util.HashSet;
26 -import java.util.Iterator;
27 -import java.util.Set;
28 -import java.util.Timer;
29 -import java.util.TimerTask;
30 -
31 -/**
32 - * Web socket servlet capable of creating various sockets for the user interface.
33 - */
34 -@Deprecated
35 -public class GuiWebSocketServlet extends WebSocketServlet {
36 -
37 - private static final long PING_DELAY_MS = 5000;
38 -
39 - private ServiceDirectory directory = new DefaultServiceDirectory();
40 -
41 - private final Set<TopologyViewWebSocket> sockets = new HashSet<>();
42 - private final Timer timer = new Timer();
43 - private final TimerTask pruner = new Pruner();
44 -
45 - @Override
46 - public void init() throws ServletException {
47 - super.init();
48 - timer.schedule(pruner, PING_DELAY_MS, PING_DELAY_MS);
49 - }
50 -
51 - @Override
52 - public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
53 - TopologyViewWebSocket socket = new TopologyViewWebSocket(directory);
54 - synchronized (sockets) {
55 - sockets.add(socket);
56 - }
57 - return socket;
58 - }
59 -
60 - // Task for pruning web-sockets that are idle.
61 - private class Pruner extends TimerTask {
62 - @Override
63 - public void run() {
64 - synchronized (sockets) {
65 - Iterator<TopologyViewWebSocket> it = sockets.iterator();
66 - while (it.hasNext()) {
67 - TopologyViewWebSocket socket = it.next();
68 - if (socket.isIdle()) {
69 - it.remove();
70 - socket.close();
71 - }
72 - }
73 - }
74 - }
75 - }
76 -}
...@@ -52,7 +52,7 @@ public class TopologyResource extends BaseResource { ...@@ -52,7 +52,7 @@ public class TopologyResource extends BaseResource {
52 ArrayNode devices = mapper.createArrayNode(); 52 ArrayNode devices = mapper.createArrayNode();
53 ArrayNode hosts = mapper.createArrayNode(); 53 ArrayNode hosts = mapper.createArrayNode();
54 54
55 - Map<String, ObjectNode> metaUi = TopologyViewMessages.getMetaUi(); 55 + Map<String, ObjectNode> metaUi = TopologyViewMessageHandler.getMetaUi();
56 for (String id : metaUi.keySet()) { 56 for (String id : metaUi.keySet()) {
57 ObjectNode memento = metaUi.get(id); 57 ObjectNode memento = metaUi.get(id);
58 if (id.charAt(17) == '/') { 58 if (id.charAt(17) == '/') {
......
...@@ -161,15 +161,4 @@ ...@@ -161,15 +161,4 @@
161 <url-pattern>/websock/*</url-pattern> 161 <url-pattern>/websock/*</url-pattern>
162 </servlet-mapping> 162 </servlet-mapping>
163 163
164 - <servlet>
165 - <servlet-name>Legacy Web Socket Service</servlet-name>
166 - <servlet-class>org.onosproject.ui.impl.GuiWebSocketServlet</servlet-class>
167 - <load-on-startup>2</load-on-startup>
168 - </servlet>
169 -
170 - <servlet-mapping>
171 - <servlet-name>Legacy Web Socket Service</servlet-name>
172 - <url-pattern>/ws/*</url-pattern>
173 - </servlet-mapping>
174 -
175 </web-app> 164 </web-app>
......
1 -/*
2 - * Copyright 2014 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 - Base CSS file
19 - */
20 -
21 -html {
22 - font-family: sans-serif;
23 - -webkit-text-size-adjust: 100%;
24 - -ms-text-size-adjust: 100%;
25 -}
26 -
27 -body {
28 - margin: 0;
29 -}
This diff could not be displayed because it is too large.
1 -/*
2 - * Copyright 2014 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 - D3 Utilities CSS file
19 - */
20 -
21 -#d3u .light.norm.c1 {
22 - color: #1f77b4;
23 -}
24 -
25 -#d3u .light.norm.c2 {
26 - color: #2ca02c;
27 -}
28 -
29 -#d3u .light.norm.c3 {
30 - color: #d62728;
31 -}
32 -
33 -#d3u .light.norm.c4 {
34 - color: #9467bd;
35 -}
36 -
37 -#d3u .light.norm.c5 {
38 - color: #e377c2;
39 -}
40 -
41 -#d3u .light.norm.c6 {
42 - color: #bcbd22;
43 -}
44 -
45 -#d3u .light.norm.c7 {
46 - color: #17becf;
47 -}
48 -
49 -
50 -
51 -#d3u .light.mute.c1 {
52 - color: #aec7e8;
53 -}
54 -
55 -#d3u .light.mute.c2 {
56 - color: #98df8a;
57 -}
58 -
59 -#d3u .light.mute.c3 {
60 - color: #ff9896;
61 -}
62 -
63 -#d3u .light.mute.c4 {
64 - color: #c5b0d5;
65 -}
66 -
67 -#d3u .light.mute.c5 {
68 - color: #f7b6d2;
69 -}
70 -
71 -#d3u .light.mute.c6 {
72 - color: #dbdb8d;
73 -}
74 -
75 -#d3u .light.mute.c7 {
76 - color: #9edae5;
77 -}
78 -
79 -
80 -
81 -#d3u .dark.norm.c1 {
82 - color: #1f77b4;
83 -}
84 -
85 -#d3u .dark.norm.c2 {
86 - color: #2ca02c;
87 -}
88 -
89 -#d3u .dark.norm.c3 {
90 - color: #d62728;
91 -}
92 -
93 -#d3u .dark.norm.c4 {
94 - color: #9467bd;
95 -}
96 -
97 -#d3u .dark.norm.c5 {
98 - color: #e377c2;
99 -}
100 -
101 -#d3u .dark.norm.c6 {
102 - color: #bcbd22;
103 -}
104 -
105 -#d3u .dark.norm.c7 {
106 - color: #17becf;
107 -}
108 -
109 -
110 -
111 -#d3u .dark.mute.c1 {
112 - color: #aec7e8;
113 -}
114 -
115 -#d3u .dark.mute.c2 {
116 - color: #639a56;
117 -}
118 -
119 -#d3u .dark.mute.c3 {
120 - color: #ff9896;
121 -}
122 -
123 -#d3u .dark.mute.c4 {
124 - color: #c5b0d5;
125 -}
126 -
127 -#d3u .dark.mute.c5 {
128 - color: #f7b6d2;
129 -}
130 -
131 -#d3u .dark.mute.c6 {
132 - color: #dbdb8d;
133 -}
134 -
135 -#d3u .dark.mute.c7 {
136 - color: #9edae5;
137 -}
138 -
1 -/*
2 - * Copyright 2014 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 - Utility functions for D3 visualizations.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - function isF(f) {
25 - return $.isFunction(f) ? f : null;
26 - }
27 -
28 - // TODO: sensible defaults
29 - function createDragBehavior(force, selectCb, atDragEnd,
30 - dragEnabled, clickEnabled) {
31 - var draggedThreshold = d3.scale.linear()
32 - .domain([0, 0.1])
33 - .range([5, 20])
34 - .clamp(true),
35 - drag,
36 - fSel = isF(selectCb),
37 - fEnd = isF(atDragEnd),
38 - fDEn = isF(dragEnabled),
39 - fCEn = isF(clickEnabled),
40 - bad = [];
41 -
42 - function naf(what) {
43 - return 'd3util.createDragBehavior(): '+ what + ' is not a function';
44 - }
45 -
46 - if (!fSel) {
47 - bad.push(naf('selectCb'));
48 - }
49 - if (!fEnd) {
50 - bad.push(naf('atDragEnd'));
51 - }
52 - if (!fDEn) {
53 - bad.push(naf('dragEnabled'));
54 - }
55 - if (!fCEn) {
56 - bad.push(naf('clickEnabled'));
57 - }
58 -
59 - if (bad.length) {
60 - alert(bad.join('\n'));
61 - return null;
62 - }
63 -
64 -
65 - function dragged(d) {
66 - var threshold = draggedThreshold(force.alpha()),
67 - dx = d.oldX - d.px,
68 - dy = d.oldY - d.py;
69 - if (Math.abs(dx) >= threshold || Math.abs(dy) >= threshold) {
70 - d.dragged = true;
71 - }
72 - return d.dragged;
73 - }
74 -
75 - drag = d3.behavior.drag()
76 - .origin(function(d) { return d; })
77 - .on('dragstart', function(d) {
78 - if (clickEnabled() || dragEnabled()) {
79 - d3.event.sourceEvent.stopPropagation();
80 -
81 - d.oldX = d.x;
82 - d.oldY = d.y;
83 - d.dragged = false;
84 - d.fixed |= 2;
85 - d.dragStarted = true;
86 - }
87 - })
88 - .on('drag', function(d) {
89 - if (dragEnabled()) {
90 - d.px = d3.event.x;
91 - d.py = d3.event.y;
92 - if (dragged(d)) {
93 - if (!force.alpha()) {
94 - force.alpha(.025);
95 - }
96 - }
97 - }
98 - })
99 - .on('dragend', function(d) {
100 - if (d.dragStarted) {
101 - d.dragStarted = false;
102 - if (!dragged(d)) {
103 - // consider this the same as a 'click'
104 - // (selection of a node)
105 - if (clickEnabled()) {
106 - selectCb(d, this); // TODO: set 'this' context instead of param
107 - }
108 - }
109 - d.fixed &= ~6;
110 -
111 - // hook at the end of a drag gesture
112 - if (dragEnabled()) {
113 - atDragEnd(d, this); // TODO: set 'this' context instead of param
114 - }
115 - }
116 - });
117 -
118 - return drag;
119 - }
120 -
121 - function loadGlow(defs) {
122 - // TODO: parameterize color
123 -
124 - var glow = defs.append('filter')
125 - .attr('x', '-50%')
126 - .attr('y', '-50%')
127 - .attr('width', '200%')
128 - .attr('height', '200%')
129 - .attr('id', 'blue-glow');
130 -
131 - glow.append('feColorMatrix')
132 - .attr('type', 'matrix')
133 - .attr('values',
134 - '0 0 0 0 0 ' +
135 - '0 0 0 0 0 ' +
136 - '0 0 0 0 .7 ' +
137 - '0 0 0 1 0 ');
138 -
139 - glow.append('feGaussianBlur')
140 - .attr('stdDeviation', 3)
141 - .attr('result', 'coloredBlur');
142 -
143 - glow.append('feMerge').selectAll('feMergeNode')
144 - .data(['coloredBlur', 'SourceGraphic'])
145 - .enter().append('feMergeNode')
146 - .attr('in', String);
147 - }
148 -
149 - // --- Ordinal scales for 7 values.
150 - // TODO: tune colors for light and dark themes
151 - // Note: These colors look good on the white background. Still, need to tune for dark.
152 -
153 - // blue brown brick red sea green purple dark teal lime
154 - var lightNorm = ['#3E5780', '#78533B', '#CB4D28', '#018D61', '#8A2979', '#006D73', '#56AF00'],
155 - lightMute = ['#A8B8CC', '#CCB3A8', '#FFC2BD', '#96D6BF', '#D19FCE', '#8FCCCA', '#CAEAA4'],
156 -
157 - darkNorm = ['#3E5780', '#78533B', '#CB4D28', '#018D61', '#8A2979', '#006D73', '#56AF00'],
158 - darkMute = ['#A8B8CC', '#CCB3A8', '#FFC2BD', '#96D6BF', '#D19FCE', '#8FCCCA', '#CAEAA4'];
159 -
160 - function cat7() {
161 - var colors = {
162 - light: {
163 - norm: d3.scale.ordinal().range(lightNorm),
164 - mute: d3.scale.ordinal().range(lightMute)
165 - },
166 - dark: {
167 - norm: d3.scale.ordinal().range(darkNorm),
168 - mute: d3.scale.ordinal().range(darkMute)
169 - }
170 - },
171 - tcid = 'd3utilTestCard';
172 -
173 - function get(id, muted, theme) {
174 - // NOTE: since we are lazily assigning domain ids, we need to
175 - // get the color from all 4 scales, to keep the domains
176 - // in sync.
177 - var ln = colors.light.norm(id),
178 - lm = colors.light.mute(id),
179 - dn = colors.dark.norm(id),
180 - dm = colors.dark.mute(id);
181 - if (theme === 'dark') {
182 - return muted ? dm : dn;
183 - } else {
184 - return muted ? lm : ln;
185 - }
186 - }
187 -
188 - function testCard(svg) {
189 - var g = svg.select('g#' + tcid),
190 - dom = d3.range(7),
191 - k, muted, theme, what;
192 -
193 - if (!g.empty()) {
194 - g.remove();
195 -
196 - } else {
197 - g = svg.append('g')
198 - .attr('id', tcid)
199 - .attr('transform', 'scale(4)translate(20,20)');
200 -
201 - for (k=0; k<4; k++) {
202 - muted = k%2;
203 - what = muted ? ' muted' : ' normal';
204 - theme = k < 2 ? 'light' : 'dark';
205 - dom.forEach(function (id, i) {
206 - var x = i * 20,
207 - y = k * 20,
208 - f = get(id, muted, theme);
209 - g.append('circle').attr({
210 - cx: x,
211 - cy: y,
212 - r: 5,
213 - fill: f
214 - });
215 - });
216 - g.append('rect').attr({
217 - x: 140,
218 - y: k * 20 - 5,
219 - width: 32,
220 - height: 10,
221 - rx: 2,
222 - fill: '#888'
223 - });
224 - g.append('text').text(theme + what)
225 - .attr({
226 - x: 142,
227 - y: k * 20 + 2,
228 - fill: 'white'
229 - })
230 - .style('font-size', '4pt');
231 - }
232 - }
233 - }
234 -
235 - return {
236 - testCard: testCard,
237 - get: get
238 - };
239 - }
240 -
241 - // === register the functions as a library
242 - onos.ui.addLib('d3util', {
243 - createDragBehavior: createDragBehavior,
244 - loadGlow: loadGlow,
245 - cat7: cat7
246 - });
247 -
248 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Geometry library - based on work by Mike Bostock.
19 - */
20 -
21 -(function() {
22 -
23 - if (typeof geo == 'undefined') {
24 - geo = {};
25 - }
26 -
27 - var tolerance = 1e-10;
28 -
29 - function eq(a, b) {
30 - return (Math.abs(a - b) < tolerance);
31 - }
32 -
33 - function gt(a, b) {
34 - return (a - b > -tolerance);
35 - }
36 -
37 - function lt(a, b) {
38 - return gt(b, a);
39 - }
40 -
41 - geo.eq = eq;
42 - geo.gt = gt;
43 - geo.lt = lt;
44 -
45 - geo.LineSegment = function(x1, y1, x2, y2) {
46 - this.x1 = x1;
47 - this.y1 = y1;
48 - this.x2 = x2;
49 - this.y2 = y2;
50 -
51 - // Ax + By = C
52 - this.a = y2 - y1;
53 - this.b = x1 - x2;
54 - this.c = x1 * this.a + y1 * this.b;
55 -
56 - if (eq(this.a, 0) && eq(this.b, 0)) {
57 - throw new Error(
58 - 'Cannot construct a LineSegment with two equal endpoints.');
59 - }
60 - };
61 -
62 - geo.LineSegment.prototype.intersect = function(that) {
63 - var d = (this.x1 - this.x2) * (that.y1 - that.y2) -
64 - (this.y1 - this.y2) * (that.x1 - that.x2);
65 -
66 - if (eq(d, 0)) {
67 - // The two lines are parallel or very close.
68 - return {
69 - x : NaN,
70 - y : NaN
71 - };
72 - }
73 -
74 - var t1 = this.x1 * this.y2 - this.y1 * this.x2,
75 - t2 = that.x1 * that.y2 - that.y1 * that.x2,
76 - x = (t1 * (that.x1 - that.x2) - t2 * (this.x1 - this.x2)) / d,
77 - y = (t1 * (that.y1 - that.y2) - t2 * (this.y1 - this.y2)) / d,
78 - in1 = (gt(x, Math.min(this.x1, this.x2)) && lt(x, Math.max(this.x1, this.x2)) &&
79 - gt(y, Math.min(this.y1, this.y2)) && lt(y, Math.max(this.y1, this.y2))),
80 - in2 = (gt(x, Math.min(that.x1, that.x2)) && lt(x, Math.max(that.x1, that.x2)) &&
81 - gt(y, Math.min(that.y1, that.y2)) && lt(y, Math.max(that.y1, that.y2)));
82 -
83 - return {
84 - x : x,
85 - y : y,
86 - in1 : in1,
87 - in2 : in2
88 - };
89 - };
90 -
91 - geo.LineSegment.prototype.x = function(y) {
92 - // x = (C - By) / a;
93 - if (this.a) {
94 - return (this.c - this.b * y) / this.a;
95 - } else {
96 - // a == 0 -> horizontal line
97 - return NaN;
98 - }
99 - };
100 -
101 - geo.LineSegment.prototype.y = function(x) {
102 - // y = (C - Ax) / b;
103 - if (this.b) {
104 - return (this.c - this.a * x) / this.b;
105 - } else {
106 - // b == 0 -> vertical line
107 - return NaN;
108 - }
109 - };
110 -
111 - geo.LineSegment.prototype.length = function() {
112 - return Math.sqrt(
113 - (this.y2 - this.y1) * (this.y2 - this.y1) +
114 - (this.x2 - this.x1) * (this.x2 - this.x1));
115 - };
116 -
117 - geo.LineSegment.prototype.offset = function(x, y) {
118 - return new geo.LineSegment(
119 - this.x1 + x, this.y1 + y,
120 - this.x2 + x, this.y2 + y);
121 - };
122 -
123 -})();
1 -/*
2 - * Copyright 2014 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 - ONOS -- SVG Glyphs Library.
19 - */
20 -
21 -
22 -(function (onos) {
23 - 'use strict';
24 -
25 - var birdViewBox = '352 224 113 112',
26 -
27 - birdData = {
28 - bird: "M427.7,300.4 c-6.9,0.6-13.1,5-19.2,7.1c-18.1,6.2-33.9," +
29 - "9.1-56.5,4.7c24.6,17.2,36.6,13,63.7,0.1c-0.5,0.6-0.7,1.3-1.3," +
30 - "1.9c1.4-0.4,2.4-1.7,3.4-2.2c-0.4,0.7-0.9,1.5-1.4,1.9c2.2-0.6," +
31 - "3.7-2.3,5.9-3.9c-2.4,2.1-4.2,5-6,8c-1.5,2.5-3.1,4.8-5.1,6.9c-1," +
32 - "1-1.9,1.9-2.9,2.9c-1.4,1.3-2.9,2.5-5.1,2.9c1.7,0.1,3.6-0.3,6.5" +
33 - "-1.9c-1.6,2.4-7.1,6.2-9.9,7.2c10.5-2.6,19.2-15.9,25.7-18c18.3" +
34 - "-5.9,13.8-3.4,27-14.2c1.6-1.3,3-1,5.1-0.8c1.1,0.1,2.1,0.3,3.2," +
35 - "0.5c0.8,0.2,1.4,0.4,2.2,0.8l1.8,0.9c-1.9-4.5-2.3-4.1-5.9-6c-2.3" +
36 - "-1.3-3.3-3.8-6.2-4.9c-7.1-2.6-11.9,11.7-11.7-5c0.1-8,4.2-14.4," +
37 - "6.4-22c1.1-3.8,2.3-7.6,2.4-11.5c0.1-2.3,0-4.7-0.4-7c-2-11.2-8.4" +
38 - "-21.5-19.7-24.8c-1-0.3-1.1-0.3-0.9,0c9.6,17.1,7.2,38.3,3.1,54.2" +
39 - "C429.9,285.5,426.7,293.2,427.7,300.4z"
40 - },
41 -
42 - glyphViewBox = '0 0 110 110',
43 -
44 - glyphData = {
45 - unknown: "M35,40a5,5,0,0,1,5-5h30a5,5,0,0,1,5,5v30a5,5,0,0,1-5,5" +
46 - "h-30a5,5,0,0,1-5-5z",
47 -
48 - node: "M15,100a5,5,0,0,1-5-5v-65a5,5,0,0,1,5-5h80a5,5,0,0,1,5,5" +
49 - "v65a5,5,0,0,1-5,5zM14,22.5l11-11a10,3,0,0,1,10-2h40a10,3,0,0,1," +
50 - "10,2l11,11zM16,35a5,5,0,0,1,10,0a5,5,0,0,1-10,0z",
51 -
52 - switch: "M10,20a10,10,0,0,1,10-10h70a10,10,0,0,1,10,10v70a10,10," +
53 - "0,0,1-10,10h-70a10,10,0,0,1-10-10zM60,26l12,0,0-8,18,13-18,13,0" +
54 - "-8-12,0zM60,60l12,0,0-8,18,13-18,13,0-8-12,0zM50,40l-12,0,0-8" +
55 - "-18,13,18,13,0-8,12,0zM50,74l-12,0,0-8-18,13,18,13,0-8,12,0z",
56 -
57 - roadm: "M10,35l25-25h40l25,25v40l-25,25h-40l-25-25zM58,26l12,0,0" +
58 - "-8,18,13-18,13,0-8-12,0zM58,60l12,0,0-8,18,13-18,13,0-8-12,0z" +
59 - "M52,40l-12,0,0-8-18,13,18,13,0-8,12,0zM52,74l-12,0,0-8-18,13," +
60 - "18,13,0-8,12,0z",
61 -
62 - endstation: "M10,15a5,5,0,0,1,5-5h65a5,5,0,0,1,5,5v80a5,5,0,0,1" +
63 - "-5,5h-65a5,5,0,0,1-5-5zM87.5,14l11,11a3,10,0,0,1,2,10v40a3,10," +
64 - "0,0,1,-2,10l-11,11zM17,19a2,2,0,0,1,2-2h56a2,2,0,0,1,2,2v26a2," +
65 - "2,0,0,1-2,2h-56a2,2,0,0,1-2-2zM20,20h54v10h-54zM20,33h54v10h" +
66 - "-54zM42,70a5,5,0,0,1,10,0a5,5,0,0,1-10,0z",
67 -
68 - router: "M10,55A45,45,0,0,1,100,55A45,45,0,0,1,10,55M20,50l12,0," +
69 - "0-8,18,13-18,13,0-8-12,0zM90,50l-12,0,0-8-18,13,18,13,0-8,12,0z" +
70 - "M50,47l0-12-8,0,13-18,13,18-8,0,0,12zM50,63l0,12-8,0,13,18,13" +
71 - "-18-8,0,0-12z",
72 -
73 - bgpSpeaker: "M10,40a45,35,0,0,1,90,0Q100,77,55,100Q10,77,10,40z" +
74 - "M50,29l12,0,0-8,18,13-18,13,0-8-12,0zM60,57l-12,0,0-8-18,13," +
75 - "18,13,0-8,12,0z",
76 -
77 - chain: "M60.4,77.6c-4.9,5.2-9.6,11.3-15.3,16.3c-8.6,7.5-20.4,6.8" +
78 - "-28-0.8c-7.7-7.7-8.4-19.6-0.8-28.4c6.5-7.4,13.5-14.4,20.9-20.9" +
79 - "c7.5-6.7,19.2-6.7,26.5-0.8c3.5,2.8,4.4,6.1,2.2,8.7c-2.7,3.1" +
80 - "-5.5,2.5-8.5,0.3c-4.7-3.4-9.7-3.2-14,0.9C37.1,58.7,31,64.8," +
81 - "25.2,71c-4.2,4.4-4.2,10.6-0.6,14.3c3.7,3.7,9.7,3.7,14.3-0.4" +
82 - "c2.9-2.5,5.3-5.5,8.3-8c1-0.9,3-1.1,4.4-0.9C54.8,76.3,57.9,77.1," +
83 - "60.4,77.6zM49.2,32.2c5-5.2,9.7-10.9,15.2-15.7c12.8-11,31.2" +
84 - "-4.9,34.3,11.2C100,34.2,98.3,40.2,94,45c-6.7,7.4-13.7,14.6" +
85 - "-21.2,21.2C65.1,73,53.2,72.7,46,66.5c-3.2-2.8-3.9-5.8-1.6-8.4" +
86 - "c2.6-2.9,5.3-2.4,8.2-0.3c5.2,3.7,10,3.3,14.7-1.1c5.8-5.6,11.6" +
87 - "-11.3,17.2-17.2c4.6-4.8,4.9-11.1,0.9-15c-3.9-3.9-10.1-3.4-15," +
88 - "1.2c-3.1,2.9-5.7,7.4-9.3,8.5C57.6,35.3,53,33,49.2,32.2z",
89 -
90 - crown: "M99.5,21.6c0,3-2.3,5.4-5.1,5.4c-0.3,0-0.7,0-1-0.1c-1.8," +
91 - "4-4.8,10-7.2,17.3c-3.4,10.6-0.9,26.2,2.7,27.3C90.4,72,91.3," +
92 - "75,88,75H22.7c-3.3,0-2.4-3-0.9-3.5c3.6-1.1,6.1-16.7,2.7-27.3" +
93 - "c-2.4-7.4-5.4-13.5-7.2-17.5c-0.5,0.2-1,0.3-1.6,0.3c-2.8,0" +
94 - "-5.1-2.4-5.1-5.4c0-3,2.3-5.4,5.1-5.4c2.8,0,5.1,2.4,5.1,5.4c0," +
95 - "1-0.2,1.9-0.7,2.7c0.7,0.8,1.4,1.6,2.4,2.6c8.8,8.9,11.9,12.7," +
96 - "18.1,11.7c6.5-1,11-8.2,13.3-14.1c-2-0.8-3.3-2.7-3.3-5.1c0-3," +
97 - "2.3-5.4,5.1-5.4c2.8,0,5.1,2.4,5.1,5.4c0,2.5-1.6,4.5-3.7,5.2" +
98 - "c2.3,5.9,6.8,13,13.2,14c6.2,1,9.3-2.7,18.1-11.7c0.7-0.7,1.4" +
99 - "-1.5,2-2.1c-0.6-0.9-1-2-1-3.1c0-3,2.3-5.4,5.1-5.4C97.2,16.2," +
100 - "99.5,18.6,99.5,21.6zM92,87.9c0,2.2-1.7,4.1-3.8,4.1H22.4c" +
101 - "-2.1,0-4.4-1.9-4.4-4.1v-3.3c0-2.2,2.3-4.5,4.4-4.5h65.8c2.1," +
102 - "0,3.8,2.3,3.8,4.5V87.9z"
103 - },
104 -
105 - badgeViewBox = '0 0 10 10',
106 -
107 - badgeData = {
108 - uiAttached: "M2,2.5a.5,.5,0,0,1,.5-.5h5a.5,.5,0,0,1,.5,.5v3" +
109 - "a.5,.5,0,0,1-.5,.5h-5a.5,.5,0,0,1-.5-.5zM2.5,2.8a.3,.3,0,0,1," +
110 - ".3-.3h4.4a.3,.3,0,0,1,.3,.3v2.4a.3,.3,0,0,1-.3,.3h-4.4" +
111 - "a.3,.3,0,0,1-.3-.3zM2,6.55h6l1,1.45h-8z"
112 - };
113 -
114 - function defStuff(defs, viewbox, data) {
115 - d3.map(data).keys().forEach(function (key) {
116 - defs.append('symbol')
117 - .attr({ id: key, viewBox: viewbox })
118 - .append('path').attr('d', data[key]);
119 - });
120 - }
121 -
122 - function loadDefs(defs) {
123 - defStuff(defs, birdViewBox, birdData);
124 - defStuff(defs, glyphViewBox, glyphData);
125 - defStuff(defs, badgeViewBox, badgeData);
126 - }
127 -
128 - onos.ui.addLib('glyphs', {
129 - loadDefs: loadDefs
130 - });
131 -
132 -}(ONOS));
1 -<!DOCTYPE html>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
4 - ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at
8 - ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~
11 - ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License.
16 - -->
17 -
18 -<!--
19 - ONOS UI - single page web app
20 - Version 1.1
21 - -->
22 -<html>
23 -<head>
24 - <meta charset="utf-8">
25 - <link rel="shortcut icon" href="../img/onos-logo.png">
26 - <title>ONOS</title>
27 -
28 - <!-- Third party library code included here -->
29 - <!--TODO: use the minified version of d3, once debugging is complete -->
30 - <script src="../tp/d3.js"></script>
31 - <script src="../tp/topojson.v1.min.js"></script>
32 - <script src="../tp/jquery-2.1.1.min.js"></script>
33 -
34 - <!-- ONOS UI Framework included here -->
35 - <script src="onos.js"></script>
36 -
37 - <!-- Framework and library stylesheets included here -->
38 - <link rel="stylesheet" href="base.css">
39 - <link rel="stylesheet" href="onos.css">
40 - <link rel="stylesheet" href="onosMast.css">
41 - <link rel="stylesheet" href="onosFloatPanel.css">
42 - <link rel="stylesheet" href="onosFlash.css">
43 - <link rel="stylesheet" href="onosQuickHelp.css">
44 -
45 - <!-- This is where contributed stylesheets get INJECTED -->
46 - <!-- TODO: replace with template marker and inject refs server-side -->
47 - <link rel="stylesheet" href="topo.css">
48 -</head>
49 -<body>
50 - <div id="frame">
51 - <div id="mast">
52 - <!-- NOTE: masthead injected here by mast.js -->
53 - </div>
54 - <div id="view">
55 - <!-- NOTE: views injected here by onos.js -->
56 - </div>
57 - <div id="floatPanels">
58 - <!-- NOTE: floating panels injected here, as needed -->
59 - <!-- see onos.ui.addFloatingPanel -->
60 - </div>
61 - <div id="alerts">
62 - <!-- NOTE: alert content injected here, as needed -->
63 - </div>
64 - <div id="feedback">
65 - <!-- NOTE: feedback flashes to user -->
66 - </div>
67 - <div id="quickhelp">
68 - <!-- NOTE: key bindings and mouse gesture help -->
69 - </div>
70 - </div>
71 -
72 - <!-- Initialize the UI...-->
73 - <script type="text/javascript">
74 - var ONOS = $.onos({
75 - comment: 'configuration options',
76 - theme: 'dark',
77 - startVid: 'topo'
78 - });
79 - </script>
80 -
81 - <!-- Library modules included here -->
82 - <script src="d3Utils.js"></script>
83 - <script src="geometry.js"></script>
84 - <script src="glyphs.js"></script>
85 -
86 - <!-- Framework modules included here -->
87 - <script src="onosMast.js"></script>
88 - <script src="onosFlash.js"></script>
89 - <script src="onosQuickHelp.js"></script>
90 -
91 - <!-- View Module Templates; REMOVE THESE LINES, FOR PRODUCTION -->
92 - <script src="module-svg-template.js"></script>
93 - <script src="module-div-template.js"></script>
94 -
95 - <!-- Sample Views; REMOVE THESE LINES, FOR PRODUCTION -->
96 - <script src="sample.js"></script>
97 - <script src="sampleRadio.js"></script>
98 - <script src="sampleKeys.js"></script>
99 - <script src="sampleHash.js"></script>
100 -
101 - <!-- Contributed (application) views injected here -->
102 - <!-- TODO: replace with template marker and inject refs server-side -->
103 - <script src="topo.js"></script>
104 -
105 - <!-- finally, build the UI-->
106 - <script type="text/javascript">
107 - $(ONOS.buildUi);
108 - </script>
109 -
110 -</body>
111 -</html>
1 -/*
2 - * Copyright 2014 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 - Module template file for DIV based view.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var list,
25 - data = [ 'foo', 'bar', 'baz' ];
26 -
27 - // invoked only the first time the view is loaded
28 - // - used to initialize the view contents
29 - function init(view, ctx, flags) {
30 - // NOTE: view.$div is a D3 selection of the view's div
31 - list = view.$div.append('ul');
32 - // ... further code to initialize the SVG view ...
33 -
34 - }
35 -
36 - // invoked just prior to loading the view
37 - // - used to clear the view of stale data
38 - function reset(view, ctx, flags) {
39 -
40 - }
41 -
42 - // invoked when the view is loaded
43 - // - used to load data into the view,
44 - // when the view is shown
45 - function load(view, ctx, flags) {
46 - list.selectAll('li')
47 - .data(data)
48 - .enter()
49 - .append('li')
50 - .text(function (d) { return d; })
51 - }
52 -
53 - // invoked when the view is unloaded
54 - // - used to clean up data that should be removed,
55 - // when the view is hidden
56 - function unload(view, ctx, flags) {
57 -
58 - }
59 -
60 - // invoked when the view is resized
61 - // - used to reconfigure elements to the new view size
62 - function resize(view, ctx, flags) {
63 - var w = view.width(),
64 - h = view.height();
65 -
66 - }
67 -
68 - // invoked when the framework needs to alert the view of an error
69 - // - (EXPERIMENTAL -- not currently used)
70 - function error(view, ctx, flags) {
71 -
72 - }
73 -
74 - // ================================================================
75 - // == register the view here, with links to lifecycle callbacks
76 -
77 - // A typical setup that initializes the view once, then reacts to
78 - // load and resize events would look like this:
79 -
80 - onos.ui.addView('myDivViewId', {
81 - init: init,
82 - load: load,
83 - resize: resize
84 - });
85 -
86 - // A minimum setup that builds the view every time it is loaded
87 - // would look like this:
88 - //
89 - // onos.ui.addView('myViewId', {
90 - // reset: true, // clear view contents on reset
91 - // load: load
92 - // });
93 -
94 - // The complete gamut of callbacks would look like this:
95 - //
96 - // onos.ui.addView('myViewId', {
97 - // init: init,
98 - // reset: reset,
99 - // load: load,
100 - // unload: unload,
101 - // resize: resize,
102 - // error: error
103 - // });
104 -
105 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Module template file for SVG based view.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var svg,
25 - data = [ 60 ];
26 -
27 - // invoked only the first time the view is loaded
28 - // - used to initialize the view contents
29 - function init(view, ctx, flags) {
30 - svg = view.$div.append('svg');
31 - resize(view);
32 - // ... further code to initialize the SVG view ...
33 -
34 - }
35 -
36 - // invoked just prior to loading the view
37 - // - used to clear the view of stale data
38 - function reset(view, ctx, flags) {
39 - // e.g. clear svg of all objects...
40 - // svg.html('');
41 -
42 - }
43 -
44 - // invoked when the view is loaded
45 - // - used to load data into the view,
46 - // when the view is shown
47 - function load(view, ctx, flags) {
48 - var w = view.width(),
49 - h = view.height();
50 -
51 - // as an example...
52 - svg.selectAll('circle')
53 - .data(data)
54 - .enter()
55 - .append('circle')
56 - .attr({
57 - cx: w / 2,
58 - cy: h / 2,
59 - r: function (d) { return d; }
60 - })
61 - .style({
62 - fill: 'goldenrod',
63 - stroke: 'black',
64 - 'stroke-width': 3.5,
65 - });
66 - }
67 -
68 - // invoked when the view is unloaded
69 - // - used to clean up data that should be removed,
70 - // when the view is hidden
71 - function unload(view, ctx, flags) {
72 -
73 - }
74 -
75 - // invoked when the view is resized
76 - // - used to reconfigure elements to the new size of the view
77 - function resize(view, ctx, flags) {
78 - var w = view.width(),
79 - h = view.height();
80 -
81 - // resize svg layer to match new size of view
82 - svg.attr({
83 - width: w,
84 - height: h
85 - });
86 -
87 - // as an example...
88 - svg.selectAll('circle')
89 - .attr({
90 - cx: w / 2,
91 - cy: h / 2
92 - });
93 -
94 - // ... further code to handle resize of view ...
95 -
96 - }
97 -
98 - // invoked when the framework needs to alert the view of an error
99 - // - (EXPERIMENTAL -- not currently used)
100 - function error(view, ctx, flags) {
101 -
102 - }
103 -
104 - // ================================================================
105 - // == register the view here, with links to lifecycle callbacks
106 -
107 - // A typical setup that initializes the view once, then reacts to
108 - // load and resize events would look like this:
109 -
110 - onos.ui.addView('mySvgViewId', {
111 - init: init,
112 - load: load,
113 - resize: resize
114 - });
115 -
116 - // A minimum setup that builds the view every time it is loaded
117 - // would look like this:
118 - //
119 - // onos.ui.addView('myViewId', {
120 - // reset: true, // clear view contents on reset
121 - // load: load
122 - // });
123 -
124 - // The complete gamut of callbacks would look like this:
125 - //
126 - // onos.ui.addView('myViewId', {
127 - // init: init,
128 - // reset: reset,
129 - // load: load,
130 - // unload: unload,
131 - // resize: resize,
132 - // error: error
133 - // });
134 -
135 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Base Framework -- CSS file
19 - */
20 -
21 -html, body {
22 - height: 100%;
23 -}
24 -
25 -/* This is to ensure that the body does not expand to account for the
26 - flyout details pane, that is positioned "off screen".
27 - */
28 -body {
29 - overflow: hidden;
30 -}
31 -
32 -#frame {
33 - width: 100%;
34 - height: 100%;
35 - background-color: #fff;
36 -}
37 -
38 -div.onosView {
39 - display: none;
40 -}
41 -
42 -div.onosView.currentView {
43 - display: block;
44 -}
45 -
46 -
47 -#alerts {
48 - display: none;
49 - position: absolute;
50 - z-index: 1200;
51 - opacity: 0.65;
52 - background-color: #006;
53 - color: white;
54 - top: 80px;
55 - left: 40px;
56 - padding: 3px 6px;
57 - -moz-border-radius: 6px;
58 - border-radius: 6px;
59 - box-shadow: 0px 2px 12px #777;
60 -}
61 -
62 -#alerts pre {
63 - margin: 0.2em 6px;
64 -}
65 -
66 -#alerts span.close {
67 - color: #6af;
68 - float: right;
69 - right: 2px;
70 - cursor: pointer;
71 -}
72 -
73 -#alerts span.close:hover {
74 - color: #fff;
75 -}
76 -
77 -#alerts p.footnote {
78 - text-align: right;
79 - font-size: 8pt;
80 - margin: 8px 0 0 0;
81 - color: #66d;
82 -}
83 -
84 -#floatPanels {
85 - z-index: 1100;
86 -}
87 -
88 -#flyout {
89 - position: absolute;
90 - display: block;
91 - top: 10%;
92 - width: 280px;
93 - right: -300px;
94 - opacity: 0;
95 - background-color: rgba(255,255,255,0.8);
96 -
97 - padding: 10px;
98 - color: black;
99 - font-size: 10pt;
100 - box-shadow: 2px 2px 16px #777;
101 -}
102 -
103 -#flyout h2 {
104 - margin: 8px 4px;
105 - color: black;
106 - vertical-align: middle;
107 -}
108 -
109 -#flyout h2 img {
110 - height: 32px;
111 - padding-right: 8px;
112 - vertical-align: middle;
113 -}
114 -
115 -#flyout p, table {
116 - margin: 4px 4px;
117 -}
118 -
119 -#flyout td.label {
120 - font-style: italic;
121 - color: #777;
122 - padding-right: 12px;
123 -}
124 -
125 -#flyout td.value {
126 -
127 -}
128 -
129 -#flyout hr {
130 - height: 1px;
131 - color: #ccc;
132 - background-color: #ccc;
133 - border: 0;
134 -}
This diff is collapsed. Click to expand it.
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Feedback layer -- CSS file
19 - */
20 -
21 -#feedback {
22 - z-index: 1400;
23 -}
24 -
25 -#feedback svg {
26 - position: absolute;
27 - bottom: 0;
28 - opacity: 0.8;
29 -}
30 -
31 -#feedback svg g.feedbackItem {
32 - background-color: teal;
33 -}
34 -
35 -#feedback svg g.feedbackItem rect {
36 - fill: #ccc;
37 -}
38 -
39 -#feedback svg g.feedbackItem text {
40 - fill: #333;
41 - stroke: none;
42 - text-anchor: middle;
43 - alignment-baseline: middle;
44 -
45 - font-size: 16pt;
46 -}
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Feedback layer
19 -
20 - Defines the feedback layer for the UI. Used to give user visual feedback
21 - of choices, typically responding to keystrokes.
22 - */
23 -
24 -(function (onos){
25 - 'use strict';
26 -
27 - // API's
28 - var api = onos.api;
29 -
30 - // Config variables
31 - var w = '100%',
32 - h = 200,
33 - fade = 200,
34 - showFor = 1200,
35 - vb = '-200 -' + (h/2) + ' 400 ' + h,
36 - xpad = 20,
37 - ypad = 10;
38 -
39 - // State variables
40 - var timer = null,
41 - data = [];
42 -
43 - // DOM elements and the like
44 - var fb = d3.select('#feedback');
45 -
46 - var svg;
47 -
48 - //var svg = fb.append('svg').attr({
49 - // width: w,
50 - // height: h,
51 - // viewBox: vb
52 - //});
53 -
54 - function computeBox(el) {
55 - var text = el.select('text'),
56 - box = text.node().getBBox();
57 -
58 - // center
59 - box.x = -box.width / 2;
60 - box.y = -box.height / 2;
61 -
62 - // add some padding
63 - box.x -= xpad;
64 - box.width += xpad * 2;
65 - box.y -= ypad;
66 - box.height += ypad * 2;
67 -
68 - return box;
69 - }
70 -
71 - function updateFeedback() {
72 - if (!svg) {
73 - svg = fb.append('svg').attr({
74 - width: w,
75 - height: h,
76 - viewBox: vb
77 - });
78 - }
79 -
80 - var items = svg.selectAll('.feedbackItem')
81 - .data(data);
82 -
83 - var entering = items.enter()
84 - .append('g')
85 - .attr({
86 - class: 'feedbackItem',
87 - opacity: 0
88 - })
89 - .transition()
90 - .duration(fade)
91 - .attr('opacity', 1);
92 -
93 - entering.each(function (d) {
94 - var el = d3.select(this),
95 - box;
96 -
97 - d.el = el;
98 - el.append('rect').attr({ rx: 10, ry: 10});
99 - el.append('text').text(d.label);
100 - box = computeBox(el);
101 - el.select('rect').attr(box);
102 - });
103 -
104 - items.exit()
105 - .transition()
106 - .duration(fade)
107 - .attr({ opacity: 0})
108 - .remove();
109 -
110 - if (svg && data.length === 0) {
111 - svg.transition()
112 - .delay(fade + 10)
113 - .remove();
114 - svg = null;
115 - }
116 - }
117 -
118 - function clearFlash() {
119 - if (timer) {
120 - clearInterval(timer);
121 - }
122 - data = [];
123 - updateFeedback();
124 - }
125 -
126 - // for now, simply display some text feedback
127 - function flash(text) {
128 - // cancel old scheduled event if there was one
129 - if (timer) {
130 - clearInterval(timer);
131 - }
132 - timer = setInterval(function () {
133 - clearFlash();
134 - }, showFor);
135 -
136 - data = [{
137 - label: text
138 - }];
139 - updateFeedback();
140 - }
141 -
142 - onos.ui.addLib('feedback', {
143 - flash: flash
144 - });
145 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Floating Panels -- CSS file
19 - */
20 -
21 -.fpanel {
22 - position: absolute;
23 - z-index: 100;
24 - display: block;
25 - top: 64px;
26 - width: 260px;
27 - right: -300px;
28 - opacity: 0;
29 - background-color: rgba(255,255,255,0.8);
30 -
31 - padding: 10px;
32 - color: black;
33 - font-size: 10pt;
34 -
35 - -moz-border-radius: 6px;
36 - border-radius: 6px;
37 - box-shadow: 0px 2px 12px #777;
38 -}
39 -
40 -/* TODO: light/dark themes */
41 -.light .fpanel {
42 -
43 -}
44 -.dark .fpanel {
45 -
46 -}
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Masthead -- CSS file
19 - */
20 -
21 -#mast {
22 - height: 36px;
23 - padding: 4px;
24 - vertical-align: baseline;
25 -}
26 -
27 -.light #mast {
28 - background-color: #bbb;
29 - box-shadow: 0 2px 8px #777;
30 -}
31 -.dark #mast {
32 - background-color: #444;
33 - box-shadow: 0 2px 8px #777;
34 -}
35 -
36 -#mast img#logo {
37 - height: 38px;
38 - padding-left: 8px;
39 - padding-right: 8px;
40 -}
41 -
42 -#mast span.title {
43 - font-size: 14pt;
44 - font-style: italic;
45 - vertical-align: 12px;
46 -}
47 -
48 -.light #mast span.title {
49 - color: #369;
50 -}
51 -.dark #mast span.title {
52 - color: #eee;
53 -}
54 -
55 -#mast span.right {
56 - padding-top: 8px;
57 - padding-right: 16px;
58 - float: right;
59 -}
60 -
61 -#mast span.radio {
62 - font-size: 10pt;
63 - margin: 4px 2px;
64 - padding: 1px 6px;
65 - -moz-border-radius: 3px;
66 - border-radius: 3px;
67 - cursor: pointer;
68 -}
69 -
70 -.light #mast span.radio {
71 - border: 1px dotted #222;
72 - color: #eee;
73 -}
74 -.dark #mast span.radio {
75 - border: 1px dotted #bbb;
76 - color: #888;
77 -}
78 -
79 -#mast span.radio.active {
80 - padding: 1px 6px;
81 -}
82 -
83 -.light #mast span.radio.active {
84 - background-color: #bbb;
85 - border: 1px solid #eee;
86 - color: #666;
87 -
88 -}
89 -.dark #mast span.radio.active {
90 - background-color: #222;
91 - border: 1px solid #eee;
92 - color: #78a;
93 -}
94 -
95 -/* Button Bar */
96 -
97 -#bb {
98 - margin: 0 30px;
99 - padding: 0 2px;
100 -}
101 -
102 -#bb .btn {
103 - margin: 0 4px;
104 - padding: 2px 6px;
105 - -moz-border-radius: 3px;
106 - border-radius: 3px;
107 - font-size: 9pt;
108 - cursor: pointer;
109 -}
110 -
111 -.light #bb .btn {
112 - border: 1px solid #fff;
113 - border-right-color: #444;
114 - border-bottom-color: #444;
115 - color: #222;
116 -}
117 -
118 -.light #bb .btn.active {
119 - border: 1px solid #444;
120 - border-right-color: #fff;
121 - border-bottom-color: #fff;
122 - background-color: #888;
123 - color: #ddf;
124 -}
125 -
126 -.dark #bb .btn {
127 - border: 1px solid #888;
128 - border-right-color: #111;
129 - border-bottom-color: #111;
130 - color: #888;
131 -}
132 -
133 -.dark #bb .btn.active {
134 - border: 1px solid #111;
135 - border-right-color: #888;
136 - border-bottom-color: #888;
137 - background-color: #555;
138 - color: #78a;
139 -}
140 -
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Masthead script
19 -
20 - Defines the masthead for the UI. Injects logo and title, as well as providing
21 - the placeholder for a set of radio buttons.
22 - */
23 -
24 -(function (onos){
25 - 'use strict';
26 -
27 - // API's
28 - var api = onos.api;
29 -
30 - // Config variables
31 - var guiTitle = 'Open Network Operating System';
32 -
33 - // DOM elements and the like
34 - var mast = d3.select('#mast');
35 -
36 - mast.append('img')
37 - .attr({
38 - id: 'logo',
39 - src: 'onos-logo.png'
40 - });
41 -
42 - mast.append('span')
43 - .attr({
44 - class: 'title'
45 - })
46 - .text(guiTitle);
47 -
48 - mast.append('span')
49 - .attr({
50 - id: 'mastRadio',
51 - class: 'right'
52 - });
53 -
54 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Quick Help layer -- CSS file
19 - */
20 -
21 -#quickhelp {
22 - z-index: 1300;
23 -}
24 -
25 -#quickhelp svg {
26 - position: absolute;
27 - top: 180px;
28 - opacity: 1;
29 -}
30 -
31 -#quickhelp svg g.help rect {
32 - fill: black;
33 - opacity: 0.7;
34 -}
35 -
36 -#quickhelp svg text.title {
37 - font-size: 10pt;
38 - font-style: italic;
39 - text-anchor: middle;
40 - fill: #999;
41 -}
42 -
43 -#quickhelp svg g.keyItem {
44 - fill: white;
45 -}
46 -
47 -#quickhelp svg g line.qhrowsep {
48 - stroke: #888;
49 - stroke-dasharray: 2 2;
50 -}
51 -
52 -#quickhelp svg text {
53 - font-size: 7pt;
54 - alignment-baseline: middle;
55 -}
56 -
57 -#quickhelp svg text.key {
58 - fill: #add;
59 -}
60 -
61 -#quickhelp svg text.desc {
62 - fill: #ddd;
63 -}
64 -
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Quick Help Layer
19 -
20 - Defines the key-map layer for the UI. Used to give user a list of
21 - key bindings; both global, and for the current view.
22 - */
23 -
24 -(function (onos){
25 - 'use strict';
26 -
27 - // Config variables
28 - var w = '100%',
29 - h = '80%',
30 - fade = 500,
31 - vb = '-200 0 400 400';
32 -
33 - // layout configuration
34 - var pad = 10,
35 - offy = 45,
36 - sepYDelta = 20,
37 - colXDelta = 16,
38 - yTextSpc = 12,
39 - offDesc = 8;
40 -
41 - // State variables
42 - var data = [],
43 - yCount;
44 -
45 - // DOM elements and the like
46 - var qhdiv = d3.select('#quickhelp'),
47 - svg = qhdiv.select('svg'),
48 - pane, rect, items;
49 -
50 - // General functions
51 - function isA(a) { return $.isArray(a) ? a : null; }
52 - function isS(s) { return typeof s === 'string'; }
53 -
54 - function cap(s) {
55 - return s.replace(/^[a-z]/, function (m) { return m.toUpperCase(); });
56 - }
57 -
58 - var keyDisp = {
59 - equals: '=',
60 - dash: '-',
61 - slash: '/',
62 - backSlash: '\\',
63 - backQuote: '`',
64 - leftArrow: 'L-arrow',
65 - upArrow: 'U-arrow',
66 - rightArrow: 'R-arrow',
67 - downArrow: 'D-arrow'
68 - };
69 -
70 - function mkKeyDisp(id) {
71 - var v = keyDisp[id] || id;
72 - return cap(v);
73 - }
74 -
75 - function addSeparator(el, i) {
76 - var y = sepYDelta/2 - 5;
77 - el.append('line')
78 - .attr({ 'class': 'qhrowsep', x1: 0, y1: y, x2: 0, y2: y });
79 - }
80 -
81 - function addContent(el, data, ri) {
82 - var xCount = 0,
83 - clsPfx = 'qh-r' + ri + '-c';
84 -
85 - function addColumn(el, c, i) {
86 - var cls = clsPfx + i,
87 - oy = 0,
88 - aggKey = el.append('g').attr('visibility', 'hidden'),
89 - gcol = el.append('g').attr({
90 - 'class': cls,
91 - transform: translate(xCount, 0)
92 - });
93 -
94 - c.forEach(function (j) {
95 - var k = j[0],
96 - v = j[1];
97 -
98 - if (k !== '-') {
99 - aggKey.append('text').text(k);
100 -
101 - gcol.append('text').text(k)
102 - .attr({
103 - 'class': 'key',
104 - y: oy
105 - });
106 - gcol.append('text').text(v)
107 - .attr({
108 - 'class': 'desc',
109 - y: oy
110 - });
111 - }
112 -
113 - oy += yTextSpc;
114 - });
115 -
116 - // adjust position of descriptions, based on widest key
117 - var kbox = aggKey.node().getBBox(),
118 - ox = kbox.width + offDesc;
119 - gcol.selectAll('.desc').attr('x', ox);
120 - aggKey.remove();
121 -
122 - // now update x-offset for next column
123 - var bbox = gcol.node().getBBox();
124 - xCount += bbox.width + colXDelta;
125 - }
126 -
127 - data.forEach(function (d, i) {
128 - addColumn(el, d, i);
129 - });
130 -
131 - // finally, return the height of the row..
132 - return el.node().getBBox().height;
133 - }
134 -
135 - function updateKeyItems() {
136 - var rows = items.selectAll('.qhRow').data(data);
137 -
138 - yCount = offy;
139 -
140 - var entering = rows.enter()
141 - .append('g')
142 - .attr({
143 - 'class': 'qhrow'
144 - });
145 -
146 - entering.each(function (r, i) {
147 - var el = d3.select(this),
148 - sep = r.type === 'sep',
149 - dy;
150 -
151 - el.attr('transform', translate(0, yCount));
152 -
153 - if (sep) {
154 - addSeparator(el, i);
155 - yCount += sepYDelta;
156 - } else {
157 - dy = addContent(el, r.data, i);
158 - yCount += dy;
159 - }
160 - });
161 -
162 - // size the backing rectangle
163 - var ibox = items.node().getBBox(),
164 - paneW = ibox.width + pad * 2,
165 - paneH = ibox.height + offy;
166 -
167 - items.selectAll('.qhrowsep').attr('x2', ibox.width);
168 - items.attr('transform', translate(-paneW/2, -pad));
169 - rect.attr({
170 - width: paneW,
171 - height: paneH,
172 - transform: translate(-paneW/2-pad, 0)
173 - });
174 -
175 - }
176 -
177 - function translate(x, y) {
178 - return 'translate(' + x + ',' + y + ')';
179 - }
180 -
181 - function checkFmt(fmt) {
182 - // should be a single array of keys,
183 - // or array of arrays of keys (one per column).
184 - // return null if there is a problem.
185 - var a = isA(fmt),
186 - n = a && a.length,
187 - ns = 0,
188 - na = 0;
189 -
190 - if (n) {
191 - // it is an array which has some content
192 - a.forEach(function (d) {
193 - isA(d) && na++;
194 - isS(d) && ns++;
195 - });
196 - if (na === n || ns === n) {
197 - // all arrays or all strings...
198 - return a;
199 - }
200 - }
201 - return null;
202 - }
203 -
204 - function buildBlock(map, fmt) {
205 - var b = [];
206 - fmt.forEach(function (k) {
207 - var v = map.get(k),
208 - a = isA(v),
209 - d = (a && a[1]);
210 -
211 - // '-' marks a separator; d is the description
212 - if (k === '-' || d) {
213 - b.push([mkKeyDisp(k), d]);
214 - }
215 - });
216 - return b;
217 - }
218 -
219 - function emptyRow() {
220 - return { type: 'row', data: []};
221 - }
222 -
223 - function mkArrRow(fmt) {
224 - var d = emptyRow();
225 - d.data.push(fmt);
226 - return d;
227 - }
228 -
229 - function mkColumnarRow(map, fmt) {
230 - var d = emptyRow();
231 - fmt.forEach(function (a) {
232 - d.data.push(buildBlock(map, a));
233 - });
234 - return d;
235 - }
236 -
237 - function mkMapRow(map, fmt) {
238 - var d = emptyRow();
239 - d.data.push(buildBlock(map, fmt));
240 - return d;
241 - }
242 -
243 - function addRow(row) {
244 - var d = row || { type: 'sep' };
245 - data.push(d);
246 - }
247 -
248 - function aggregateData(bindings) {
249 - var hf = '_helpFormat',
250 - gmap = d3.map(bindings.globalKeys),
251 - gfmt = bindings.globalFormat,
252 - vmap = d3.map(bindings.viewKeys),
253 - vgest = bindings.viewGestures,
254 - vfmt, vkeys;
255 -
256 - // filter out help format entry
257 - vfmt = checkFmt(vmap.get(hf));
258 - vmap.remove(hf);
259 -
260 - // if bad (or no) format, fallback to sorted keys
261 - if (!vfmt) {
262 - vkeys = vmap.keys();
263 - vfmt = vkeys.sort();
264 - }
265 -
266 - data = [];
267 -
268 - addRow(mkMapRow(gmap, gfmt));
269 - addRow();
270 - addRow(isA(vfmt[0]) ? mkColumnarRow(vmap, vfmt) : mkMapRow(vmap, vfmt));
271 - addRow();
272 - addRow(mkArrRow(vgest));
273 - }
274 -
275 -
276 - function popBind(bindings) {
277 - pane = svg.append('g')
278 - .attr({
279 - class: 'help',
280 - opacity: 0
281 - });
282 -
283 - rect = pane.append('rect')
284 - .attr('rx', 8);
285 -
286 - pane.append('text')
287 - .text('Quick Help')
288 - .attr({
289 - class: 'title',
290 - dy: '1.2em',
291 - transform: translate(-pad,0)
292 - });
293 -
294 - items = pane.append('g');
295 - aggregateData(bindings);
296 - updateKeyItems();
297 -
298 - _fade(1);
299 - }
300 -
301 - function fadeBindings() {
302 - _fade(0);
303 - }
304 -
305 - function _fade(o) {
306 - svg.selectAll('g.help')
307 - .transition()
308 - .duration(fade)
309 - .attr('opacity', o);
310 - }
311 -
312 - function addSvg() {
313 - svg = qhdiv.append('svg')
314 - .attr({
315 - width: w,
316 - height: h,
317 - viewBox: vb
318 - });
319 - }
320 -
321 - function removeSvg() {
322 - svg.transition()
323 - .delay(fade + 20)
324 - .remove();
325 - }
326 -
327 - function showQuickHelp(bindings) {
328 - svg = qhdiv.select('svg');
329 - if (svg.empty()) {
330 - addSvg();
331 - popBind(bindings);
332 - } else {
333 - hideQuickHelp();
334 - }
335 - }
336 -
337 - function hideQuickHelp() {
338 - svg = qhdiv.select('svg');
339 - if (!svg.empty()) {
340 - fadeBindings();
341 - removeSvg();
342 - return true;
343 - }
344 - return false;
345 - }
346 -
347 - onos.ui.addLib('quickHelp', {
348 - show: showQuickHelp,
349 - hide: hideQuickHelp
350 - });
351 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Sample module file to illustrate framework integration.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var pi = Math.PI,
25 - svg,
26 - dotG,
27 - nCircles = 12,
28 - circleData = [],
29 - dotId = 0,
30 - angle = 360 / nCircles,
31 - baseAngle = -90 - angle,
32 - groupRadius = 120,
33 - dotRadius = 24,
34 - dotMoveMs = 800,
35 - dotAppearMs = 300,
36 - dotEase = 'elastic',
37 - colorScale = d3.scale.linear()
38 - .domain([-pi/2, 2*pi/4, 3*pi/2])
39 - .range(['green', 'goldenrod', 'blue']);
40 -
41 - // set the size of the SVG layer to match that of the view
42 - function sizeSvg(view) {
43 - svg.attr({
44 - width: view.width(),
45 - height: view.height()
46 - });
47 - }
48 -
49 - // gets invoked only the first time the view is loaded
50 - function init(view, ctx, flags) {
51 - // prepare our SVG layer...
52 - svg = view.$div.append('svg');
53 - sizeSvg(view);
54 - dotG = svg.append('g').attr('id', 'dots');
55 - }
56 -
57 - // gets invoked just before our view is loaded
58 - function reset(view, ctx, flags) {
59 - // clear dot group and reset circle data
60 - dotG.html('');
61 - circleData = [];
62 - // also clear text, if any
63 - svg.selectAll('text').remove();
64 - }
65 -
66 - function updateCirclePositions(view, addNew) {
67 - var w = view.width(),
68 - h = view.height(),
69 - ox = w / 2,
70 - oy = h / 2;
71 -
72 - // reposition existing dots
73 - circleData.forEach(function (c, i) {
74 - var inc = addNew ? 1 : 0,
75 - theta = ((i + inc) * angle + baseAngle) * pi/180,
76 - dx = Math.cos(theta) * groupRadius,
77 - dy = Math.sin(theta) * groupRadius,
78 - x = ox + dx,
79 - y = oy + dy;
80 - if (!addNew && i === 0) {
81 - x = ox;
82 - y = oy;
83 - }
84 - c.cx = x;
85 - c.cy = y;
86 - c.rgb = colorScale(theta);
87 - });
88 -
89 - if (addNew) {
90 - // introduce a new dot
91 - circleData.unshift({
92 - cx: ox,
93 - cy: oy,
94 - id: dotId++
95 - });
96 - }
97 -
98 - // +1 to account for the circle in the center..
99 - if (circleData.length > nCircles + 1) {
100 - circleData.splice(nCircles + 1, 1);
101 - }
102 - }
103 -
104 - function doCircles(view) {
105 - var ox = view.width() / 2,
106 - oy = view.height() / 2,
107 - stroke = 'black',
108 - fill = 'red',
109 - hoverFill = 'magenta';
110 -
111 - // move existing circles, and add a new one
112 - updateCirclePositions(view, true);
113 -
114 - var circ = dotG.selectAll('circle')
115 - .data(circleData, function (d) { return d.id; });
116 -
117 - // operate on existing elements
118 - circ.on('mouseover', null)
119 - .on('mouseout', null)
120 - .on('click', null)
121 - .transition()
122 - .duration(dotMoveMs)
123 - .ease(dotEase)
124 - .attr({
125 - cx: function (d) { return d.cx; },
126 - cy: function (d) { return d.cy; }
127 - })
128 - .style({
129 - cursor: 'default',
130 - fill: function (d) { return d.rgb; }
131 - });
132 -
133 - // operate on entering elements
134 - circ.enter()
135 - .append('circle')
136 - .attr({
137 - cx: function (d) { return d.cx; },
138 - cy: function (d) { return d.cy; },
139 - r: 0
140 - })
141 - .style({
142 - fill: fill,
143 - stroke: stroke,
144 - 'stroke-width': 3.5,
145 - cursor: 'pointer',
146 - opacity: 0
147 - })
148 - .on('mouseover', function (d) {
149 - d3.select(this).style('fill', hoverFill);
150 - })
151 - .on('mouseout', function (d) {
152 - d3.select(this).style('fill', fill);
153 - })
154 - .on('click', function (d) {
155 - setTimeout(function() {
156 - doCircles(view, true);
157 - }, 10);
158 - })
159 - .transition()
160 - .delay(dotMoveMs)
161 - .duration(dotAppearMs)
162 - .attr('r', dotRadius)
163 - .style('opacity', 1);
164 -
165 - // operate on exiting elements
166 - circ.exit()
167 - .transition()
168 - .duration(750)
169 - .style('opacity', 0)
170 - .attr({
171 - cx: ox,
172 - cy: oy,
173 - r: groupRadius - dotRadius
174 - })
175 - .remove();
176 - }
177 -
178 - function load(view, ctx, flags) {
179 - var ctxText = ctx ? 'Context is "' + ctx + '"' : '';
180 -
181 - // display our view context
182 - if (ctxText) {
183 - svg.append('text')
184 - .text(ctxText)
185 - .attr({
186 - x: 20,
187 - y: '1.5em'
188 - })
189 - .style({
190 - fill: 'darkgreen',
191 - 'font-size': '20pt'
192 - });
193 - }
194 -
195 - doCircles(view);
196 - }
197 -
198 - function resize(view, ctx, flags) {
199 - sizeSvg(view);
200 - updateCirclePositions(view);
201 -
202 - // move exiting dots into new positions, relative to view size
203 - var circ = dotG.selectAll('circle')
204 - .data(circleData, function (d) { return d.id; });
205 - circ.attr({
206 - cx: function (d) { return d.cx; },
207 - cy: function (d) { return d.cy; }
208 - });
209 - }
210 -
211 - // == register our view here, with links to lifecycle callbacks
212 -
213 - onos.ui.addView('sample', {
214 - init: init,
215 - reset: reset,
216 - load: load,
217 - resize: resize
218 - });
219 -
220 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Sample view to illustrate hash formats.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var intro = "Try using the following hashes in the address bar:",
25 - hashPrefix = '#sampleHash',
26 - suffixes = [
27 - '',
28 - ',one',
29 - ',two',
30 - ',context,ignored',
31 - ',context,ignored?a,b,c',
32 - ',two?foo',
33 - ',three?foo,bar'
34 - ],
35 - $d;
36 -
37 - function note(txt) {
38 - $d.append('p')
39 - .text(txt)
40 - .style({
41 - 'font-size': '10pt',
42 - color: 'darkorange',
43 - padding: '0 20px',
44 - margin: 0
45 - });
46 - }
47 -
48 - function para(txt, color) {
49 - var c = color || 'black';
50 - $d.append('p')
51 - .text(txt)
52 - .style({
53 - padding: '2px 8px',
54 - color: c
55 - });
56 - }
57 -
58 - function load(view, ctx, flags) {
59 - var c = ctx || '(undefined)',
60 - f = flags ? d3.map(flags).keys() : [];
61 -
62 - $d = view.$div;
63 -
64 - para(intro);
65 -
66 - suffixes.forEach(function (s) {
67 - note(hashPrefix + s);
68 - });
69 -
70 - para('View ID: ' + view.vid, 'blue');
71 - para('Context: ' + c, 'blue');
72 - para('Flags: { ' + f.join(', ') + ' }', 'magenta');
73 - }
74 -
75 - // == register the view here, with links to lifecycle callbacks
76 -
77 - onos.ui.addView('sampleHash', {
78 - reset: true, // empty the div on reset
79 - load: load
80 - });
81 -
82 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Sample view to illustrate key bindings.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var keyDispatch = {
25 - Z: keyUndo,
26 - X: keyCut,
27 - C: keyCopy,
28 - V: keyPaste,
29 - space: keySpace
30 - };
31 -
32 - function keyUndo(view) {
33 - note(view, 'Z = UNDO');
34 - }
35 -
36 - function keyCut(view) {
37 - note(view, 'X = CUT');
38 - }
39 -
40 - function keyCopy(view) {
41 - note(view, 'C = COPY');
42 - }
43 -
44 - function keyPaste(view) {
45 - note(view, 'V = PASTE');
46 - }
47 -
48 - function keySpace(view) {
49 - note(view, 'The SpaceBar');
50 - }
51 -
52 - function note(view, msg) {
53 - view.$div.append('p')
54 - .text(msg)
55 - .style({
56 - 'font-size': '10pt',
57 - color: 'darkorange',
58 - padding: '0 20px',
59 - margin: 0
60 - });
61 - }
62 -
63 - function keyCallback(view, key, keyCode, event) {
64 - note(view, 'Key = ' + key + ' KeyCode = ' + keyCode);
65 - }
66 -
67 - function load(view, ctx) {
68 - // this maps specific keys to specific functions (1)
69 - view.setKeys(keyDispatch);
70 - // whereas, this installs a general key handler function (2)
71 - view.setKeys(keyCallback);
72 -
73 - // Note that (1) takes precedence over (2)
74 -
75 - view.$div.append('p')
76 - .text('Press a key or two (try Z,X,C,V and others) ...')
77 - .style('padding', '2px 8px');
78 - }
79 -
80 - // == register the view here, with links to lifecycle callbacks
81 -
82 - onos.ui.addView('sampleKeys', {
83 - reset: true, // empty the div on reset
84 - load: load
85 - });
86 -
87 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - Sample view to illustrate radio buttons.
19 - */
20 -
21 -(function (onos) {
22 - 'use strict';
23 -
24 - var intro = [ 'Yo, radio button set...', 'Time to shine' ],
25 - btnSet = [
26 - { text: 'First Button', cb: cbRadio },
27 - { text: 'Second Button', cb: cbRadio },
28 - { text: 'Third Button', cb: cbRadio }
29 - ];
30 -
31 - // radio button callback
32 - function cbRadio(view, btn) {
33 - write(view, 'You pressed the ' + btn.text);
34 - }
35 -
36 - function write(view, msg) {
37 - view.$div.append('p')
38 - .text(msg)
39 - .style({
40 - 'font-size': '10pt',
41 - color: 'green',
42 - padding: '0 20px',
43 - margin: '2px'
44 - });
45 - }
46 -
47 - // invoked when the view is loaded
48 - function load(view, ctx) {
49 - view.setRadio(btnSet);
50 -
51 - view.$div.selectAll('p')
52 - .data(intro)
53 - .enter()
54 - .append('p')
55 - .text(function (d) { return d; })
56 - .style('padding', '2px 8px');
57 - }
58 -
59 - // == register the view here, with links to lifecycle callbacks
60 -
61 - onos.ui.addView('sampleRadio', {
62 - reset: true, // empty the div on reset
63 - load: load
64 - });
65 -
66 -}(ONOS));
1 -/*
2 - * Copyright 2014 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 - ONOS GUI -- Topology view -- CSS file
19 - */
20 -
21 -#topo svg #topo-bg {
22 - opacity: 0.5;
23 -}
24 -
25 -#topo #map {
26 - stroke-width: 2px;
27 - stroke: #eee;
28 - fill: transparent;
29 -}
30 -
31 -/* TODO: move glyphs into framework */
32 -
33 -#topo svg .glyphIcon {
34 - fill: black;
35 - stroke: none;
36 - fill-rule: evenodd;
37 -}
38 -#topo svg .glyphIcon rect {
39 - fill: #ddd;
40 - stroke: none;
41 -}
42 -
43 -
44 -#topo svg .noDevsLayer {
45 - visibility: hidden;
46 -}
47 -
48 -#topo svg .noDevsLayer text {
49 - font-size: 60pt;
50 - font-style: italic;
51 - fill: #dde;
52 -}
53 -
54 -#topo svg .noDevsBird {
55 - fill: #ecd;
56 -}
57 -
58 -/* NODES */
59 -
60 -#topo svg .node {
61 - cursor: pointer;
62 -}
63 -
64 -#topo svg .node.selected rect,
65 -#topo svg .node.selected circle {
66 - fill: #f90;
67 - filter: url(#blue-glow);
68 -}
69 -
70 -#topo svg .node text {
71 - pointer-events: none;
72 -}
73 -
74 -/* Device Nodes */
75 -
76 -#topo svg .node.device {
77 -}
78 -
79 -#topo svg .node.device rect {
80 - stroke-width: 1.5;
81 -}
82 -
83 -#topo svg .node.device.fixed rect {
84 - stroke-width: 1.5;
85 - stroke: #ccc;
86 -}
87 -
88 -/* note: device is offline without the 'online' class */
89 -#topo svg .node.device {
90 - fill: #777;
91 -}
92 -
93 -#topo svg .node.device.online {
94 - fill: #6e7fa3;
95 -}
96 -
97 -/* note: device is offline without the 'online' class */
98 -#topo svg .node.device text {
99 - fill: #bbb;
100 - font: 10pt sans-serif;
101 -}
102 -
103 -#topo svg .node.device.online text {
104 - fill: white;
105 -}
106 -
107 -#topo svg .node.device .glyphIcon rect {
108 - fill: #aaa;
109 -}
110 -#topo svg .node.device .glyphIcon use {
111 - fill: #777;
112 -}
113 -#topo svg .node.device.selected .glyphIcon rect {
114 - fill: #f90;
115 -}
116 -#topo svg .node.device.online .glyphIcon rect {
117 - fill: #ccc;
118 -}
119 -#topo svg .node.device.online .glyphIcon use {
120 - fill: #000;
121 -}
122 -#topo svg .node.device.online.selected .glyphIcon rect {
123 - fill: #f90;
124 -}
125 -
126 -
127 -/* Host Nodes */
128 -
129 -#topo svg .node.host {
130 - stroke: #000;
131 -}
132 -
133 -#topo svg .node.host text {
134 - fill: #846;
135 - stroke: none;
136 - font: 9pt sans-serif;
137 -}
138 -
139 -svg .node.host circle {
140 - stroke: #000;
141 - fill: #edb;
142 -}
143 -
144 -/* LINKS */
145 -
146 -#topo svg .link {
147 - opacity: .9;
148 -}
149 -
150 -#topo svg .link.inactive {
151 - opacity: .5;
152 - stroke-dasharray: 8 4;
153 -}
154 -
155 -#topo svg .link.secondary {
156 - stroke: rgba(0,153,51,0.5);
157 - stroke-width: 3px;
158 -}
159 -#topo svg .link.primary {
160 - stroke: #ffA300;
161 - stroke-width: 4px;
162 -}
163 -#topo svg .link.animated {
164 - stroke: #ffA300;
165 -}
166 -
167 -#topo svg .link.secondary.optical {
168 - stroke: rgba(128,64,255,0.5);
169 - stroke-width: 4px;
170 -}
171 -#topo svg .link.primary.optical {
172 - stroke: #74f;
173 - stroke-width: 6px;
174 -}
175 -#topo svg .link.animated.optical {
176 - stroke: #74f;
177 - stroke-width: 10px;
178 -}
179 -
180 -#topo svg .linkLabel rect {
181 - fill: #eee;
182 - stroke: none;
183 -}
184 -#topo svg .linkLabel text {
185 - text-anchor: middle;
186 - stroke: #777;
187 - stroke-width: 0.1;
188 - font-size: 9pt;
189 -}
190 -
191 -/* Fly-in summary pane */
192 -
193 -#topo-summary {
194 - /* gets base CSS from .fpanel in floatPanel.css */
195 - top: 64px;
196 -}
197 -
198 -#topo-summary svg {
199 - display: inline-block;
200 - width: 42px;
201 - height: 42px;
202 -}
203 -
204 -#topo-summary svg .glyphIcon {
205 - fill: black;
206 - stroke: none;
207 - fill-rule: evenodd;
208 -}
209 -
210 -#topo-summary h2 {
211 - position: absolute;
212 - margin: 0 4px;
213 - top: 20px;
214 - left: 50px;
215 - color: black;
216 -}
217 -
218 -#topo-summary h3 {
219 - margin: 0 4px;
220 - top: 20px;
221 - left: 50px;
222 - color: black;
223 -}
224 -
225 -#topo-summary p, table {
226 - margin: 4px 4px;
227 -}
228 -
229 -#topo-summary td.label {
230 - font-style: italic;
231 - color: #777;
232 - padding-right: 12px;
233 -}
234 -
235 -#topo-summary td.value {
236 -}
237 -
238 -#topo-summary hr {
239 - height: 1px;
240 - color: #ccc;
241 - background-color: #ccc;
242 - border: 0;
243 -}
244 -
245 -/* Fly-in details pane */
246 -
247 -#topo-detail {
248 - /* gets base CSS from .fpanel in floatPanel.css */
249 - top: 320px;
250 -
251 -}
252 -
253 -#topo-detail svg {
254 - display: inline-block;
255 - width: 42px;
256 - height: 42px;
257 -}
258 -
259 -#topo-detail svg .glyphIcon {
260 - fill: black;
261 - stroke: none;
262 - fill-rule: evenodd;
263 -}
264 -
265 -#topo-detail h2 {
266 - position: absolute;
267 - margin: 0 4px;
268 - top: 20px;
269 - left: 50px;
270 - color: black;
271 -}
272 -
273 -#topo-detail h3 {
274 - margin: 0 4px;
275 - top: 20px;
276 - left: 50px;
277 - color: black;
278 -}
279 -
280 -#topo-detail p, table {
281 - margin: 4px 4px;
282 -}
283 -
284 -#topo-detail td.label {
285 - font-style: italic;
286 - color: #777;
287 - padding-right: 12px;
288 -}
289 -
290 -#topo-detail td.value {
291 -}
292 -
293 -
294 -#topo-detail .actionBtn {
295 - margin: 6px 12px;
296 - padding: 2px 6px;
297 - font-size: 9pt;
298 - cursor: pointer;
299 - width: 200px;
300 - text-align: center;
301 -
302 - /* theme specific... */
303 - border: 2px solid #ddd;
304 - border-radius: 4px;
305 - color: #eee;
306 - background: #888;
307 -}
308 -
309 -#topo-detail .actionBtn:hover {
310 - /* theme specific... */
311 - border: 2px solid #ddd;
312 - color: #eee;
313 - background: #444;
314 -}
315 -
316 -
317 -#topo-detail hr {
318 - height: 1px;
319 - color: #ccc;
320 - background-color: #ccc;
321 - border: 0;
322 -}
323 -
324 -/* ONOS instance stuff */
325 -
326 -#topo-oibox {
327 - height: 100px;
328 -}
329 -
330 -#topo-oibox div.onosInst {
331 - display: inline-block;
332 - width: 170px;
333 - height: 85px;
334 - cursor: pointer;
335 -}
336 -
337 -#topo-oibox svg rect {
338 - fill: #ccc;
339 - stroke: #aaa;
340 - stroke-width: 3.5;
341 -}
342 -#topo-oibox .online svg rect {
343 - opacity: 1;
344 - fill: #9cf;
345 - stroke: #555;
346 -}
347 -
348 -#topo-oibox svg .glyphIcon {
349 - fill: #888;
350 - fill-rule: evenodd;
351 -}
352 -#topo-oibox .online svg .glyphIcon {
353 - fill: #000;
354 -}
355 -
356 -#topo-oibox svg .badgeIcon {
357 - fill: #777;
358 - fill-rule: evenodd;
359 -}
360 -
361 -#topo-oibox .online svg .badgeIcon {
362 - fill: #fff;
363 -}
364 -
365 -#topo-oibox svg text {
366 - text-anchor: middle;
367 - fill: #777;
368 -}
369 -#topo-oibox .online svg text {
370 - fill: #eee;
371 -}
372 -
373 -#topo-oibox svg text.instTitle {
374 - font-size: 11pt;
375 - font-weight: bold;
376 -}
377 -#topo-oibox svg text.instLabel {
378 - font-size: 9pt;
379 - font-style: italic;
380 -}
381 -
382 -#topo-oibox .onosInst.mastership {
383 - opacity: 0.3;
384 -}
385 -#topo-oibox .onosInst.mastership.affinity {
386 - opacity: 1.0;
387 -}
388 -#topo-oibox .onosInst.mastership.affinity svg rect {
389 - filter: url(#blue-glow);
390 -}
391 -
392 -
393 -#topo svg .suppressed {
394 - opacity: 0.2;
395 -}
396 -
397 -/* Death Mask (starts hidden) */
398 -
399 -#topo-mask {
400 - display: none;
401 - position: absolute;
402 - top: 0;
403 - left: 0;
404 - width: 10000px;
405 - height: 8000px;
406 - z-index: 5000;
407 - background-color: rgba(0,0,0,0.75);
408 - padding: 60px;
409 -}
410 -
411 -#topo-mask p {
412 - margin: 8px 20px;
413 - color: #ddd;
414 - font-size: 14pt;
415 - font-style: italic;
416 -}
417 -
This diff is collapsed. Click to expand it.
1 -/*
2 - * Copyright 2015 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 -package org.onosproject.ui.impl;
18 -
19 -import com.fasterxml.jackson.databind.node.ObjectNode;
20 -import com.google.common.collect.ImmutableSet;
21 -import org.junit.Before;
22 -import org.junit.Test;
23 -import org.onlab.osgi.ServiceDirectory;
24 -import org.onlab.osgi.TestServiceDirectory;
25 -import org.onlab.packet.ChassisId;
26 -import org.onlab.packet.IpAddress;
27 -import org.onlab.packet.MacAddress;
28 -import org.onlab.packet.VlanId;
29 -import org.onosproject.cluster.ClusterService;
30 -import org.onosproject.cluster.ClusterServiceAdapter;
31 -import org.onosproject.core.CoreService;
32 -import org.onosproject.core.CoreServiceAdapter;
33 -import org.onosproject.core.Version;
34 -import org.onosproject.mastership.MastershipService;
35 -import org.onosproject.mastership.MastershipServiceAdapter;
36 -import org.onosproject.net.DefaultDevice;
37 -import org.onosproject.net.DefaultHost;
38 -import org.onosproject.net.Device;
39 -import org.onosproject.net.DeviceId;
40 -import org.onosproject.net.Host;
41 -import org.onosproject.net.HostId;
42 -import org.onosproject.net.HostLocation;
43 -import org.onosproject.net.Port;
44 -import org.onosproject.net.PortNumber;
45 -import org.onosproject.net.device.DeviceService;
46 -import org.onosproject.net.device.DeviceServiceAdapter;
47 -import org.onosproject.net.flow.FlowEntry;
48 -import org.onosproject.net.flow.FlowRuleService;
49 -import org.onosproject.net.flow.FlowRuleServiceAdapter;
50 -import org.onosproject.net.host.HostService;
51 -import org.onosproject.net.host.HostServiceAdapter;
52 -import org.onosproject.net.intent.IntentService;
53 -import org.onosproject.net.intent.IntentServiceAdapter;
54 -import org.onosproject.net.link.LinkService;
55 -import org.onosproject.net.link.LinkServiceAdapter;
56 -import org.onosproject.net.provider.ProviderId;
57 -import org.onosproject.net.statistic.StatisticService;
58 -import org.onosproject.net.statistic.StatisticServiceAdapter;
59 -import org.onosproject.net.topology.TopologyService;
60 -import org.onosproject.net.topology.TopologyServiceAdapter;
61 -
62 -import java.util.ArrayList;
63 -import java.util.List;
64 -import java.util.Set;
65 -
66 -import static org.junit.Assert.assertEquals;
67 -
68 -public class TopologyViewWebSocketTest {
69 -
70 - private static final ProviderId PID = new ProviderId("of", "foo.bar");
71 - private static final ChassisId CHID = new ChassisId(123L);
72 - private static final MacAddress MAC = MacAddress.valueOf("00:00:00:00:00:19");
73 - private static final DeviceId DID = DeviceId.deviceId("of:foo");
74 - private static final Set<IpAddress> IPS = ImmutableSet.of(IpAddress.valueOf("1.2.3.4"));
75 -
76 - private TestWebSocket ws;
77 - private TestServiceDirectory sd;
78 -
79 - @Before
80 - public void setUp() {
81 - sd = new TestServiceDirectory();
82 - sd.add(DeviceService.class, new TestDeviceService());
83 - sd.add(ClusterService.class, new ClusterServiceAdapter());
84 - sd.add(LinkService.class, new LinkServiceAdapter());
85 - sd.add(HostService.class, new TestHostService());
86 - sd.add(MastershipService.class, new MastershipServiceAdapter());
87 - sd.add(IntentService.class, new IntentServiceAdapter());
88 - sd.add(FlowRuleService.class, new TestFlowService());
89 - sd.add(StatisticService.class, new StatisticServiceAdapter());
90 - sd.add(TopologyService.class, new TopologyServiceAdapter());
91 - sd.add(CoreService.class, new TestCoreService());
92 - ws = new TestWebSocket(sd);
93 - }
94 -
95 - @Test
96 - public void requestDetailsDevice() {
97 - // build the request
98 - String request = "{\"event\":\"requestDetails\", \"sid\":0, "
99 - + "\"payload\":{\"id\":\"of:000001\",\"class\":\"device\"}}";
100 - ws.onMessage(request);
101 - // look at the ws reply, and verify that it is correct
102 - assertEquals("incorrect id", "of:000001", ws.reply.path("payload").path("id").asText());
103 - assertEquals("incorrect mfr", "foo", ws.reply.path("payload").path("props").path("Vendor").asText());
104 - }
105 -
106 - @Test
107 - public void requestDetailsHost() {
108 - // build the request
109 - String request = "{\"event\":\"requestDetails\", \"sid\":0, "
110 - + "\"payload\":{\"id\":\"00:00:00:00:00:19/-1\",\"class\":\"host\"}}";
111 - ws.onMessage(request);
112 - // look at the ws reply, and verify that it is correct
113 - assertEquals("incorrect id", "00:00:00:00:00:19/-1", ws.reply.path("payload").path("id").asText());
114 - assertEquals("incorrect ip address", "1.2.3.4", ws.reply.path("payload").path("props").path("IP").asText());
115 - }
116 -
117 - private class TestWebSocket extends TopologyViewWebSocket {
118 -
119 - private ObjectNode reply;
120 -
121 - /**
122 - * Creates a new web-socket for serving data to GUI topology view.
123 - *
124 - * @param directory service directory
125 - */
126 - public TestWebSocket(ServiceDirectory directory) {
127 - super(directory);
128 - }
129 -
130 - @Override
131 - protected synchronized void sendMessage(ObjectNode data) {
132 - reply = data;
133 - }
134 - }
135 -
136 - private class TestCoreService extends CoreServiceAdapter {
137 - @Override
138 - public Version version() {
139 - return Version.version("1.2.3");
140 - }
141 - }
142 -
143 - private class TestDeviceService extends DeviceServiceAdapter {
144 -
145 - @Override
146 - public Device getDevice(DeviceId deviceId) {
147 - return new DefaultDevice(PID, deviceId, Device.Type.SWITCH,
148 - "foo", "hw", "sw", "sn", CHID);
149 - }
150 -
151 - @Override
152 - public List<Port> getPorts(DeviceId deviceId) {
153 - return new ArrayList<>();
154 - }
155 - }
156 -
157 - private class TestFlowService extends FlowRuleServiceAdapter {
158 - @Override
159 - public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
160 - return new ArrayList<>();
161 - }
162 - }
163 -
164 - private class TestHostService extends HostServiceAdapter {
165 - @Override
166 - public Host getHost(HostId hostId) {
167 - return new DefaultHost(PID, hostId, MAC, VlanId.NONE,
168 - new HostLocation(DID, PortNumber.P0, 123L), IPS);
169 - }
170 - }
171 -}
...\ No newline at end of file ...\ No newline at end of file