Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Simon Hunt
2014-10-30 11:27:23 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b4d9d4c7db65c363bd5b4534abd5e1d9b8184fa1
b4d9d4c7
1 parent
69e5257d
Added 'useLiveData' configuration switch.
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
web/gui/src/main/webapp/network.js
web/gui/src/main/webapp/network.js
View file @
b4d9d4c
...
...
@@ -28,6 +28,7 @@
// configuration data
var
config
=
{
useLiveData
:
true
,
debugOn
:
false
,
debug
:
{
showNodeXY
:
false
,
...
...
@@ -37,10 +38,18 @@
layering
:
true
,
collisionPrevention
:
true
},
jsonUrl
:
'rs/topology/graph'
,
jsonPrefix
:
''
,
XjsonUrl
:
'json/network.json'
,
XjsonPrefix
:
'json/'
,
data
:
{
live
:
{
jsonUrl
:
'rs/topology/graph'
,
detailPrefix
:
'rs/topology/graph/'
,
detailSuffix
:
''
},
fake
:
{
jsonUrl
:
'json/network2.json'
,
detailPrefix
:
'json/'
,
detailSuffix
:
'.json'
}
},
iconUrl
:
{
device
:
'img/device.png'
,
host
:
'img/host.png'
,
...
...
@@ -109,6 +118,22 @@
return
config
.
debugOn
&&
config
.
debug
[
what
];
}
function
urlData
()
{
return
config
.
data
[
config
.
useLiveData
?
'live'
:
'fake'
];
}
function
networkJsonUrl
()
{
return
urlData
().
jsonUrl
;
}
function
detailJsonUrl
(
id
)
{
var
u
=
urlData
(),
encId
=
config
.
useLiveData
?
encodeURIComponent
(
id
)
:
id
.
replace
(
/
[^
a-z0-9
]
/gi
,
'_'
);
return
u
.
detailPrefix
+
encId
+
u
.
detailSuffix
;
}
// load the topology view of the network
function
loadNetworkView
()
{
// Hey, here I am, calling something on the ONOS api:
...
...
@@ -117,10 +142,11 @@
resize
();
// go get our network data from the server...
d3
.
json
(
config
.
jsonUrl
,
function
(
err
,
data
)
{
var
url
=
networkJsonUrl
();
d3
.
json
(
url
,
function
(
err
,
data
)
{
if
(
err
)
{
alert
(
'Oops! Error reading JSON...\n\n'
+
'URL: '
+
config
.
jsonU
rl
+
'\n\n'
+
'URL: '
+
u
rl
+
'\n\n'
+
'Error: '
+
err
.
message
);
return
;
}
...
...
@@ -898,21 +924,13 @@
flyinPane
(
null
);
}
function
detailUrl
(
id
)
{
if
(
config
.
jsonPrefix
)
{
var
safeId
=
id
.
replace
(
/
[^
a-z0-9
]
/gi
,
'_'
);
return
config
.
jsonPrefix
+
safeId
+
'.json'
;
}
return
config
.
jsonUrl
+
'/'
+
encodeURIComponent
(
id
);
}
function
flyinPane
(
obj
)
{
var
pane
=
d3
.
select
(
'#flyout'
),
url
;
if
(
obj
)
{
// go get details of the selected object from the server...
url
=
detailUrl
(
obj
.
id
);
url
=
detail
Json
Url
(
obj
.
id
);
d3
.
json
(
url
,
function
(
err
,
data
)
{
if
(
err
)
{
alert
(
'Oops! Error reading JSON...\n\n'
+
...
...
Please
register
or
login
to post a comment