-
Notifications
You must be signed in to change notification settings - Fork 92
/
ip-ip-lb-backend-probe.controller.js
44 lines (37 loc) · 1.22 KB
/
ip-ip-lb-backend-probe.controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import difference from 'lodash/difference';
angular.module('Module.ip.controllers').controller('IplbBackendSetProbeCtrl', ($scope, $rootScope, $translate, Ip, Iplb, Alerter) => {
$scope.data = $scope.currentActionData; // service
$scope.model = {};
$scope.loading = true;
Ip.getIpModels().then((models) => {
$scope.probes = difference(models['ip.LoadBalancingBackendProbeEnum'].enum, [$scope.data.backend.probe]);
$scope.loading = false;
});
$scope.orderByProbeAlias = function orderByProbeAlias(a) {
const result = $translate.instant(`iplb_backend_probe_${a.toUpperCase()}`);
return result === 'iplb_backend_probe_' ? a.toUpperCase() : result;
};
/* Action */
$scope.setProbe = function setProbe() {
$scope.loading = true;
Iplb
.putBackend(
$scope.data.selectedIplb.value,
$scope.data.backend.backend,
{
probe: $scope.model.probe,
},
)
.then(
() => {
$rootScope.$broadcast('iplb.backends.needUpdate');
},
(reason) => {
Alerter.alertFromSWS($translate.instant('iplb_backend_setprobe_failure'), reason);
},
)
.finally(() => {
$scope.resetAction();
});
};
});