From 50e5d0cda51a072b254b48feea89f0a3fd86f8e3 Mon Sep 17 00:00:00 2001 From: Yago Diaz Date: Mon, 22 Jun 2026 10:28:02 +0200 Subject: [PATCH 1/4] wip: Implemented previous canges Fixed minor errors issue #2185 --- lib/Ravada/Front.pm | 1 + public/js/admin.js | 12 ++++++---- public/js/ravada.js | 27 +++++++++++++++++----- script/rvd_front | 4 ++-- templates/main/admin_machines.html.ep | 32 ++++++++++++++++++++++----- templates/main/list_bases_ng.html.ep | 27 +++++++++++++++++++--- templates/main/vm_actions.html.ep | 15 +++++++------ 7 files changed, 91 insertions(+), 27 deletions(-) diff --git a/lib/Ravada/Front.pm b/lib/Ravada/Front.pm index d84a0ac9f..26f6bd32b 100644 --- a/lib/Ravada/Front.pm +++ b/lib/Ravada/Front.pm @@ -216,6 +216,7 @@ sub _get_clone_info($user, $base, $clone = Ravada::Front::Domain->open($base->{i ,is_active => $clone->is_active ,screenshot => $clone->_data('screenshot') ,date_changed => $clone->_data('date_changed') + ,autostart=> $clone->_data('autostart') }; $c->{can_hibernate} = ($clone->is_active && !$clone->is_volatile); diff --git a/public/js/admin.js b/public/js/admin.js index d1c1aaf73..a7f94df2e 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -563,15 +563,19 @@ ravadaApp.directive("solShowMachine", swMach) }); }; - $scope.action = function(target,action,machineId){ + $scope.action = function(target,action,machine, confirmed){ if (action === 'view-new-tab') { - window.open('/machine/view/' + machineId + '.html'); + window.open('/machine/view/' + machine.id + '.html'); } else if (action === 'view') { - window.location.assign('/machine/view/' + machineId + '.html'); + window.location.assign('/machine/view/' + machine.id + '.html'); + } + else if ((action === 'shutdown' || action === 'force_shutdown') && machine.autostart == 1 && !confirmed) { + machine.pending_shutdown_action = action; + $('#afc_' + mahchine.id).modal('show'); } else { - $http.get('/'+target+'/'+action+'/'+machineId+'.json') + $http.get('/'+target+'/'+action+'/'+machine.id+'.json') .then(function(response) { if(response.status == 300 || response.status == 403) { console.error('Reponse error', response.status); diff --git a/public/js/ravada.js b/public/js/ravada.js index 4efc57fde..056f67fea 100644 --- a/public/js/ravada.js +++ b/public/js/ravada.js @@ -47,7 +47,7 @@ }; - function suppFormCtrl($scope){ + function suppFormCtrl($scope){ this.user = {}; $scope.showErr = false; $scope.isOkey = function() { @@ -174,7 +174,7 @@ } } }; - + $scope.action = function(machine, action, confirmed) { machine.action = false; if (action == 'start') { @@ -200,6 +200,12 @@ $scope.host_shutdown = 0; $scope.host_force_shutdown = 0; } else if (action == 'shutdown' || action == 'hibernate' || action == 'force_shutdown' || action == 'reboot') { + if (machine.autostart == 1 && (action == 'shutdown' || action == 'force_shutdown') && !confirmed) { + machine.pending_shutdown_action = action; + $('#afc_' + machine.id).modal('show'); + return; + } + $scope.host_restore = 0; var id=machine.id; if (machine.clone) { @@ -332,6 +338,7 @@ subscribe_list_bookings(url); } }; + $scope.tmp_action = null; $scope.only_public = false; $scope.toggle_only_public=function() { $scope.only_public = !$scope.only_public; @@ -506,15 +513,21 @@ return string; }; - $scope.action = function(target,action,machineId,params){ + $scope.action = function(target,action,machine,params){ + params = params || {}; + if (action === 'view-new-tab') { - window.open('/machine/view/' + machineId + '.html'); + window.open('/machine/view/' + machine.id + '.html'); } else if (action === 'view') { - window.location.assign('/machine/view/' + machineId + '.html'); + window.location.assign('/machine/view/' + machine.id + '.html'); } + else if (action === 'shutdown' && machine.autostart == 1 && !params.confirmed) { + $scope.pending_shutdown_params = params; + $('#shutdownModal').modal('show'); + } else { - $http.get('/'+target+'/'+action+'/'+machineId+'.json'+'?'+this.getQueryStringFromObject(params)) + $http.get('/'+target+'/'+action+'/'+machine.id+'.json'+'?'+this.getQueryStringFromObject(params)) .then(function() { }, function(data,status) { console.error('Repos error', status, data); @@ -522,6 +535,8 @@ }); } }; + $scope.tmp_action = null; + $scope.force = null; var domainRequestsSocket = null; diff --git a/script/rvd_front b/script/rvd_front index a3a6c2bb2..e876f9d71 100644 --- a/script/rvd_front +++ b/script/rvd_front @@ -4594,9 +4594,9 @@ sub shutdown_machine { if ($domain) { my $req; $req = Ravada::Request->force_shutdown_domain(id_domain => $domain->id, uid => $USER->id) - if ($c->param('force')); + if ($c->param('force') eq 'true'); $req = Ravada::Request->shutdown_domain(id_domain => $domain->id, uid => $USER->id) - unless ($c->param('force')); + unless ($c->param('force') eq 'true'); $id_req = $req->id if $req; } return $c->redirect_to('/machines') if $type eq 'html'; diff --git a/templates/main/admin_machines.html.ep b/templates/main/admin_machines.html.ep index 6e00f25a2..ee7aad2f0 100644 --- a/templates/main/admin_machines.html.ep +++ b/templates/main/admin_machines.html.ep @@ -199,7 +199,7 @@ @@ -279,7 +279,7 @@
+ +
+ + <%=l 'Prepare base' %> + >Prepare base
<%=l 'Preparing a base will create a template for all the users to clone.' %> diff --git a/templates/main/vm_actions.html.ep b/templates/main/vm_actions.html.ep index a8af5d238..bdb97bfc3 100644 --- a/templates/main/vm_actions.html.ep +++ b/templates/main/vm_actions.html.ep @@ -2,7 +2,7 @@
+%= include 'main/vm_actions_shutdown_modal'
From 3ee18b91b0864b0d59b7f9ae9b90266d47544186 Mon Sep 17 00:00:00 2001 From: Yago Diaz Date: Mon, 22 Jun 2026 10:31:28 +0200 Subject: [PATCH 2/4] wip: Added needed file issue #2185 --- .../main/vm_actions_shutdown_modal.html.ep | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 templates/main/vm_actions_shutdown_modal.html.ep diff --git a/templates/main/vm_actions_shutdown_modal.html.ep b/templates/main/vm_actions_shutdown_modal.html.ep new file mode 100644 index 000000000..0b579806c --- /dev/null +++ b/templates/main/vm_actions_shutdown_modal.html.ep @@ -0,0 +1,18 @@ + From 95790ab080014f6a6404394a7384551ca5006548 Mon Sep 17 00:00:00 2001 From: Yago Diaz Date: Mon, 22 Jun 2026 11:46:35 +0200 Subject: [PATCH 3/4] Fixed spelling error Added translations to confirmation message issue #2185 --- lib/Ravada/I18N/ca.po | 9 +++++++++ lib/Ravada/I18N/en.po | 15 +++++++++++++++ lib/Ravada/I18N/es.po | 21 +++++++++++++++++++++ public/js/admin.js | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/Ravada/I18N/ca.po b/lib/Ravada/I18N/ca.po index f094dba92..62a66406e 100644 --- a/lib/Ravada/I18N/ca.po +++ b/lib/Ravada/I18N/ca.po @@ -2716,3 +2716,12 @@ msgstr "l'usuari pot iniciar i accedir a la pantalla de qualsevol màquina virtu msgid "Are you sure you want to remove this user?" msgstr "Estàs segur de voler eliminar aquest usuari?" + +msgid "Shutdown confirmation" +msgstr "Confirmació de tancament" + +msgid "Attention this machine has the autostart option activated!" +msgstr "Atenció aquesta màquina té l'opció d'inici automàtic activada!" + +msgid "Are you sure you want to shutdown the machine?" +msgstr "Estàs segur de voler apagar la màquina?" diff --git a/lib/Ravada/I18N/en.po b/lib/Ravada/I18N/en.po index 8f2ea5449..2273f2eb7 100644 --- a/lib/Ravada/I18N/en.po +++ b/lib/Ravada/I18N/en.po @@ -2544,3 +2544,18 @@ msgstr "the user can start and access the screen of any virtual machine" msgid "Are you sure you want to remove this user?" msgstr "Are you sure you want to remove this user?" + +msgid "Shutdown grace time" +msgstr "Shutdown grace time" + +msgid "Minutes of grace time before shutdown." +msgstr "Minutes of grace time before shutdown." + +msgid "Shutdown confirmation" +msgstr "Shutdown confirmation" + +msgid "Attention this machine has the autostart option activated!" +msgstr "Attention this machine has the autostart option activated!" + +msgid "Are you sure you want to shutdown the machine?" +msgstr "Are you sure you want to shutdown the machine?" diff --git a/lib/Ravada/I18N/es.po b/lib/Ravada/I18N/es.po index 76d247342..5213a6caf 100644 --- a/lib/Ravada/I18N/es.po +++ b/lib/Ravada/I18N/es.po @@ -2628,3 +2628,24 @@ msgstr "el usuario puede iniciar y acceder a la pantalla de cualquier máquina v msgid "Are you sure you want to remove this user?" msgstr "¿Estás seguro de querer eliminar este usuario?" + +msgid "Minutes of grace time before shutdown." +msgstr "Minutos de gracia antes de apagado." + +msgid "Shutdown grace time" +msgstr "Tiempo de gracia de apagado" + +msgid "list" +msgstr "lista" + +msgid "purge" +msgstr "purgar" + +msgid "Shutdown confirmation" +msgstr "Confirmación de apagado" + +msgid "Attention this machine has the autostart option activated!" +msgstr "¡Atención esta máquina tiene la opción de autoarranque activada!" + +msgid "Are you sure you want to shutdown the machine?" +msgstr "¿Estás seguro de querer apagar la máquina?" diff --git a/public/js/admin.js b/public/js/admin.js index a7f94df2e..c6fcbe3c6 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -572,7 +572,7 @@ ravadaApp.directive("solShowMachine", swMach) } else if ((action === 'shutdown' || action === 'force_shutdown') && machine.autostart == 1 && !confirmed) { machine.pending_shutdown_action = action; - $('#afc_' + mahchine.id).modal('show'); + $('#afc_' + machine.id).modal('show'); } else { $http.get('/'+target+'/'+action+'/'+machine.id+'.json') From d3f983f3cac00376658ece3397bc6a1717ddc585 Mon Sep 17 00:00:00 2001 From: Yago Diaz Date: Tue, 23 Jun 2026 11:57:20 +0200 Subject: [PATCH 4/4] Fix admin machines shutdown message Add last shutdown message translations issue #2185 --- lib/Ravada/I18N/ca.po | 3 ++ lib/Ravada/I18N/en.po | 3 ++ lib/Ravada/I18N/es.po | 3 ++ public/js/admin.js | 15 ++++++++-- templates/main/admin_machines.html.ep | 42 ++++++++++++--------------- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/lib/Ravada/I18N/ca.po b/lib/Ravada/I18N/ca.po index 62a66406e..beb428291 100644 --- a/lib/Ravada/I18N/ca.po +++ b/lib/Ravada/I18N/ca.po @@ -2725,3 +2725,6 @@ msgstr "Atenció aquesta màquina té l'opció d'inici automàtic activada!" msgid "Are you sure you want to shutdown the machine?" msgstr "Estàs segur de voler apagar la màquina?" + +msgid "Are you sure you want to shutdown the machine " +msgstr "Estàs segur de voler apagar la màquina " diff --git a/lib/Ravada/I18N/en.po b/lib/Ravada/I18N/en.po index 2273f2eb7..574535e41 100644 --- a/lib/Ravada/I18N/en.po +++ b/lib/Ravada/I18N/en.po @@ -2559,3 +2559,6 @@ msgstr "Attention this machine has the autostart option activated!" msgid "Are you sure you want to shutdown the machine?" msgstr "Are you sure you want to shutdown the machine?" + +msgid "Are you sure you want to shutdown the machine " +msgstr "Are you sure you want to shutdown the machine " diff --git a/lib/Ravada/I18N/es.po b/lib/Ravada/I18N/es.po index 5213a6caf..92f2a4134 100644 --- a/lib/Ravada/I18N/es.po +++ b/lib/Ravada/I18N/es.po @@ -2649,3 +2649,6 @@ msgstr "¡Atención esta máquina tiene la opción de autoarranque activada!" msgid "Are you sure you want to shutdown the machine?" msgstr "¿Estás seguro de querer apagar la máquina?" + +msgid "Are you sure you want to shutdown the machine " +msgstr "¿Estás seguro de querer apagar la máquina " diff --git a/public/js/admin.js b/public/js/admin.js index c6fcbe3c6..9cb4195b2 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -571,8 +571,10 @@ ravadaApp.directive("solShowMachine", swMach) window.location.assign('/machine/view/' + machine.id + '.html'); } else if ((action === 'shutdown' || action === 'force_shutdown') && machine.autostart == 1 && !confirmed) { - machine.pending_shutdown_action = action; - $('#afc_' + machine.id).modal('show'); + $scope.maadminchine_to_confirm = machine; + $scope.action_to_confirm = action; + $('#global_autostart_modal').modal('show'); + return; } else { $http.get('/'+target+'/'+action+'/'+machine.id+'.json') @@ -589,6 +591,15 @@ ravadaApp.directive("solShowMachine", swMach) ; } }; + $scope.prepare_shutdown = function(machine, action_name) { + if (machine.autostart == 1) { + $scope.machine_to_confirm = machine; + $scope.action_to_confirm = action_name; + $('#global_autostart_modal').modal('show'); + } else { + $scope.action('machine', action_name, machine, true); + } + }; $scope.set_autostart= function(machineId, value) { $http.get("/machine/autostart/"+machineId+"/"+value); }; diff --git a/templates/main/admin_machines.html.ep b/templates/main/admin_machines.html.ep index ee7aad2f0..aa0baa181 100644 --- a/templates/main/admin_machines.html.ep +++ b/templates/main/admin_machines.html.ep @@ -6,6 +6,24 @@
+ %= include 'bootstrap/navigation'
@@ -295,34 +313,12 @@ - -