Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
encyclopedia-gui
Commits
d5981560
Commit
d5981560
authored
Apr 06, 2021
by
Lauri Himanen
Browse files
Merged.
parents
bc872242
f57df8cd
Changes
5
Show whitespace changes
Inline
Side-by-side
client/css/styles.css
View file @
d5981560
...
...
@@ -1447,6 +1447,14 @@ text.structure-viewer-legend-labels{
margin-bottom
:
10px
;
}
#missing-prompt
{
margin-top
:
0.5rem
;
background-color
:
#E56400
;
color
:
white
;
padding
:
16px
;
display
:
none
;
}
/*
.tooltip {
visibility: hidden;
...
...
client/src/material-mod/DataStore.js
View file @
d5981560
...
...
@@ -33,6 +33,7 @@ let calcMap = new Map();
let
ready
=
false
;
let
hasThermal
;
let
hasElecStructure
;
let
missing
=
false
;
function
setMaterialData
(
dataFromAPI
){
materialData
=
dataFromAPI
;
...
...
@@ -42,6 +43,14 @@ function getMaterialData(){
return
materialData
;
}
function
setMissing
(
value
)
{
missing
=
value
;
}
function
getMissing
()
{
return
missing
;
}
function
setIdealizedStructure
(
structure
){
idealizedStructure
=
structure
;
}
...
...
@@ -129,6 +138,9 @@ function getGroupId(leafId) {
function
isReady
(
matId
)
{
if
(
materialData
!==
undefined
)
{
if
(
missing
&&
matId
==
materialData
.
material_id
)
{
return
true
;
}
if
(
idealizedStructure
!==
undefined
)
{
if
(
calcs
!==
undefined
)
{
if
(
groups
!==
undefined
)
{
...
...
@@ -147,6 +159,7 @@ function clear() {
calcs
=
undefined
;
groups
=
undefined
;
idealizedStructure
=
undefined
;
missing
=
false
;
}
function
isInAnyGroup
(
calcId
){
...
...
@@ -192,6 +205,8 @@ module.exports = {
isInAnyNotDisabledGroup
,
getGroupLeafId
,
isReady
,
setMissing
,
getMissing
,
clear
,
setIdealizedStructure
,
getIdealizedStructure
,
...
...
client/src/material-mod/MaterialMod.js
View file @
d5981560
...
...
@@ -48,6 +48,9 @@ class MaterialMod {
constructor
(){
this
.
element
=
document
.
createElement
(
'
div
'
);
this
.
element
.
setAttribute
(
"
id
"
,
'
material-module
'
);
this
.
missingPrompt
=
document
.
createElement
(
'
div
'
);
this
.
missingPrompt
.
id
=
"
missing-prompt
"
;
this
.
element
.
appendChild
(
this
.
missingPrompt
)
this
.
overview
=
new
Overview
();
this
.
overview
.
attachAndSetEvents
(
this
.
element
);
...
...
@@ -138,11 +141,25 @@ class MaterialMod {
* Called upon loading the overview page for a specific material.
*/
_loadMaterial
(
matId
,
view
)
{
// Set to loading mode
this
.
_setView
(
view
);
let
show
=
()
=>
{
// Show error message if resource not found
const
missingPrompt
=
document
.
getElementById
(
"
missing-prompt
"
);
if
(
DataStore
.
getMissing
())
{
// Hide the current view
if
(
this
.
currentDetailView
===
null
)
{
this
.
overview
.
element
.
style
.
display
=
'
none
'
;
}
else
{
this
.
currentDetailView
.
element
.
style
.
display
=
'
none
'
;
}
const
msg
=
`
Could not find information for material with identifier
${
matId
}
.
Either the material does not exist or is not yet visible in the Encyclopedia.
`
;
missingPrompt
.
textContent
=
msg
;
missingPrompt
.
style
.
display
=
"
block
"
;
}
else
{
missingPrompt
.
style
.
display
=
"
none
"
;
this
.
_setView
(
view
);
let
materialData
=
DataStore
.
getMaterialData
();
let
idealizedStructure
=
DataStore
.
getIdealizedStructure
();
// Cell viewer needs to be set only after page is visible so that it is
...
...
@@ -163,6 +180,7 @@ class MaterialMod {
this
.
overview
.
setCalcsData
(
markedTreeLeafs
);
this
.
_setCellViewer
(
this
.
overview
.
vizBox
);
}
}
};
let
isReady
=
()
=>
{
let
ready
=
DataStore
.
isReady
(
matId
);
...
...
@@ -175,6 +193,7 @@ class MaterialMod {
// If material is already loaded, nothing fetched.
if
(
!
isReady
())
{
DataStore
.
clear
();
this
.
overview
.
clearCalcsData
();
LoadingPopup
.
reset
();
this
.
structureViewer
.
axisCheckbox
.
checked
=
true
;
this
.
structureViewer
.
bondsCheckbox
.
checked
=
true
;
...
...
@@ -187,9 +206,16 @@ class MaterialMod {
// Request basic material data
LoadingPopup
.
show
(
"
load_basic
"
);
util
.
serverReq
(
util
.
getMaterialURL
(
matId
),
e1
=>
{
// Check for error
let
stat
=
e1
.
target
.
status
;
if
(
stat
>=
400
&&
stat
<
500
)
{
DataStore
.
setMissing
(
true
);
DataStore
.
setMaterialData
({
material_id
:
matId
});
}
else
{
let
materialData
=
JSON
.
parse
(
e1
.
target
.
response
);
DataStore
.
setMaterialData
(
materialData
);
util
.
materialId
=
materialData
.
material_id
;
}
isReady
();
LoadingPopup
.
hide
(
"
load_basic
"
);
});
...
...
@@ -197,6 +223,11 @@ class MaterialMod {
// Request basic details for all calculations related to this material
LoadingPopup
.
show
(
"
load_calculations
"
);
util
.
serverReq
(
util
.
getMaterialXsURL
(
'
calculations
'
,
matId
),
e4
=>
{
// Check for error
let
stat
=
e4
.
target
.
status
;
if
(
stat
>=
400
&&
stat
<
500
)
{
DataStore
.
setMissing
(
true
);
}
else
{
let
calculations
=
JSON
.
parse
(
e4
.
target
.
response
);
let
representatives
=
calculations
.
representatives
;
let
idealId
=
representatives
.
idealized_structure
;
...
...
@@ -207,22 +238,35 @@ class MaterialMod {
let
query
=
JSON
.
stringify
({
properties
:
[
"
idealized_structure
"
]});
LoadingPopup
.
show
(
"
load_idealized
"
);
util
.
serverReqPOST
(
util
.
getMaterialCalcURL
(
matId
,
idealId
),
query
,
e2
=>
{
// Check for error
let
stat
=
e2
.
target
.
status
;
if
(
stat
>=
400
&&
stat
<
500
)
{
DataStore
.
setMissing
(
true
);
}
else
{
let
struct
=
JSON
.
parse
(
e2
.
target
.
response
).
idealized_structure
;
DataStore
.
setIdealizedStructure
(
struct
);
this
.
structureViewer
.
load
(
struct
);
document
.
getElementById
(
'
structure-ov
'
).
style
.
visibility
=
'
visible
'
;
document
.
getElementById
(
'
methodology-ov
'
).
style
.
visibility
=
'
visible
'
;
}
isReady
();
LoadingPopup
.
hide
(
"
load_idealized
"
);
});
}
LoadingPopup
.
hide
(
"
load_calculations
"
);
});
// Request groups
LoadingPopup
.
show
(
"
load_groups
"
);
util
.
serverReq
(
util
.
getMaterialXsURL
(
'
groups
'
,
matId
),
e5
=>
{
// Check for error
let
stat
=
e5
.
target
.
status
;
if
(
stat
>=
400
&&
stat
<
500
)
{
DataStore
.
setMissing
(
true
);
}
else
{
let
groups
=
JSON
.
parse
(
e5
.
target
.
response
);
DataStore
.
setGroups
(
groups
);
}
isReady
();
LoadingPopup
.
hide
(
"
load_groups
"
);
});
...
...
client/src/material-mod/Overview.view.js
View file @
d5981560
...
...
@@ -358,6 +358,14 @@ class Overview {
return
false
;
}
clearCalcsData
()
{
this
.
materialId
=
null
;
this
.
calcMaterialId
=
null
;
let
bsLoaded
=
false
;
let
phononLoaded
=
false
;
let
dosLoaded
=
false
;
}
setCalcsData
(
markedTreeLeafs
)
{
let
matData
=
DataStore
.
getMaterialData
();
let
calcs
=
DataStore
.
getCalculations
();
...
...
client/src/search-mod/MaterialList.view.js
View file @
d5981560
...
...
@@ -303,7 +303,6 @@ class MatListContainer{
${
mat
.
space_group_international_short_symbol
?
mat
.
space_group_international_short_symbol
:
''
}
</td>
<td>
${
mat
.
structure_type
?
mat
.
structure_type
:
''
}
</td>
<td style="text-align:center" >
${
mat
.
n_calculations
?
mat
.
n_calculations
:
''
}
</td>
</tr>`
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment