blob: 403d71412aa417743f1934ccd6e2a96d1f88ba50 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var h = require('mercury').h;
var toArray = require('../../util').toArray;
module.exports = render;
function render(state, channels) {
var peers = toArray(state.peers).sort(sort);
return h('.constellation', [
h('ul.peers', peers.map(map))
]);
}
function map(peer) {
var chunks = peer.id.split('/');
var uuid = chunks[chunks.length - 1];
return h('li.peer', [
h('strong', peer.status + ': '),
h('span', uuid)
]);
}
// Sort an array of peers by revese alphabetical status.
function sort(a, b) {
if (a.status > b.status) {
return -1;
}
if (a.status < b.status) {
return 1;
}
return 0;
}