diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-05-11 17:32:10 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-05-13 11:34:44 +0200 |
commit | 4c6e3a90f10e90ad888f32738a408cadedb28aa3 (patch) | |
tree | 81cdcf2d9be4cad180578bb3c1ccc9321ba91292 /ogcp | |
parent | 08cae4b6caf164f3e7fd5609fec5d37158ea6330 (diff) |
Show last command result for clients in ogLive
If the last command sent to a client/s finishes with errors, their icons
in the scopes tree change to a yellow circle with an times sign inside.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/static/js/ogcp.js | 15 | ||||
-rw-r--r-- | ogcp/views.py | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 9612370..f9785e1 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -169,20 +169,25 @@ function updateScopes(scopes) { if (scope.state) { const scopeId = `${scope.name}_${scope.id}`.replaceAll(/[.]|[ ]/g, '_'); const iconEl = document.querySelector(`#${scopeId} .nav-icon`); - const iconCls = ['fas', 'far', 'text-danger', 'text-success', + const iconCls = ['fas', 'far', 'fa-circle', 'fa-check-circle', + 'fa-times-circle', 'text-danger', 'text-success', 'text-warning', 'text-wol']; iconEl.classList.remove(...iconCls); let newIconCls = []; if (scope.state === 'OPG') { newIconCls.push('fas', 'text-warning'); + if (scope.last_cmd.result === 'failure') + newIconCls.push('fa-times-circle'); + else + newIconCls.push('fa-circle'); } else if (scope.state === 'BSY') { - newIconCls.push('fas', 'text-danger'); + newIconCls.push('fas', 'fa-circle', 'text-danger'); } else if (scope.state === 'VDI') { - newIconCls.push('fas', 'text-success'); + newIconCls.push('fas', 'fa-circle', 'text-success'); } else if (scope.state === 'WOL_SENT') { - newIconCls.push('fas', 'text-wol'); + newIconCls.push('fas', 'fa-circle', 'text-wol'); } else { - newIconCls.push('far'); + newIconCls.push('far', 'fa-circle'); } iconEl.classList.add(...newIconCls); diff --git a/ogcp/views.py b/ogcp/views.py index 2d995fd..36bd216 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -140,6 +140,8 @@ def add_state_and_ips(scope, clients, ips): if client: scope['state'] = client['state'] scope['link'] = client.get('speed') + scope['last_cmd'] = {} + scope['last_cmd']['result'] = client.get('last_cmd').get('result') else: scope['state'] = 'off' scope['ip'] = [scope['ip']] |