Skip to content

Commit

Permalink
🐞 add census data second batch will not be executed (#322) (#329)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#119
  • Loading branch information
Findeton committed Jul 19, 2023
1 parent 8d77eda commit 38efd77
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
6 changes: 6 additions & 0 deletions SequentConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ var SequentConfigData = {
// Information regarding OpenID Connect authentication
openIDConnectProviders: [],

//Minimum loading time (milliseconds)
minLoadingTime: 12000,

// Server timeout (seconds)
serverTimeoutSeconds: 200,

// contact data where users can reach to a human when they need it
contact: {
// Support contact email displayed in the footer links
Expand Down
21 changes: 16 additions & 5 deletions avRegistration/auth-method-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ angular.module('avRegistration')
$interval,
$state,
$location,
$document
$document,
$q
) {
var backendUrl = ConfigService.authAPI;
var authId = ConfigService.freeAuthId;
Expand Down Expand Up @@ -387,7 +388,14 @@ angular.module('avRegistration')
"field-validation": validation,
"census": data
};
return $http.post(backendUrl + 'auth-event/' + id + '/census/', d);
var url = backendUrl + 'auth-event/' + id + '/census/';

return $http({
method : "POST",
url : url,
timeout: ConfigService.serverTimeoutSeconds * 1000,
data: d
});
};

authmethod.getCensus = function(id, params) {
Expand Down Expand Up @@ -710,22 +718,25 @@ angular.module('avRegistration')
};

authmethod.launchPingDaemon = function(autheventid) {
var deferred = $q.defer();
var postfix = "_authevent_" + autheventid;

// ping daemon is not active for normal users
if (!authmethod.admin) {
return;
deferred.reject("not an admin");
return deferred.promise;
}
// if document is hidden, then do not update the cookie, and redirect
// to admin logout if cookie expired
if (document.visibilityState === 'hidden') {
if (!$cookies.get("auth" + postfix)) {
$state.go("admin.logout");
}
return;
deferred.reject("tab not focused");
return deferred.promise;
}
var now = Date.now();
authmethod.ping()
return authmethod.ping()
.then(function(response) {
var options = {};
if (ConfigService.authTokenExpirationSeconds) {
Expand Down
6 changes: 6 additions & 0 deletions dist/SequentConfig-v9.0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ var SequentConfigData = {
// Information regarding OpenID Connect authentication
openIDConnectProviders: [],

//Minimum loading time (milliseconds)
minLoadingTime: 12000,

// Server timeout (seconds)
serverTimeoutSeconds: 200,

// contact data where users can reach to a human when they need it
contact: {
// Support contact email displayed in the footer links
Expand Down
20 changes: 14 additions & 6 deletions dist/appCommon-v9.0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function $buo_f() {
}

if (angular.module("avRegistration", [ "ui.bootstrap", "ui.utils", "ui.router" ]),
angular.module("avRegistration").config(function() {}), angular.module("avRegistration").factory("Authmethod", [ "$http", "$cookies", "ConfigService", "$interval", "$state", "$location", "$document", function($http, $cookies, ConfigService, $interval, $state, $location, $document) {
angular.module("avRegistration").config(function() {}), angular.module("avRegistration").factory("Authmethod", [ "$http", "$cookies", "ConfigService", "$interval", "$state", "$location", "$document", "$q", function($http, $cookies, ConfigService, $interval, $state, $location, $document, $q) {
var backendUrl = ConfigService.authAPI, authId = ConfigService.freeAuthId, authmethod = {
captcha_code: null,
captcha_image_url: "",
Expand Down Expand Up @@ -199,7 +199,12 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
"field-validation": validation = !angular.isDefined(validation) ? "enabled" : validation,
census: d
};
return $http.post(backendUrl + "auth-event/" + id + "/census/", d);
return $http({
method: "POST",
url: backendUrl + "auth-event/" + id + "/census/",
timeout: 1e3 * ConfigService.serverTimeoutSeconds,
data: d
});
},
getCensus: function(id, params) {
return angular.isObject(params) ? $http.get(backendUrl + "auth-event/" + id + "/census/", {
Expand Down Expand Up @@ -363,15 +368,18 @@ angular.module("avRegistration").config(function() {}), angular.module("avRegist
return $http.post(url, data);
},
launchPingDaemon: function(autheventid) {
var now, postfix = "_authevent_" + autheventid;
authmethod.admin && ("hidden" !== document.visibilityState ? (now = Date.now(),
authmethod.ping().then(function(response) {
var deferred = $q.defer(), postfix = "_authevent_" + autheventid;
if (!authmethod.admin) return deferred.reject("not an admin"), deferred.promise;
if ("hidden" === document.visibilityState) return $cookies.get("auth" + postfix) || $state.go("admin.logout"),
deferred.reject("tab not focused"), deferred.promise;
var now = Date.now();
return authmethod.ping().then(function(response) {
var options = {};
ConfigService.authTokenExpirationSeconds && (options.expires = new Date(now + 1e3 * ConfigService.authTokenExpirationSeconds)),
$cookies.put("auth" + postfix, response.data["auth-token"], options), $cookies.put("isAdmin" + postfix, $cookies.get("isAdmin" + postfix), options),
$cookies.put("userid" + postfix, $cookies.get("userid" + postfix), options), $cookies.put("userid" + postfix, $cookies.get("userid" + postfix), options),
$cookies.put("user" + postfix, $cookies.get("user" + postfix), options), authmethod.setAuth($cookies.get("auth" + postfix), $cookies.get("isAdmin" + postfix), autheventid);
})) : $cookies.get("auth" + postfix) || $state.go("admin.logout"));
});
},
getUserDraft: function() {
if (authmethod.isLoggedIn()) return $http.get(backendUrl + "user/draft/", {});
Expand Down

0 comments on commit 38efd77

Please sign in to comment.