Refactor selected clients drawing in commands

Refactor duplicated code as a jinja macro.
multi-ogserver
Javier Sánchez Parra 2022-02-23 16:05:08 +01:00
parent cc008a0e62
commit 42ba24c9f9
8 changed files with 22 additions and 35 deletions

View File

@ -1,5 +1,6 @@
{% extends 'scopes.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -9,11 +10,7 @@
{{ _('Delete %(ip_count)d client(s)', ip_count=ip_count) }}
</h1>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_client_delete'),

View File

@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -7,11 +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>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_image_restore'),

View File

@ -1,5 +1,6 @@
{% extends 'commands.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -7,11 +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>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_mode'),

View File

@ -1,5 +1,6 @@
{% extends 'commands.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -7,11 +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>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_oglive'),

View File

@ -1,5 +1,6 @@
{% extends 'commands.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -9,11 +10,7 @@
{{ _('Power off %(ip_count)d client(s)', ip_count=ip_count) }}
</h1>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_poweroff'),

View File

@ -1,5 +1,6 @@
{% extends 'commands.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -9,11 +10,7 @@
{{ _('Reboot %(ip_count)d client(s)', ip_count=ip_count) }}
</h1>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_reboot'),

View File

@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "macros.html" as macros %}
{% block content %}
@ -7,11 +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>
<ul class="list-group mx-5 list-group-horizontal-sm">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{{ macros.cmd_selected_clients(ip_list) }}
{{ wtf.quick_form(form,
action=url_for('action_wol'),

View File

@ -52,3 +52,11 @@
{% macro selected_clients() -%}
<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">
{% for ip in ip_list %}
<li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{% endmacro %}