From 4a74de1064c6cf0ef9ce10934efa24b63e661083 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 17 Jun 2024 12:52:32 +0200 Subject: ogcp: add move client to scopes management Add front end for the client/move REST API. Enable the move of multiple clients selected from the sidebar of Scopes Management. Show the target of the move operation as a list of paths in a dropdown widget in the form. Each path will be structured as: Server/Center/Room The path will also contain folders if they are present. --- ogcp/forms/action_forms.py | 5 +++ ogcp/templates/actions/client_move.html | 25 +++++++++++++ ogcp/templates/scopes.html | 2 ++ ogcp/views.py | 63 ++++++++++++++++++++++++++++++++- 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 ogcp/templates/actions/client_move.html diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index 718bd3d..9e3a9f6 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -142,6 +142,11 @@ class ClientDetailsForm(FlaskForm): boot = SelectField(label=_l('Boot Mode'), validate_choice=False) submit = SubmitField(label=_l('Submit')) +class ClientMoveForm(FlaskForm): + ips = HiddenField() + scopes = SelectField(label=_l('Scopes'), validate_choice=False) + submit = SubmitField(label=_l('Submit')) + class ImportClientsForm(FlaskForm): server = HiddenField() room = SelectField(label=_l('Room')) diff --git a/ogcp/templates/actions/client_move.html b/ogcp/templates/actions/client_move.html new file mode 100644 index 0000000..d9bcaac --- /dev/null +++ b/ogcp/templates/actions/client_move.html @@ -0,0 +1,25 @@ +{% extends 'scopes.html' %} +{% import "bootstrap/wtf.html" as wtf %} +{% import "macros.html" as macros %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_client %} active {% endblock %} +{% block nav_client_move %} active {% endblock %} +{% block content %} + +{% set ip_list = form.ips.data.split(' ') %} +{% set ip_count = ip_list | length %} +

+ {{ _('Move %(ip_count)d client(s)', ip_count=ip_count) }} +

+ +{{ macros.cmd_selected_clients(selected_clients) }} + +{{ wtf.quick_form(form, + method='post', + button_map={'submit': 'primary'}, + extra_classes="mx-5") }} + +{% endblock %} diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html index 0dde6a6..a96ae62 100644 --- a/ogcp/templates/scopes.html +++ b/ogcp/templates/scopes.html @@ -26,6 +26,8 @@ form="scopesForm" formaction="{{ url_for('action_client_add') }}" formmethod="get"> +