Commits (1)
This diff is collapsed.
window.nomadEnv = {
//host: "https://labdev-nomad.esc.rzg.mpg.de/dev/nomad/encyclopedia-api/",
//path: "api/encyclopedia/",
//userCookieDomain: ".esc.rzg.mpg.de",
host: "/",
path: "",
......
......@@ -180,7 +180,7 @@ PubSub.subscribe('show-material', data => {
if (typeof materialModDOM === 'undefined'){
MaterialModule = new MaterialMod();
materialModDOM= MaterialModule.element;
materialModDOM = MaterialModule.element;
}
showModuleDOM(materialModDOM);
MaterialModule.setMaterialView(data);
......@@ -213,23 +213,15 @@ PubSub.subscribe('show-search', search => {
});
/****** App routing config ******/
Router.add('search', search => PubSub.publish('show-search', search));
Router.add('material', (matId, view) => PubSub.publish('show-material', {'material_id': matId, 'view': view}));
/****** init ******/
searchMod = new SearchModule();
//console.log('document.location: '+document.location.hash);
if (document.location.hash === '') document.location += "#/search";
Router.route();
/********* User authentication ***********/
let userNameElement = document.querySelector('#user-name');
......
......@@ -172,7 +172,7 @@ class ElectronicStructDetails extends DetailsViewBase {
this.fermiBox= this.element.getElementsByClassName('fermi-box')[0];
// Load the x3dom library
util.loadLib("lib/x3dom.js");
//util.loadLib("lib/x3dom.js");
this.bzViewerWrapper = new BZViewerWrapper(this.element.querySelector('.bz-viewer-wrapper'));
......
......@@ -41,7 +41,8 @@ let LoadingPopup = require('../common/LoadingPopup.js');
// Store material data at this level (material model) ?
let materialData = null, materialCalcsData = null;
let materialData = {};
let materialCalcsData = null;
// Store the default marked tree leafs
let markedTreeLeafs = { eStruct: null, thermalProps: null };
......@@ -76,16 +77,7 @@ class MaterialMod {
}
setMaterialView(data) {
if (materialData === null || materialData.material_id !== data.material_id){
// Reset the checkboxes to the initial checked value (new material)
this.structureViewer.axisCheckbox.checked = true;
this.structureViewer.bondsCheckbox.checked = true;
this._loadMaterial(data.material_id, data.view);
} else {
this._setView(data.view);
document.querySelector('title').innerHTML = 'NOMAD Encyclopedia - '+
util.getMaterialTitle(DataStore.getMaterialData(), false);
}
this._loadMaterial(data.material_id, data.view);
}
getCurrentPageStatus(){
......@@ -113,7 +105,6 @@ class MaterialMod {
this.currentDetailView = null;
this.currentDetailViewId = null;
this.overview.setVisible();
this._setCellViewer(this.overview.vizBox);
} else {
this.currentDetailViewId = view;
this._setDetailView(util.MAT_VIEW[view]);
......@@ -145,18 +136,6 @@ class MaterialMod {
// Show the view
this.currentDetailView.setVisible();
// Load data into active view. Only reloads if data has changed (as
// detected from materialId).
this.currentDetailView.load();
// Cell viewer needs to be set only after page is visible so that it is
// resized correctly.
if (view === util.MAT_VIEW.structure)
this._setCellViewer(this.structureDetails.vizBox);
if (view === util.MAT_VIEW.methodology) {
this.methodologyDetails.updateSelection();
}
}
/**
......@@ -165,56 +144,95 @@ class MaterialMod {
_loadMaterial(matId, view) {
// Set to loading mode
document.getElementById('e-structure-ov').style.display = 'none';
document.getElementById('thermal-props-ov').style.display = 'none';
this.overview.element.style.visibility= 'hidden';
LoadingPopup.show("load_overview");
LoadingPopup.show("load_groups");
// Request basic material data
util.serverReq(util.getMaterialURL(matId), e1 => {
materialData = JSON.parse(e1.target.response);
util.materialId = materialData.material_id;
if (e1.target.status === 200) {
// Get basic details for all calculations related to this material
util.serverReq(util.getMaterialXsURL('calculations', matId), e4 => {
let calculations = JSON.parse(e4.target.response);
let representatives = calculations.representatives;
let idealId = representatives.idealized_structure;
DataStore.setCalculations(calculations);
// Get the idealized structure
//util.serverReq(util.getMaterialXsURL('idealized_structure', matId), e2 => {
let query = JSON.stringify({properties: ["idealized_structure"]});
util.serverReqPOST(util.getMaterialCalcURL(matId, idealId), query, e2 => {
materialData.idealized_structure = JSON.parse(e2.target.response).idealized_structure;
this._setView(view);
let show = () => {
// Cell viewer needs to be set only after page is visible so that it is
// resized correctly.
if (this.currentDetailView !== null) {
this.currentDetailView.load();
if (view === util.MAT_VIEW.structure)
this.structureViewer.load(materialData.idealized_structure);
this._setView(view);
this.overview.element.style.visibility = 'visible';
// Store data for later use
DataStore.setMaterialData(materialData);
document.querySelector('title').innerHTML =
'NOMAD Encyclopedia - '+util.getMaterialTitle(materialData, false);
this.overview.setMaterialData();
// Show the view
LoadingPopup.hide("load_overview");
let name = (materialData.material_name === null ? materialData.formula : materialData.material_name);
this.overview.setCalcsData(markedTreeLeafs);
});
});
// Get groups
util.serverReq(util.getMaterialXsURL('groups', matId), e5 => {
let groups = JSON.parse(e5.target.response);
DataStore.setGroups(groups);
LoadingPopup.hide("load_groups");
this._setCellViewer(this.structureDetails.vizBox);
if (view === util.MAT_VIEW.methodology) {
this.methodologyDetails.updateSelection();
}
} else {
document.querySelector('title').innerHTML =
'NOMAD Encyclopedia - '+util.getMaterialTitle(materialData, false);
this.overview.setMaterialData();
let name = (materialData.material_name === null ? materialData.formula : materialData.material_name);
this.overview.setCalcsData(markedTreeLeafs);
this.structureViewer.load(materialData.idealized_structure);
this._setCellViewer(this.overview.vizBox);
}
};
let isReady = () => {
let materialData = DataStore.getMaterialData();
let calcs = DataStore.getCalculations();
let groups = DataStore.getGroups();
if (materialData !== undefined) {
if (materialData.idealized_structure !== undefined) {
if (calcs !== undefined) {
if (groups !== undefined) {
if (matId === materialData.material_id) {
show();
return true;
}
}
}
}
}
return false;
};
// If material is already loaded, nothing fetched.
if (!isReady()) {
this.structureViewer.axisCheckbox.checked = true;
this.structureViewer.bondsCheckbox.checked = true;
// Request basic material data
LoadingPopup.show("load_basic");
util.serverReq(util.getMaterialURL(matId), e1 => {
let basicMaterialData = JSON.parse(e1.target.response);
Object.assign(materialData, basicMaterialData);
util.materialId = materialData.material_id;
isReady();
LoadingPopup.hide("load_basic");
});
// Request basic details for all calculations related to this material
LoadingPopup.show("load_calculations");
util.serverReq(util.getMaterialXsURL('calculations', matId), e4 => {
let calculations = JSON.parse(e4.target.response);
let representatives = calculations.representatives;
let idealId = representatives.idealized_structure;
DataStore.setCalculations(calculations);
// Get the idealized structure
//util.serverReq(util.getMaterialXsURL('idealized_structure', matId), e2 => {
let query = JSON.stringify({properties: ["idealized_structure"]});
LoadingPopup.show("load_idealized");
util.serverReqPOST(util.getMaterialCalcURL(matId, idealId), query, e2 => {
materialData.idealized_structure = JSON.parse(e2.target.response).idealized_structure;
isReady();
LoadingPopup.hide("load_idealized");
});
};
});
}
LoadingPopup.hide("load_calculations");
});
// Request groups
LoadingPopup.show("load_groups");
util.serverReq(util.getMaterialXsURL('groups', matId), e5 => {
let groups = JSON.parse(e5.target.response);
DataStore.setGroups(groups);
DataStore.setMaterialData(materialData);
isReady();
LoadingPopup.hide("load_groups");
});
}
};
} // class MaterialMod
......
......@@ -45,6 +45,9 @@ class Overview {
this.element = document.createElement('div');
this.element.setAttribute('id','overview');
this.materialId;
let bsLoaded = false;
let phononLoaded = false;
let dosLoaded = false;
this.element.innerHTML=`
<div class="material-title">
......@@ -352,6 +355,23 @@ class Overview {
return value;
}
isLoaded(hasBs, hasDOS, hasPhonon) {
let materialData = DataStore.getMaterialData();
let material_id = materialData.material_id;
if (this.materialId === material_id) {
if (hasBs && !this.bsLoaded) {
return false;
}
if (hasDOS && !this.dosLoaded) {
return false;
}
if (hasPhonon && !this.phononLoaded) {
return false;
}
return true;
}
return false;
}
setCalcsData(markedTreeLeafs) {
let matData = DataStore.getMaterialData();
......@@ -364,6 +384,13 @@ class Overview {
let calcWithDOS = DataStore.getCalc(DataStore.getRepresentatives().electronic_dos);
let calcWithHeat = DataStore.getCalc(DataStore.getRepresentatives().thermodynamical_properties);
if (this.isLoaded(calcWithBS !== undefined, calcWithDOS !== undefined, calcWithHeat !== undefined)) {
return;
}
this.bsLoaded = false;
this.dosLoaded = false;
this.phononLoaded = false;
// Gather how many calculations there are for each functional and code
for (let i = 0; i < calcs.length; i++) {
if (functionalMap.has(calcs[i].functional_type)){
......@@ -450,6 +477,7 @@ class Overview {
'</b><br><span style="font-size: 0.8em">('+calcWithBS.functional_type+' - '+calcWithBS.code_name+')</span>';
if (bandStructData.section_k_band_segment[0].band_energies.length === 2)
this.spinLegend.style.display = 'block';
this.bsLoaded = true;
}
LoadingPopup.hide("overview_electronic_band_structure");
});
......@@ -470,6 +498,7 @@ class Overview {
'</b><br><span style="font-size: 0.8em">('+calcWithDOS.functional_type+' - '+calcWithDOS.code_name+')</span>';
if (dosData.dos_values.length === 2)
this.spinLegend.style.display = 'block';
this.dosLoaded = true;
}
LoadingPopup.hide("overview_electronic_dos");
});
......@@ -503,6 +532,7 @@ class Overview {
this.heatPlotter.setData(t, thermoProp.specific_heat_capacity);
this.heatCalcIdBox.innerHTML = 'From calculation <b>'+util.getShortCode(calcWithHeat.calc_id)+'</b>'+
'</b> <span style="font-size: 0.8em">('+calcWithHeat.functional_type+' - '+calcWithHeat.code_name+')</span>';
this.phononLoaded = true;
}
LoadingPopup.hide();
});
......