frontend: registration is Ok
This commit is contained in:
parent
7b0e8195ff
commit
024d34f0e4
3 changed files with 32 additions and 25 deletions
|
@ -491,23 +491,23 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
})
|
||||
.controller("RegisterController", function($scope, $rootScope, $location, $http) {
|
||||
.controller("RegisterController", function($scope, $rootScope, $location, $http, $interval) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_tag = undefined;
|
||||
$rootScope.title = "Bienvenue au challenge forensic !";
|
||||
$rootScope.authors = null;
|
||||
|
||||
$scope.members = [{}];
|
||||
$scope.form = {"teamName": "", "members": [{}]};
|
||||
|
||||
$scope.AddMember = function() {
|
||||
$scope.members.push({});
|
||||
$scope.form.members.push({});
|
||||
}
|
||||
$scope.RemoveMember = function(k) {
|
||||
$scope.members.splice(k, 1);
|
||||
$scope.form.members.splice(k, 1);
|
||||
}
|
||||
$scope.Validate = function() {
|
||||
if ($scope.teamName.length <= 3) {
|
||||
if ($scope.form.teamName.length <= 3) {
|
||||
$('#teamName').addClass("is-invalid")
|
||||
return;
|
||||
} else {
|
||||
|
@ -522,32 +522,32 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
return $scope.Validate();
|
||||
|
||||
// Remove empty members
|
||||
$scope.members = $scope.members.filter(function(m) {
|
||||
$scope.form.members = $scope.form.members.filter(function(m) {
|
||||
return ((m.lastname != undefined && m.lastname != "") || (m.firstname != undefined && m.firstname != "") || (m.nickname != undefined && m.nickname != ""));
|
||||
});
|
||||
|
||||
if ($scope.members.length == 0) {
|
||||
if ($scope.form.members.length == 0) {
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
$scope.message = "Veuillez ajouter au moins un membre dans votre équipe !";
|
||||
|
||||
$scope.members.push({});
|
||||
$scope.form.members.push({});
|
||||
return;
|
||||
}
|
||||
|
||||
$http({
|
||||
url: "/registration",
|
||||
method: "POST",
|
||||
data: {
|
||||
teamName: $scope.teamName,
|
||||
members: $scope.members,
|
||||
}
|
||||
}).then(function(response, status, header, config) {
|
||||
data: $scope.form
|
||||
}).then(function(response) {
|
||||
$scope.messageClass = {"text-success": true};
|
||||
$scope.message = response.data.errmsg;
|
||||
|
||||
$rootScope.refresh();
|
||||
if ($scope.my)
|
||||
$location.url("/");
|
||||
$interval(function(){
|
||||
$http.get("/my.json").then(function(response) {
|
||||
$rootScope.refresh();
|
||||
});
|
||||
}, 1500);
|
||||
|
||||
}, function(response) {
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
if (response.data && response.data.errmsg)
|
||||
|
@ -557,9 +557,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
}
|
||||
|
||||
if ($scope.my) {
|
||||
$location.url("/");
|
||||
}
|
||||
$scope.$watch("my", function(my){
|
||||
if (my)
|
||||
$location.url("/");
|
||||
});
|
||||
})
|
||||
.controller("TagController", function($scope, $rootScope, $routeParams) {
|
||||
$rootScope.current_theme = 0;
|
||||
|
|
Reference in a new issue