frontend: team registration
This commit is contained in:
parent
bc135d00c5
commit
184714aeeb
10 changed files with 208 additions and 28 deletions
|
@ -13,6 +13,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
controller: "RankController",
|
||||
templateUrl: "views/rank.html"
|
||||
})
|
||||
.when("/register", {
|
||||
controller: "RegisterController",
|
||||
templateUrl: "views/register.html"
|
||||
})
|
||||
.when("/videos", {
|
||||
controller: "VideosController",
|
||||
templateUrl: "views/videos.html"
|
||||
|
@ -74,7 +78,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
updTime();
|
||||
$interval(updTime, 1000);
|
||||
})
|
||||
.controller("DataController", function($sce, $scope, $http, $rootScope, $timeout) {
|
||||
.controller("DataController", function($sce, $scope, $http, $rootScope, $timeout, $location) {
|
||||
var actMenu = function() {
|
||||
if ($scope.my && $scope.themes) {
|
||||
angular.forEach($scope.themes, function(theme, key) {
|
||||
|
@ -146,6 +150,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
});
|
||||
}
|
||||
}, function(response) {
|
||||
if (!$scope.my && response.status == 404) {
|
||||
$location.url("/register");
|
||||
}
|
||||
});
|
||||
console.log("refresh!");
|
||||
}
|
||||
|
@ -358,6 +366,76 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
})
|
||||
.controller("RegisterController", function($scope, $rootScope, $location, $http) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.title = "Bienvenue au challenge forensic !";
|
||||
$rootScope.authors = null;
|
||||
|
||||
$scope.members = [{}];
|
||||
|
||||
$scope.AddMember = function() {
|
||||
$scope.members.push({});
|
||||
}
|
||||
$scope.RemoveMember = function(k) {
|
||||
$scope.members.splice(k, 1);
|
||||
}
|
||||
$scope.Validate = function() {
|
||||
if ($scope.teamName.length <= 3) {
|
||||
$('#teamName').addClass("is-invalid")
|
||||
return;
|
||||
} else {
|
||||
$('#vldBtn').removeClass("input-group-btn");
|
||||
$('#vldBtn').css("display", "none");
|
||||
$scope.part2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.rsubmit = function() {
|
||||
if (!$scope.part2)
|
||||
return $scope.Validate();
|
||||
|
||||
// Remove empty members
|
||||
$scope.members = $scope.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) {
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
$scope.message = "Veuillez ajouter au moins un membre dans votre équipe !";
|
||||
|
||||
$scope.members.push({});
|
||||
return;
|
||||
}
|
||||
|
||||
$http({
|
||||
url: "/registration",
|
||||
method: "POST",
|
||||
data: {
|
||||
teamName: $scope.teamName,
|
||||
members: $scope.members,
|
||||
}
|
||||
}).then(function(response, status, header, config) {
|
||||
$scope.messageClass = {"text-success": true};
|
||||
$scope.message = response.data.errmsg;
|
||||
|
||||
$rootScope.refresh();
|
||||
if ($scope.my)
|
||||
$location.url("/");
|
||||
}, function(response) {
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
console.log(response);
|
||||
if (response.data && response.data.errmsg)
|
||||
$scope.message = response.data.errmsg;
|
||||
else
|
||||
$scope.message = "Une erreur est survenue lors de l'inscription de l'équipe. Veuillez réessayer dans quelques instants.";
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.my) {
|
||||
$location.url("/");
|
||||
}
|
||||
})
|
||||
.controller("RankController", function($scope, $rootScope) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
|
|
Reference in a new issue