1 import { controllers
} from './components/Controller.js';
2 import { simVars
} from './simVars.js';
4 /** Service request for fetching the conf.json file. */
5 export async
function getConfigurations() {
6 await
fetch('conf.json').then(response
=> response
.json()).then(function(configData
) {
7 if (configData
.organization
) {
8 simVars
.organization
= configData
.organization
;
10 document
.title
= simVars
.organization
;
12 if (configData
.flags
) {
13 const simulationFlags
= document
.querySelector('#simulation-flags');
14 let flags
= configData
.flags
;
16 let spanElement
= document
.createElement('span');
17 spanElement
.className
= 'displayTest';
18 spanElement
.innerText
= flag
;
19 simulationFlags
.appendChild(spanElement
);
23 console
.error('Error fetching conf.json : ' + error
);
27 /** Service request for building the initial catalogMenu */
28 export async
function getCatalogEntries() {
31 const response
= await
fetch('simulations/catalog.json');
32 json
= response
.json();
34 console
.error('Error fetching catalog entries: ' + error
);
39 /** Service request for fetching a selected simulation from the menu. */
40 export function getSimulation(path
) {
41 // fetch(path).then(response => response.json()).then(function(selectedSimulation) {
42 fetch(path
.replaceAll(':', '_')).then(response
=> response
.json()).then(function(selectedSimulation
) {
43 // store in global state
44 simVars
.rasters
= selectedSimulation
;
45 // simVars.rasterBase = path.substring(0, path.lastIndexOf('/') + 1);
46 simVars
.rasterBase
= path
.replaceAll(':', '_').substring(0, path
.lastIndexOf('/') + 1);
47 // retrieve all domains
48 controllers
.domainInstance
.setValue(Object
.keys(selectedSimulation
));
50 console
.error('Error fetching simulation at ' + path
);