Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshviewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastruktur
meshviewer
Commits
0a90cdb7
Commit
0a90cdb7
authored
Mar 25, 2015
by
Nils Schneider
Browse files
Options
Downloads
Patches
Plain Diff
more refactoring (sidebar, meshstats)
parent
2c57cff2
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
lib/infobox/main.js
+1
-1
1 addition, 1 deletion
lib/infobox/main.js
lib/main.js
+13
-60
13 additions, 60 deletions
lib/main.js
lib/map.js
+1
-1
1 addition, 1 deletion
lib/map.js
lib/meshstats.js
+34
-0
34 additions, 0 deletions
lib/meshstats.js
lib/sidebar.js
+34
-0
34 additions, 0 deletions
lib/sidebar.js
with
83 additions
and
62 deletions
lib/infobox/main.js
+
1
−
1
View file @
0a90cdb7
...
...
@@ -14,7 +14,7 @@ define(["infobox/link", "infobox/node"], function (Link, Node) {
destroy
()
el
=
document
.
createElement
(
"
div
"
)
sidebar
.
insertBefore
(
el
,
sidebar
.
firstChild
)
sidebar
.
container
.
insertBefore
(
el
,
sidebar
.
container
.
firstChild
)
el
.
scrollIntoView
(
false
)
el
.
classList
.
add
(
"
infobox
"
)
...
...
This diff is collapsed.
Click to expand it.
lib/main.js
+
13
−
60
View file @
0a90cdb7
require
([
"
map
"
,
"
infobox/main
"
],
function
(
Map
,
Infobox
)
{
require
([
"
map
"
,
"
sidebar
"
,
"
meshstats
"
,
"
infobox/main
"
],
function
(
Map
,
Sidebar
,
Meshstats
,
Infobox
)
{
main
()
function
main
()
{
...
...
@@ -7,9 +7,9 @@ require(["map", "infobox/main"], function (Map, Infobox) {
var
linkScale
=
chroma
.
scale
(
chroma
.
interpolate
.
bezier
([
'
green
'
,
'
yellow
'
,
'
red
'
])).
domain
([
1
,
5
])
var
sidebar
=
mk
Sidebar
(
document
.
body
)
var
sidebar
=
new
Sidebar
(
document
.
body
)
var
gotoAnything
=
new
gotoBuild
er
(
config
)
var
gotoAnything
=
new
Rout
er
(
config
)
var
infobox
=
new
Infobox
(
config
,
sidebar
,
gotoAnything
)
gotoAnything
.
addTarget
(
infobox
)
...
...
@@ -18,17 +18,19 @@ require(["map", "infobox/main"], function (Map, Infobox) {
document
.
body
.
insertBefore
(
map
.
div
,
document
.
body
.
firstChild
)
gotoAnything
.
addTarget
(
map
)
var
meshstats
=
new
Meshstats
()
sidebar
.
add
(
meshstats
)
var
urls
=
[
config
.
dataPath
+
'
nodes.json
'
,
config
.
dataPath
+
'
graph.json
'
]
var
p
=
Promise
.
all
(
urls
.
map
(
getJSON
))
p
.
then
(
handle_data
(
config
,
linkScale
,
sidebar
,
infobox
,
map
,
gotoAnything
))
p
.
then
(
handle_data
(
config
,
linkScale
,
sidebar
,
meshstats
,
infobox
,
map
,
gotoAnything
))
})
}
function
handle_data
(
config
,
linkScale
,
sidebar
,
infobox
,
map
,
gotoAnything
)
{
function
handle_data
(
config
,
linkScale
,
sidebar
,
meshstats
,
infobox
,
map
,
gotoAnything
)
{
return
function
(
data
)
{
var
nodedict
=
data
[
0
]
var
nodes
=
Object
.
keys
(
nodedict
.
nodes
).
map
(
function
(
key
)
{
return
nodedict
.
nodes
[
key
]
})
...
...
@@ -94,12 +96,12 @@ require(["map", "infobox/main"], function (Map, Infobox) {
d
.
target
.
node
.
neighbours
.
push
({
node
:
d
.
source
.
node
,
link
:
d
})
})
map
.
setData
(
linkScale
,
sidebar
,
now
,
newnodes
,
lostnodes
,
onlinenodes
,
links
)
map
.
setData
(
linkScale
,
now
,
newnodes
,
lostnodes
,
onlinenodes
,
links
)
meshstats
.
setData
(
nodes
)
showMeshstats
(
sidebar
,
nodes
)
mkNodesList
(
sidebar
,
config
.
showContact
,
"
firstseen
"
,
gotoAnything
.
node
,
"
Neue Knoten
"
,
newnodes
)
mkNodesList
(
sidebar
,
config
.
showContact
,
"
lastseen
"
,
gotoAnything
.
node
,
"
Verschwundene Knoten
"
,
lostnodes
)
mkLinkList
(
sidebar
,
linkScale
,
gotoAnything
.
link
,
links
)
mkNodesList
(
sidebar
.
container
,
config
.
showContact
,
"
firstseen
"
,
gotoAnything
.
node
,
"
Neue Knoten
"
,
newnodes
)
mkNodesList
(
sidebar
.
container
,
config
.
showContact
,
"
lastseen
"
,
gotoAnything
.
node
,
"
Verschwundene Knoten
"
,
lostnodes
)
mkLinkList
(
sidebar
.
container
,
linkScale
,
gotoAnything
.
link
,
links
)
var
historyDict
=
{
nodes
:
{},
links
:
{}
}
...
...
@@ -121,31 +123,6 @@ require(["map", "infobox/main"], function (Map, Infobox) {
}
}
function
mkSidebar
(
el
)
{
var
sidebar
=
document
.
createElement
(
"
div
"
)
sidebar
.
classList
.
add
(
"
sidebar
"
)
el
.
appendChild
(
sidebar
)
var
button
=
document
.
createElement
(
"
button
"
)
sidebar
.
appendChild
(
button
)
button
.
classList
.
add
(
"
sidebarhandle
"
)
button
.
onclick
=
function
()
{
sidebar
.
classList
.
toggle
(
"
hidden
"
)
}
var
container
=
document
.
createElement
(
"
div
"
)
container
.
classList
.
add
(
"
container
"
)
sidebar
.
appendChild
(
container
)
container
.
getWidth
=
function
()
{
var
small
=
window
.
matchMedia
(
"
(max-width: 60em)
"
);
return
small
.
matches
?
0
:
sidebar
.
offsetWidth
}
return
container
}
function
mkLinkList
(
el
,
linkScale
,
gotoProxy
,
links
)
{
if
(
links
.
length
==
0
)
return
...
...
@@ -259,30 +236,6 @@ require(["map", "infobox/main"], function (Map, Infobox) {
el
.
appendChild
(
table
)
}
function
showMeshstats
(
el
,
nodes
)
{
var
h2
=
document
.
createElement
(
"
h2
"
)
h2
.
textContent
=
"
Übersicht
"
el
.
appendChild
(
h2
)
var
p
=
document
.
createElement
(
"
p
"
)
var
totalNodes
=
sum
(
nodes
.
filter
(
online
).
map
(
one
))
var
totalClients
=
sum
(
nodes
.
filter
(
online
).
map
(
function
(
d
)
{
return
d
.
statistics
.
clients
}))
var
totalGateways
=
sum
(
nodes
.
filter
(
online
).
filter
(
function
(
d
)
{
return
d
.
flags
.
gateway
}).
map
(
one
))
p
.
textContent
=
totalNodes
+
"
Knoten (online),
"
+
totalClients
+
"
Clients,
"
+
totalGateways
+
"
Gateways
"
p
.
appendChild
(
document
.
createElement
(
"
br
"
))
p
.
appendChild
(
document
.
createTextNode
(
"
Diese Daten sind
"
+
moment
.
utc
(
nodes
.
timestamp
).
fromNow
(
true
)
+
"
alt.
"
))
el
.
appendChild
(
p
)
}
function
pushHistory
(
d
)
{
var
s
=
"
#!
"
...
...
@@ -320,7 +273,7 @@ require(["map", "infobox/main"], function (Map, Infobox) {
}
}
function
gotoBuild
er
(
config
,
nodes
)
{
function
Rout
er
(
config
,
nodes
)
{
var
targets
=
[]
var
self
=
this
...
...
This diff is collapsed.
Click to expand it.
lib/map.js
+
1
−
1
View file @
0a90cdb7
...
...
@@ -76,7 +76,7 @@ define(function () {
var
nodeDict
=
{}
var
linkDict
=
{}
self
.
setData
=
function
(
linkScale
,
sidebar
,
now
,
newnodes
,
lostnodes
,
onlinenodes
,
links
)
{
self
.
setData
=
function
(
linkScale
,
now
,
newnodes
,
lostnodes
,
onlinenodes
,
links
)
{
nodeDict
=
{}
linkDict
=
{}
...
...
This diff is collapsed.
Click to expand it.
lib/meshstats.js
0 → 100644
+
34
−
0
View file @
0a90cdb7
define
(
function
()
{
return
function
()
{
var
self
=
this
var
p
self
.
setData
=
function
(
nodes
)
{
var
totalNodes
=
sum
(
nodes
.
filter
(
online
).
map
(
one
))
var
totalClients
=
sum
(
nodes
.
filter
(
online
).
map
(
function
(
d
)
{
return
d
.
statistics
.
clients
}))
var
totalGateways
=
sum
(
nodes
.
filter
(
online
).
filter
(
function
(
d
)
{
return
d
.
flags
.
gateway
}).
map
(
one
))
p
.
textContent
=
totalNodes
+
"
Knoten (online),
"
+
totalClients
+
"
Clients,
"
+
totalGateways
+
"
Gateways
"
p
.
appendChild
(
document
.
createElement
(
"
br
"
))
p
.
appendChild
(
document
.
createTextNode
(
"
Diese Daten sind
"
+
moment
.
utc
(
nodes
.
timestamp
).
fromNow
(
true
)
+
"
alt.
"
))
}
self
.
render
=
function
(
el
)
{
var
h2
=
document
.
createElement
(
"
h2
"
)
h2
.
textContent
=
"
Übersicht
"
el
.
appendChild
(
h2
)
p
=
document
.
createElement
(
"
p
"
)
el
.
appendChild
(
p
)
}
return
self
}
})
This diff is collapsed.
Click to expand it.
lib/sidebar.js
0 → 100644
+
34
−
0
View file @
0a90cdb7
define
([],
function
()
{
return
function
(
el
)
{
var
self
=
this
var
sidebar
=
document
.
createElement
(
"
div
"
)
sidebar
.
classList
.
add
(
"
sidebar
"
)
el
.
appendChild
(
sidebar
)
var
button
=
document
.
createElement
(
"
button
"
)
sidebar
.
appendChild
(
button
)
button
.
classList
.
add
(
"
sidebarhandle
"
)
button
.
onclick
=
function
()
{
sidebar
.
classList
.
toggle
(
"
hidden
"
)
}
var
container
=
document
.
createElement
(
"
div
"
)
container
.
classList
.
add
(
"
container
"
)
sidebar
.
appendChild
(
container
)
self
.
getWidth
=
function
()
{
var
small
=
window
.
matchMedia
(
"
(max-width: 60em)
"
);
return
small
.
matches
?
0
:
sidebar
.
offsetWidth
}
self
.
add
=
function
(
d
)
{
d
.
render
(
container
)
}
self
.
container
=
container
return
self
}
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment