From 17f91229d6792aa182d1a67adf323488bf2d784d Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Thu, 25 Aug 2022 17:22:54 +0200 Subject: Add ogServer parameter to imagesForm When users select an image, its ogServer is sent too. Then, the back-end (flask) processes the form to obtain this ogServer and send it the pertinent requests. It also makes "Image details" view use this new parameter, and adds javascript code to ensure that users can only work with several images at the same time if they belong to the same ogServer. --- ogcp/static/js/ogcp.js | 17 +++++++++++++++++ ogcp/templates/images.html | 17 +++++++++++++++-- ogcp/views.py | 8 +++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index bdd7581..d5615b8 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -248,3 +248,20 @@ function RemovePartition(evt) { }); } +function checkImageServer() { + const images = $('input:checkbox[form|="imagesForm"]:not(:hidden)') + + images.on('change', function() { + const selectedServer = $('#' + $.escapeSelector(this.dataset.server)); + const serversSelector = 'input:checkbox[name|="image-server"]'; + const nonSelectedServers = $(serversSelector).not(selectedServer); + + selectedServer.prop('checked', true); + + nonSelectedServers.each(function() { + $(this).prop('checked', false); + const checkboxes = $('input:checkbox[data-server|="' + this.id + '"]'); + checkboxes.prop('checked', false); + }); + }); +} diff --git a/ogcp/templates/images.html b/ogcp/templates/images.html index 4231df2..d053913 100644 --- a/ogcp/templates/images.html +++ b/ogcp/templates/images.html @@ -8,17 +8,31 @@ {{ super() }} + + {% endblock %} {% block sidebar %}