Project

General

Profile

« Previous | Next » 

Revision 33139

repo selection

View differences:

addRepoApi.js
23 23
	};
24 24
});
25 25

  
26
module.directive('ngSelectRepoField', function($http) {
27
	return {
28
		restrict: 'E',
29
		scope: {
30
            'label'     : '@',
31
            'typology'  : '=',
32
            'selection' : '='
33
		},
34
		templateUrl: '../resources/html/addRepoApi/ngSelectRepoField.html',
35
		link: function(scope, element, attrs, ctrl) {
36
			scope.repositories = [];
37
			scope.current = '';
38
			scope.$watch('typology', function() {
39
				scope.repositories = [];
40
				if (scope.typology) {
41
					showSpinner();
42
					$http.get('listRepositories.json?type=' + scope.typology).success(function(data) {
43
						scope.repositories = data;
44
						hideSpinner();
45
					}).error(function() {
46
						show_notification("error", "An error occurred while fetching datasource of type " + scope.typology);
47
						hideSpinner();
48
					});
49
				}
50
			});
51
		}
52
	}
53
});
54

  
55

  
56
module.directive('ngFixedValueField', function() {
57
	return {
58
		restrict: 'E',
59
		scope: {
60
            'label'  : '@',
61
            'value'  : '='
62
		},
63
		templateUrl: '../resources/html/addRepoApi/ngFixedValueField.html'
64
	}
65
});
66

  
26 67
module.directive('ngApiIdValidation', function() {
27 68
	return {
28 69
		restrict: 'A',
......
43 84
		restrict: 'E',
44 85
		scope: {
45 86
			'label'     : '@',
46
			'prefix'    : '=',
87
			'prefix'    : '@',
47 88
			'selection' : '=',
48 89
			'exclusion' : '='
49 90
		},
......
130 171
	}
131 172
});
132 173

  
133
module.controller('addRepoApiCtrl', function ($scope, $http) {
174
module.controller('addRepoApiCtrl', function ($scope, $http, $sce, $location) {
175
	
176
	common_init($scope, $http, $sce, $location)
177
	
134 178
	$scope.values = {
135 179
		'compliances'         : getCompliances(),
136 180
		'types'               : getTypes(),
137 181
		'contentDescriptions' : getContentDescriptions(),
138 182
		'protocols'           : getProtocols()
139 183
	}
140
	$scope.repo = {};
141
	$scope.currentParams = [];
142
	$scope.api = {
143
		accessParams : {},
144
		extraFields : {}
145
	};
146 184
		
147
	$scope.searchDatasource = function(text) {
148
		$scope.repo = {
149
			'name' : text,
150
			'id'     : 'id1234',
151
			'prefix' : 'api::id_1234::',
152
			'apis'   : [ 'api::id_1234::test', 'api::id_1234::ftp', 'api::id_1234::oai' ]
185
	$scope.$watch('repo', function() {
186
		if ($scope.repo) {
187
			$scope.api = {
188
				'typology'     : $scope.repo.typology,
189
				'accessParams' : {},
190
				'extraFields'  : {}
191
			};
153 192
		}
154
		$scope.api = {
155
			accessParams : {},
156
			extraFields : {}
157
		};
158
	}
193
	});
159 194
	
160
	$scope.resetDatasource = function() {
195
	$scope.resetForm = function() {
196
		$scope.currentParams = [];
197
		$scope.selectedTypology = '';
161 198
		$scope.repo = {};
162 199
		$scope.api = {};
163 200
	}
164 201
	
165
	$scope.test = function(id) {
166
		alert(id);
167
	}
202
	$scope.resetForm();
168 203
});

Also available in: Unified diff