Commit 8d641c55 authored by fv3rdugo's avatar fv3rdugo
Browse files

refactor(frontend): Add poweroff action

Issue #1407
parent ab1c46e3
......@@ -129,7 +129,7 @@ our %VALID_ARG = (
);
our %CMD_SEND_MESSAGE = map { $_ => 1 }
qw( create start shutdown prepare_base remove remove_base rename_domain screenshot download
qw( create start shutdown force_shutdown prepare_base remove remove_base rename_domain screenshot download
clone
set_base_vm remove_base_vm
domain_autostart hibernate hybernate
......
......@@ -101,7 +101,8 @@
if ( action == 'restore' ) {
$scope.host_restore = machine.id_clone;
$scope.host_shutdown = 0;
} else if (action == 'shutdown' || action == 'hibernate') {
$scope.host_force_shutdown = 0;
} else if (action == 'shutdown' || action == 'hibernate' || action == 'force_shutdown') {
$scope.host_restore = 0;
$http.get( '/machine/'+action+'/'+machine.id_clone+'.json');
} else {
......
......@@ -557,6 +557,12 @@ get '/machine/shutdown/(:id).(:type)' => sub {
return shutdown_machine($c);
};
get '/machine/force_shutdown/(:id).(:type)' => sub {
my $c = shift;
return access_denied($c) if !$USER ->can_shutdown($c->stash('id'));
return force_shutdown_machine($c);
};
any '/machine/remove/(:id).(:type)' => sub {
my $c = shift;
return access_denied($c) if !$USER->can_remove_machine($c->stash('id'));
......@@ -2210,6 +2216,17 @@ sub shutdown_machine {
return $c->render(json => { req => $req->id });
}
sub force_shutdown_machine {
my $c = shift;
return login($c) if !_logged_in($c);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->force_shutdown_domain(id_domain => $domain->id, uid => $USER->id);
return $c->redirect_to('/machines') if $type eq 'html';
return $c->render(json => { req => $req->id });
}
sub _do_remove_machine {
my $c = shift;
return login($c) if !_logged_in($c);
......
......@@ -56,7 +56,8 @@
<a ng-show="machine.is_active && machine.can_hibernate" class="dropdown-item"
ng-click="machine.action=false;action(machine,'hibernate')">
<i class="fa fa-snowflake" aria-hidden="true"></i>&nbsp;<%=l 'Hibernate' %></a>
<a class="dropdown-item" href="#">
<a ng-show="machine.is_active" class="dropdown-item"
ng-click="machine.action=false;action(machine,'force_shutdown')">
<i class="fa fa-times" aria-hidden="true"></i>&nbsp;<%=l 'Poweroff' %></a>
</div>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment