From 29ab4abf0d9ee969801d190eac827dd85083ab74 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Tue, 9 Aug 2022 19:11:00 +0200 Subject: Add current ogServer to scopesForm With this commit when users select a scope, the ogServer to which it belongs is also sent. Then when processing the form we obtain this ogServer and we can send it the pertinent requests. This commit also makes action "Add client" to use the ogServer sent in the form. --- ogcp/forms/action_forms.py | 1 + ogcp/static/js/ogcp.js | 6 ++++++ ogcp/templates/macros.html | 7 ++++++- ogcp/views.py | 24 ++++++++++++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ogcp/forms/action_forms.py b/ogcp/forms/action_forms.py index 951ea06..c81b326 100644 --- a/ogcp/forms/action_forms.py +++ b/ogcp/forms/action_forms.py @@ -98,6 +98,7 @@ class ImageRestoreForm(FlaskForm): restore = SubmitField(label=_l('Restore')) class ClientDetailsForm(FlaskForm): + server = HiddenField() name = StringField(label=_l('Name')) ip = StringField(label=_l('IP')) mac = StringField(label=_l('MAC')) diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 8678759..bdd7581 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -64,6 +64,12 @@ function checkParentsCheckboxes() { if (checkboxChildren.length == 0) return; + if (this.name == "scope-server") { + const checkedChildren = checkboxChildren.filter(":checked"); + checkbox.checked = checkedChildren.length > 0; + return; + } + const unCheckedChildren = checkboxChildren.filter(":not(:checked)"); checkbox.indeterminate = diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index 28c4f5a..f67b1a6 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -23,7 +23,12 @@ {% macro scopes_tree_collapse_level(scopes, parent_id, state) -%} {% for scope in scopes %}