Skip to content
Snippets Groups Projects
Commit ee9e97ac authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Removed forgotten alert

parent 028ddb4d
No related branches found
No related tags found
1 merge request!106Removed forgotten alert
Pipeline #39843 passed
...@@ -603,8 +603,6 @@ DOIView.prototype.renderMetadata = function(data) { ...@@ -603,8 +603,6 @@ DOIView.prototype.renderMetadata = function(data) {
}; };
DOIView.prototype.setDataAccessMessage = function(doiData) { DOIView.prototype.setDataAccessMessage = function(doiData) {
alert("test");
console.log(doiData);
if (doiData.accessibility === "Open access") { if (doiData.accessibility === "Open access") {
return "The data can be accessed by clicking on the link below"; return "The data can be accessed by clicking on the link below";
} else if (doiData.accessibility === "Restricted access") { } else if (doiData.accessibility === "Restricted access") {
......
function DOIView() { function DOIView() {
this.mainPanelId = "main";
this.mainPanelId = "main"; this.reportPanelId = "expReport";
this.reportPanelId = "expReport"; this.badgePanelId = "badges";
this.badgePanelId = "badges"; this.metadataDivId = "metadata";
this.metadataDivId = 'metadata';
this.reportExperimentFileNames = null;
this.reportExperimentFileNames = null; this.failedRecievingExpReport = false;
this.failedRecievingExpReport = false; this.isDOIAlreadyRendered = false;
this.isDOIAlreadyRendered = false; this.onDOIRendered = new Event(this);
this.onDOIRendered = new Event(this);
} }
DOIView.prototype.setLoading = function (message) { DOIView.prototype.setLoading = function (message) {
if (message == false) { if (message == false) {
$("body").removeClass("loading"); $("body").removeClass("loading");
return; return;
} }
$("body").addClass("loading"); $("body").addClass("loading");
}; };
/** /**
* Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered. * Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered.
*/ */
DOIView.prototype.setDOIInTopBanner = function (doiCode) { DOIView.prototype.setDOIInTopBanner = function (doiCode) {
$("#doiValue").text("DOI > " + doiCode.toUpperCase()); $("#doiValue").text("DOI > " + doiCode.toUpperCase());
}; };
/** /**
...@@ -31,150 +30,172 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) { ...@@ -31,150 +30,172 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) {
* @param {array} data The filename list to be displayed * @param {array} data The filename list to be displayed
*/ */
DOIView.prototype.renderExperimentalReportData = function (data) { DOIView.prototype.renderExperimentalReportData = function (data) {
if (data) { if (data) {
var _this = this; var _this = this;
/** Only render the list of files if DOI has already been rendered * */ /** Only render the list of files if DOI has already been rendered * */
if (this.isDOIAlreadyRendered) { if (this.isDOIAlreadyRendered) {
dust.render('experimentalreport_tpl', { dust.render(
data: data "experimentalreport_tpl",
}, function (err, out) { {
$('#' + _this.reportPanelId).html(out); data: data,
}); },
} else { function (err, out) {
this.reportExperimentFileNames = data; $("#" + _this.reportPanelId).html(out);
} }
);
} else { } else {
this.reportExperimentFileNames = data;
} }
} else {
}
}; };
DOIView.prototype.renderDOIData = function (doiData) { DOIView.prototype.renderDOIData = function (doiData) {
var _this = this; var _this = this;
dust.render('landingpage_tpl', { dust.render(
data: doiData, "landingpage_tpl",
constants: CONSTANTS {
}, function (err, out) { data: doiData,
$('#' + _this.mainPanelId).html(out); constants: CONSTANTS,
_this.isDOIAlreadyRendered = true; },
_this.renderBadges(doiData); function (err, out) {
_this.renderMetadata(doiData); $("#" + _this.mainPanelId).html(out);
/** _this.isDOIAlreadyRendered = true;
* If there are experimental reports already retrieved then render them after _this.renderBadges(doiData);
* the rendering of the DOI _this.renderMetadata(doiData);
*/ /**
if (_this.failedRecievingExpReport) { * If there are experimental reports already retrieved then render them after
_this.renderErrorForExperimentalReport(); * the rendering of the DOI
} else if (_this.reportExperimentFileNames) { */
_this.renderExperimentalReportData(_this.reportExperimentFileNames); if (_this.failedRecievingExpReport) {
} _this.renderErrorForExperimentalReport();
}); } else if (_this.reportExperimentFileNames) {
_this.renderExperimentalReportData(_this.reportExperimentFileNames);
}
}
);
}; };
/** /**
* Render the error message * Render the error message
* *
* @param {string} errorThrown The error which was thrown * @param {string} errorThrown The error which was thrown
* @param {string} origin The page which caused this rendering. This directly influences the element id * @param {string} origin The page which caused this rendering. This directly influences the element id
*/ */
DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) { DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) {
var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl"); var template = origin === "welcome-page" ? "doinotfound2_tpl" : "doinotfound_tpl";
var message = ""; var message = "";
if (errorThrown === "Bad Prefix") { if (errorThrown === "Bad Prefix") {
if (origin === "welcome-page") { if (origin === "welcome-page") {
message = '<h3> Not found ! </h3> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>'; message =
} else { '<h3> Not found ! </h3> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
message = '<h2> Not found ! </h2> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
}
} else if (errorThrown === "Not Found") {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>";
} else {
message = "<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>";
}
} else if (errorThrown === "timeout") {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>";
} else {
message = "<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>";
}
} else if (errorThrown === "" && jqXHR.responseText === "The resource you are looking for doesn't exist.") {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
} else {
message = "<h2> Not found ! </h2> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
}
} else { } else {
if (origin === "welcome-page") { message =
message = "<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>"; '<h2> Not found ! </h2> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
} else { }
message = "<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>"; } else if (errorThrown === "Not Found") {
} if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>";
} else {
message = "<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>";
} }
dust.render(template, { } else if (errorThrown === "timeout") {
message: message if (origin === "welcome-page") {
}, function (err, out) { message = "<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>";
$("#error").html(out); } else {
}); message = "<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>";
}
} else if (errorThrown === "" && jqXHR.responseText === "The resource you are looking for doesn't exist.") {
if (origin === "welcome-page") {
message =
"<h3> Not found ! </h3> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
} else {
message =
"<h2> Not found ! </h2> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
}
} else {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>";
} else {
message = "<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>";
}
}
dust.render(
template,
{
message: message,
},
function (err, out) {
$("#error").html(out);
}
);
}; };
DOIView.prototype.renderErrorForExperimentalReport = function () { DOIView.prototype.renderErrorForExperimentalReport = function () {
this.failedRecievingExpReport = true; this.failedRecievingExpReport = true;
var out = '<div class="card-header text-center"> <label>Experimental report </label> </div> <div class="card-body padding10"> <p> The filename list is not available. </p> </div>'; var out =
$('#' + this.reportPanelId).html(out); '<div class="card-header text-center"> <label>Experimental report </label> </div> <div class="card-body padding10"> <p> The filename list is not available. </p> </div>';
$("#" + this.reportPanelId).html(out);
}; };
/**
/**
* Render the badge template in the corresponding div * Render the badge template in the corresponding div
* @param {object} data : the doiData object as constructed by the doiController * @param {object} data : the doiData object as constructed by the doiController
*/ */
DOIView.prototype.renderBadges = function (data) { DOIView.prototype.renderBadges = function (data) {
if (data) { if (data) {
var _this = this; var _this = this;
dust.render('badges_tpl', { dust.render(
data: data, "badges_tpl",
constants: CONSTANTS {
}, function (err, out) { data: data,
$('#' + _this.badgePanelId).html(out); constants: CONSTANTS,
}); },
} function (err, out) {
$("#" + _this.badgePanelId).html(out);
}
);
}
}; };
/** /**
* Render the badge template in the corresponding div * Render the badge template in the corresponding div
*/ */
DOIView.prototype.renderMetadata = function (data) { DOIView.prototype.renderMetadata = function (data) {
if (data) { if (data) {
var _this = this; var _this = this;
data.sessionDate = moment(data.sessionDate).format('YYYY-M-D'); data.sessionDate = moment(data.sessionDate).format("YYYY-M-D");
dust.render('metadata_tpl', { dust.render(
data: data, "metadata_tpl",
constants: CONSTANTS {
}, function (err, out) { data: data,
$('#' + _this.metadataDivId).html(out); constants: CONSTANTS,
}); },
} function (err, out) {
$("#" + _this.metadataDivId).html(out);
}
);
}
}; };
/** /**
* Set the message which is displayed just above the "Access data button" in experimental data box. * Set the message which is displayed just above the "Access data button" in experimental data box.
* @param {object} doiData json object reference. * @param {object} doiData json object reference.
* @return {string} message to display * @return {string} message to display
*/ */
DOIView.prototype.setDataAccessMessage = function (doiData) { DOIView.prototype.setDataAccessMessage = function (doiData) {
alert("test"); if (doiData.accessibility === "Open access") {
console.log(doiData); return "The data can be accessed by clicking on the link below";
if (doiData.accessibility === "Open access") { } else if (doiData.accessibility === "Restricted access") {
return "The data can be accessed by clicking on the link below"; return (
} else if (doiData.accessibility === "Restricted access") { "The data are under embargo until <b>" +
return "The data are under embargo until <b>" + doiData.publiclyAccessibleYear + "</b> but could be released earlier." + doiData.publiclyAccessibleYear +
" Currently, they are only accessible to proposal team members."; "</b> but could be released earlier." +
} " Currently, they are only accessible to proposal team members."
);
}
}; };
/** /**
...@@ -182,10 +203,7 @@ alert("test"); ...@@ -182,10 +203,7 @@ alert("test");
* @param {string} data doi metadata in Json+LD format as provided by datacite. * @param {string} data doi metadata in Json+LD format as provided by datacite.
*/ */
DOIView.prototype.addDOIMetadataToHead = function (data) { DOIView.prototype.addDOIMetadataToHead = function (data) {
$('<script>') $("<script>").attr("type", "application/ld+json").text(data).appendTo("head");
.attr('type', 'application/ld+json')
.text(data)
.appendTo('head');
}; };
/** /**
...@@ -193,8 +211,5 @@ DOIView.prototype.addDOIMetadataToHead = function (data) { ...@@ -193,8 +211,5 @@ DOIView.prototype.addDOIMetadataToHead = function (data) {
* @param {String} doiURL URL to the DOI * @param {String} doiURL URL to the DOI
*/ */
DOIView.prototype.addCanonicalURLToHead = function (doiURL) { DOIView.prototype.addCanonicalURLToHead = function (doiURL) {
$('<link>') $("<link>").attr("rel", "canonical").attr("href", doiURL).appendTo("head");
.attr('rel', 'canonical')
.attr('href', doiURL)
.appendTo('head');
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment