質問編集履歴
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,9 +18,9 @@
|
|
18
18
|
|
19
19
|
"controller_id": 0,
|
20
20
|
|
21
|
-
"created_at": "2018-09-
|
21
|
+
"created_at": "2018-09-10T09:15:33.673Z",
|
22
|
-
|
22
|
+
|
23
|
-
"updated_at": "2018-09-
|
23
|
+
"updated_at": "2018-09-10T09:15:33.917Z",
|
24
24
|
|
25
25
|
"graph": {
|
26
26
|
|
@@ -283,155 +283,3 @@
|
|
283
283
|
}
|
284
284
|
|
285
285
|
```
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
``` coffeescript
|
290
|
-
|
291
|
-
window.topology = ->
|
292
|
-
|
293
|
-
init = ->
|
294
|
-
|
295
|
-
getTopologyJson()
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
getTopologyJson = ->
|
300
|
-
|
301
|
-
# http request
|
302
|
-
|
303
|
-
jqXHR = $.ajax({
|
304
|
-
|
305
|
-
async: true
|
306
|
-
|
307
|
-
url: '/topology'
|
308
|
-
|
309
|
-
type: 'get'
|
310
|
-
|
311
|
-
dataType: 'json'
|
312
|
-
|
313
|
-
cache: false
|
314
|
-
|
315
|
-
})
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
# ajax callback
|
320
|
-
|
321
|
-
jqXHR.done (data, stat, xhr) ->
|
322
|
-
|
323
|
-
nodes = data.graph.nodes
|
324
|
-
|
325
|
-
links = data.graph.links
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
# vis用にnode, edge変数を用意
|
330
|
-
|
331
|
-
nos = []
|
332
|
-
|
333
|
-
edges = []
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
for n in nodes
|
338
|
-
|
339
|
-
# host or switch でlabelを変える
|
340
|
-
|
341
|
-
if n['name'][0..3] is "host"
|
342
|
-
|
343
|
-
nos.push({
|
344
|
-
|
345
|
-
id: n['id'],
|
346
|
-
|
347
|
-
label: n['name'][0..4] + n['ip'],
|
348
|
-
|
349
|
-
group: 'host',
|
350
|
-
|
351
|
-
value: 3,
|
352
|
-
|
353
|
-
})
|
354
|
-
|
355
|
-
else
|
356
|
-
|
357
|
-
nos.push({
|
358
|
-
|
359
|
-
id: n['id'],
|
360
|
-
|
361
|
-
label: n['name'],
|
362
|
-
|
363
|
-
group: 'switch',
|
364
|
-
|
365
|
-
value: 3,
|
366
|
-
|
367
|
-
})
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
for e in links
|
372
|
-
|
373
|
-
edges.push({
|
374
|
-
|
375
|
-
from: e['src_node_id'],
|
376
|
-
|
377
|
-
to : e['dest_node_id'],
|
378
|
-
|
379
|
-
})
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
container = document.getElementById('topology')
|
384
|
-
|
385
|
-
data = {
|
386
|
-
|
387
|
-
nodes: nos,
|
388
|
-
|
389
|
-
edges: edges,
|
390
|
-
|
391
|
-
}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
options = {
|
396
|
-
|
397
|
-
width: '960px',
|
398
|
-
|
399
|
-
height: '500px',
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
groups: {
|
404
|
-
|
405
|
-
switch: {
|
406
|
-
|
407
|
-
shape: 'dot',
|
408
|
-
|
409
|
-
color: "#2B7CE9"
|
410
|
-
|
411
|
-
},
|
412
|
-
|
413
|
-
host: {
|
414
|
-
|
415
|
-
shape: 'dot',
|
416
|
-
|
417
|
-
color: '#444444'
|
418
|
-
|
419
|
-
}
|
420
|
-
|
421
|
-
}
|
422
|
-
|
423
|
-
}
|
424
|
-
|
425
|
-
network = new vis.Network(container, data, options)
|
426
|
-
|
427
|
-
init()
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
$(document).ready(topology)
|
432
|
-
|
433
|
-
$(document).on('page:load', topology)
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
```
|