Commit 9580c044 authored by robertperez-upc's avatar robertperez-upc Committed by Francesc Guasch
Browse files

Feat/1500 start clones seq/develop (#1537)

feat: add option to start all clones sequentially

* Adds Exec Time param

* Maybe exec-time of start/stop clones works on Firefox

* Disable buttons if start/stop time is in the past
parent ae0b1dc0
......@@ -191,6 +191,19 @@
};
function singleMachinePageC($scope, $http, $interval, request, $location) {
$scope.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
$scope.exec_time_start = new Date();
$scope.exec_time = new Date();
$scope.getUnixTimeFromDate = function(date) {
date = (date instanceof Date) ? date : date ? new Date(date) : new Date();
return date.getTime() / 1000;
};
$scope.isPastTime = function(date, now_date) {
return $scope.getUnixTimeFromDate(date) < $scope.getUnixTimeFromDate(now_date ? now_date : new Date());
};
var subscribed_extra = false;
subscribe_machine_info= function(url) {
var ws = new WebSocket(url);
......
......@@ -1168,6 +1168,10 @@ post '/request/(:name)/' => sub {
app->log->info($USER->name." requesting $name ".encode_json($args)) if $CONFIG_FRONT->{log}->{log};
my $req;
$name = 'start_clones_sequentially' if (($name eq 'start_clones') && ($args->{'exec_sequentially'}));
delete($args->{exec_sequentially});
delete($args->{at}) if ((! $args->{at}) || ($args->{at} < time()));
if ($name eq 'start_clones_sequentially') {
my $domain = $RAVADA->search_domain_by_id($args->{'id_domain'}) or do {
......
......@@ -2,18 +2,28 @@
<div class="row">
<label><%=l 'These actions affect all the clones on the machine' %></label>
</div>
<div class="row">
<div class="col-md-2"><label><%=l 'Exec. time' %></label></div>
<div class="col-md-10">
<input type="datetime-local" ng-model="exec_time" /> [ {{timezone}} ]
</div>
</div>
<div class="row">
<div class="col-md-12" align="left">
<input type="checkbox" name="exec_sequentially" ng-model="exec_sequentially"
ng-true-value="1" ng-false-value="0"
> <label><%=l 'Exec clones sequentially' %></label>
</div>
</div>
<div class="row">
<button class="btn btn-primary mr-2" id="start-clones" name="start-clones"
ng-click="request('start_clones_sequentially',{ 'id_domain': showmachine.id })"
>
<%=l 'Start all clones sequentially' %>
</button>
<button class="btn btn-primary mr-2" id="start-clones" name="start-clones"
ng-click="request('start_clones',{ 'id_domain': showmachine.id })"
ng-disabled="isPastTime(exec_time, exec_time_start)"
ng-click="request('start_clones',{ 'id_domain': showmachine.id, 'at': isPastTime(exec_time) ? '' : getUnixTimeFromDate(exec_time), 'exec_sequentially': exec_sequentially })"
>
<%=l 'Start all clones' %>
</button>
<button class="btn btn-danger" id="shutdown-clones" name="shutdown-clones"
ng-disabled="isPastTime(exec_time, exec_time_start)"
ng-click="shutdown_clones=1"
>
<%=l 'Shutdown all clones' %>
......@@ -26,7 +36,7 @@
<a type="button" class="btn btn-primary text-white"
ng-click="shutdown_clones=0"
><%=l 'No' %></a>
<a type="button" class="btn btn-danger text-white" ng-click="request('shutdown_clones',{ 'id_domain': showmachine.id });shutdown_clones=0"
<a type="button" class="btn btn-danger text-white" ng-click="request('shutdown_clones',{ 'id_domain': showmachine.id, 'at': isPastTime(exec_time) ? '' : getUnixTimeFromDate(exec_time) });shutdown_clones=0"
><%=l 'Yes, shutwdown all the clones' %></a>
</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