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

Removed starting many machines dialog on admin pages

parent b9123de7
...@@ -311,37 +311,8 @@ ravadaApp.directive("solShowMachine", swMach) ...@@ -311,37 +311,8 @@ ravadaApp.directive("solShowMachine", swMach)
}); });
}; };
$scope.confirmingMachineStopOnNewMachineStartData = null; $scope.action = function(target,action,machineId){
if (action === 'view') {
$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'); window.location.assign('/machine/view/' + machineId + '.html');
} }
else { else {
......
...@@ -97,25 +97,25 @@ ...@@ -97,25 +97,25 @@
); );
}; };
$scope.confirmingMachineStopOnNewMachineStartData = null; $scope.confirming_stop_data = null;
$scope.confirmingMachineStopOnNewMachineStartDataCancelled = function() { $scope.confirmingStopCancelled = function() {
$scope.confirmingMachineStopOnNewMachineStartData = null; $scope.confirming_stop_data = null;
}; };
$scope.confirmingMachineStopOnNewMachineStartDataDone = function() { $scope.confirmingStopDone = function() {
$scope.action($scope.confirmingMachineStopOnNewMachineStartData.machine, $scope.confirmingMachineStopOnNewMachineStartData.action, true); $scope.action($scope.confirming_stop_data.machine, $scope.confirming_stop_data.action, true);
$scope.confirmingMachineStopOnNewMachineStartData = null; $scope.confirming_stop_data = null;
}; };
$scope.checkExecutionMachineLimits = function(action,machine) { $scope.checkMaxMachines = function(action,machine) {
$http.get('/execution_machines_limit') $http.get('/execution_machines_limit')
.then(function(data) { .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)) { 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); $scope.action(machine, action, true);
} }
else { else {
$scope.confirmingMachineStopOnNewMachineStartData = { action: action, machine: machine }; $scope.confirming_stop_data = { action: action, machine: machine };
} }
}, function(data,status) { }, function(data,status) {
console.error('Repos error', status, data); console.error('Repos error', status, data);
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
machine.action = false; machine.action = false;
if (action == 'start') { if (action == 'start') {
if (! confirmed) { if (! confirmed) {
$scope.checkExecutionMachineLimits(action, machine); $scope.checkMaxMachines(action, machine);
} else { } else {
window.location.assign('/machine/clone/' + machine.id + '.html'); window.location.assign('/machine/clone/' + machine.id + '.html');
} }
...@@ -253,37 +253,8 @@ ...@@ -253,37 +253,8 @@
return string; return string;
}; };
$scope.confirmingMachineStopOnNewMachineStartData = null; $scope.action = function(target,action,machineId,params){
if (action === 'view') {
$scope.confirmingMachineStopOnNewMachineStartDataCancelled = function() {
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.confirmingMachineStopOnNewMachineStartDataDone = function() {
$scope.action($scope.confirmingMachineStopOnNewMachineStartData.target, $scope.confirmingMachineStopOnNewMachineStartData.action, $scope.confirmingMachineStopOnNewMachineStartData.machine, $scope.confirmingMachineStopOnNewMachineStartData.params, true);
$scope.confirmingMachineStopOnNewMachineStartData = null;
};
$scope.checkExecutionMachineLimits = function(target,action,machineId,params) {
$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, params, true);
}
else {
$scope.confirmingMachineStopOnNewMachineStartData = { target: target, action: action, machine: machineId, params: params };
}
}, function(data,status) {
console.error('Repos error', status, data);
window.location.reload();
});
};
$scope.action = function(target,action,machineId,params,confirmed){
if (((action === 'start') || (action === 'view')) && (! confirmed)) {
$scope.checkExecutionMachineLimits(target, action, machineId, params);
}
else if (action === 'view') {
window.location.assign('/machine/view/' + machineId + '.html'); window.location.assign('/machine/view/' + machineId + '.html');
} }
else { else {
......
...@@ -2714,10 +2714,8 @@ sub get_execution_machines_limit_per_current_user { ...@@ -2714,10 +2714,8 @@ sub get_execution_machines_limit_per_current_user {
my $c = shift; my $c = shift;
return login($c) if !_logged_in($c); return login($c) if !_logged_in($c);
my $settings = $RAVADA->settings_global();
my %grants = $USER->grants(); my %grants = $USER->grants();
my $start_limit = ((exists($grants{'start_limit'})) && ($grants{'start_limit'} > 0)) ? $grants{'start_limit'} : $settings->{'backend'}->{'start_limit'}->{'value'}; my $start_limit = ((exists($grants{'start_limit'})) && ($grants{'start_limit'} > 0)) ? $grants{'start_limit'} : $RAVADA->settings_global()->{'backend'}->{'start_limit'}->{'value'};
my $can_start_many = $USER->can_start_many; my $can_start_many = $USER->can_start_many;
my @running_domains; my @running_domains;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</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 ng-show="(confirming_stop_data) && (confirming_stop_data.machine === machine)" class="row alert alert-warning" role="alert">
<div> <div>
<span><%=l 'One of the machines that are currently running will be shutdown.' %></span> <span><%=l 'One of the machines that are currently running will be shutdown.' %></span>
<br> <br>
...@@ -46,14 +46,14 @@ ...@@ -46,14 +46,14 @@
<br> <br>
</div> </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="confirmingStopDone()">
<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="confirmingStopCancelled()">
</div> </div>
<br> <br>
</div> </div>
<div class="row"> <div class="row">
<a type="button" class="btn btn-success mr-2" ng-hide="machine.action" <button class="btn btn-success mr-2" ng-hide="machine.action"
ng-click="action(machine,'start')"><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></button>
<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"
......
...@@ -10,20 +10,6 @@ ...@@ -10,20 +10,6 @@
<br><br> <br><br>
</div> </div>
<div ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'start')" class="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 ng-show="showmachine.can_view"> <div ng-show="showmachine.can_view">
<button type="button" class="btn btn-primary btn-sm" <button type="button" class="btn btn-primary btn-sm"
ng-click="action('machine','view',showmachine.id)" ng-click="action('machine','view',showmachine.id)"
...@@ -34,20 +20,6 @@ ...@@ -34,20 +20,6 @@
<br><br> <br><br>
</div> </div>
<div type="warning" ng-show="(confirmingMachineStopOnNewMachineStartData) && (confirmingMachineStopOnNewMachineStartData.action === 'view')" class="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-primary 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 ng-show="showmachine.can_hibernate"> <div ng-show="showmachine.can_hibernate">
<button type="button" class="btn btn-warning btn-sm" <button type="button" class="btn btn-warning btn-sm"
ng-click="action('machine','hibernate',showmachine.id)" ng-click="action('machine','hibernate',showmachine.id)"
......
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