diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-02-23 16:05:08 +0100 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-02-24 17:05:12 +0100 |
commit | 42ba24c9f9e751038cb63cef45016d231915fefe (patch) | |
tree | d854e520e43f07f728e0f7fbca90832aac30445e /ogcp | |
parent | cc008a0e628ace4ff8e94c6c7f94b87fe7839edd (diff) |
Refactor selected clients drawing in commands
Refactor duplicated code as a jinja macro.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/templates/actions/delete_client.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/image_restore.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/mode.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/oglive.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/poweroff.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/reboot.html | 7 | ||||
-rw-r--r-- | ogcp/templates/actions/wol.html | 7 | ||||
-rw-r--r-- | ogcp/templates/macros.html | 8 |
8 files changed, 22 insertions, 35 deletions
diff --git a/ogcp/templates/actions/delete_client.html b/ogcp/templates/actions/delete_client.html index 0c793c1..ea46b4f 100644 --- a/ogcp/templates/actions/delete_client.html +++ b/ogcp/templates/actions/delete_client.html @@ -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'), diff --git a/ogcp/templates/actions/image_restore.html b/ogcp/templates/actions/image_restore.html index 9742bbd..6120688 100644 --- a/ogcp/templates/actions/image_restore.html +++ b/ogcp/templates/actions/image_restore.html @@ -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'), diff --git a/ogcp/templates/actions/mode.html b/ogcp/templates/actions/mode.html index e2e9bcf..63f3d8f 100644 --- a/ogcp/templates/actions/mode.html +++ b/ogcp/templates/actions/mode.html @@ -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'), diff --git a/ogcp/templates/actions/oglive.html b/ogcp/templates/actions/oglive.html index f35b371..ea85d00 100644 --- a/ogcp/templates/actions/oglive.html +++ b/ogcp/templates/actions/oglive.html @@ -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'), diff --git a/ogcp/templates/actions/poweroff.html b/ogcp/templates/actions/poweroff.html index 2ff9440..11b14d8 100644 --- a/ogcp/templates/actions/poweroff.html +++ b/ogcp/templates/actions/poweroff.html @@ -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'), diff --git a/ogcp/templates/actions/reboot.html b/ogcp/templates/actions/reboot.html index 5794a95..2b4cba6 100644 --- a/ogcp/templates/actions/reboot.html +++ b/ogcp/templates/actions/reboot.html @@ -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'), diff --git a/ogcp/templates/actions/wol.html b/ogcp/templates/actions/wol.html index 0692589..4dba226 100644 --- a/ogcp/templates/actions/wol.html +++ b/ogcp/templates/actions/wol.html @@ -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'), diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index 7864cd4..a839ce5 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -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 %} |