mirror of https://git.48k.eu/ogcp
Use pill style in confirmation pages
Draw selected clients from confirmation pages like selected clients from scopes and commands pages.multi-ogserver
parent
dc8759d2b9
commit
3db3659499
|
@ -10,7 +10,7 @@
|
|||
{{ _('Delete %(ip_count)d client(s)', ip_count=ip_count) }}
|
||||
</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_client_delete'),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% set ip_count = ip_list | length %}
|
||||
<h1 class="m-5">Restore partition image to {{ip_count}} {%if ip_count > 1%}computers{% else %}computer{% endif %}</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_image_restore'),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% set ip_count = ip_list | length %}
|
||||
<h1 class="m-5">Changing boot mode of {{ip_count}} {%if ip_count > 1%}computers{% else %}computer{% endif %}</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_mode'),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% set ip_count = ip_list | length %}
|
||||
<h1 class="m-5">Changing ogLive of {{ip_count}} {%if ip_count > 1%}computers{% else %}computer{% endif %}</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_oglive'),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{{ _('Power off %(ip_count)d client(s)', ip_count=ip_count) }}
|
||||
</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_poweroff'),
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{{ _('Reboot %(ip_count)d client(s)', ip_count=ip_count) }}
|
||||
</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_reboot'),
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{{ _('Start %(ip_count)d client(s) session', ip_count=ip_count) }}
|
||||
</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_session'),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% set ip_count = ip_list | length %}
|
||||
<h1 class="m-5">Powering on {{ip_count}} {%if ip_count > 1%}computers{% else %}computer{% endif %}</h1>
|
||||
|
||||
{{ macros.cmd_selected_clients(ip_list) }}
|
||||
{{ macros.cmd_selected_clients(selected_clients) }}
|
||||
|
||||
{{ wtf.quick_form(form,
|
||||
action=url_for('action_wol'),
|
||||
|
|
|
@ -53,14 +53,16 @@
|
|||
<div id="selected-clients" class="d-flex flex-wrap justify-content-center"></div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro cmd_selected_clients(ip_list) -%}
|
||||
<ul class="list-group mx-5 list-group-horizontal-sm d-flex flex-wrap">
|
||||
{% set max_clients = 50 %}
|
||||
{% for ip in ip_list[:max_clients] %}
|
||||
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
|
||||
{% if loop.last %}
|
||||
<li class="list-group-item flex-fill list-group-item-info">...</li>
|
||||
{% macro cmd_selected_clients(selected_clients) -%}
|
||||
<div class="d-flex flex-wrap justify-content-center">
|
||||
{% set max_clients = 50 %}
|
||||
{% for name_id, ip in selected_clients[:max_clients] %}
|
||||
<div id="pill-{{ name_id|replace(".", "_") }}" class="badge badge-pill badge-light">
|
||||
{{ name_id }}<br>{{ ip }}
|
||||
</div>
|
||||
{% if loop.last and (selected_clients|length > max_clients) %}
|
||||
<div class="badge badge-pill badge-light">...</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
|
@ -277,7 +277,9 @@ def action_poweroff():
|
|||
form.ips.data = " ".join(ips)
|
||||
if validate_elements(ips):
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/poweroff.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
else:
|
||||
return redirect(url_for('commands'))
|
||||
|
@ -299,7 +301,9 @@ def action_wol():
|
|||
form.ips.data = " ".join(ips)
|
||||
if validate_elements(ips, min_len=1):
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/wol.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
else:
|
||||
return redirect(url_for('commands'))
|
||||
|
@ -470,8 +474,10 @@ def action_image_restore():
|
|||
for disk_id, part_id in part_choices ]
|
||||
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
|
||||
return render_template('actions/image_restore.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
|
||||
@app.route('/action/hardware', methods=['GET', 'POST'])
|
||||
|
@ -569,7 +575,9 @@ def action_session():
|
|||
f"{os['name']} ({os['disk']},{os['partition']})")
|
||||
form.os.choices.append(choice)
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/session.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
|
||||
@app.route('/action/client/info', methods=['GET'])
|
||||
|
@ -673,6 +681,20 @@ def action_client_add():
|
|||
form.create.render_kw = {"formaction": url_for('action_client_add')}
|
||||
return render_template('actions/client_details.html', form=form)
|
||||
|
||||
def get_selected_clients(scopes):
|
||||
selected_clients = dict()
|
||||
|
||||
for scope in scopes:
|
||||
scope_type = scope.get('type')
|
||||
selected = scope.get('selected')
|
||||
if ((scope_type == 'computer') and selected):
|
||||
name_id = scope.get('name') + '_' + str(scope.get('id'))
|
||||
selected_clients[name_id] = scope.get('ip')[0]
|
||||
else:
|
||||
selected_clients.update(get_selected_clients(scope['scope']))
|
||||
|
||||
return selected_clients
|
||||
|
||||
@app.route('/action/client/delete', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def action_client_delete():
|
||||
|
@ -696,7 +718,9 @@ def action_client_delete():
|
|||
form.ips.data = " ".join(ips)
|
||||
if validate_elements(ips):
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/delete_client.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
else:
|
||||
return redirect(url_for('scopes'))
|
||||
|
@ -728,7 +752,10 @@ def action_mode():
|
|||
|
||||
form.ok.render_kw = { 'formaction': url_for('action_mode') }
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
return render_template('actions/mode.html', form=form, scopes=scopes, clients=clients)
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/mode.html', form=form, scopes=scopes,
|
||||
selected_clients=selected_clients,
|
||||
clients=clients)
|
||||
|
||||
|
||||
@app.route('/action/oglive', methods=['GET', 'POST'])
|
||||
|
@ -765,7 +792,9 @@ def action_oglive():
|
|||
|
||||
form.ok.render_kw = {'formaction': url_for('action_oglive')}
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
return render_template('actions/oglive.html', form=form, scopes=scopes)
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/oglive.html', form=form, scopes=scopes,
|
||||
selected_clients=selected_clients)
|
||||
|
||||
|
||||
@app.route('/action/image/create', methods=['GET', 'POST'])
|
||||
|
@ -839,7 +868,9 @@ def action_reboot():
|
|||
form.ips.data = " ".join(ips)
|
||||
if validate_elements(ips):
|
||||
scopes, clients = get_scopes(set(ips))
|
||||
selected_clients = list(get_selected_clients(scopes['scope']).items())
|
||||
return render_template('actions/reboot.html', form=form,
|
||||
selected_clients=selected_clients,
|
||||
scopes=scopes)
|
||||
else:
|
||||
return redirect(url_for('commands'))
|
||||
|
|
Loading…
Reference in New Issue