Add link speed to pills

If the clients API response include link speed information, show it in
clients' pills.
multi-ogserver
Javier Sánchez Parra 2022-05-05 17:33:44 +02:00
parent ce651453c4
commit 08cae4b6ca
2 changed files with 9 additions and 2 deletions

View File

@ -141,7 +141,9 @@ function updateScopeState() {
}, Interval);
}
function updatePillStatus(state, pill) {
function updatePillStatus(scope, pill) {
const state = scope.state
const link = scope.link
const pillCls = ['badge-danger', 'badge-success', 'badge-warning',
'badge-wol', 'badge-light'];
pill.classList.remove(...pillCls);
@ -156,6 +158,10 @@ function updatePillStatus(state, pill) {
} else {
pill.classList.add('badge-light');
}
$('[name="link"]', pill).remove()
if (link)
$(pill).append('<b name="link"><br>' + link + ' Mb/s'+ '</b>');
}
function updateScopes(scopes) {
@ -183,7 +189,7 @@ function updateScopes(scopes) {
const pillScopeId = `pill-${scopeId}`;
const pillEl = document.querySelector(`#${pillScopeId}`);
if (pillEl)
updatePillStatus(scope.state, pillEl);
updatePillStatus(scope, pillEl);
}
if (scope.scope) {
// This is a level so we should update all childs

View File

@ -139,6 +139,7 @@ def add_state_and_ips(scope, clients, ips):
client = next(filtered_client, False)
if client:
scope['state'] = client['state']
scope['link'] = client.get('speed')
else:
scope['state'] = 'off'
scope['ip'] = [scope['ip']]