Commit 2759a318 authored by Chaillet Maxime's avatar Chaillet Maxime

Fix merge conflicts. run grunt dev and grunt.

parents 9804b28b e695453e
function Author(){}Author.prototype.setFirstName=function(e){this.firstName=e},Author.prototype.setFamilyName=function(e){this.familyName=e},Author.prototype.setSingleName=function(e){this.singleName=e},Author.prototype.getRawFamilyName=function(){if(this.familyName)return this.familyName;if(this.singleName){var e=new RegExp(/(\S+)/g),t=this.singleName.match(e);if(2===t.length)return this.familyName=t[1],this.familyName;var r=new RegExp(/\s([^a-z]+$)/).exec(this.singleName);return r&&(this.familyName=r[1]),this.familyName}},Author.prototype.getRawFirstName=function(){if(this.firstName)return this.firstName;if(this.singleName){var e=new RegExp(/(\S+)/g),t=this.singleName.match(e);if(2===t.length)return this.firstName=t[0],this.firstName;var r=new RegExp(/^(.[^A-Z]+)+\b/).exec(this.singleName);return r&&(this.firstName=r[0]),r}},Author.prototype.getTitleCaseFamilyName=function(){if(this.familyName){allLowerCase=this.familyName.toLowerCase();var e=new RegExp(/^./);return allLowerCase.replace(e,function(e){return e.toUpperCase()})}return console.log("family name is undefined"),null},Author.prototype.getFirstNameInitials=function(){var e=new RegExp(/(\S+)/g);return this.firstName?this.firstName.replace(e,function(e){return e.charAt(0)+"."}):(console.log("first name is undefined"),null)};var BEAMLINEURL=[{name:"BM05",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"},{name:"BM29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"},{name:"CM01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"},{name:"ID01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"},{name:"ID06",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"},{name:"ID11",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"},{name:"ID16A",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"},{name:"ID16B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"},{name:"ID17",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"},{name:"ID19",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"},{name:"ID21",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"},{name:"ID22",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id22"},{name:"ID23-1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"},{name:"ID23-2",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"},{name:"ID29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"},{name:"ID30A1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/MASSIF1"},{name:"ID30A3",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"},{name:"ID30B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id30b"},{name:"ID32",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/ID32"}];function Citation(e){this.isBuildable=!!(e&&e.creator&&0!==e.creator.length&&e.date_registered&&e.title&&e.publisher&&e.doi)}Citation.prototype.getAuthorsForCitation=function(e){if(this.isBuildable){var t=_.transform(e,function(e,t,r,n){n instanceof Array||(t=n);var i=null;if(t.givenName?((i=new Author).setFamilyName(t.familyName),i.setFirstName(t.givenName),e.push(i.getTitleCaseFamilyName()+" "+i.getFirstNameInitials())):((i=new Author).setSingleName(t.name),i.getRawFamilyName()&&i.getRawFirstName()?e.push(i.getTitleCaseFamilyName()+" "+i.getFirstNameInitials()):e.push(t.name)),!(n instanceof Array))return!1},[]);return _.join(t,", ")}return console.log("the author list for the citation could not be generated."),""};var CONSTANTS={ES_RESOURCE_TYPE:"experimental session resource type",DC_RESOURCE_TYPE:"dataset collection resource type"};function DOIController(e){var r=this;this.doiServer="https://api.test.datacite.org/",this.acceptedPrefix=["10.5072","10.15151"],this.view=e,this.experimentalReportController=new ExperimentalReportController,this.experimentalReportController.onSuccess.attach(function(e,t){r.view.renderExperimentalReportData(t)}),this.experimentalReportController.onError.attach(function(e,t){console.log("Error when retrieving fileList from SMIS."),r.view.renderErrorForExperimentalReport()})}function DoiData(){}function DOIView(){this.mainPanelId="main",this.reportPanelId="expReport",this.badgePanelId="badges",this.metadataDivId="metadata",this.reportExperimentFileNames=null,this.failedRecievingExpReport=!1,this.isDOIAlreadyRendered=!1,this.onDOIRendered=new Event(this)}function Event(e){this._sender=e,this._listeners=[]}function ExperimentalReportController(){this.server="https://wwws.esrf.fr/misapps/SMISServer/rest/reports/fileNames",this.timeout=5e3,this.onSuccess=new Event(this),this.onError=new Event(this)}function JsonExtractor(e){}function proposalBeamLineTable(e,t,r,n){return e.write('<table class="table table-striped">'),e.write(" <thead>"),e.write("<tr>"),e.write('<th scope="col">First</th>'),e.write('<th scope="col">Last</th>'),e.write("</tr>"),e.write("</thead>"),e.write("<tbody>"),e.write("<tr>"),e.write("<td>Mark</td>"),e.write("<td>Otto</td>"),e.write("</tr>"),e.write("</tbody>"),e.write("</table>"),e.render(r,t)}DOIController.prototype.isValidDOIData=function(e){return 3<_.keysIn(e).length&&0<_.find(_.keysIn(e),function(e){return"title"===e}).length},DOIController.prototype.getData=function(i){var a=this;this.view.setDOIInTopBanner(i),this.hasAcceptedPrefix(i)?$.ajax({headers:{Accept:"application/vnd.datacite.datacite+json"},type:"GET",timeout:15e3,url:this.doiServer+i,beforeSend:function(e){a.view.setLoading("Retrieving data from Server"),e.setRequestHeader("Authorization","Basic "+btoa("DATACITE.ESRF:datacyte1"))},complete:function(){a.view.setLoading(!1)}}).done(function(e){if(e)if(a.isValidDOIData(e)){var t=new DoiData;t.title=e.title,t.doi=e.doi.toUpperCase(),t.dataciteLink=a.doiServer+i,t.publisher=e.publisher,t.creator=e.creator;var r=new JsonExtractor;if(t.mintingYear=r.getMintingYear(e),t.sessionDate=r.getSessionDate(e),t.publiclyAccessibleYear=e.publication_year,t.proposalType=r.getFieldFromSubject(e.subject,"Proposal Type Description"),t.proposalName=r.getFieldFromSubject(e.subject,"Proposal"),a.experimentalReportController.requestFilenameList(t.proposalName),t.beamline=r.getFieldFromSubject(e.subject,"Instrument"),t.investigationId=r.extractInvestigationId(e),t.resourceType=r.getResourceType(e),t.accessibility=t.getAccessibilityStatus(t.resourceType,t.sessionDate,t.publiclyAccessibleYear),t.accessMessage=a.view.setDataAccessMessage(t),t.citation=a.createCitation(e),t.resourceTypeGeneral=r.getResourceTypeGeneral(e),t.DC_RESOURCE_TYPE=CONSTANTS.DC_RESOURCE_TYPE,t.ES_RESOURCE_TYPE=CONSTANTS.ES_RESOURCE_TYPE,e.date_collected){var n=moment(e.date_collected);t.beamlineUrl=a.getBeamlineUrl(t.beamline,n)}else t.beamlineUrl="noLink";a.view.renderDOIData(t)}else a.view.renderError("Not Found",a.origin)}).fail(function(e,t,r){a.view.renderError(e,r,a.origin),a.view.setLoading(!1)}):a.view.renderError("Bad Prefix",a.origin)},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return-1!=_.findIndex(this.acceptedPrefix,function(e){return t==e})},DOIController.prototype.displayMainContent=function(e){"welcome-page"===this.origin&&dust.render("welcome_tpl",{},function(e,t){$("#main").html(t)}),"index"===this.origin&&this.getData(e)},DOIController.prototype.setOrigin=function(e){this.origin=e},DOIController.prototype.getBeamlineUrl=function(e,t){for(var r=0;r<BEAMLINEURL.length;r++){var n=moment(BEAMLINEURL[r].startDate),i=moment(BEAMLINEURL[r].endDate);if(BEAMLINEURL[r].name.toLowerCase()===e.toLowerCase()&&n<=t&&t<=i)return BEAMLINEURL[r].url}return null},DOIController.prototype.createCitation=function(e){var t=new Citation(e);return t.isBuildable?t.getAuthorsForCitation(e.creator)+" ("+moment(e.date_registered).year()+"). "+e.title+". "+e.publisher+" (ESRF). <a href='https://doi.esrf.fr/"+e.doi+"'> doi:"+e.doi.toUpperCase()+"</a>":"The citation could not be generated."},DoiData.prototype.getAccessibilityStatus=function(e,t,r){if(e)if(e===CONSTANTS.ES_RESOURCE_TYPE){if(r&&t){var n=moment(r,"YYYY"),i=moment();if(n<i)return"Open access";if(i<=n)return"Restricted access"}}else if(e===CONSTANTS.DC_RESOURCE_TYPE)return"Open access";return console.log("Failed to determine whether the accessibility of the DOI."),"Accessibility status could not be determined"},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOIInTopBanner=function(e){$("#doiValue").text("DOI > "+e.toUpperCase())},DOIView.prototype.renderExperimentalReportData=function(e){if(e){var r=this;this.isDOIAlreadyRendered?dust.render("experimentalreport_tpl",{data:e},function(e,t){$("#"+r.reportPanelId).html(t)}):this.reportExperimentFileNames=e}},DOIView.prototype.renderDOIData=function(r){var n=this;dust.render("landingpage_tpl",{data:r},function(e,t){$("#"+n.mainPanelId).html(t),n.isDOIAlreadyRendered=!0,n.renderBadges(r),n.renderMetadata(r),n.failedRecievingExpReport?n.renderErrorForExperimentalReport():n.reportExperimentFileNames&&n.renderExperimentalReportData(n.reportExperimentFileNames)})},DOIView.prototype.renderError=function(e,t,r){var n="welcome-page"===r?"doinotfound2_tpl":"doinotfound_tpl",i="";i="Bad Prefix"===t?"welcome-page"===r?'<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>':'<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>':"Not Found"===t?"welcome-page"===r?"<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>":"<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>":"timeout"===t?"welcome-page"===r?"<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>":"<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>":""===t&&"The resource you are looking for doesn't exist."===e.responseText?"welcome-page"===r?"<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>":"<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>":"welcome-page"===r?"<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>":"<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>",dust.render(n,{message:i},function(e,t){$("#error").html(t)})},DOIView.prototype.renderErrorForExperimentalReport=function(){this.failedRecievingExpReport=!0;$("#"+this.reportPanelId).html('<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>')},DOIView.prototype.renderBadges=function(e){if(e){var r=this;dust.render("badges_tpl",{data:e},function(e,t){$("#"+r.badgePanelId).html(t)})}},DOIView.prototype.renderMetadata=function(e){if(e){var r=this;dust.render("metadata_tpl",{data:e},function(e,t){$("#"+r.metadataDivId).html(t)})}},DOIView.prototype.setDataAccessMessage=function(e){return"Open access"===e.accessibility?"The data can be accessed by clicking on the link below":"Restricted access"===e.accessibility?"The data are under embargo until <b>"+e.publiclyAccessibleYear+"</b> but could be released earlier. Currently, they are only accessible to proposal team members.":void 0},Event.prototype={attach:function(e){this._listeners.push(e)},notify:function(e){for(var t=0;t<this._listeners.length;t++)this._listeners[t](this._sender,e)}},ExperimentalReportController.prototype.requestFilenameList=function(e){var t=this;if(e){aroundHyphenRegExp=new RegExp(/^(.*)-(.*)/);var r=aroundHyphenRegExp.exec(e)[1],n=aroundHyphenRegExp.exec(e)[2];r&&n&&$.ajax({type:"GET",timeout:this.timeout,url:this.server,data:{categoryCode:r,categoryCounter:n},dataType:"json",success:function(e){t.onSuccess.notify(e)},error:function(e){t.onError.notify(e)}})}else t.onError.notify("Proposal is null")},ExperimentalReportController.prototype.openFileInNewTab=function(t){if(t)try{window.open("ftp://www.esrf.eu/pub/UserReports/"+t,"_blank")}catch(e){alert("The requested file "+t+" could not be downloaded.")}},JsonExtractor.prototype.extractInvestigationId=function(e){RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);return"investigationId"},JsonExtractor.prototype.getFieldFromSubject=function(e,t){if(e&&e[0])for(var r=new RegExp("^"+t,"i"),n=0;n<e[0].length;n++)if(r.test(e[0][n].subject_scheme)&&e[0][n].text)return _.split(e[0][n].text,",");return null},JsonExtractor.prototype.getMintingYear=function(e){return e&&e.date_registered&&null!=e.date_registered?moment(e.date_registered).year():null},JsonExtractor.prototype.getSessionDate=function(e){return e&&e.date_collected&&null!=e.date_collected?moment(e.date_collected).format("YYYY-M-D"):null},JsonExtractor.prototype.getResourceTypeGeneral=function(e){return e&&e.resource_type_general?e.resource_type_general:null},JsonExtractor.prototype.getResourceType=function(e){if(e&&e.resource_type){if("Experiment Session"===e.resource_type)return CONSTANTS.ES_RESOURCE_TYPE;if("Datacollection"===e.resource_type)return CONSTANTS.DC_RESOURCE_TYPE}return null},dust.helpers.proposalBeamLineTable=proposalBeamLineTable;
\ No newline at end of file
function Author(){}Author.prototype.setFirstName=function(e){this.firstName=e},Author.prototype.setFamilyName=function(e){this.familyName=e},Author.prototype.setSingleName=function(e){this.singleName=e},Author.prototype.getRawFamilyName=function(){if(this.familyName)return this.familyName;if(this.singleName){var e=new RegExp(/(\S+)/g),t=this.singleName.match(e);if(2===t.length)return this.familyName=t[1],this.familyName;var r=new RegExp(/\s([^a-z]+$)/).exec(this.singleName);return r&&(this.familyName=r[1]),this.familyName}},Author.prototype.getRawFirstName=function(){if(this.firstName)return this.firstName;if(this.singleName){var e=new RegExp(/(\S+)/g),t=this.singleName.match(e);if(2===t.length)return this.firstName=t[0],this.firstName;var r=new RegExp(/^(.[^A-Z]+)+\b/).exec(this.singleName);return r&&(this.firstName=r[0]),r}},Author.prototype.getTitleCaseFamilyName=function(){if(this.familyName){allLowerCase=this.familyName.toLowerCase();var e=new RegExp(/^./);return allLowerCase.replace(e,function(e){return e.toUpperCase()})}return console.log("family name is undefined"),null},Author.prototype.getFirstNameInitials=function(){var e=new RegExp(/(\S+)/g);return this.firstName?this.firstName.replace(e,function(e){return e.charAt(0)+"."}):(console.log("first name is undefined"),null)};var BEAMLINEURL=[{name:"BM05",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"},{name:"BM29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"},{name:"CM01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"},{name:"ID01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"},{name:"ID06",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"},{name:"ID11",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"},{name:"ID16A",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"},{name:"ID16B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"},{name:"ID17",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"},{name:"ID19",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"},{name:"ID21",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"},{name:"ID22",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id22"},{name:"ID23-1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"},{name:"ID23-2",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"},{name:"ID29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"},{name:"ID30A1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/MASSIF1"},{name:"ID30A3",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"},{name:"ID30B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id30b"},{name:"ID32",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/ID32"}];function Citation(e){this.isBuildable=!!(e&&e.creator&&0!==e.creator.length&&e.date_registered&&e.title&&e.publisher&&e.doi)}Citation.prototype.getAuthorsForCitation=function(e){if(this.isBuildable){var t=_.transform(e,function(e,t,r,n){n instanceof Array||(t=n);var i=null;if(t.givenName?((i=new Author).setFamilyName(t.familyName),i.setFirstName(t.givenName),e.push(i.getTitleCaseFamilyName()+" "+i.getFirstNameInitials())):((i=new Author).setSingleName(t.name),i.getRawFamilyName()&&i.getRawFirstName()?e.push(i.getTitleCaseFamilyName()+" "+i.getFirstNameInitials()):e.push(t.name)),!(n instanceof Array))return!1},[]);return _.join(t,", ")}return console.log("the author list for the citation could not be generated."),""};var CONSTANTS={ES_RESOURCE_TYPE:"experimental session resource type",DC_RESOURCE_TYPE:"dataset collection resource type"};function DOIController(e){var r=this;this.doiServer="https://api.test.datacite.org/",this.acceptedPrefix=["10.5072","10.15151"],this.view=e,this.experimentalReportController=new ExperimentalReportController,this.experimentalReportController.onSuccess.attach(function(e,t){r.view.renderExperimentalReportData(t)}),this.experimentalReportController.onError.attach(function(e,t){console.log("Error when retrieving fileList from SMIS."),r.view.renderErrorForExperimentalReport()})}function DoiData(){}function DOIView(){this.mainPanelId="main",this.reportPanelId="expReport",this.badgePanelId="badges",this.metadataDivId="metadata",this.reportExperimentFileNames=null,this.failedRecievingExpReport=!1,this.isDOIAlreadyRendered=!1,this.onDOIRendered=new Event(this)}function Event(e){this._sender=e,this._listeners=[]}function ExperimentalReportController(){this.server="https://wwws.esrf.fr/misapps/SMISServer/rest/reports/fileNames",this.timeout=5e3,this.onSuccess=new Event(this),this.onError=new Event(this)}function JsonExtractor(e){}function proposalBeamLineTable(e,t,r,n){var i=n.proposals,a=n.beamlines;e.write('<table class="table table-striped">'),e.write("<thead>"),e.write("<tr>"),e.write('<th scope="col">Proposal</th>'),e.write('<th scope="col">Beamline</th>'),e.write("</tr>"),e.write("</thead>"),e.write("<tbody>");for(var o=0;o<i.length;o++){i[o],a[o];e.write("<tr>"),e.write("<td>"+i[o]+"</td>"),a[o]?e.write("<td>"+a[o]+"</td>"):chunck.write("<td> unknown </td>"),e.write("</tr>")}return e.write("</tbody>"),e.write("</table>"),e.render(r.block,t)}DOIController.prototype.isValidDOIData=function(e){return 3<_.keysIn(e).length&&0<_.find(_.keysIn(e),function(e){return"title"===e}).length},DOIController.prototype.getData=function(i){var a=this;this.view.setDOIInTopBanner(i),this.hasAcceptedPrefix(i)?$.ajax({headers:{Accept:"application/vnd.datacite.datacite+json"},type:"GET",timeout:15e3,url:this.doiServer+i,beforeSend:function(e){a.view.setLoading("Retrieving data from Server"),e.setRequestHeader("Authorization","Basic "+btoa("DATACITE.ESRF:datacyte1"))},complete:function(){a.view.setLoading(!1)}}).done(function(e){if(e)if(a.isValidDOIData(e)){var t=new DoiData;t.title=e.title,t.doi=e.doi.toUpperCase(),t.dataciteLink=a.doiServer+i,t.publisher=e.publisher,t.creator=e.creator;var r=new JsonExtractor;if(t.mintingYear=r.getMintingYear(e),t.sessionDate=r.getSessionDate(e),t.publiclyAccessibleYear=e.publication_year,t.proposalType=r.getFieldFromSubject(e.subject,"Proposal Type Description"),t.proposalName=r.getFieldFromSubject(e.subject,"Proposal"),a.experimentalReportController.requestFilenameList(t.proposalName),t.beamline=r.getFieldFromSubject(e.subject,"Instrument"),t.investigationId=r.extractInvestigationId(e),t.resourceType=r.getResourceType(e),t.accessibility=t.getAccessibilityStatus(t.resourceType,t.sessionDate,t.publiclyAccessibleYear),t.accessMessage=a.view.setDataAccessMessage(t),t.citation=a.createCitation(e),t.resourceTypeGeneral=r.getResourceTypeGeneral(e),t.DC_RESOURCE_TYPE=CONSTANTS.DC_RESOURCE_TYPE,t.ES_RESOURCE_TYPE=CONSTANTS.ES_RESOURCE_TYPE,e.date_collected){var n=moment(e.date_collected);t.beamlineUrl=a.getBeamlineUrl(t.beamline,n)}else t.beamlineUrl="noLink";a.view.renderDOIData(t)}else a.view.renderError("Not Found",a.origin)}).fail(function(e,t,r){a.view.renderError(e,r,a.origin),a.view.setLoading(!1)}):a.view.renderError("Bad Prefix",a.origin)},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return-1!=_.findIndex(this.acceptedPrefix,function(e){return t==e})},DOIController.prototype.displayMainContent=function(e){"welcome-page"===this.origin&&dust.render("welcome_tpl",{},function(e,t){$("#main").html(t)}),"index"===this.origin&&this.getData(e)},DOIController.prototype.setOrigin=function(e){this.origin=e},DOIController.prototype.getBeamlineUrl=function(e,t){for(var r=0;r<BEAMLINEURL.length;r++){var n=moment(BEAMLINEURL[r].startDate),i=moment(BEAMLINEURL[r].endDate);if(BEAMLINEURL[r].name.toLowerCase()===e.toLowerCase()&&n<=t&&t<=i)return BEAMLINEURL[r].url}return null},DOIController.prototype.createCitation=function(e){var t=new Citation(e);return t.isBuildable?t.getAuthorsForCitation(e.creator)+" ("+moment(e.date_registered).year()+"). "+e.title+". "+e.publisher+" (ESRF). <a href='https://doi.esrf.fr/"+e.doi+"'> doi:"+e.doi.toUpperCase()+"</a>":"The citation could not be generated."},DoiData.prototype.getAccessibilityStatus=function(e,t,r){if(e)if(e===CONSTANTS.ES_RESOURCE_TYPE){if(r&&t){var n=moment(r,"YYYY"),i=moment();if(n<i)return"Open access";if(i<=n)return"Restricted access"}}else if(e===CONSTANTS.DC_RESOURCE_TYPE)return"Open access";return console.log("Failed to determine whether the accessibility of the DOI."),"Accessibility status could not be determined"},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOIInTopBanner=function(e){$("#doiValue").text("DOI > "+e.toUpperCase())},DOIView.prototype.renderExperimentalReportData=function(e){if(e){var r=this;this.isDOIAlreadyRendered?dust.render("experimentalreport_tpl",{data:e},function(e,t){$("#"+r.reportPanelId).html(t)}):this.reportExperimentFileNames=e}},DOIView.prototype.renderDOIData=function(r){var n=this;dust.render("landingpage_tpl",{data:r},function(e,t){$("#"+n.mainPanelId).html(t),n.isDOIAlreadyRendered=!0,n.renderBadges(r),n.renderMetadata(r),n.failedRecievingExpReport?n.renderErrorForExperimentalReport():n.reportExperimentFileNames&&n.renderExperimentalReportData(n.reportExperimentFileNames)})},DOIView.prototype.renderError=function(e,t,r){var n="welcome-page"===r?"doinotfound2_tpl":"doinotfound_tpl",i="";i="Bad Prefix"===t?"welcome-page"===r?'<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>':'<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>':"Not Found"===t?"welcome-page"===r?"<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>":"<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>":"timeout"===t?"welcome-page"===r?"<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>":"<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>":""===t&&"The resource you are looking for doesn't exist."===e.responseText?"welcome-page"===r?"<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>":"<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>":"welcome-page"===r?"<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>":"<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>",dust.render(n,{message:i},function(e,t){$("#error").html(t)})},DOIView.prototype.renderErrorForExperimentalReport=function(){this.failedRecievingExpReport=!0;$("#"+this.reportPanelId).html('<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>')},DOIView.prototype.renderBadges=function(e){if(e){var r=this;dust.render("badges_tpl",{data:e},function(e,t){$("#"+r.badgePanelId).html(t)})}},DOIView.prototype.renderMetadata=function(e){if(e){var r=this;dust.render("metadata_tpl",{data:e},function(e,t){$("#"+r.metadataDivId).html(t)})}},DOIView.prototype.setDataAccessMessage=function(e){return"Open access"===e.accessibility?"The data can be accessed by clicking on the link below":"Restricted access"===e.accessibility?"The data are under embargo until <b>"+e.publiclyAccessibleYear+"</b> but could be released earlier. Currently, they are only accessible to proposal team members.":void 0},Event.prototype={attach:function(e){this._listeners.push(e)},notify:function(e){for(var t=0;t<this._listeners.length;t++)this._listeners[t](this._sender,e)}},ExperimentalReportController.prototype.requestFilenameList=function(e){var t=this;if(e){aroundHyphenRegExp=new RegExp(/^(.*)-(.*)/);var r=aroundHyphenRegExp.exec(e)[1],n=aroundHyphenRegExp.exec(e)[2];r&&n&&$.ajax({type:"GET",timeout:this.timeout,url:this.server,data:{categoryCode:r,categoryCounter:n},dataType:"json",success:function(e){t.onSuccess.notify(e)},error:function(e){t.onError.notify(e)}})}else t.onError.notify("Proposal is null")},ExperimentalReportController.prototype.openFileInNewTab=function(t){if(t)try{window.open("ftp://www.esrf.eu/pub/UserReports/"+t,"_blank")}catch(e){alert("The requested file "+t+" could not be downloaded.")}},JsonExtractor.prototype.extractInvestigationId=function(e){RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);return"investigationId"},JsonExtractor.prototype.getFieldFromSubject=function(e,t){if(e&&e[0])for(var r=new RegExp("^"+t,"i"),n=0;n<e[0].length;n++)if(r.test(e[0][n].subject_scheme)&&e[0][n].text)return _.split(e[0][n].text,",");return null},JsonExtractor.prototype.getMintingYear=function(e){return e&&e.date_registered&&null!=e.date_registered?moment(e.date_registered).year():null},JsonExtractor.prototype.getSessionDate=function(e){return e&&e.date_collected&&null!=e.date_collected?moment(e.date_collected).format("YYYY-M-D"):null},JsonExtractor.prototype.getResourceTypeGeneral=function(e){return e&&e.resource_type_general?e.resource_type_general:null},JsonExtractor.prototype.getResourceType=function(e){if(e&&e.resource_type){if("Experiment Session"===e.resource_type)return CONSTANTS.ES_RESOURCE_TYPE;if("Datacollection"===e.resource_type)return CONSTANTS.DC_RESOURCE_TYPE}return null},dust.helpers.proposalBeamLineTable=proposalBeamLineTable;
\ No newline at end of file
......@@ -104,4 +104,4 @@ JsonExtractor.prototype.getResourceType = function (data) {
}
}
return null;
};
\ No newline at end of file
};
......@@ -11,9 +11,9 @@ function proposalBeamLineTable(chunk, context, bodies, params) {
chunk.write('</thead>');
chunk.write('<tbody>');
for (let index = 0; index < proposals.length; index++) {
const proposal = proposals[index];
const beamline = beamlines[index];
for (var index = 0; index < proposals.length; index++) {
var proposal = proposals[index];
var beamline = beamlines[index];
chunk.write('<tr>');
chunk.write('<td>' + proposals[index] + '</td>');
......
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