mirror of https://git.48k.eu/ogcp
templates: add name and status to client list
Add a client name column to the client list view accessed through the Dashboard. Add status column to the client list. Move client status leyend into a separate file. Show the client status leyend in client list. Fix the 0 link speed conditional. Reuse the data returned by get_scopes() to reduce the number of requests.master
parent
6b33268b5c
commit
696a81fd11
|
@ -8,6 +8,8 @@
|
|||
|
||||
<div class="container mx-5">
|
||||
|
||||
{% include 'client_status_leyend.html' %}
|
||||
|
||||
{% for server_id, server_data in servers_data.items() %}
|
||||
<div class="accordion card" id="shellAccordion">
|
||||
<div class="card-header" id="heading_1">
|
||||
|
@ -22,8 +24,10 @@
|
|||
<table class="table table-hover">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>{{ _('Name') }}</th>
|
||||
<th>{{ _('IP') }}</th>
|
||||
<th>{{ _('Link speed') }}</th>
|
||||
<th>{{ _('Status') }}</th>
|
||||
<th>{{ _('Details') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -31,9 +35,10 @@
|
|||
<tbody data-target="cache-fieldset" id="cacheTable" class="text-left">
|
||||
{% for client_data in server_data.clients %}
|
||||
<tr data-toggle="fieldset-entry">
|
||||
<td>{{ client_data.name }}</td>
|
||||
<td>{{ client_data.addr }}</td>
|
||||
<td>
|
||||
{% if client_data.speed is not none %}
|
||||
{% if client_data.speed is not none and client_data.speed > 0 %}
|
||||
{% if client_data.speed >= 1000 %}
|
||||
{{ (client_data.speed / 1000) | int }} Gb/s
|
||||
{% else %}
|
||||
|
@ -43,6 +48,31 @@
|
|||
{{ _('Not available') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<i class="nav-icon fa-circle
|
||||
{% if client_data.state == 'OPG' and client_data.last_cmd.result == 'failure' %}
|
||||
fas text-warning fa-times-circle
|
||||
{% elif client_data.state == 'OPG' %}
|
||||
fas text-warning
|
||||
{% elif client_data.state == 'LNX' %}
|
||||
fas text-linux
|
||||
{% elif client_data.state == 'LNX' %}
|
||||
fas fa-user-circle text-linux
|
||||
{% elif client_data.state == 'WIN' %}
|
||||
fas text-windows
|
||||
{% elif client_data.state == 'WIN' %}
|
||||
fas fa-user-circle text-windows
|
||||
{% elif client_data.state == 'BSY' %}
|
||||
fas text-danger
|
||||
{% elif client_data.state == 'VDI' %}
|
||||
fas text-success
|
||||
{% elif client_data.state == 'WOL_SENT' %}
|
||||
fas text-wol
|
||||
{% else %}
|
||||
far
|
||||
{% endif %}
|
||||
"></i>
|
||||
</td>
|
||||
<td><a href="{{ url_for('action_client_info', client_ip = client_data.addr) }}">{{ _('View details') }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<ul id="clients-color-legend" class="d-flex flex-wrap justify-content-center nav ogcp-nav nav-pills">
|
||||
<li class="nav-item"><i class="nav-icon far fa-circle"></i> {{_('Shutdown')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-wol"></i> {{_('WoL sent')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-warning"></i> ogLive </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-danger"></i> {{_('Busy')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-linux"></i> Linux </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-user-circle text-linux"></i> {{_('Linux session')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-windows"></i> Windows </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-user-circle text-windows"></i> {{_('Windows session')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-success"></i> VDI </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -93,21 +93,9 @@
|
|||
|
||||
{% macro selected_clients() -%}
|
||||
<h2 class="mx-5 subhead-heading">{{_('Selected clients')}}</h2>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<ul id="clients-color-legend" class="d-flex flex-wrap justify-content-center nav ogcp-nav nav-pills">
|
||||
<li class="nav-item"><i class="nav-icon far fa-circle"></i> {{_('Shutdown')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-wol"></i> {{_('WoL sent')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-warning"></i> ogLive </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-danger"></i> {{_('Busy')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-linux"></i> Linux </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-user-circle text-linux"></i> {{_('Linux session')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-windows"></i> Windows </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-user-circle text-windows"></i> {{_('Windows session')}} </li>
|
||||
<li class="nav-item"><i class="nav-icon fas fa-circle text-success"></i> VDI </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include 'client_status_leyend.html' %}
|
||||
|
||||
<div id="selected-clients" class="d-flex flex-wrap justify-content-center"></div>
|
||||
{% endmacro %}
|
||||
|
||||
|
|
|
@ -222,10 +222,12 @@ def get_client_setup_json():
|
|||
|
||||
def get_clients(state_filter=None):
|
||||
responses = multi_request('get', '/clients')
|
||||
|
||||
clients_list = []
|
||||
for r in responses:
|
||||
clients_list = clients_list + r['json']['clients']
|
||||
req_clients = r['json']['clients']
|
||||
for client in req_clients:
|
||||
client['server'] = r['server']
|
||||
clients_list = clients_list + req_clients
|
||||
|
||||
clients = {}
|
||||
clients['clients'] = clients_list
|
||||
|
@ -600,21 +602,34 @@ def get_client_mac():
|
|||
return jsonify(pretty_mac)
|
||||
|
||||
|
||||
def get_server_data_from_scopes(scopes, clients):
|
||||
servers_data = {}
|
||||
|
||||
ip_to_name = {ip: c['name'] for c in parse_scopes_from_tree(scopes, 'computer') for ip in c['ip']}
|
||||
|
||||
for client in clients['clients']:
|
||||
client['name'] = ip_to_name[client['addr']]
|
||||
server_id = client['server'].id
|
||||
if server_id not in servers_data:
|
||||
servers_data[server_id] = {'clients': []}
|
||||
|
||||
for server in servers:
|
||||
if server.id == server_id:
|
||||
servers_data[server_id]['name'] = server.name
|
||||
|
||||
servers_data[server_id]['clients'].append(client)
|
||||
|
||||
for server_id in servers_data:
|
||||
servers_data[server_id]['clients'].sort(key=lambda x: x['name'])
|
||||
|
||||
return servers_data
|
||||
|
||||
@app.route('/client/list', methods=['GET'])
|
||||
@login_required
|
||||
def client_list():
|
||||
clients_response = multi_request('get', '/clients')
|
||||
servers_data = {}
|
||||
for i in clients_response:
|
||||
server_id = i['server'].id
|
||||
if server_id not in servers_data:
|
||||
servers_data[server_id] = {}
|
||||
servers_data[server_id]['clients'] = i['json']['clients']
|
||||
for server in servers:
|
||||
if server.id == server_id:
|
||||
servers_data[server_id]['name'] = server.name
|
||||
|
||||
scopes, clients = get_scopes()
|
||||
servers_data = get_server_data_from_scopes(scopes, clients)
|
||||
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
|
||||
return render_template('client_list.html', servers_data=servers_data,
|
||||
|
|
Loading…
Reference in New Issue