Commit 5d5474a2 authored by Maxime Chaillet's avatar Maxime Chaillet

Update experimental report/data texts. It fixes #49

parent ddd2beb8
This diff is collapsed.
This diff is collapsed.
function DOIView() {
this.mainPanelId = "main";
this.reportPanelId = "expReport";
this.mainPanelId = "main";
this.reportPanelId = "expReport";
this.reportExperimentFileNames = null;
this.failedRecievingExpReport = false;
this.isDOIAlreadyRendered = false;
this.onDOIRendered = new Event(this);
this.reportExperimentFileNames = null;
this.failedRecievingExpReport = false;
this.isDOIAlreadyRendered = false;
this.onDOIRendered = new Event( this );
}
DOIView.prototype.setLoading = function(message) {
if (message == false) {
$("body").removeClass("loading");
return;
}
$("body").addClass("loading");
DOIView.prototype.setLoading = function( message ) {
if ( message == false ) {
$( "body" ).removeClass( "loading" );
return;
}
$( "body" ).addClass( "loading" );
};
DOIView.prototype.setDOI = function(doi) {
$("#doiPanel").html(doi.toUpperCase());
DOIView.prototype.setDOI = function( doi ) {
$( "#doiPanel" ).html( doi.toUpperCase() );
};
/**
......@@ -27,41 +27,41 @@ DOIView.prototype.setDOI = function(doi) {
* @param {array}
* data The filename list to be displayed
*/
DOIView.prototype.renderExperimentalReportData = function(data) {
if (data) {
var _this = this;
/** Only render the list of files if DOI has already been rendered * */
if (this.isDOIAlreadyRendered) {
dust.render('experimentalreport_tpl', {
data : data
}, function(err, out) {
$('#' + _this.reportPanelId).html(out);
});
DOIView.prototype.renderExperimentalReportData = function( data ) {
if ( data ) {
var _this = this;
/** Only render the list of files if DOI has already been rendered * */
if ( this.isDOIAlreadyRendered ) {
dust.render( 'experimentalreport_tpl', {
data: data
}, function( err, out ) {
$( '#' + _this.reportPanelId ).html( out );
} );
} else {
this.reportExperimentFileNames = data;
}
} else {
this.reportExperimentFileNames = data;
}
} else {
}
}
};
DOIView.prototype.renderDOIData = function(doiData, target) {
var _this = this;
dust.render('landingpage_tpl', {
data : doiData
}, function(err, out) {
$('#' + _this.mainPanelId).html(out);
_this.isDOIAlreadyRendered = true;
/**
* If there are experimental reports already retrieved then reder them after
* the rendering of the DOI *
*/
if (_this.failedRecievingExpReport) {
_this.renderErrorForExperimentalReport();
} else if (_this.reportExperimentFileNames) {
_this.renderExperimentalReportData(_this.reportExperimentFileNames);
}
});
DOIView.prototype.renderDOIData = function( doiData, target ) {
var _this = this;
dust.render( 'landingpage_tpl', {
data: doiData
}, function( err, out ) {
$( '#' + _this.mainPanelId ).html( out );
_this.isDOIAlreadyRendered = true;
/**
* If there are experimental reports already retrieved then reder them after
* the rendering of the DOI *
*/
if ( _this.failedRecievingExpReport ) {
_this.renderErrorForExperimentalReport();
} else if ( _this.reportExperimentFileNames ) {
_this.renderExperimentalReportData( _this.reportExperimentFileNames );
}
} );
};
/**
......@@ -73,47 +73,47 @@ DOIView.prototype.renderDOIData = function(doiData, target) {
* origin The page which caused this rendering. This directly
* influence the element id
*/
DOIView.prototype.renderError = function(error, origin) {
var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl");
DOIView.prototype.renderError = function( error, origin ) {
var template = ( ( origin === "welcome-page" ) ? "doinotfound2_tpl" : "doinotfound_tpl" );
var message = "";
var message = "";
if (error === "Bad Prefix") {
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>';
} else {
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 (error === "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 (error === "timeout") {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>";
if ( error === "Bad Prefix" ) {
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>';
} else {
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 ( error === "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 ( error === "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 {
message = "<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>";
if ( origin === "welcome-page" ) {
message = "<h3> Not found ! </h3> <p> Connexion problem to the server. </p>";
} else {
message = "<h2> Not found ! </h2> <p> Connexion problem to the server. </p>";
}
}
} else {
if (origin === "welcome-page") {
message = "<h3> Not found ! </h3> <p> Connexion problem to the server. </p>";
} else {
message = "<h2> Not found ! </h2> <p> Connexion problem to the server. </p>";
}
}
dust.render(template, {
message : message
}, function(err, out) {
$("#error").html(out);
});
dust.render( template, {
message: message
}, function( err, out ) {
$( "#error" ).html( out );
} );
};
DOIView.prototype.renderErrorForExperimentalReport = function() {
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>';
$('#' + this.reportPanelId).html(out);
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>';
$( '#' + this.reportPanelId ).html( out );
};
/**
......@@ -122,15 +122,15 @@ DOIView.prototype.renderErrorForExperimentalReport = function() {
* @param {object}
* data The json object reference.
*/
DOIView.prototype.setDataAccessMessage = function(data) {
var publicationDate = moment(data.publication_year, "YYYY");
var now = moment();
DOIView.prototype.setDataAccessMessage = function( data ) {
var publicationDate = moment( data.publication_year, "YYYY" );
var now = moment();
if (now > publicationDate) {
data.accessMessage = "The data can be downloaded by clicking on the link below";
} else {
data.accessMessage = "The data is under embargo until <b>" + data.publication_year +
"</b> but could be released earlier. It is currently only available to download if you are a member of the proposal team.";
}
if ( now > publicationDate ) {
data.accessMessage = "The data can be accessed by clicking on the link below";
} else {
data.accessMessage = "The data is under embargo until <b>" + data.publication_year + "</b> but could be released earlier. </p> " +
" <p> Currently, it is only accessible to proposal team members. </p>";
}
};
......@@ -5,14 +5,14 @@
<div class="card-body padding10">
{?data}
{@eq key=data.length value=1}
<p> A <b> single </b> report was found for this proposal. </p>
<p> <b> One </b> report has been found for this proposal. </p>
</div>
<div class="card-footer">
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="javascript:(function(){ var expRep = new ExperimentalReportController(); expRep.openFileInNewTab('{data[0]}'); })()" > <span class="fa fa-download whiteFont"></span> Download </button>
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="javascript:(function(){ var expRep = new ExperimentalReportController(); expRep.openFileInNewTab('{data[0]}'); })()" > <span class="fa fa-download whiteFont"></span> {data[0]} </button>
</div>
{/eq}
{@gt key=data.length value=1}
<p> <b> {data.length} </b> reports found for this proposal : </p>
<p> In total, <b> {data.length} </b> reports have been found for this proposal: </p>
<div class="scroll-box">
<div class="row">
{#data}
......@@ -27,8 +27,7 @@
{/gt}
</div>
{:else}
<p> No experimental report found. </p>
<p> Please check again later. </p>
<p> There is currently no experimental report. </p>
</div>
{/data}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment