Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Ravada/Front.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions lib/Ravada/I18N/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
18 changes: 18 additions & 0 deletions lib/Ravada/I18N/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
24 changes: 24 additions & 0 deletions lib/Ravada/I18N/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
23 changes: 19 additions & 4 deletions public/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
};
Expand Down
27 changes: 21 additions & 6 deletions public/js/ravada.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

};

function suppFormCtrl($scope){
function suppFormCtrl($scope){
this.user = {};
$scope.showErr = false;
$scope.isOkey = function() {
Expand Down Expand Up @@ -174,7 +174,7 @@
}
}
};

$scope.action = function(machine, action, confirmed) {
machine.action = false;
if (action == 'start') {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -506,22 +513,30 @@
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);
window.location.reload();
});
}
};
$scope.tmp_action = null;
$scope.force = null;

var domainRequestsSocket = null;

Expand Down
4 changes: 2 additions & 2 deletions script/rvd_front
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
28 changes: 23 additions & 5 deletions templates/main/admin_machines.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@
<div ng-controller="machinesPage" ng-init="subscribe_all('<%= url_for('ws_subscribe')->to_abs %>');n_clones_hide=<%= $n_clones_hide %>;check_netdata='<%= $check_netdata %>'"
id="controller"
>
<div class="modal fade" id="global_autostart_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><%=l 'Shutdown confirmation' %></h4>
</div>
<div class="modal-body">
<p><%=l 'Attention this machine has the autostart option activated!' %></p>
<p><%=l 'Are you sure you want to shutdown the machine?' %> </p>
</div>
<div class="modal-footer">
<button type="button" ng-click="action('machine', action_to_confirm, machine_to_confirm, true)" class="btn btn-danger" data-dismiss="modal"><%=l 'Yes' %></button>
<button type="button" class="btn btn-secondary" data-dismiss="modal"
><%=l 'No' %></button>
</div>
</div>
</div>
</div>
%= include 'bootstrap/navigation'
<div id="page-wrapper">
<div id="admin-content">
Expand Down Expand Up @@ -199,7 +217,7 @@
</div>
<div class="modal-footer" ng-show="machine.info">
<button type="button" class="btn btn-secondary" data-dismiss="modal" ng-click="cancel_modal(machine,'is_base')"><%=l 'No' %></button>
<button type="button" class="btn btn-primary" ng-click="cancel_modal(machine);action('machine','remove_base',machine.id)" ng-show="!machine.is_base" data-dismiss="modal"><%=l 'Yes' %></button>
<button type="button" class="btn btn-primary" ng-click="cancel_modal(machine);action('machine','remove_base',machine)" ng-show="!machine.is_base" data-dismiss="modal"><%=l 'Yes' %></button>
<button type="button" class="btn btn-primary" ng-click="cancel_modal();request('prepare_base',{ 'id_domain': machine.id, 'with_cd': with_cd })" ng-show="machine.is_base" data-dismiss="modal"><%=l 'Yes' %></button>
</div>
</div>
Expand Down Expand Up @@ -279,30 +297,30 @@
<td class="lgMachToggle" style="white-space:nowrap">
<div ng-hide="machine.is_locked||machine.is_base">
<button type="button" class="btn btn-success btn-sm"
ng-click="action('machine','start',machine.id)"
ng-click="action('machine','start',machine)"
ng-disabled="machine.is_active"
ng-show="machine.can_start"
title="<%=l 'Start' %>">
<i class="fa fa-play"></i>
</button>
<button
type="button" class="btn btn-warning btn-sm"
ng-click="action('machine','hibernate',machine.id)"
ng-click="action('machine','hibernate',machine)"
ng-disabled="!machine.is_active"
ng-show="machine.can_hibernate"
title="<%=l 'Hibernate' %>">
<i class="fa fa-pause"></i>
</button>
<button
type="button" class="btn btn-danger btn-sm"
ng-click="action('machine','shutdown',machine.id)"
ng-click="prepare_shutdown(machine, 'shutdown')"
ng-disabled="!machine.is_active"
ng-show="machine.can_shutdown"
title="<%=l 'ShutDown' %>">
<i class="fa fa-power-off"></i>
</button>
<button type="button" class="btn btn-primary btn-sm"
ng-click="action('machine','view-new-tab',machine.id)"
ng-click="action('machine','view-new-tab',machine)"
ng-show="machine.can_view"
title="<%=l 'View' %>">
<i class="fa fa-desktop"></i>
Expand Down
27 changes: 24 additions & 3 deletions templates/main/list_bases_ng.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a ng-show="machine.clone.is_active || machine.is_active" class="dropdown-item"
ng-click="machine.action=false;action(machine,'shutdown')">
ng-click="machine.action=false;action(machine,'shutdown', false)">
<i class="fa fa-angle-double-down" aria-hidden="true"></i>&nbsp;<%=l 'Shutdown'%></a>
<a ng-show="machine.clone.is_active || machine.is_active" class="dropdown-item"
ng-click="machine.action=false;action(machine,'reboot')">
Expand All @@ -83,17 +83,38 @@
ng-click="machine.action=false;action(machine,'hibernate')">
<i class="fa fa-snowflake" aria-hidden="true"></i>&nbsp;<%=l 'Hibernate' %></a>
<a ng-show="machine.is_active || machine.clone.is_active" class="dropdown-item"
ng-click="machine.action=false;action(machine,'force_shutdown')">
ng-click="machine.action=false;action(machine,'force_shutdown', false)">
<i class="fa fa-times" aria-hidden="true"></i>&nbsp;<%=l 'Poweroff' %></a>
<a ng-show="machine.clone.can_remove" class="dropdown-item"
ng-click="host_restore=machine.clone.id">
<i class="fa fa-trash" aria-hidden="true"></i>&nbsp;<%=l 'Restore' %></a>
</div>
</div>
<!-- Pop-up window confirming the shutdown action and force shutdown. #issue 2185 -->
<div id="afc_{{machine.id}}" class="modal fade">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><%=l 'Shutdown confirmation' %></h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<p><%=l 'Are you sure you want to shutdown the machine ' %> {{machine.name}} <%=l '?' %> </p>
</div>
<div class="modal-footer">
<button type="button" ng-click="action(machine, machine.pending_shutdown_action, true)" class="btn btn-danger" data-dismiss="modal"><%=l 'Yes' %></button>
<button type="button" class="btn btn-secondary" data-dismiss="modal"
><%=l 'No' %></button>
</div>
</div>

</div>
</div>
<a type="button" class="btn btn-primary text-white"
ng-show="!machine.is_base && !machine.action && !machine.is_active && machine.can_prepare_base"
ng-click="machine.action='prepare'"
><%=l 'Prepare base' %>
>Prepare base
</a>
<div ng-show="machine.action=='prepare'">
<%=l 'Preparing a base will create a template for all the users to clone.' %>
Expand Down
15 changes: 8 additions & 7 deletions templates/main/vm_actions.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<span ng-show="!showmachine"><i class="fas fa-sync-alt fa-spin"></i></span>
<div ng-show="!showmachine || showmachine.can_start">
<button type="button" class="btn btn-success btn-sm"
ng-click="action('machine','start',showmachine.id)"
ng-click="action('machine','start',showmachine)"
ng-disabled="!showmachine || showmachine.is_active"
title="<%=l 'Start' %>">
<i class="fa fa-play"></i>
Expand All @@ -13,7 +13,7 @@

<div ng-show="!showmachine || showmachine.can_view">
<button type="button" class="btn btn-primary btn-sm"
ng-click="action('machine','view',showmachine.id)"
ng-click="action('machine','view',showmachine)"
ng-disabled="!showmachine"
title="<%=l 'View' %>">
<i class="fa fa-desktop"></i>
Expand All @@ -24,7 +24,7 @@

<div ng-show="!showmachine || showmachine.can_hibernate">
<button type="button" class="btn btn-warning btn-sm"
ng-click="action('machine','hibernate',showmachine.id)"
ng-click="action('machine','hibernate',showmachine)"
ng-disabled="showmachine && !showmachine.is_active"
title="<%=l 'Hibernate' %>">
<i class="fa fa-pause"></i>
Expand All @@ -35,7 +35,7 @@

<div ng-show="showmachine.can_shutdown">
<button type="button" class="btn btn-danger btn-sm"
ng-click="action('machine','shutdown',showmachine.id)"
ng-click="action('machine','shutdown',showmachine, {force: false, confirmed: false})"
ng-disabled="!showmachine || !showmachine.is_active"
title="<%=l 'ShutDown' %>">
<i class="fa fa-power-off"></i>
Expand All @@ -46,7 +46,7 @@

<div ng-show="showmachine.can_shutdown">
<button type="button" class="btn btn-danger btn-sm"
ng-click="action('machine','shutdown',showmachine.id, { force: true })"
ng-click="action('machine','shutdown',showmachine, { force: true, confirmed: false})"
ng-disabled="!showmachine.is_active"
title="<%=l 'Force ShutDown' %>">
<i class="fa fa-power-off"></i>
Expand All @@ -57,7 +57,7 @@

<div ng-show="!showmachine || showmachine.can_reboot">
<button type="button" class="btn btn-danger btn-sm"
ng-click="action('machine','reboot',showmachine.id)"
ng-click="action('machine','reboot',showmachine, {force: false})"
ng-disabled="!showmachine || !showmachine.is_active"
title="<%=l 'Reboot' %>">
<i class="fa fa-redo"></i>
Expand All @@ -68,14 +68,15 @@

<div ng-show="showmachine.can_reboot">
<button type="button" class="btn btn-danger btn-sm"
ng-click="action('machine','reboot',showmachine.id, { force: true })"
ng-click="action('machine','reboot',showmachine, { force: true })"
ng-disabled="!showmachine.is_active"
title="<%=l 'Force Reboot' %>">
<i class="fa fa-redo"></i>
</button>
<span><%=l 'Force Reboot' %></span>
<br><br>
</div>
%= include 'main/vm_actions_shutdown_modal'

</div>

Expand Down
Loading
Loading