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

Confirms machine start if running machines limit reached (on admin machines)

parent 27c3c5ec
......@@ -300,25 +300,59 @@ ravadaApp.directive("solShowMachine", swMach)
}
}
$scope.request = function(request, args) {
$http.post('/request/'+request+'/'
,JSON.stringify(args)
).then(function(response) {
$scope.request = function(request, args) {
$http.post('/request/'+request+'/'
,JSON.stringify(args)
).then(function(response) {
if(response.status == 300 ) {
console.error('Response error', response.status);
window.location.reload();
}
});
};
});
};
$scope.action = function(target,action,machineId){
$http.get('/'+target+'/'+action+'/'+machineId+'.json')
.then(function(response) {
if(response.status == 300 ) {
console.error('Reponse error', response.status);
window.location.reload();
$scope.confirmingMachineStopOnNewMachineStartData = null;
$scope.confirmingMachineStopOnNewMachineStartDataCancelled = function() {
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.confirmingMachineStopOnNewMachineStartDataDone = function() {
$scope.action($scope.confirmingMachineStopOnNewMachineStartData.target, $scope.confirmingMachineStopOnNewMachineStartData.action, $scope.confirmingMachineStopOnNewMachineStartData.machine, true);
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.checkExecutionMachineLimits = function(target,action,machineId) {
$http.get('/execution_machines_limit')
.then(function(data) {
if ((data.data.can_start_many) || (data.data.running_domains.indexOf(machineId) >= 0) || (data.data.start_limit > data.data.running_domains.length)) {
$scope.action(target, action, machineId, true);
}
});
else {
$scope.confirmingMachineStopOnNewMachineStartData = { target: target, action: action, machine: machineId };
}
}, function(data,status) {
console.error('Repos error', status, data);
window.location.reload();
});
};
$scope.action = function(target,action,machineId,confirmed){
if (((action === 'start') || (action === 'view')) && (! confirmed)) {
$scope.checkExecutionMachineLimits(target, action, machineId);
}
else if (action === 'view') {
window.location.assign('/machine/view/' + machineId + '.html');
}
else {
$http.get('/'+target+'/'+action+'/'+machineId+'.json')
.then(function(response) {
if(response.status == 300 ) {
console.error('Reponse error', response.status);
window.location.reload();
}
});
}
};
$scope.set_autostart= function(machineId, value) {
$http.get("/machine/autostart/"+machineId+"/"+value);
......
......@@ -235,7 +235,7 @@
$scope.checkExecutionMachineLimits = function(target,action,machineId,params) {
$http.get('/execution_machines_limit')
.then(function(data) {
if ((data.data.cant_start_many) || (data.data.running_domains.indexOf(machineId) >= 0) || (data.data.start_limit > data.data.running_domains.length)) {
if ((data.data.can_start_many) || (data.data.running_domains.indexOf(machineId) >= 0) || (data.data.start_limit > data.data.running_domains.length)) {
$scope.action(target, action, machineId, params, true);
}
else {
......
......@@ -275,12 +275,11 @@
title="<%=l 'ShutDown' %>">
<i class="fa fa-power-off"></i>
</button>
<a type="button" class="btn btn-primary btn-sm"
ng-show="machine.can_view"
ng-href="/machine/view/{{machine.id}}.html"
<button type="button" class="btn btn-primary btn-sm"
ng-click="action('machine','view',showmachine.id)"
title="<%=l 'View' %>">
<i class="fa fa-desktop"></i>
</a>
</button>
</div>
<div ng-show="machine.is_locked" ng-cloak>Machine <a href="/request/{{machine.is_locked}}.html"><%=l 'locked' %></a></div>
<div ng-show="machine.is_base && !machine.is_locked"
......
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