From b6b16f895e72a049eeafc0e07eb9336d0bd9825e Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Thu, 18 Jan 2024 13:19:02 +0100 Subject: views: preselect most used bootmode In "set boot-mode" preselect bootmode that is most used by the clients selected. --- ogcp/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index c0b2c98..f560fa1 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -1347,7 +1347,11 @@ def action_mode(): flash(_('Ogserver replied with status code not ok'), category='error') return redirect(url_for('commands')) - available_modes = [(mode, mode) for mode in r.json()['modes']] + most_used_mode = max(modes_set, key=lambda m: len(modes_set[m])) + available_modes = [] + if most_used_mode in r.json()['modes']: + available_modes.append((most_used_mode, most_used_mode)) + available_modes.extend([(mode, mode) for mode in r.json()['modes'] if mode != most_used_mode]) if not available_modes: flash(_('no boot templates are available in the server'), category='error') -- cgit v1.2.3-18-g5258