Segment visualization fix show fx name

This commit is contained in:
Ewoud
2023-02-15 18:13:30 +01:00
parent b6024d2ed0
commit ab8b260608
3 changed files with 806 additions and 795 deletions

View File

@@ -9,7 +9,7 @@ function toggleCEEditor(name, segID) {
d.getElementById('ceEditor').style.transform = (isCEEditor) ? "translateY(0px)":"translateY(100%)"; d.getElementById('ceEditor').style.transform = (isCEEditor) ? "translateY(0px)":"translateY(100%)";
} }
function fetchAndExecute(url, name, callback, toast=true) function fetchAndExecute(url, name, callback, callError)
{ {
fetch fetch
(url+name, { (url+name, {
@@ -17,19 +17,20 @@ function fetchAndExecute(url, name, callback, toast=true)
}) })
.then(res => { .then(res => {
if (!res.ok) { if (!res.ok) {
if (toast) showToast("File " + name + " not found", true); callError("File " + name + " not found");
return ""; return "";
} }
return res.text(); return res.text();
}) })
.then(text => { .then(text => {
console.log("text", text);
callback(text); callback(text);
}) })
.catch(function (error) { .catch(function (error) {
if (toast) showToast("Error getting " + name, true); callError("Error getting " + name);
console.log(error);
}) })
.finally(() => { .finally(() => {
console.log("finally");
// if (callback) setTimeout(callback,99); // if (callback) setTimeout(callback,99);
}); });
} }
@@ -51,6 +52,9 @@ function loadLogFile(name, attempt) {
} }
else else
ceLogArea.value = logtext; ceLogArea.value = logtext;
}, function(error){
showToast(error);
console.log(error);
}); });
} }
@@ -114,6 +118,9 @@ function populateCEEditor(name, segID)
ceLogArea.value = "."; ceLogArea.value = ".";
loadLogFile(name + ".wled.log", 1); loadLogFile(name + ".wled.log", 1);
}, function(error){
showToast(error);
console.log(error);
}); });
} }
@@ -133,6 +140,9 @@ function downloadCEFile(url, name) {
var ceProgramArea = d.getElementById("ceProgramArea"); var ceProgramArea = d.getElementById("ceProgramArea");
ceProgramArea.value = text; ceProgramArea.value = text;
} }
}, function(error){
showToast(error);
console.log(error);
}); });
return; return;

View File

@@ -1360,7 +1360,10 @@ function drawSegments() {
ctx.fill(); ctx.fill();
} }
post(); post();
}, false); //false: no toast }, function(error) { //error handling
console.log(error);
post();
});
} }
else else
post(); post();
@@ -2893,7 +2896,7 @@ function genPresets()
} }
//WLEDMM: utility function to load contents of file from FS (used in draw) //WLEDMM: utility function to load contents of file from FS (used in draw)
function fetchAndExecute(url, name, callback, toast=true) function fetchAndExecute(url, name, callback, callError)
{ {
fetch fetch
(url+name, { (url+name, {
@@ -2901,10 +2904,9 @@ function fetchAndExecute(url, name, callback, toast=true)
}) })
.then(res => { .then(res => {
if (!res.ok) { if (!res.ok) {
if (toast) showToast("File " + name + " not found", true); callError("File " + name + " not found");
return ""; return "";
} }
console.log("res", res);
return res.text(); return res.text();
}) })
.then(text => { .then(text => {
@@ -2912,8 +2914,7 @@ function fetchAndExecute(url, name, callback, toast=true)
callback(text); callback(text);
}) })
.catch(function (error) { .catch(function (error) {
if (toast) showToast("Error getting " + name, true); callError("Error getting " + name);
console.log(error);
}) })
.finally(() => { .finally(() => {
console.log("finally"); console.log("finally");

File diff suppressed because it is too large Load Diff