Skip to content

Commit

Permalink
[#200] auto start checkbox on run machine
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jun 1, 2017
1 parent 0fc69dd commit cbdcf69
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
11 changes: 11 additions & 0 deletions public/js/ravada.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
.controller("bases", mainpageCrtl)
.controller("singleMachinePage", singleMachinePageC)
.controller("notifCrtl", notifCrtl)
.controller("run_domain",run_domain_ctrl)



Expand Down Expand Up @@ -225,6 +226,16 @@

};

function run_domain_ctrl($scope, $http, request ) {
$http.get('/auto_start').then(function(response) {
$scope.auto_start = response.auto_start;
});
$scope.toggle_auto_start = function() {
$http.get('/auto_start/toggle').then(function(response) {
$scope.auto_start = response.auto_start;
});
};
};
// list users
function usersCrtl($scope, $http, request, listUsers) {

Expand Down
25 changes: 24 additions & 1 deletion rvd_front.pl
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,26 @@
$c->render(template => 'main/settings');
};

any '/auto_start/(#value)/' => sub {
my $c = shift;
my $value = $c->stash('value');
if ($value =~ /toggle/i) {
$value = $c->session('auto_start');
if ($value) {
$value = 0;
} else {
$value = 1;
}
}
$c->session('auto_start' => $value);
return $c->render(json => {auto_start => $c->session('auto_start') });
};

get '/auto_start' => sub {
my $c = shift;
return $c->render(json => {auto_start => $c->session('auto_start') });
};

###################################################

## user_settings
Expand Down Expand Up @@ -1033,11 +1053,14 @@ sub show_link {
}
_open_iptables($c,$domain)
if !$req;
# $c->stash(url => $uri);
$c->stash(url => $uri) if $c->session('auto_start');
my ($display_ip, $display_port) = $uri =~ m{\w+://(\d+\.\d+\.\d+\.\d+):(\d+)};
$c->render(template => 'main/run'
,name => $domain->name
,password => $domain->spice_password
,url_display => $uri
,display_ip => $display_ip
,display_port => $display_port
,login => $c->session('login'));
}

Expand Down
18 changes: 15 additions & 3 deletions templates/main/run.html.ep
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

<!DOCTYPE html>
<html>
<html ng-app="ravada.app">
%= include 'bootstrap/header'
<body role="document">
%= include 'bootstrap/navigation'
<div class="container theme-showcase" role="main">
<div class="container theme-showcase" role="main" ng-controller="run_domain">
<div class="jumbotron">
<h2>Running <%= $name %></h2>
<h2>Running <a href="<%= $url_display %>"><%= $name %></a></h2>

<div class="panel-body">
<ul>
Expand All @@ -16,7 +16,19 @@
% }
<li><%=l 'Display URL :' %>
<a href="<%= $url_display %>"><%= $url_display %></a></li>
<li><%=l 'Display IP:' %> <b><%= $display_ip %></b></li>
<li><%=l 'Display Port:' %> <b><%= $display_port %></b></li>
</ul>
<label for="automatic"><input type="checkbox" ng-click="toggle_auto_start()"
% if ($c->session('auto_start')) {
checked
% }
>Start automatically next time</input>
<br/>
<a type="button" class="btn btn-success" href="<%= $url_display %>">
<b><%=l 'start' %></b> <%= $name %></a>
</div>
<div class="panel-body">
<div class="alert alert-warning">
<%=l 'It is required a viewer to run the virtual machines.' %>
<a href="/requirements"><%=l 'Read more.' %></a>
Expand Down

0 comments on commit cbdcf69

Please sign in to comment.