Commit 1f6cce25 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed layout issues.

parent 4e780b18
Pipeline #78614 skipped with stage
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,12 +2,12 @@ window.nomadEnv = {
//host: "https://labdev-nomad.esc.rzg.mpg.de/dev/nomad/encyclopedia-api/",
//path: "api/encyclopedia/",
//userCookieDomain: ".esc.rzg.mpg.de",
host: "https://repository.nomad-coe.eu/app/",
path: "api/encyclopedia/",
userCookieDomain: ".repository.nomad-coe.eu",
//host: "/",
//path: "",
//userCookieDomain: ".localhost",
//host: "https://repository.nomad-coe.eu/app/",
//path: "api/encyclopedia/",
//userCookieDomain: ".repository.nomad-coe.eu",
host: "/",
path: "",
userCookieDomain: ".localhost",
guestUserToken: 'eyJhbGciOiJIUzI1NiIsImlhdCI6MTUyMzg4MDE1OSwiZXhwIjoxNjgxNTYwMTU5fQ.ey'+
'JpZCI6ImVuY2d1aSJ9.MsMWQa3IklH7cQTxRaIRSF9q8D_2LD5Fs2-irpWPTp4'
};
......@@ -22,8 +22,15 @@
In addition it creates app life-time entities for convenience
*/
let materialData;
let groups;
let calcsInGroups;
let calcs;
let representatives;
let idealizedStructure;
let calcMap = new Map();
let ready = false;
let hasThermalData, hasElecStructureData;
function setMaterialData(dataFromAPI){
materialData = dataFromAPI;
......@@ -33,10 +40,13 @@ function getMaterialData(){
return materialData;
}
function setIdealizedStructure(structure){
idealizedStructure = structure;
}
let calcs;
let representatives;
let calcMap = new Map();
function getIdealizedStructure(){
return idealizedStructure;
}
function setCalculations(calcsFromAPI){
calcs = calcsFromAPI.results;
......@@ -58,9 +68,6 @@ function getCalc(calcId){
return calcMap.get(calcId);
}
let groups;
let calcsInGroups;
/**
* Stores the group information from API into an easily accessible format.
*/
......@@ -102,6 +109,28 @@ function getGroupId(leafId) {
return leafId.substring(4);
}
function isReady(matId) {
if (materialData !== undefined) {
if (idealizedStructure !== undefined) {
if (calcs !== undefined) {
if (groups !== undefined) {
if (matId === materialData.material_id) {
return true;
}
}
}
}
}
return false;
}
function clear() {
materialData = undefined;
calcs = undefined;
groups = undefined;
idealizedStructure = undefined;
}
function isInAnyGroup(calcId){
return calcsInGroups.has(calcId);
}
......@@ -119,7 +148,6 @@ function getGroupLeafId(calcId){
}
let hasThermalData, hasElecStructureData;
/*
function hasThermalData(bool){
......@@ -143,5 +171,5 @@ function setHasElecStructureData(bool){
// EXPORTS
module.exports = { getRepresentatives, setMaterialData, getMaterialData, getCalculations, getCalc,
setCalculations, getGroups, getGroupId, setGroups, isGroup, getGroupType,
getReprCalc, isInAnyGroup, isInAnyNotDisabledGroup, getGroupLeafId,
getReprCalc, isInAnyGroup, isInAnyNotDisabledGroup, getGroupLeafId, isReady, clear, setIdealizedStructure, getIdealizedStructure,
hasThermalData, hasElecStructureData};
......@@ -40,10 +40,6 @@ let DataStore = require('./DataStore.js');
let LoadingPopup = require('../common/LoadingPopup.js');
// Store material data at this level (material model) ?
let materialData = {};
let materialCalcsData = null;
// Store the default marked tree leafs
let markedTreeLeafs = { eStruct: null, thermalProps: null };
......@@ -147,48 +143,40 @@ class MaterialMod {
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._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 materialData = DataStore.getMaterialData();
let idealizedStructure = DataStore.getIdealizedStructure();
// 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(idealizedStructure);
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(idealizedStructure);
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;
}
}
}
}
let ready = DataStore.isReady(matId);
if (ready) {
show();
}
return false;
return ready;
};
// If material is already loaded, nothing fetched.
if (!isReady()) {
DataStore.clear();
this.structureViewer.axisCheckbox.checked = true;
this.structureViewer.bondsCheckbox.checked = true;
document.getElementById('methodology-ov').style.visibility = 'hidden';
......@@ -200,8 +188,8 @@ class MaterialMod {
// 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);
let materialData = JSON.parse(e1.target.response);
DataStore.setMaterialData(materialData);
util.materialId = materialData.material_id;
isReady();
LoadingPopup.hide("load_basic");
......@@ -220,7 +208,9 @@ class MaterialMod {
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;
let struct = JSON.parse(e2.target.response).idealized_structure;
console.log(struct);
DataStore.setIdealizedStructure(struct);
document.getElementById('structure-ov').style.visibility = 'visible';
document.getElementById('methodology-ov').style.visibility = 'visible';
isReady();
......@@ -234,7 +224,6 @@ class MaterialMod {
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");
});
......@@ -255,7 +244,7 @@ class StructureViewerWrapper {
view: {
autoResize: false,
autoFit: true,
fitMargin: 0.3,
fitMargin: 0.5,
},
structure: {
createLegend: false,
......
......@@ -445,7 +445,6 @@ class Overview {
if (calcWithBS === undefined && calcWithDOS === undefined) {
DataStore.hasElecStructureData = false;
} else {
console.log("HERE");
document.getElementById('e-structure-ov').style.display = 'block';
let isReady = () => {
if (this.dosLoaded && this.bsLoaded) {
......@@ -530,7 +529,7 @@ class Overview {
LoadingPopup.show();
let query = JSON.stringify({properties: ["thermodynamical_properties"]});
util.serverReqPOST(url, query, e => {
if (e.target.status === 200){
if (e.target.status === 200) {
let response = JSON.parse(e.target.response);
let thermoProp = response.thermodynamical_properties;
let t = thermoProp.thermodynamical_property_temperature;
......@@ -544,9 +543,7 @@ class Overview {
});
}
}
} // setCalcsData function
}
}
// EXPORTS
......
Supports Markdown
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