1
|
var module = angular.module('repoEnablerUI', []);
|
2
|
|
3
|
module.controller('repoEnablerCtrl', function ($scope, $http, $sce, $location) {
|
4
|
$scope.currType = '';
|
5
|
$scope.repos = [];
|
6
|
$scope.types = getTypologies();
|
7
|
$scope.repoFilter = {name: ''};
|
8
|
|
9
|
common_init($scope, $http, $sce, $location)
|
10
|
|
11
|
$scope.selectType = function (type) {
|
12
|
|
13
|
if (type != $scope.currType) {
|
14
|
$scope.repos = [];
|
15
|
$scope.currType = type;
|
16
|
$scope.repoFilter = {name: ''};
|
17
|
}
|
18
|
|
19
|
$scope.showSpinner();
|
20
|
$http.get('listRepositories.json?type=' + type).success(
|
21
|
function (data) {
|
22
|
$scope.repos = data;
|
23
|
hideSpinner();
|
24
|
})
|
25
|
.error(
|
26
|
function () {
|
27
|
scope.showError("An error occurred while fetching datasource of type " + type);
|
28
|
$scope.hideSpinner();
|
29
|
});
|
30
|
}
|
31
|
|
32
|
$scope.setValidation = function (id, valid) {
|
33
|
$scope.showSpinner();
|
34
|
|
35
|
$http.get('validateRepo.do?b=' + valid + "&id=" + id).success(
|
36
|
function (data) {
|
37
|
var newId = data;
|
38
|
angular.forEach($scope.repos, function (r) {
|
39
|
if (r.id == id) {
|
40
|
r.id = newId;
|
41
|
r.valid = valid;
|
42
|
}
|
43
|
});
|
44
|
$scope.hideSpinner();
|
45
|
}
|
46
|
).error(
|
47
|
function () {
|
48
|
if (valid == false) {
|
49
|
$scope.showError('An error occurred: please verify that there are no workflows related to this datasource');
|
50
|
} else {
|
51
|
$scope.showError('An error occurred validating the datasource');
|
52
|
}
|
53
|
$scope.hideSpinner();
|
54
|
}
|
55
|
);
|
56
|
};
|
57
|
|
58
|
if ($scope.types.length > 0) {
|
59
|
$scope.selectType($scope.types[0].name);
|
60
|
}
|
61
|
|
62
|
});
|