Show fork value over capacity adjuster slider

This commit is contained in:
Marliana Lara 2018-07-18 13:01:13 -04:00
parent 0e663f3967
commit 91900d5534
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 47 additions and 27 deletions

View File

@ -7,7 +7,8 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait, strings) {
templateUrl: templateUrl('instance-groups/capacity-adjuster/capacity-adjuster'),
restrict: 'E',
replace: true,
link: function(scope) {
link: function(scope, el, attrs, controller) {
const capacityAdjusterController = controller;
const adjustment_values = [{
label: strings.get('capacityAdjuster.CPU'),
value: scope.state.cpu_capacity,
@ -18,32 +19,48 @@ function CapacityAdjuster (templateUrl, ProcessErrors, Wait, strings) {
scope.min_capacity = _.min(adjustment_values, 'value');
scope.max_capacity = _.max(adjustment_values, 'value');
},
controller: function($http) {
const vm = this || {};
vm.slide = (state) => {
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');
});
};
capacityAdjusterController.init();
},
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'
};
}

View File

@ -1,5 +1,7 @@
<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">
<p>{{min_capacity.label}} {{min_capacity.value}}</p>
<input string-to-number

View File

@ -44,7 +44,8 @@ function InstanceGroupsStrings (BaseString) {
ns.capacityAdjuster = {
CPU: t.s('CPU'),
RAM: t.s('RAM')
RAM: t.s('RAM'),
FORKS: t.s('Forks')
};
ns.jobs = {