|
|
@ -28,34 +28,34 @@ function humanTimeAgo(utcDate) { |
|
|
|
const filters = { |
|
|
|
bandwidth: node => `${prettyBytes(node.advertised_bandwidth)}/s`, |
|
|
|
uptime: node => { |
|
|
|
// Check node is up
|
|
|
|
// Check node is up
|
|
|
|
if (!node.running) { |
|
|
|
return 'Down'; |
|
|
|
} |
|
|
|
|
|
|
|
// Check uptime
|
|
|
|
// Check uptime
|
|
|
|
return humanTimeAgo(node.last_restarted); |
|
|
|
}, |
|
|
|
pagination: (req, direction) => { |
|
|
|
// Clone query string
|
|
|
|
// Clone query string
|
|
|
|
const query = Object.assign({}, req.query); |
|
|
|
|
|
|
|
// Set page as 1 by default
|
|
|
|
// Set page as 1 by default
|
|
|
|
query.p = query.p ? query.p : 1; |
|
|
|
|
|
|
|
// Update page
|
|
|
|
// Update page
|
|
|
|
if (direction === 'next') { |
|
|
|
query.p++; |
|
|
|
} else if (direction === 'prev') { |
|
|
|
query.p--; |
|
|
|
} |
|
|
|
|
|
|
|
// Don't add p var if it's page 1
|
|
|
|
// Don't add p var if it's page 1
|
|
|
|
if (query.p === 1) { |
|
|
|
delete query.p; |
|
|
|
} |
|
|
|
|
|
|
|
// Encode query string
|
|
|
|
// Encode query string
|
|
|
|
const queryString = querystring.encode(query); |
|
|
|
return queryString ? `/?${queryString}` : '/'; |
|
|
|
}, |
|
|
@ -69,8 +69,8 @@ const filters = { |
|
|
|
return name; |
|
|
|
}, |
|
|
|
status: node => node.running ? |
|
|
|
`Up for ${humanTimeAgo(node.last_restarted)}` : |
|
|
|
`Down for ${humanTimeAgo(node.last_seen)}` |
|
|
|
`Up for ${humanTimeAgo(node.last_restarted)}` : |
|
|
|
`Down for ${humanTimeAgo(node.last_seen)}` |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports = app => Object.keys(filters).forEach(filter => { |
|
|
|