1
|
var repoAccessParamsEditor = angular.module("repoAccessParamsEditor", ['wfFormFields']);
|
2
|
|
3
|
repoAccessParamsEditor.directive("repoAccessParamsModal", function ($http, $route) {
|
4
|
return {
|
5
|
restrict: 'E',
|
6
|
transclude: true,
|
7
|
replace:true,
|
8
|
scope: {
|
9
|
'protocol' : '@',
|
10
|
'dsId' : '@',
|
11
|
'iface' : '@',
|
12
|
'reload' : '@',
|
13
|
'visible' : '='
|
14
|
},
|
15
|
templateUrl: '/html/wf/repo-access-params-modal.html',
|
16
|
|
17
|
link: function (scope, element, attrs, ctrl) {
|
18
|
|
19
|
scope.fields = [];
|
20
|
|
21
|
$(element).modal({'show': false});
|
22
|
|
23
|
scope.$watch(function() {
|
24
|
return scope.visible;
|
25
|
}, function(value) {
|
26
|
if (value == true) {
|
27
|
$(element).modal('show');
|
28
|
scope.visible = false;
|
29
|
scope.fields = [];
|
30
|
scope.params = {};
|
31
|
scope.originalParams = {};
|
32
|
|
33
|
showSpinner();
|
34
|
|
35
|
$http.get("/ajax/wfs/protocolParameters?dsId=" + scope.dsId + "&ifaceId=" + scope.iface).success(
|
36
|
function (data) {
|
37
|
|
38
|
angular.forEach(data, function (value) {
|
39
|
scope.params[value.name] = '';
|
40
|
scope.originalParams[value.name] = '';
|
41
|
});
|
42
|
|
43
|
scope.fields = data;
|
44
|
hideSpinner();
|
45
|
}
|
46
|
).error(
|
47
|
function () {
|
48
|
showError('Something really bad must have happened to our fellow hamster..');
|
49
|
hideSpinner();
|
50
|
}
|
51
|
);
|
52
|
}
|
53
|
});
|
54
|
|
55
|
scope.updateRepoApi = function() {
|
56
|
showSpinner();
|
57
|
var map = {};
|
58
|
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
|
59
|
|
60
|
var params = {};
|
61
|
angular.forEach(scope.params, function (value, key) {
|
62
|
if (angular.isArray(value)) {
|
63
|
params[key] = value.join(',')
|
64
|
} else {
|
65
|
params[key] = value;
|
66
|
}
|
67
|
});
|
68
|
|
69
|
$http.post('repo/repoApi.update', $.param({
|
70
|
'id' : scope.dsId,
|
71
|
'iface' : scope.iface,
|
72
|
'accessParams': JSON.stringify(params)
|
73
|
})).success(function (data) {
|
74
|
show_notification('info', 'Api correctly saved !');
|
75
|
hideSpinner();
|
76
|
if (scope.reload) {
|
77
|
$route.reload();
|
78
|
}
|
79
|
}).error(function (err) {
|
80
|
show_notification('error', 'Error saving access parameters: ' + err.message);
|
81
|
hideSpinner();
|
82
|
});
|
83
|
};
|
84
|
|
85
|
}
|
86
|
}
|
87
|
});
|