From 6b33268b5c03db29cb003acb4e2042c9254402d2 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Tue, 10 Sep 2024 13:33:05 +0200 Subject: ogcp: add view to assign repo to clients Add /action/repo/set in Commands to assign a repository to multiple clients. The view includes the actual repo assigned in the client pills and shows a table with the clients grouped by repo when multiple repos are assigned among the selected clients. --- ogcp/forms/action_forms.py | 5 +++ ogcp/templates/actions/repo_set.html | 69 ++++++++++++++++++++++++++++++++++++ ogcp/templates/commands.html | 2 ++ ogcp/views.py | 62 +++++++++++++++++++++++++++++++- 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 ogcp/templates/actions/repo_set.html diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index b4dfe7b..49c9f60 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -189,6 +189,11 @@ class OgliveForm(FlaskForm): oglive = SelectField(label=_l('ogLive')) ok = SubmitField(label=_l('Submit')) +class SetRepoForm(FlaskForm): + ips = HiddenField() + repo = SelectField(label=_l('Repository')) + ok = SubmitField(label=_l('Submit')) + class ImageCreateForm(FlaskForm): ip = HiddenField() os = SelectField(label=_l('Partition'), choices=[]) diff --git a/ogcp/templates/actions/repo_set.html b/ogcp/templates/actions/repo_set.html new file mode 100644 index 0000000..bdd7abf --- /dev/null +++ b/ogcp/templates/actions/repo_set.html @@ -0,0 +1,69 @@ +{% extends 'commands.html' %} +{% import "bootstrap/wtf.html" as wtf %} +{% import "macros.html" as macros %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_setup %} active{% endblock %} +{% block content %} + +{% set ip_list = form.ips.data.split(' ') %} +{% set ip_count = ip_list | length %} +

+ {{ _('Changing repository of %(ip_count)d computer(s)', ip_count=ip_count) }} +

+ +{{ macros.cmd_selected_clients(selected_clients) }} + +{% if repos_set|length > 1 %} +
+

Selected clients have different ogLive

+ + + + + + + + + + {% for repo, clients in repos_set.items() %} + + + + + {% endfor %} + +
RepositoryClients
{{repo}} + {% for ip in clients %}
{{ ip }}
{% endfor %} +
+
+{% endif %} + +{{ wtf.quick_form(form, + action=url_for('action_repo_set'), + method='post', + button_map={'ok': 'primary'}, + extra_classes="m-5") }} + + + + + + + +{% endblock %} diff --git a/ogcp/templates/commands.html b/ogcp/templates/commands.html index 48630ea..41a0917 100644 --- a/ogcp/templates/commands.html +++ b/ogcp/templates/commands.html @@ -40,6 +40,8 @@