Project

General

Profile

« Previous | Next » 

Revision 57596

User Registration form

View differences:

organizations.js
1
var orgsModule = angular.module('orgs', ['ngRoute']);
1
var orgsModule = angular.module('orgs', ['ngRoute', 'checklist-model']);
2 2

  
3 3
orgsModule.config(function($routeProvider) {
4 4
	$routeProvider
......
268 268

  
269 269

  
270 270

  
271
orgsModule.controller('usersCtrl', function ($scope, $http) {
271
orgsModule.controller('usersCtrl', function ($scope, $http, $timeout, $route) {
272 272
	$scope.users = [];
273
	$scope.vocabularies = {};
273
	$scope.vocs = {};
274
	$scope.currentUser = {};
274 275
	
275 276
	$http.get('api/vocabularies').then(function successCallback(res) {
276
		$scope.vocabularies = res.data;
277
		$scope.vocs = res.data;
277 278

  
278 279
		$http.get('api/users').then(function successCallback(res) {
279 280
			$scope.users = res.data;
......
284 285
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
285 286
	});
286 287
	
288
	$scope.setCurrentUser = function(user) {
289
		angular.copy(user, $scope.currentUser);
290
	}
291
	
292
	$scope.saveUser = function(user) {
293
		$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
294
		$http.post('api/users', user).then(function successCallback(res) {
295
			$scope.users = res.data;
296
		}, function errorCallback(res) {
297
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
298
		});
299
	}
300
	
301
	$scope.deleteUser = function(email) {
302
		if (confirm("Are you sure ?")) {
303
			$http.delete('api/users?email=' + email).then(function successCallback(res) {
304
				$scope.users = res.data;
305
			}, function errorCallback(res) {
306
				alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
307
			});
308
		}
309
	}
287 310
});

Also available in: Unified diff