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
d3bbf606
Commit
d3bbf606
authored
Apr 2, 2015
by
Nils Schneider
Browse files
Options
Downloads
Patches
Plain Diff
make nodelist.setData idempotent
parent
7ddfbd96
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/nodelist.js
+49
-52
49 additions, 52 deletions
lib/nodelist.js
with
49 additions
and
52 deletions
lib/nodelist.js
+
49
−
52
View file @
d3bbf606
define
([
"
tablesort
"
,
"
tablesort.numeric
"
],
function
(
Tablesort
)
{
define
([
"
tablesort
"
,
"
virtual-dom
"
,
"
tablesort.numeric
"
],
function
(
Tablesort
,
V
)
{
return
function
(
router
)
{
function
showUptime
(
el
,
now
,
d
)
{
function
showUptime
(
now
,
d
)
{
var
uptime
if
(
d
.
flags
.
online
&&
"
uptime
"
in
d
.
statistics
)
uptime
=
Math
.
round
(
d
.
statistics
.
uptime
/
3600
)
...
...
@@ -15,12 +16,11 @@ define(["tablesort", "tablesort.numeric"], function (Tablesort) {
else
s
=
uptime
+
"
h
"
el
.
textContent
=
s
el
.
setAttribute
(
"
data-sort
"
,
uptime
!==
undefined
?
-
uptime
:
0
)
return
{
v
:
s
,
sort
:
uptime
!==
undefined
?
-
uptime
:
0
}
}
var
self
=
this
var
el
var
el
,
tbody
,
sort
self
.
render
=
function
(
d
)
{
el
=
document
.
createElement
(
"
div
"
)
...
...
@@ -31,11 +31,14 @@ define(["tablesort", "tablesort.numeric"], function (Tablesort) {
if
(
data
.
nodes
.
all
.
length
===
0
)
return
if
(
!
tbody
)
{
var
h2
=
document
.
createElement
(
"
h2
"
)
h2
.
textContent
=
"
Alle Knoten
"
el
.
appendChild
(
h2
)
var
table
=
document
.
createElement
(
"
table
"
)
el
.
appendChild
(
table
)
var
thead
=
document
.
createElement
(
"
thead
"
)
var
tr
=
document
.
createElement
(
"
tr
"
)
...
...
@@ -53,47 +56,41 @@ define(["tablesort", "tablesort.numeric"], function (Tablesort) {
tr
.
appendChild
(
th3
)
thead
.
appendChild
(
tr
)
table
.
appendChild
(
thead
)
var
tbody
=
document
.
createElement
(
"
tbody
"
)
data
.
nodes
.
all
.
forEach
(
function
(
d
)
{
var
row
=
document
.
createElement
(
"
tr
"
)
var
td1
=
document
.
createElement
(
"
td
"
)
var
a
=
document
.
createElement
(
"
a
"
)
a
.
textContent
=
d
.
nodeinfo
.
hostname
a
.
href
=
"
#
"
a
.
onclick
=
router
.
node
(
d
)
a
.
classList
.
add
(
"
hostname
"
)
a
.
classList
.
add
(
d
.
flags
.
online
?
"
online
"
:
"
offline
"
)
td1
.
appendChild
(
a
)
row
.
appendChild
(
td1
)
if
(
has_location
(
d
))
{
var
span
=
document
.
createElement
(
"
span
"
)
span
.
classList
.
add
(
"
icon
"
)
span
.
classList
.
add
(
"
ion-location
"
)
td1
.
appendChild
(
span
)
tbody
=
document
.
createElement
(
"
tbody
"
)
tbody
.
last
=
V
.
h
(
"
tbody
"
)
table
.
appendChild
(
tbody
)
sort
=
new
Tablesort
(
table
)
}
var
td2
=
document
.
createElement
(
"
td
"
)
showUptime
(
td2
,
data
.
now
,
d
)
row
.
appendChild
(
td2
)
var
td3
=
document
.
createElement
(
"
td
"
)
td3
.
text
Content
=
"
clients
"
in
d
.
statistics
?
d
.
statistics
.
clients
:
""
row
.
appendChild
(
td3
)
var
items
=
data
.
nodes
.
all
.
map
(
function
(
d
)
{
var
td1
Content
=
[]
var
aClass
=
[
"
hostname
"
,
d
.
flags
.
online
?
"
online
"
:
"
offline
"
]
tbody
.
appendChild
(
row
)
})
td1Content
.
push
(
V
.
h
(
"
a
"
,
{
className
:
aClass
.
join
(
"
"
),
onclick
:
router
.
node
(
d
),
href
:
"
#
"
},
d
.
nodeinfo
.
hostname
))
table
.
appendChild
(
tbody
)
if
(
has_location
(
d
))
td1Content
.
push
(
V
.
h
(
"
span
"
,
{
className
:
"
icon ion-location
"
}))
new
Tablesort
(
table
)
var
uptime
=
showUptime
(
data
.
now
,
d
)
el
.
appendChild
(
table
)
var
td1
=
V
.
h
(
"
td
"
,
td1Content
)
var
td2
=
V
.
h
(
"
td
"
,
{
attributes
:
{
"
data-sort
"
:
uptime
.
sort
}},
uptime
.
v
)
var
td3
=
V
.
h
(
"
td
"
,
"
clients
"
in
d
.
statistics
?
d
.
statistics
.
clients
:
""
)
return
V
.
h
(
"
tr
"
,
[
td1
,
td2
,
td3
])
})
var
tbodyNew
=
V
.
h
(
"
tbody
"
,
items
)
tbody
=
V
.
patch
(
tbody
,
V
.
diff
(
tbody
.
last
,
tbodyNew
))
tbody
.
last
=
tbodyNew
sort
.
refresh
()
}
}
})
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