Project

General

Profile

« Previous | Next » 

Revision 34549

updated dedup UI, add similarity group almost done

View differences:

dedup_inspector_controllers.js
33 33
	
34 34
		common_init($scope, $http, $sce, $location);
35 35
	
36
		$scope.validEntityTypes = [ {id:'50', type:'result', label:'Publication'}, {id:'20', type:'organization', label:'Organization'} ];
36
		$scope.validEntityTypes = { 
37
			'result' 		: 	{id:'50', type:'result', label:'Publication'}, 
38
			'organization' 	: 	{id:'20', type:'organization', label:'Organization'} 
39
		};
40
		$scope.group = {
41
			group : [],
42
			entitytype : $scope.validEntityTypes[$routeParams.entitytype]
43
		};			
44

  
45
		$scope.groupIdDetails = {};
37 46
		
38
		$scope.entitytype = $routeParams.entitytype;
39
		$scope.tmpId = '';
40
		$scope.group = {
41
				group : []
42
		};		
47
		if($routeParams.query && $routeParams.query.length > 0) {
48
			$scope.query = $routeParams.query;
49
		}
50
		if($routeParams.start) {
51
			$scope.start = parseInt($routeParams.start);			
52
		} else {
53
			$scope.start = 0;
54
		}
55
		$scope.rows = 20;
43 56
	
57
		$scope.search = function() {
58
			$scope.showSpinner();
59
			var q = '';
60
			if($scope.query.match('^[0-9][0-9]\|.{12}::[a-zA-Z0-9]{32}$')) {
61
				q = 'objidentifier exact "' + $scope.query + '"';
62
			} else {
63
				q = $scope.query;
64
			}			
65
			$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
66
			$http.post('dedup/search.do', $.param({
67
				'entitytype' : $scope.group.entitytype.type,
68
				'query'  : q,
69
				'start'	 : $scope.start,
70
				'rows'	 : $scope.rows
71
			})).success(function(res) {
72
            	if(res) {
73
            		$scope.results = res;
74
            		$scope.hideSpinner();
75
            	} else {
76
                	$scope.hideSpinner();
77
            		$scope.showError('Registration failed');
78
            	}
79
			}).error(function(err) {
80
				$scope.hideSpinner();
81
				$scope.showError('Registration failed: ' + err.message);
82
			});			
83
		}		
84
		
85
		if($scope.query) {
86
			$scope.search();
87
		}
88
		
44 89
		$scope.resetForm = function() {
45
			$scope.group = {
46
					group : []
47
			};	
48
			$scope.tmpId = '';
90
			if (confirm('Reset group?')) {
91
				$scope.group.group = [];
92
				$scope.groupIdDetails = {};
93
			}
49 94
		}
50

  
51
		$scope.groupid = $routeParams.groupid;
52
		if($scope.groupid && $scope.groupid.length > 0) {
53
   			$scope.showSpinner();
54
   			$http.get('dedup/getSimpleGroup.do?groupid=' + $scope.groupid).success(
55
   				function(res) {
56
   					$scope.group = res;
57
               		$scope.hideSpinner();
58
   				}).error(function(err) {
59
   					$scope.hideSpinner();
60
   					$scope.showError('Unable to get group');
61
   				});
62
		}
63

  
95
		
