Commit 4e780b18 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed ordering issue in methodology page.

parent 67cf0ecf
Pipeline #78520 skipped with stage
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -469,7 +469,12 @@ function generateDiagramSteps(maxVal, d=4){
return [stepArray, exp];
}
function getDefault(value, fallback="unavailable") {
if (value === undefined || value === null) {
return fallback;
}
return value;
}
/*
function addBandGapData(calcJson, bsData){
......@@ -533,6 +538,7 @@ module.exports = {
getAverage,
generateDiagramSteps,
getCalcMapByFunctional,
getDefault,
//is2DSystem_temporary_patch
//addBandGapData
};
......@@ -135,8 +135,8 @@ class FilterInGroupsComponent {
calcs.forEach( c => {
if (!lCalcTypesMap.has(c.type))
lCalcTypesMap.set(c.type, calcTypesMap.get(c.type));
if (!lDensityFunctionalMap.has(c.functional))
lDensityFunctionalMap.set(c.functional, c.functional);
if (!lDensityFunctionalMap.has(c.functional_type))
lDensityFunctionalMap.set(c.functional_type, c.functional_type);
if (!lCodeMap.has(c.code))
lCodeMap.set(c.code, c.code);
if (!lPotentialMap.has(c.core_electron_treatment))
......@@ -247,16 +247,14 @@ class MethodologyDetails extends DetailsViewBase {
this.moreInfoRow.className= 'moreinfo';
this.moreInfoCalcId = null;
// filtering feature initialitation
// Filtering feature initialization
this.filterComponent = new FilterInGroupsComponent('meth-filter-component');
this.element.querySelector('.filter-placeholder').
appendChild(this.filterComponent.element);
this.filterComponent.setItemListener( propsSel => {
// console.log('FILTERING propsSel: ',propsSel);
this.sortedCalcs.forEach( rowCalcData => { //leafId => {
let calcProps = rowCalcData.dataCalcProps.split(',');
//console.log('FILTERING calcProps: ',calcProps);
let propsPresent = true;
calcProps.forEach( e => {
if (propsSel.indexOf(e) < 0) propsPresent = false;
......@@ -267,16 +265,16 @@ class MethodologyDetails extends DetailsViewBase {
this._render();
});
// row sorting feature initialitation
// Row sorting feature initialization
this.sortingButtonWrappers =
this.dataTableWrapper.querySelectorAll('.sorting-button');
this.sortingButtons = [];
let sortingButtonsMap = new Map([
[ 'id', undefined ],
[ 'calc_id', undefined ],
[ 'type', undefined ],
[ 'functional', undefined ],
[ 'functional_type', undefined ],
[ 'code', undefined ],
[ 'core_electron_treatment', undefined ],
[ 'basis_set_type', undefined ] ]);
......@@ -289,7 +287,6 @@ class MethodologyDetails extends DetailsViewBase {
this.sortingButtons.push(component);
component.setListener( (descendingOrder, field) => {
//console.log(descendingOrder, field);
this.sortingButtons.forEach( el => {
if (el !== component) el.init();
});
......@@ -403,9 +400,9 @@ class MethodologyDetails extends DetailsViewBase {
this.sortedCalcs.push({
calc_id: c.calc_id,
type: calcType,
functional: c.functional_type,
functional_type: util.getDefault(c.functional_type),
code: c.code_name,
core_electron_treatment: c.core_electron_treatment,
core_electron_treatment: util.getDefault(c.core_electron_treatment),
basis_set_type: c.basis_set_type,
dataCalcProps: calcType+','+c.functional_type+','+c.code_name+
','+c.core_electron_treatment+','+c.basis_set_type,
......@@ -415,7 +412,7 @@ class MethodologyDetails extends DetailsViewBase {
this.filterComponent.addGroupsItems(this.sortedCalcs);
this._sortRowsCalcDataBy(true, 'id');
this._sortRowsCalcDataBy(true, 'calc_id');
this._render();
}
......@@ -424,28 +421,24 @@ class MethodologyDetails extends DetailsViewBase {
_sortRowsCalcDataBy(descendingOrder, field){
this.sortedCalcs.sort( (a, b) => {
if(a[field] < b[field]) return (descendingOrder ? -1 : 1);
if(a[field] > b[field]) return (descendingOrder ? 1 : -1);
return 0;
let order = descendingOrder ? -1 : 1;
return a[field] < b[field] ? order : -order;
});
}
updateMarkedLeaf(leafId){ }
_render(){
let html = '';
this.sortedCalcs.forEach( rowCalcData => { //leafId => {
//html+= getRowHtml(leafId, calc, calcType);
if (rowCalcData.visible) html+= getRowHtml(rowCalcData);
});
this.tbody.innerHTML = html;
InfoSys.addToInfoSystem(this.tbody);
function getRowHtml(rowCalcData/*leafId, calc, calcType*/){
function getRowHtml(rowCalcData/*leafId, calc, calcType*/) {
let calc = DataStore.getCalc( /*DataStore.getCalcReprIntId(*/rowCalcData.calc_id);
let calcType = rowCalcData.type;
......@@ -469,8 +462,8 @@ class MethodologyDetails extends DetailsViewBase {
${calcType}</span>
</td>
<td>
<span info-sys-data="functional-type.value:${calc.functional_type}">
${calc.functional_type}</span>
<span info-sys-data="functional-type.value:${rowCalcData.functional_type}">
${rowCalcData.functional_type}</span>
${getOptValue(calc.functional_long_name)}
</td>
<td>
......@@ -480,8 +473,8 @@ class MethodologyDetails extends DetailsViewBase {
</td>
<td>
<span info-sys-data="core-electron-treatment.value:${calc.core_electron_treatment}">
${getPotentialValue(calc.core_electron_treatment)}</span>
<span info-sys-data="core-electron-treatment.value:${rowCalcData.core_electron_treatment}">
${rowCalcData.core_electron_treatment}</span>
</td>
<td>
<span info-sys-data="basis-set-type.value:${calc.basis_set_type}">
......@@ -497,16 +490,6 @@ class MethodologyDetails extends DetailsViewBase {
</tr>`;
}
function getOptValue(value){
if (value === undefined || value === null) return '';
else return '('+value+')';
}
function getPotentialValue(value){
if (value === undefined || value === null) return 'unavailable';
else return value;
}
}
}
......@@ -516,14 +499,16 @@ function getValueHTML(text,value){
else return '<b>'+text+'</b>: '+value+'<br>';
}
function getSmearingHTML(value){
let values = value.substring(1,value.length-1).split(',');
return (values[0] === 'none' ? '' : '<b>smearing kind</b>: '+values[0]+' , ')+
(values[1] === '0' ? '' : '<b>smearing width</b>: '+values[1]);
}
function getOptValue(value){
if (value === undefined || value === null) return '';
else return '('+value+')';
}
// EXPORTS
module.exports = MethodologyDetails;
......@@ -340,22 +340,6 @@ class Overview {
}
}
/**
* Used to calculate a score that indicates the "quality" of the calculation.
*/
_evaluateCalc(calc){
let value = 0;
if (calc.functional_type === 'GGA') value += 100;
if (calc.has_band_structure && calc.has_dos) value += 10;
switch (calc.code_name.trim()) {
case 'FHI-aims': value += 3; break;
case 'VASP': value += 2; break;
case 'Quantum Espresso': value += 1; break;
}
return value;
}
isLoaded(hasBs, hasDOS, hasPhonon) {
let materialData = DataStore.getMaterialData();
let material_id = materialData.material_id;
......@@ -434,8 +418,8 @@ class Overview {
let container = document.createElement("div");
functionalMap.forEach((number, functional) => {
let span = document.createElement("span");
span.setAttribute("info-sys-data", "functional-type.value:" + functional);
span.textContent = number + ' ' + functional;
span.setAttribute("info-sys-data", "functional-type.value:" + util.getDefault(functional));
span.textContent = number + ' ' + util.getDefault(functional);
container.appendChild(span);
let linebreak = document.createElement("br");
container.appendChild(linebreak);
......@@ -443,7 +427,7 @@ class Overview {
this.functional.append(container);
InfoSys.addToInfoSystem(this.functional);
//// Add list of codes
// Add list of codes
this.code.textContent = "";
let container2 = document.createElement("div");
codeMap.forEach((number, codeName) => {
......
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