Commit 93643237 authored by Roberto P. Rubio's avatar Roberto P. Rubio
Browse files

Adds machine start confirmation on list-machines if limit per user reached

parent 665abd05
...@@ -97,9 +97,41 @@ ...@@ -97,9 +97,41 @@
); );
}; };
$scope.action = function(machine, action) { $scope.confirmingMachineStopOnNewMachineStartData = null;
$scope.confirmingMachineStopOnNewMachineStartDataCancelled = function() {
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.confirmingMachineStopOnNewMachineStartDataDone = function() {
$scope.action($scope.confirmingMachineStopOnNewMachineStartData.machine, $scope.confirmingMachineStopOnNewMachineStartData.action, true);
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.checkExecutionMachineLimits = function(action,machine) {
$http.get('/execution_machines_limit')
.then(function(data) {
if ((data.data.can_start_many) || (data.data.running_domains.indexOf(machine.id) >= 0) || (data.data.start_limit > data.data.running_domains.length)) {
$scope.action(machine, action, true);
}
else {
$scope.confirmingMachineStopOnNewMachineStartData = { action: action, machine: machine };
}
}, function(data,status) {
console.error('Repos error', status, data);
window.location.reload();
});
};
$scope.action = function(machine, action, confirmed) {
machine.action = false; machine.action = false;
if ( action == 'restore' ) { if (action == 'start') {
if (! confirmed) {
$scope.checkExecutionMachineLimits(action, machine);
} else {
window.location.assign('/machine/clone/' + machine.id + '.html');
}
} else if ( action == 'restore' ) {
$scope.host_restore = machine.id_clone; $scope.host_restore = machine.id_clone;
$scope.host_shutdown = 0; $scope.host_shutdown = 0;
$scope.host_force_shutdown = 0; $scope.host_force_shutdown = 0;
......
...@@ -38,9 +38,22 @@ ...@@ -38,9 +38,22 @@
</div> </div>
</div> </div>
<div class="card-body" id="step2"> <div class="card-body" id="step2">
<div ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'start')" class="row alert alert-warning" role="alert">
<div>
<span><%=l 'One of the machines that are currently running will be shutdown.' %></span>
<br>
<span><%=l 'Continue?' %></span>
<br>
</div>
<div class="pull-right">
<input type="button" class="btn btn-danger btn-xs" value="<%=l 'Yes' %>" ng-click="confirmingMachineStopOnNewMachineStartDataDone()">
<input type="button" class="btn btn-primary btn-xs" value="<%=l 'No' %>" ng-click="confirmingMachineStopOnNewMachineStartDataCancelled()">
</div>
<br>
</div>
<div class="row"> <div class="row">
<a type="button" class="btn btn-success mr-2" ng-hide="machine.action" <a type="button" class="btn btn-success mr-2" ng-hide="machine.action"
href="/machine/clone/{{machine.id}}.html"><strong><i class="fa fa-play" aria-hidden="true"></i>&nbsp;<%=l 'Start' %></strong></a> ng-click="action(machine,'start')"><strong><i class="fa fa-play" aria-hidden="true"></i>&nbsp;<%=l 'Start' %></strong></a>
<div class="dropdown"> <div class="dropdown">
<button ng-show="machine.is_active && !machine.action" class="btn btn-secondary dropdown-toggle" <button ng-show="machine.is_active && !machine.action" class="btn btn-secondary dropdown-toggle"
ng-click="$parent.refresh=20" type="button" id="dropdownMenuButton" ng-click="$parent.refresh=20" type="button" id="dropdownMenuButton"
......
...@@ -11,10 +11,12 @@ ...@@ -11,10 +11,12 @@
</div> </div>
<div ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'start')" class="alert alert-warning" role="alert"> <div ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'start')" class="alert alert-warning" role="alert">
<span><%=l 'One of the machines that are currently running will be shutdown.' %></span> <div>
<br> <span><%=l 'One of the machines that are currently running will be shutdown.' %></span>
<span><%=l 'Continue?' %></span> <br>
<br> <span><%=l 'Continue?' %></span>
<br>
</div>
<div class="pull-right"> <div class="pull-right">
<input type="button" class="btn btn-danger btn-xs" value="<%=l 'Yes' %>" ng-click="confirmingMachineStopOnNewMachineStartDataDone()"> <input type="button" class="btn btn-danger btn-xs" value="<%=l 'Yes' %>" ng-click="confirmingMachineStopOnNewMachineStartDataDone()">
<input type="button" class="btn btn-primary btn-xs" value="<%=l 'No' %>" ng-click="confirmingMachineStopOnNewMachineStartDataCancelled()"> <input type="button" class="btn btn-primary btn-xs" value="<%=l 'No' %>" ng-click="confirmingMachineStopOnNewMachineStartDataCancelled()">
...@@ -33,10 +35,12 @@ ...@@ -33,10 +35,12 @@
</div> </div>
<div type="warning" ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'view')" class="alert alert-warning" role="alert"> <div type="warning" ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'view')" class="alert alert-warning" role="alert">
<span><%=l 'One of the machines that are currently running will be shutdown.' %></span> <div>
<br> <span><%=l 'One of the machines that are currently running will be shutdown.' %></span>
<span><%=l 'Continue?' %></span> <br>
<br> <span><%=l 'Continue?' %></span>
<br>
</div>
<div class="pull-right"> <div class="pull-right">
<input type="button" class="btn btn-primary btn-xs" value="<%=l 'Yes' %>" ng-click="confirmingMachineStopOnNewMachineStartDataDone()"> <input type="button" class="btn btn-primary btn-xs" value="<%=l 'Yes' %>" ng-click="confirmingMachineStopOnNewMachineStartDataDone()">
<input type="button" class="btn btn-primary btn-xs" value="<%=l 'No' %>" ng-click="confirmingMachineStopOnNewMachineStartDataCancelled()"> <input type="button" class="btn btn-primary btn-xs" value="<%=l 'No' %>" ng-click="confirmingMachineStopOnNewMachineStartDataCancelled()">
......
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