64 96
		$scope.registerSimilarities = function() {
65 97
			if (confirm('Add new similarity group?')) {
66 98
				$scope.showSpinner();
67 99
				$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
68
				$http.post('dedup/addSimRels.do', $.param({
69
					'entityType' : $scope.group.entitytype.id,
70
					'idsCsv'  : $scope.group.group.join()
71
				})).success(function(res) {
100
				$http.post('dedup/addSimRels.do', $.param($scope.group)).success(function(res) {
72 101
	            	if(res) {
73 102
	            		$scope.showNotification('The Similarities has been registered');
74 103
	            		$scope.hideSpinner();
......
109 138
			}
110 139
		}
111 140
		
112
		$scope.$watch('tmpId', function() {
113
			if ($scope.tmpId) {
114
				$scope.group.group.push($scope.tmpId);
115
				$scope.tmpId = '';
116
			}			
117
		});
141

  
142
		
143
		$scope.searchById = function(objidentifier, entitytype) {
144
			if(!$scope.groupIdDetails[objidentifier]) {
145
				$http.post('dedup/searchById.do', $.param({
146
					'entitytype' : entitytype,
147
					'objidentifier' : objidentifier
148
				})).success(function(res) {
149
		        	if(res) {
150
		    			$scope.groupIdDetails[objidentifier] = res;
151
		        		$scope.hideSpinner();
152
		        	} else {
153
		            	$scope.hideSpinner();
154
		        		$scope.showError('Registration failed');
155
		        	}
156
				}).error(function(err) {
157
					$scope.hideSpinner();
158
					$scope.showError('Registration failed: ' + err.message);
159
				});			
160
			}
161
		}
162
		
163
		$scope.add = function(idCsv) {
164
			var size = $scope.group.group.length;
165
		    angular.forEach(idCsv.split(","), function(id) {
166
		    	if(jQuery.grep($scope.group.group, function(val, i) {
167
		    		  return val == id;
168
				}).length == 0) {
169
		        	$scope.group.group.push(id);
170
		    	} else {
171
		    		$scope.showError('id already selected');
172
		    	};
173
		    });	
174
		    var newSize = $scope.group.group.length - size;
175
		    if (newSize > 0) {
176
		    	$scope.showNotification('added ' + newSize + ' element(s)');
177
		    }
178
		}
179
		
180
		$scope.remove = function(idCsv) {
181
			var tmpGroup = [];
182
			var toRemove = idCsv.split(",");
183
			var size = $scope.group.group.length;
184
		    angular.forEach($scope.group.group, function(id) {
185
		    	if(jQuery.grep(toRemove, function(val, i) {
186
		    		  return val == id;
187
				}).length == 0) {
188
		        	tmpGroup.push(id);
189
		    	};
190
		    });
191
		    $scope.group.group = tmpGroup;
192
		    var newSize = size - tmpGroup.length;
193
		    if (newSize > 0) {
194
		    	$scope.showNotification('removed ' + newSize + ' element(s)');
195
		    }
196
		}	
197
		
198
		$scope.isSelected = function(idCsv) {
199
			var res = true;
200
			angular.forEach(idCsv.split(","), function(id) {
201
				if(jQuery.grep($scope.group.group, function(val, i) {
202
					  return val == id;
203
				}).length == 0) {
204
			    	res = false;
205
			    	return;
206
				};
207
			});
208
			return res;
209
		}
210
		
118 211
	}
119 212
]);
120 213

  
......
124 217

  
125 218
		common_init($scope, $http, $sce, $location);
126 219
		
127
		$scope.validEntityTypes = [ {id:'result' , name: 'Publication'}, {id:'organization' , name: 'Organization'}, {id:'all', name:'All'} ];
220
		$scope.validEntityTypes = [ {id:'result' , name: 'Publications'}, {id:'organization' , name: 'Organizations'}, {id:'all', name:'All'} ];
128 221
		
129 222
		$scope.groups = [];
130 223
		
131
		$scope.type = $routeParams.type;
132
		$scope.offset = parseInt($routeParams.offset);
133
		$scope.limit = parseInt($routeParams.limit);
224
		if($routeParams.type) {
225
			$scope.type = $routeParams.type;
226
		} else {
227
			$scope.type = 'all';
228
		}
229
		if($routeParams.offset) {
230
			$scope.offset = parseInt($routeParams.offset);
231
		} else {
232
			$scope.offset = 0;
233
		}
234
		if($routeParams.limit) {
235
			$scope.limit = parseInt($routeParams.limit);
236
		} else {
237
			$scope.limit = 0;
238
		}
134 239
		
135 240
		$scope.refresh = function() {
136 241
			$scope.showSpinner();

Also available in: Unified diff