mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Show fork value over capacity adjuster slider
This commit is contained in:
@@ -7,7 +7,8 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait, strings) {
|
|||||||
templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'),
|
templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'),
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
replace: true,
|
replace: true,
|
||||||
link: function(scope) {
|
link: function(scope, el, attrs, controller) {
|
||||||
|
const capacityAdjusterController = controller;
|
||||||
const adjustment_values = [{
|
const adjustment_values = [{
|
||||||
label: strings.get('capacityAdjuster.CPU'),
|
label: strings.get('capacityAdjuster.CPU'),
|
||||||
value: scope.state.cpu_capacity,
|
value: scope.state.cpu_capacity,
|
||||||
@@ -18,32 +19,48 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait, strings) {
|
|||||||
|
|
||||||
scope.min_capacity = _.min(adjustment_values, 'value');
|
scope.min_capacity = _.min(adjustment_values, 'value');
|
||||||
scope.max_capacity = _.max(adjustment_values, 'value');
|
scope.max_capacity = _.max(adjustment_values, 'value');
|
||||||
},
|
|
||||||
controller: function($http) {
|
|
||||||
const vm = this || {};
|
|
||||||
|
|
||||||
vm.slide = (state) => {
|
capacityAdjusterController.init();
|
||||||
Wait('start');
|
|
||||||
const data = {
|
|
||||||
"capacity_adjustment": `${state.capacity_adjustment}`
|
|
||||||
};
|
|
||||||
const req = {
|
|
||||||
method: 'PUT',
|
|
||||||
url: state.url,
|
|
||||||
data
|
|
||||||
};
|
|
||||||
$http(req)
|
|
||||||
.catch(({data, status}) => {
|
|
||||||
ProcessErrors(data, status, null, {
|
|
||||||
hdr: 'Error!',
|
|
||||||
msg: 'Call failed. Return status: ' + status
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
Wait('stop');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
controller: ['$scope', '$http', 'InstanceGroupsStrings',
|
||||||
|
function($scope, $http, strings) {
|
||||||
|
const vm = this || {};
|
||||||
|
vm.strings = strings;
|
||||||
|
|
||||||
|
function computeForks () {
|
||||||
|
$scope.forks = Math.floor($scope.min_capacity.value + ($scope.max_capacity.value - $scope.min_capacity.value) * $scope.state.capacity_adjustment);
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.init = () => {
|
||||||
|
computeForks();
|
||||||
|
};
|
||||||
|
|
||||||
|
vm.slide = (state) => {
|
||||||
|
Wait('start');
|
||||||
|
|
||||||
|
computeForks();
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
"capacity_adjustment": `${state.capacity_adjustment}`
|
||||||
|
};
|
||||||
|
const req = {
|
||||||
|
method: 'PUT',
|
||||||
|
url: state.url,
|
||||||
|
data
|
||||||
|
};
|
||||||
|
$http(req)
|
||||||
|
.catch(({data, status}) => {
|
||||||
|
ProcessErrors(data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Call failed. Return status: ' + status
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
Wait('stop');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
],
|
||||||
controllerAs: 'vm'
|
controllerAs: 'vm'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<div class="CapacityAdjuster">
|
<div class="CapacityAdjuster">
|
||||||
<span class="CapacityAdjuster-valueLabel">{{ state.capacity_adjustment }}</span>
|
<span class="CapacityAdjuster-valueLabel">
|
||||||
|
{{ forks }} {{:: vm.strings.get('capacityAdjuster.FORKS')}}
|
||||||
|
</span>
|
||||||
<div class="at-InputSlider">
|
<div class="at-InputSlider">
|
||||||
<p>{{min_capacity.label}} {{min_capacity.value}}</p>
|
<p>{{min_capacity.label}} {{min_capacity.value}}</p>
|
||||||
<input string-to-number
|
<input string-to-number
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ function InstanceGroupsStrings (BaseString) {
|
|||||||
|
|
||||||
ns.capacityAdjuster = {
|
ns.capacityAdjuster = {
|
||||||
CPU: t.s('CPU'),
|
CPU: t.s('CPU'),
|
||||||
RAM: t.s('RAM')
|
RAM: t.s('RAM'),
|
||||||
|
FORKS: t.s('Forks')
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.jobs = {
|
ns.jobs = {
|
||||||
|
|||||||
Reference in New Issue
Block a user