Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
8d641c55
Commit
8d641c55
authored
Oct 30, 2020
by
fv3rdugo
Browse files
refactor(frontend): Add poweroff action
Issue #1407
parent
ab1c46e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/Request.pm
View file @
8d641c55
...
...
@@ -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
...
...
public/js/ravada.js
View file @
8d641c55
...
...
@@ -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
{
...
...
script/rvd_front
View file @
8d641c55
...
...
@@ -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);
...
...
templates/main/list_bases_ng.html.ep
View file @
8d641c55
...
...
@@ -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>
<
%=
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>
<
%=
l
'
Poweroff
'
%
></a>
</div>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment