1
|
var module = angular.module('dedupInspector', ['ngRoute', 'dedupInspectorControllers']);
|
2
|
|
3
|
module.run(function($rootScope) {
|
4
|
$rootScope.Utils = {
|
5
|
keys : Object.keys,
|
6
|
values : Object.values
|
7
|
}
|
8
|
});
|
9
|
|
10
|
module.config([
|
11
|
'$routeProvider',
|
12
|
function($routeProvider) {
|
13
|
$routeProvider
|
14
|
.when('/add/:entityType', { templateUrl: '../resources/html/dedup/add.html', controller: 'addSimRelsCtrl' })
|
15
|
.when('/add/:entityType/:actionSet', { templateUrl: '../resources/html/dedup/add.html', controller: 'addSimRelsCtrl' })
|
16
|
.when('/add/:entityType/:actionSet/:query/:start', { templateUrl: '../resources/html/dedup/add.html', controller: 'addSimRelsCtrl' });
|
17
|
//.otherwise({ redirectTo: '/manage/all/0/10' });
|
18
|
}
|
19
|
]);
|
20
|
|
21
|
module.controller('moduleMenuCtrl', [ '$scope', '$location', '$http', '$routeParams',
|
22
|
function ($scope, $location, $http, $routeParams) {
|
23
|
$scope.app = {};
|
24
|
|
25
|
$scope.configurations = {};
|
26
|
|
27
|
//alert($scope.app.activeConf);
|
28
|
|
29
|
$scope.lookupConfigurations = function() {
|
30
|
$http.get('dedup/lookupConfigurations.do').success(function(res) {
|
31
|
if(res) {
|
32
|
$scope.configurations = res;
|
33
|
} else {
|
34
|
$scope.showError('Unable to lookup Dedup confs');
|
35
|
}
|
36
|
}).error(function(err) {
|
37
|
$scope.showError('Unable to lookup Dedup confs: ' + err.message);
|
38
|
});
|
39
|
}
|
40
|
if (jQuery.isEmptyObject($scope.configurations)) {
|
41
|
$scope.lookupConfigurations();
|
42
|
}
|
43
|
|
44
|
$scope.contains = function(array, s) {
|
45
|
for (var i = 0; i < array.length; i++) {
|
46
|
if (array[i] === s) {
|
47
|
return true;
|
48
|
}
|
49
|
}
|
50
|
return false;
|
51
|
}
|
52
|
}
|
53
|
]);
|
54
|
|
55
|
module.directive('bsHasError', function() {
|
56
|
return {
|
57
|
restrict: "A",
|
58
|
link: function(scope, element, attrs, ctrl) {
|
59
|
element.toggleClass('has-feedback', true);
|
60
|
var input = element.find('input[ng-model], select[ng-model]');
|
61
|
if (input) {
|
62
|
scope.$watch(function() {
|
63
|
if (input.hasClass('ng-invalid')) {
|
64
|
return 0;
|
65
|
} else if (input.hasClass('empty')) {
|
66
|
return 1;
|
67
|
} else {
|
68
|
return 2;
|
69
|
}
|
70
|
}, function(code) {
|
71
|
if (code < 0) return;
|
72
|
|
73
|
element.toggleClass('has-error', (code == 0));
|
74
|
element.toggleClass('has-warning', (code == 1));
|
75
|
element.toggleClass('has-success', (code == 2));
|
76
|
|
77
|
var feedback = element.find('.form-control-feedback');
|
78
|
if (feedback) {
|
79
|
feedback.toggleClass('glyphicon-remove', (code == 0));
|
80
|
feedback.toggleClass('glyphicon-warning-sign', (code == 1));
|
81
|
feedback.toggleClass('glyphicon-ok', (code == 2));
|
82
|
}
|
83
|
});
|
84
|
}
|
85
|
}
|
86
|
};
|
87
|
});
|
88
|
|
89
|
module.directive('compileTemplate', function($compile, $parse){
|
90
|
return {
|
91
|
link: function(scope, element, attr) {
|
92
|
var parsed = $parse(attr.ngBindHtml);
|
93
|
|
94
|
function getStringValue() { return (parsed(scope) || '').toString(); }
|
95
|
|
96
|
//Recompile if the template changes
|
97
|
scope.$watch(getStringValue, function() {
|
98
|
$compile(element, null, -9999)(scope); //The -9999 makes it skip directives so that we do not recompile ourselves
|
99
|
});
|
100
|
}
|
101
|
}
|
102
|
});
|
103
|
|
104
|
module.directive('ngDedupRecordsTable', function() {
|
105
|
return {
|
106
|
restrict: 'E',
|
107
|
scope: {
|
108
|
'theads' : '@',
|
109
|
'fields' : '@',
|
110
|
'results' : '=',
|
111
|
'group' : '=',
|
112
|
|
113
|
'showMergedFn' : '=',
|
114
|
'addToGroupFn' : '=',
|
115
|
'removeFromGroupFn' : '=',
|
116
|
'removeFromGroupAndDeassociateFn' : '=',
|
117
|
},
|
118
|
templateUrl: '../resources/html/dedup/recordTable.html',
|
119
|
link: function(scope, element, attrs, ctrl) {
|
120
|
scope.headers = scope.theads.split(",");
|
121
|
scope.fnames = scope.fields.split(",");
|
122
|
|
123
|
scope.containsList = function(idList, set) {
|
124
|
var res = true;
|
125
|
if (idList && set && set.length > 0) {
|
126
|
var ids = idList.split(",");
|
127
|
angular.forEach(ids, function(id) {
|
128
|
if(jQuery.grep(set, function(val, i) {
|
129
|
return val == id;
|
130
|
}).length == 0) {
|
131
|
res = false;
|
132
|
return;
|
133
|
};
|
134
|
});
|
135
|
} else {
|
136
|
return false;
|
137
|
}
|
138
|
return res;
|
139
|
}
|
140
|
}
|
141
|
}
|
142
|
});
|
143
|
|
144
|
module.service('groupService', function () {
|
145
|
var group = null;
|
146
|
var dissimilar = null;
|
147
|
return {
|
148
|
getGroup: function () { return group; },
|
149
|
setGroup: function (g) { group = g; },
|
150
|
|
151
|
getDissimilar: function () { return dissimilar; },
|
152
|
setDissimilar: function (d) { dissimilar = d; }
|
153
|
};
|
154
|
});
|
155
|
|
156
|
|
157
|
|