nginx: error pages are now respond as json if accept header request it.
As a consequence, we can rely on them to display a correct information on user pages through angularJS.
This commit is contained in:
parent
cf290732dc
commit
63a55a8a0b
12 changed files with 103 additions and 27 deletions
|
@ -293,17 +293,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
};
|
||||
})
|
||||
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
|
||||
$rootScope.sberr = "";
|
||||
$scope.sberr = null;
|
||||
|
||||
var cbs;
|
||||
var cbd;
|
||||
|
||||
$scope.$watch("my", function(my) {
|
||||
if (!my || !my.exercices || !my.exercices[$rootScope.current_exercice]) {
|
||||
if (cbs)
|
||||
$timeout.cancel(cbs);
|
||||
cbs = $timeout(waitMy, 420);
|
||||
} else {
|
||||
if (my && my.exercices && my.exercices[$rootScope.current_exercice]) {
|
||||
angular.forEach(my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) {
|
||||
angular.forEach(mcq["choices"], function(choice,cid) {
|
||||
this[cid] = {
|
||||
|
@ -322,6 +318,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$scope.ssubmit = function() {
|
||||
var resp = {}
|
||||
var check = undefined
|
||||
$scope.sberr = null;
|
||||
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].flags && Object.keys($scope.my.exercices[$rootScope.current_exercice].flags).length)
|
||||
{
|
||||
|
@ -384,10 +381,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
return;
|
||||
}
|
||||
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
$rootScope.sberr = "";
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response) {
|
||||
$scope.messageClass = {"text-success": true};
|
||||
$scope.message = response.data.errmsg;
|
||||
$scope.sberr = null;
|
||||
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
flag.value = "";
|
||||
|
@ -407,15 +404,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
checkDiff();
|
||||
}, function(response, status, header, config) {
|
||||
if (status >= 500) {
|
||||
}, function(response) {
|
||||
if (response.status >= 500) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
||||
}
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
if (status != 402) {
|
||||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
$scope.sberr = "Oups !";
|
||||
$scope.message = response.data.errmsg;
|
||||
});
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
||||
};
|
||||
|
|
Reference in a new issue