Commit 133b9401 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#303] Show a nicer timeout message

parent b6551295
......@@ -9,6 +9,7 @@ use Data::Dumper;
use Digest::SHA qw(sha256_hex);
use Hash::Util qw(lock_hash);
use Mojolicious::Lite 'Ravada::I18N';
use Time::Piece;
#use Mojolicious::Plugin::I18N;
use Mojo::Home;
......@@ -1140,6 +1141,7 @@ sub show_link {
}
$c->stash(description => $description);
$c->stash(domain => $domain );
$c->stash(msg_timeout => _message_timeout($domain));
$c->render(template => 'main/run'
,name => $domain->name
,password => $domain->spice_password
......@@ -1151,6 +1153,21 @@ sub show_link {
,login => $c->session('login'));
}
sub _message_timeout {
my $domain = shift;
my $msg_timeout = "in ".int($domain->run_timeout / 60 )
." minutes.";
for my $request ( $domain->list_requests ) {
if ( $request->command eq 'shutdown' ) {
my $t1 = Time::Piece->localtime($request->at_time);
my $t2 = localtime();
$msg_timeout = " in ".($t1 - $t2)->pretty;
}
}
return $msg_timeout;
}
sub _open_iptables {
my ($c, $domain) = @_;
my $req = Ravada::Request->open_iptables(
......
......@@ -17,15 +17,9 @@
% if ($description && $domain->run_timeout) {
<hr>
% }
% if ($domain->run_timeout ) {
% my $msg_timeout = "in ".int($domain->run_timeout / 60 )
% ." minutes.";
% for my $request ( $domain->list_requests ) {
% if ( $request->command eq 'shutdown' ) {
% $msg_timeout = " at ".localtime($request->at_time);
% }
% }
This machine will shut down <%= $msg_timeout %>.
% if ($msg_timeout ) {
This machine will shut down
<%= $msg_timeout %>.
% }
</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