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 @@ -212,6 +212,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
11 changes: 7 additions & 4 deletions public/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,18 @@ 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.open_modal('afc_', machine);
}
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 Down
36 changes: 27 additions & 9 deletions public/js/ravada.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,21 @@
$scope.host_shutdown = 0;
$scope.host_force_shutdown = 0;
} else if (action == 'shutdown' || action == 'hibernate' || action == 'force_shutdown' || action == 'reboot') {
$scope.host_restore = 0;
var id=machine.id;
if (machine.clone) {
id=machine.clone.id;
if (machine.autostart == 1 && confirmed && (action == 'shutdown' || action == 'force_shutdown')) {
action = tmp_action;
}
if (machine.autostart == 1 && (action == 'shutdown' || action == 'force_shutdown') && !confirmed) {
$('#'+'afc_'+machine.id).modal({show:true})
tmp_action = action;
}
else {
$scope.host_restore = 0;
var id=machine.id;
if (machine.clone) {
id=machine.clone.id;
}
$http.get( '/machine/'+action+'/'+id+'.json');
}
$http.get( '/machine/'+action+'/'+id+'.json');
} else {
alert("unknown action "+action);
}
Expand Down Expand Up @@ -332,11 +341,13 @@
subscribe_list_bookings(url);
}
};
$scope.tmp_action = null;
$scope.only_public = false;
$scope.toggle_only_public=function() {
$scope.only_public = !$scope.only_public;
};
$scope.startIntro = startIntro;

};

function singleMachinePageC($scope, $http, $interval, request, $location) {
Expand Down Expand Up @@ -498,22 +509,29 @@
return string;
};

$scope.action = function(target,action,machineId,params){
$scope.action = function(target,action,machine,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' || action === 'force_shutdown') && machine.autostart == 1 && !params.confirmed) {
$('#shutdownModal').modal({show:true})
$scope.tmp_action = action;
$scope.force = params.force;
}
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 subscribe_requests = function(url) {
var ws = new WebSocket(url);
Expand Down
4 changes: 2 additions & 2 deletions script/rvd_front
Original file line number Diff line number Diff line change
Expand Up @@ -4408,9 +4408,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
32 changes: 27 additions & 5 deletions templates/main/admin_machines.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,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 +279,52 @@
<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="action('machine','shutdown',machine, false)"
ng-disabled="!machine.is_active"
ng-show="machine.can_shutdown"
title="<%=l 'ShutDown' %>">
<i class="fa fa-power-off"></i>
</button>
<!-- 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 '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', 'shutdown', machine, true)" class="btn btn-danger" data-dismiss="modal"><%=l 'Yes' %></button>
<button type="button" ng-click="cancel_modal(machine, undefined)" class="btn btn-secondary" data-dismiss="modal"
><%=l 'No' %></button>
</div>
</div>

</div>
</div>
<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
26 changes: 24 additions & 2 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,13 +83,35 @@
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 '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, 'shutdown', 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'"
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
20 changes: 20 additions & 0 deletions templates/main/vm_actions_shutdown_modal.html.ep
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div id="shutdownModal" 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 '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', tmp_action, showmachine, {force, confirmed: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>
Loading