Commit 4da5a611 authored by Iker Hurtado's avatar Iker Hurtado
Browse files

Open source code release (step 6)

parent c76feacb
Pipeline #30997 passed with stages
in 6 seconds
/**
* Copyright 2016-2018 Iker Hurtado
*
......@@ -15,8 +16,12 @@
*
*/
/* Not finished ****************/
/*
Base class from which other main 'Details' view containers inherit.
Every of these containers shows all the material info related to a type of info:
Structure, Electronic Structure, etc
*/
"use strict";
let util = require('../common/util.js');
......@@ -34,29 +39,32 @@ class DetailsViewBase {
this.element.style.display= 'none';
}
attachAndSetEvents(element){
element.appendChild(this.element);
this.materialTitle= this.element.querySelector('.material-title');
//console.log('attachAndSetEvents');
}
attachNavTree(navTree){
navTree.attach(this.navTreeWrapper);
//console.log('ELECT attachNavTree '+this.navTreeWrapper);
}
setVisible(){
this.element.style.display= 'block';
}
setMaterialData() {
this.materialTitle.innerHTML= util.getMaterialTitle(DataStore.getMaterialData());
}
updateCalcs(calcs){
}
updateMarkedCalc(calc){
}
......
/*
Pending to implement
*/
"use strict";
let DetailsViewBase = require('./DetailsViewBase.js');
......
/**
* Copyright 2016-2018 Iker Hurtado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
'Details' view container that shows all the material info related to
its electronic structure.
This container is quite complex.
In the file there are two defined (classes) components used in the container:
- SummaryByFunctionalsComponent: the component (left panel, below part)
showing a band gap summary info by functional.
- BZViewerWrapper: This component is a wrapper for the Brillouin zone viewer
*/
"use strict";
let DetailsViewBase = require('./DetailsViewBase.js');
......@@ -339,10 +368,10 @@ class ElectronicStructDetails extends DetailsViewBase{
this.nextCalcListener= listener;
}
}
class SummaryByFunctionalsComponent{
constructor(calcMapByFunctional, hostElement){
......@@ -495,11 +524,13 @@ class SummaryByFunctionalsComponent{
class BZViewerWrapper{
constructor(hostElement) {
this.hostElement = hostElement;
this.bzViewer = null;
}
setCalcData(bzData, bsData){
if (this.bzViewer === null)
this.bzViewer = new BrillouinZoneViewer(this.hostElement);
......@@ -507,6 +538,7 @@ class BZViewerWrapper{
this.hostElement.style.visibility = 'visible';
}
setNoData(){
this.hostElement.style.visibility = 'hidden';
}
......@@ -529,7 +561,9 @@ class BZViewerWrapper{
}
return data;
}
}
// EXPORTS
module.exports = ElectronicStructDetails;
......@@ -19,7 +19,7 @@
/*
This file implements the Material Module of the application.
It's a container UI component that displays the selected material information.
It's a UI component container that displays the selected material information.
It's complex because of the amount and diversity of material info available.
In this file other two inner components of the module are implemented
......
/**
* Copyright 2016-2018 Iker Hurtado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
'Details' view container that shows a table with the methodology info used
to get the material calculations.
In the file there is a defined (class) component used as a filter widget for
the table: FilterInGroupsComponent.
*/
"use strict";
let DetailsViewBase = require('./DetailsViewBase.js');
......
/**
* Copyright 2016-2018 Iker Hurtado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
The NavTree class define the UI tree component showing the material calculations.
There is only one instance that is shared by several 'Details' views.
*/
"use strict";
let util = require('../common/util.js');
......@@ -10,11 +32,10 @@ function buildCalcTree(calcs, calcsInGroups){
let calcTree = new Map();
calcsInGroups.forEach( (groupData, groupId) => {
//console.log('GROPOOO ',groupId, reprId, calcMap);
let representative = DataStore.getCalc(DataStore.getCalcReprIntId(groupId));
let codeNameTrimed= representative.code_name.trim();
let functionalType = representative.functional_type;
//console.log('GROUP CODE:',codeNameTrimed);
/***** Exception: disable grouping for some codes
if (codeNameTrimed !== 'VASP' && codeNameTrimed !== 'FHI-aims') */
......@@ -65,7 +86,8 @@ function buildCalcTree(calcs, calcsInGroups){
}
}
/* May these functions (getNextNode, getPreviousNode) can be removed
/* Maybe these functions (getNextNode, getPreviousNode) can be removed
searching by node class calc-l and node-selected. Think about this */
function getNextNode(nodeBox){
......@@ -87,6 +109,7 @@ function getNextNode(nodeBox){
return nextCalcNodeBox;
}
function getPreviousNode(nodeBox){
let prevCalcNodeBox;
if (nodeBox.previousElementSibling !== null)
......@@ -112,14 +135,12 @@ function getPreviousNode(nodeBox){
class NavTree {
constructor() {
//this.calcMap = new Map();
this.selectedCalcs= new Set();
this.element = document.createElement('div');
this.element.setAttribute('id','navigation-tree');
this.parentElement= null;
this.markedNode = null;
//this.calcMarked= true;
this._events();
}
......@@ -134,7 +155,6 @@ class NavTree {
build(materialName){
// Reset
//this.calcMap.clear();
this.selectedCalcs.clear();
this.markedNode = null;
this.element.innerHTML= '';
......@@ -164,21 +184,9 @@ class NavTree {
return '&nbsp; <span class="calc-graph-aval">'+html+'</span>';
}
/*** TO REMOVE
function getCalcSectionAvalabilityHTML(calc){
let html= '';
if (calc.has_band_structure || calc.has_dos || calc.has_fermi_surface)
html += 'data-electronic="true" ';
if (calc.has_heat_capacity_cv || calc.has_qha_data)
html += 'data-thermal="true"';
return html;
}*/
// Init map to store calculations data
let calcs = DataStore.getCalculations();
//for (let i = 0; i < calcs.length; i++)
//this.calcMap.set(calcs[i].id, calcs[i]);
let tree= buildCalcTree(calcs, this.calcsInGroups);
let rootElement= document.createElement('div');
......@@ -186,7 +194,6 @@ class NavTree {
rootElement.innerHTML= getNodeHTML('material-l',materialName,true);
let functionalLevelBox= document.createElement('div');
//this.functionalLevelBox.setAttribute('class','functional-l level-wrapper');
rootElement.appendChild(functionalLevelBox);
tree.forEach((codeMap, functionalName) => {
......@@ -194,20 +201,16 @@ class NavTree {
functionalLevelBox.innerHTML+= getNodeHTML('functional-l',functionalName,true);
let codeLevelBox= document.createElement('div');
//codeLevelBox.setAttribute('class','code-l level-wrapper');
functionalLevelBox.appendChild(codeLevelBox);
codeMap.forEach( (calcArray, codeName) => {
codeLevelBox.innerHTML+= getNodeHTML('code-l', codeName, false, calcArray.length);
let calcLevelBox= document.createElement('div');
//calcLevelBox.setAttribute('class','calc-l level-wrapper');
//calcLevelBox.setAttribute('style','display: none'); /*** level collapsed -> getNodeHTML(false
codeLevelBox.appendChild(calcLevelBox);
calcLevelBox.style.display= 'none';
for (var i = 0; i < calcArray.length; i++) {
//console.log('GGGG', calcArray[i]);
let graphInfoAvalabilityHTML = getCalcGraphInfoAvalabilityHTML(
DataStore.getCalc(DataStore.getCalcReprIntId(calcArray[i])));
......@@ -236,16 +239,13 @@ class NavTree {
}
});
});
// this._events();
} // build method
selectAll(initMarkedLeafId){
let materialNodeBox= this.element.children[0].children[0];
//console.log("TREE.selectAll "+materialNodeBox.innerHTML);
this._recursiveNodeSelection(materialNodeBox, true);
keepTreeIntegrity(materialNodeBox, true);
//this.treeSelectionListener(this.selectedCalcs); selectAll() is called before the tree is shown
// No calc marked
}
......@@ -261,7 +261,6 @@ class NavTree {
if (leafId === null) this._markFirstSelectedNode();
else{
let nodeBox = this.element.querySelector('div[data-calc-id="'+leafId+'"]');
//console.log('setMarkedLeaf:',leafId, nodeBox);
this._setMarkedCalc(nodeBox);
}
}
......@@ -269,13 +268,9 @@ class NavTree {
_events() {
this.element.addEventListener('click',(e) => {
let classString = e.target.className;
//console.log("EVENT TARGET " +classString+ ' '+e.target.innerHTML);
// drop down/up event
if (classString.indexOf('folded') >= 0){
......@@ -283,7 +278,6 @@ class NavTree {
// descendant selection/deselection event
}else if ((classString.indexOf('node-checkbox') >= 0)){
//&& (e.target.parentElement.className.indexOf('material-l') < 0)){
let selectMode= (e.target.parentElement.className.indexOf('selected') < 0);
this._recursiveNodeSelection(e.target.parentElement, selectMode);
......@@ -293,24 +287,13 @@ class NavTree {
}else if (/*this.calcMarked && */(classString.indexOf('node-label') >= 0 )
&& (e.target.parentElement.className === 'calc-l node-selected')){
// console.log('EVENT className: '+e.target.parentElement.className);
this._setMarkedCalc(e.target.parentElement/*nodeBox*/);
}
});
//if (this.calcMarked){
/*
this.element.addEventListener('wheel',(e) => {
e.preventDefault();
//console.log("wheel EVENT " +e.deltaY);
if (e.deltaY > 0){
this.markNextCalc();
}else
this.markPrevCalc();
});
*/
}
_foldTreeNode(dropDowmElement){
let siblingElement= dropDowmElement.parentElement.nextElementSibling;
let classString = dropDowmElement.className;
......@@ -368,10 +351,6 @@ class NavTree {
}
_keepCalcMarked(select){
if (select && (this.markedNode === null)){
......@@ -387,7 +366,6 @@ class NavTree {
this._markFirstSelectedNode();
}
}
//console.log("firstCalcNodeBox: "+ firstCalcNodeBox.innerHTML);
} // _keepCalcMarked
......@@ -436,29 +414,21 @@ class NavTree {
this.element.style.height = heightPx+'px';
}
/** disableCalcsElectronicStructure(bool){ NOT 'data-electronic="true" '
disableCalcsThermal(bool){ NOT 'data-thermal="true" '
Diablew events
*/
}
} // class NavTree
function keepTreeIntegrity(nodeBox, select){
if (nodeBox.className.indexOf('material-l') >= 0) return;
//if (nodeBox.className.indexOf('functional-l') >= 0) return;
let levelBox= nodeBox.parentElement;
for (let i = 0; i < levelBox.children.length; i++ ) {
let siblingNodeBox = levelBox.children[i++];
//console.log('SIBLING NODE - '+siblingNodeBox.innerHTML+' '+i);
if (siblingNodeBox !== nodeBox &&
siblingNodeBox/*.children[1]*/.className.indexOf('selected') < 0)
return;
}//console.log('ALL SIBLINGS SELECTED');
}
let parentNodeBox= levelBox.previousElementSibling;
if (select){
parentNodeBox.className += ' node-selected';
......
/**
* Copyright 2016-2018 Iker Hurtado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
'Details' view container that shows all the material info related to
its structure.
This container is extremely complex.
In the file there are two defined (classes) components used in the container:
- TreeLeafViewer: The panel on the right showing the data of the tree leaf marked
- SummaryByFunctionalsComponent: the component (central panel, below part)
showing a summary for the selected item on the tree (by functional)
*/
"use strict";
let DetailsViewBase = require('./DetailsViewBase.js');
......@@ -148,11 +177,6 @@ class StructureDetails extends DetailsViewBase {
InfoSys.addToInfoSystem(this.element);
}
/*
_events() {
super._events();
}*/
setMaterialData() {
let data = DataStore.getMaterialData();
......
/**
* Copyright 2016-2018 Iker Hurtado
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
'Details' view container that shows the material calculations info related to
their vibrational and thermal properties.
*/
"use strict";
let DetailsViewBase = require('./DetailsViewBase.js');
......
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