-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
265 lines (254 loc) · 9.74 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<html>
<head>
<title>Embedded Map Demonstration Page</title>
<script type="module">
import "./src/components/MapCanvas.component.js";
</script>
</head>
<body>
<table style='width:100%;'>
<tr>
<th colspan='3'>
<h1>Embedded Map Demonstration page</h1>
</th>
<tr>
<td style='width:20%'>
<a href='?editPanel=true'>Edit Mode On</a>
<a href='?'>Edit Mode Off</a>
<a href="/autodetect.html">Autodetect Demo</a>
</td>
<tr>
<td colspan='2' style='width:80%;'>
<div id='mapContainer'>
<esnet-map-canvas id='mapCanvas' height='400'>
</esnet-map-canvas>
</div>
</td>
</tr>
<tr>
<td style='width:40%'>Topology Data (edit to change the map)</td>
<td style='width:40%'>Map Options (edit to change the map)</td>
<td style='width:20%'></td>
</tr>
<tr>
<td id='mapDataContainer'>
<textarea id='topologyText' style='height:300px; width:100%;'>
</textarea>
</td>
<td id='mapOptionsContainer'>
<textarea id='optionsText' style='height:300px; width:100%;'>
</textarea>
</td>
</tr>
</table>
<script type="module">
import { sanitizeTopology } from "./src/components/lib/topologyTools.js"
import { signals } from "./src/signals.js"
var parsedData = {};
var lavender = "rgb(202, 149, 229)"
var topology = [
{
"name": "Test Layer",
"layer": "test-layer",
"pathLayout": {
"type": "curveCardinal",
"tension": 0.6
},
"edges":[
{
"name": "A--B",
"meta": {
"capacity": 100000000000,
"endpoint_identifiers": {
"names": ["A","B"]
}
},
"azDisplayValue": "9.0141 Gbps",
"zaDisplayValue": "3.1506 Gbps",
"coordinates": [
[49.02,-105.99],
[45.81,-101.77],
[44.59,-96.06]
],
"children": [],
},
{
"name": "B--C",
"meta": {
"capacity": 100000000000,
"endpoint_identifiers": {
"names": ["B","C"]
}
},
"azDisplayValue": "9.898 Gbps",
"zaDisplayValue": "1.727 Gbps",
"coordinates":[[44.59,-96.06],[47.99,-93.86],[52.16,-93.95]],
"children":[],
},
{
"name": "A--C",
"meta": {
"capacity": 100000000000,
"endpoint_identifiers": {
"names": ["A","C"]
}
},
"azDisplayValue": "8.9017 Gbps",
"zaDisplayValue": "3.5614 Gbps",
"coordinates":[[49.02,-105.99],[51.90,-100.72],[52.16,-93.95]],
"children":[],
},
{
"name": "A--D-Parent",
"meta": {
"capacity": 100000000000,
"endpoint_identifiers": {
"names": ["A","D-Parent"]
}
},
"azDisplayValue": "8.9017 Gbps",
"zaDisplayValue": "3.5614 Gbps",
"coordinates":[[49.02,-105.99],[48,-99]],
"children":[],
}
],
"nodes":[
{
"name":"A",
"meta":{},
"coordinate":[49.02,-105.99],
},
{
"name":"B",
"meta":{},
"coordinate":[44.59,-96.06],
},
{
"name":"C",
"meta":{},
"coordinate":[52.16,-93.95],
},
{
"name":"D-Parent",
"meta":{ "svg": "<g><rect height='100' width='100' x='-50' y='-50 ' style='fill:#AAA; border:2px solid black;' /></g>"},
"coordinate":[48,-99],
"children": ["A", "B"]
},
{
"name": "E-Parent",
"meta": { "svg": "<g><rect height='30' width='30' x='-15' y='-15' /></g>" },
"coordinate":[52.36,-93.95],
"children": ["D-Parent"],
},
{
"name":"F-Parent",
"meta":{ "svg": "<g><rect height='20' width='20' x='-10' y='-10' /></g>" },
"coordinate":[52.26,-93.95],
"children": ["C"],
},
{
"name":"G-Parent",
"meta":{ "svg": "<g><rect height='20' width='20' x='-10' y='-10' /></g>" },
"coordinate":[52.26,-93.95],
"children": ["A"],
},
]
},
];
var options = {
"initialViewStrategy": "viewport",
"showSidebar": true,
"showViewControls": true,
"enableEdgeAnimation": true,
"enableNodeAnimation": true,
"enableScrolling": true,
"enableEditing": true,
"background":"#EDEDED",
"multiLayerNodeSnap": false,
"topologySource": "json",
"viewport": {
"top": 33,
"left": -141,
"bottom": 43,
"right": -41,
"center": {
"lat":38.68,
"lng":-96.96,
},
"zoom":3.5
},
"tileset": {
// global options
// this string corresponds to options in RenderMap.js
"geographic":"esri.shaded",
// this string (or null) corresponds to options in RenderMap.js
"boundaries":"toner.boundaries",
// this string (or null) corresponds to options in RenderMap.js
"labels": null,
},
"layers": [
{
// layer 1 rendering options
"visible":true,
"color": lavender,
"endpointId":"names",
"nodeWidth":4,
"edgeWidth":2,
"pathOffset":2,
"name":"Parent-Child Topology",
"legend":true,
},
{
// layer 2 rendering options
"visible":false,
"color": lavender,
"endpointId":"names",
"nodeWidth":5,
"edgeWidth":3,
"pathOffset":3,
"name":"Example Network Topology",
"legend":true,
},
{
// layer 3 rendering options
"visible":false,
"color": lavender,
"endpointId":"names",
"nodeHighlight":"red",
"nodeWidth":6.5,
"edgeWidth":2,
"pathOffset":1.5,
"name":"Peer Topology",
"legend":false,
}
]
};
var canvas = document.getElementById("mapCanvas");
var optionsElem = document.getElementById('optionsText');
var topologyElem = document.getElementById('topologyText');
console.log("Available signals:", signals);
const receiveOptionsUpdates = function(options){
optionsElem.value = JSON.stringify(options, null, " ");
}
const receiveTopologyUpdates = function(topology){
var cleanTopology = [];
for(var i=0; i<3; i++){
if(topology[i]){
cleanTopology[i] = sanitizeTopology(topology[i]);
}
}
topologyElem.value = JSON.stringify(cleanTopology, null, " ");
}
canvas.listen(signals.TOPOLOGY_UPDATED, receiveTopologyUpdates);
canvas.listen(signals.OPTIONS_UPDATED, receiveOptionsUpdates);
canvas.setTopology(topology);
canvas.setOptions(options);
topologyElem.onchange = function(event){
canvas.setTopology(JSON.parse(event.target.value));
}
optionsElem.onchange = function(event){
canvas.setOptions(JSON.parse(event.target.value));
}
</script>
</body>
</html>