From e3fda2c317c0329b7fff828cbd4d97e1b4818297 Mon Sep 17 00:00:00 2001 From: Benoit Seignovert Date: Tue, 20 Feb 2024 15:36:40 +0100 Subject: [PATCH] First cluster is always selected when present --- src/glicid_spawner/templates/views/slurm.jinja | 11 ++++++----- tests/test_form.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/glicid_spawner/templates/views/slurm.jinja b/src/glicid_spawner/templates/views/slurm.jinja index f00fb2e..5486b16 100644 --- a/src/glicid_spawner/templates/views/slurm.jinja +++ b/src/glicid_spawner/templates/views/slurm.jinja @@ -17,7 +17,8 @@
{%- for cluster in sinfo.values() -%}
- + @@ -27,7 +28,7 @@
{% endif %} -
+
{%- for cluster in sinfo.values() -%} @@ -125,9 +126,6 @@ not_enough_resources = function (err) { toggle_config = function() { var config = get_config(); - if (config['cluster'] !== undefined) { - $('.partitions').removeClass('hidden'); - } if (config['partition'] !== undefined) { $('.nodes').removeClass('hidden'); } @@ -140,6 +138,9 @@ toggle_config = function() { _toggle(el, config['cpu'], config['mem'], config['gpu'], config['cluster'], config['partition']); }) + // Reload config + config = get_config(); + if ($partitions.not('.hidden').length == 0) { $('.partitions').addClass('hidden'); } else { diff --git a/tests/test_form.py b/tests/test_form.py index a43417b..2a706a1 100644 --- a/tests/test_form.py +++ b/tests/test_form.py @@ -153,13 +153,18 @@ def test_options_form_slurm(mock_cluster): assert '
' in html assert '
' in html - assert '' in html + # The 1st cluster is always selected when present… + assert ( + '' in html + ) assert ( '' in html ) - # Partitions (hidden by default for multi-cluster) - assert '