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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
(function() {
'use strict';
angular
.module('moon')
.controller('PolicyMapController', PolicyMapController);
PolicyMapController.$inject = ['$scope', 'alertService', '$translate', 'formService', 'policyService', 'pdpService', 'utilService'];
function PolicyMapController($scope, alertService, $translate, formService, policyService, pdpService, utilService ) {
var map = this;
/*
*
*/
map.pdps = [];
map.pdp = $scope.pdp;
map.addPolicyToList = false;
map.map = mapToPdp;
activate();
function activate() {
resolvePolicies();
}
function resolvePolicies() {
map.policiesLoading = true;
policyService.findAllWithCallback(function(policies){
map.policies = policies;
map.policiesLoading = false;
}
);
}
function mapToPdp() {
if (formService.isInvalid(map.form)) {
formService.checkFieldsValidity(map.form);
} else {
map.mappingLoading = true;
var pdpToSend = angular.copy(map.pdp);
pdpToSend.security_pipeline.push(map.selectedPolicy.id);
pdpService.update(pdpToSend, mapSuccess, mapError);
}
function mapSuccess(data) {
var pdpReceived = utilService.transformOne(data, 'pdps');
$translate('moon.policy.map.success', {pdpName: pdpReceived.name, policyName: map.selectedPolicy.name}).then(function (translatedValue) {
alertService.alertSuccess(translatedValue);
});
map.mappingLoading = false;
$scope.$emit('event:policyMapToPdpSuccess', pdpReceived);
}
function mapError(response) {
$translate('moon.policy.map.error', {
pdpName: map.pdp.name,
policyName: map.selectedPolicy.name
}).then(function (translatedValue) {
alertService.alertError(translatedValue);
});
map.mappingLoading = false;
$scope.$emit('event:policyMapToPdpError');
}
}
}
})();
|