|
@@ -1,3 +1,4 @@
|
|
|
|
|
+// Specific code for the 'federation-structures' page
|
|
|
|
|
|
|
|
const variants_uris = {
|
|
const variants_uris = {
|
|
|
"preprod.opentalent.fr": "https://api.preprod.opentalent.fr",
|
|
"preprod.opentalent.fr": "https://api.preprod.opentalent.fr",
|
|
@@ -35,11 +36,6 @@ function sphericDistance(lat1, lon1, lat2, lon2)
|
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
const queryParameters = new URLSearchParams(window.location.search);
|
|
const queryParameters = new URLSearchParams(window.location.search);
|
|
|
- let organizationId = queryParameters.get('organization-id');
|
|
|
|
|
-
|
|
|
|
|
- if (!organizationId) {
|
|
|
|
|
- throw 'Missing organization-id parameter';
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// Init
|
|
// Init
|
|
|
let document = $('html, body');
|
|
let document = $('html, body');
|
|
@@ -50,6 +46,7 @@ $(document).ready(function() {
|
|
|
let resultsPageDiv = structureFrame.find('.structures-page').first();
|
|
let resultsPageDiv = structureFrame.find('.structures-page').first();
|
|
|
let pleaseWaitSpan = structureFrame.find('.please-wait').first();
|
|
let pleaseWaitSpan = structureFrame.find('.please-wait').first();
|
|
|
let noResultSpan = structureFrame.find('.no-result').first();
|
|
let noResultSpan = structureFrame.find('.no-result').first();
|
|
|
|
|
+ let errorMsgSpan = structureFrame.find(".error-message").first();
|
|
|
let cardDivModel = structureFrame.find('.structure-card-model').first();
|
|
let cardDivModel = structureFrame.find('.structure-card-model').first();
|
|
|
let paginationBar = structureFrame.find('.pagination-bar').first();
|
|
let paginationBar = structureFrame.find('.pagination-bar').first();
|
|
|
let paginationList = structureFrame.find('.pagination-list').first();
|
|
let paginationList = structureFrame.find('.pagination-list').first();
|
|
@@ -68,6 +65,14 @@ $(document).ready(function() {
|
|
|
let resetButton = form.find("button.reset-search").first();
|
|
let resetButton = form.find("button.reset-search").first();
|
|
|
let submitButton = form.find("button.submit-search").first();
|
|
let submitButton = form.find("button.submit-search").first();
|
|
|
|
|
|
|
|
|
|
+ let organizationId = queryParameters.get('organization-id') || structureFrame.data('organization-id');
|
|
|
|
|
+ if (!organizationId) {
|
|
|
|
|
+ pleaseWaitSpan.hide();
|
|
|
|
|
+ errorMsgSpan.show();
|
|
|
|
|
+ throw 'Missing organization-id parameter';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// Translations
|
|
// Translations
|
|
|
let tr = {};
|
|
let tr = {};
|
|
|
$('#labels').find('span').each(function (i, elt) {
|
|
$('#labels').find('span').each(function (i, elt) {
|
|
@@ -349,15 +354,18 @@ $(document).ready(function() {
|
|
|
type: 'GET',
|
|
type: 'GET',
|
|
|
url: apiGetUrl,
|
|
url: apiGetUrl,
|
|
|
dataType: "json",
|
|
dataType: "json",
|
|
|
- contentType: "application/json; charset=utf-8"
|
|
|
|
|
|
|
+ contentType: "application/json; charset=utf-8",
|
|
|
|
|
+ timeout : 5000
|
|
|
})
|
|
})
|
|
|
.done(function(res) {
|
|
.done(function(res) {
|
|
|
structures = res["hydra:member"];
|
|
structures = res["hydra:member"];
|
|
|
populateFederationsSelect();
|
|
populateFederationsSelect();
|
|
|
refresh();
|
|
refresh();
|
|
|
})
|
|
})
|
|
|
- .fail(function() {
|
|
|
|
|
- structureFrame.find(".error-message").show()
|
|
|
|
|
|
|
+ .fail(function(xhr, textStatus, errorThrown) {
|
|
|
|
|
+ pleaseWaitSpan.hide();
|
|
|
|
|
+ errorMsgSpan.show();
|
|
|
|
|
+ throw 'Error while fetching the API data: ' + textStatus + ' - ' + errorThrown;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|