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/lib/Ravada/I18N/ca.po b/lib/Ravada/I18N/ca.po index f094dba92..beb428291 100644 --- a/lib/Ravada/I18N/ca.po +++ b/lib/Ravada/I18N/ca.po @@ -2716,3 +2716,15 @@ 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?" + +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..574535e41 100644 --- a/lib/Ravada/I18N/en.po +++ b/lib/Ravada/I18N/en.po @@ -2544,3 +2544,21 @@ 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?" + +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..92f2a4134 100644 --- a/lib/Ravada/I18N/es.po +++ b/lib/Ravada/I18N/es.po @@ -2628,3 +2628,27 @@ 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?" + +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 d1c1aaf73..9cb4195b2 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -563,15 +563,21 @@ 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) { + $scope.maadminchine_to_confirm = machine; + $scope.action_to_confirm = action; + $('#global_autostart_modal').modal('show'); + return; } 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); @@ -585,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/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..aa0baa181 100644 --- a/templates/main/admin_machines.html.ep +++ b/templates/main/admin_machines.html.ep @@ -6,6 +6,24 @@
+ %= include 'bootstrap/navigation'
@@ -199,7 +217,7 @@
@@ -279,7 +297,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'
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 @@ +