Skip to content
Snippets Groups Projects
Commit 260effac authored by Duc Bui Tien's avatar Duc Bui Tien
Browse files

add error handling for no config file found

parent 8656912a
No related branches found
No related tags found
2 merge requests!2UnicadoGuiBackend,!1New UnicadoGUI Branch
...@@ -158,13 +158,21 @@ ...@@ -158,13 +158,21 @@
} }
async function getModuleConf(module){ async function getModuleConf(module){
const res = await fetch("http://127.0.0.1:8000/modules/"+module+"/config"); try {
const data = await res.json(); const res = await fetch("http://127.0.0.1:8000/modules/" + module + "/config");
modalModule.name = module; const data = await res.json();
modalModule.response = JSON.parse(data); modalModule.name = module;
modalModule.html= [] modalModule.response = JSON.parse(data);
generateHTML(modalModule.response) modalModule.html = []
modalModule=modalModule; generateHTML(modalModule.response)
modalModule = modalModule;
}catch (error){
console.error(error);
modalModule.name = "no";
modalModule.response={};
modalModule.html=[];
modalModule.html.push(new SettingsLabel("No config found!"))
}
} }
function generateHTML(json: object){ function generateHTML(json: object){
Object.entries(json).forEach(([key, value]) =>{ Object.entries(json).forEach(([key, value]) =>{
...@@ -179,8 +187,10 @@ ...@@ -179,8 +187,10 @@
} }
} }
modalModule.html.push(new SettingsSelector(key,value.description,value,options)) modalModule.html.push(new SettingsSelector(key,value.description,value,options))
}else if(value.hasOwnProperty("unit")){ }else if(value.hasOwnProperty("unit")) {//spaeter entweder unit oder Unit in XML
modalModule.html.push((new SettingsNumberfield(key,value.description,value,value.unit))) modalModule.html.push((new SettingsNumberfield(key, value.description, value, value.unit)))
}else if(value.hasOwnProperty("Unit")){
modalModule.html.push((new SettingsNumberfield(key,value.description,value,value.Unit)))
}else{ }else{
modalModule.html.push(new SettingsTextfield(key,value.description,value,key)) modalModule.html.push(new SettingsTextfield(key,value.description,value,key))
} }
...@@ -352,7 +362,7 @@ ...@@ -352,7 +362,7 @@
{element.description} {element.description}
</Tooltip> </Tooltip>
{:else if element.type=="numberfield"} {:else if element.type=="numberfield"}
{#if element.unit !="1"&&element.unit !="-" } {#if element.unit !="1"&&element.unit !="-"&&element.unit!="count"}
<h7>{formatLabel(element.label)} (in {element.unit})</h7> <h7>{formatLabel(element.label)} (in {element.unit})</h7>
{:else} {:else}
<h7>{formatLabel(element.label)}</h7> <h7>{formatLabel(element.label)}</h7>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment