Просмотр исходного кода

Make raw configuration editor requests asynchronous

SybexXx 1 день назад
Родитель
Сommit
990dcca2f0
1 измененных файлов с 17 добавлено и 12 удалено
  1. 17 12
      sd-card/html/edit_config_raw.html

+ 17 - 12
sd-card/html/edit_config_raw.html

@@ -61,17 +61,22 @@
 			domainname = getDomainname(); 
 
 
-	function LoadConfigNeu() {
-		domainname = getDomainname();  
-		loadConfig(domainname); 	
-		document.getElementById("inputTextToSave").value = getConfig();
-		}
-
-	function saveTextAsFile()
-	{
-		FileDeleteOnServer("/config/config.ini", domainname);
-		var textToSave = document.getElementById("inputTextToSave").value;
-		FileSendContent(textToSave, "/config/config.ini", domainname);
+	async function LoadConfigNeu() {
+        domainname = getDomainname();
+        if (!await loadConfig(domainname)) {
+            firework.launch('Configuration could not be loaded!', 'danger', 10000);
+            return;
+        }
+        document.getElementById("inputTextToSave").value = getConfig();
+    }
+
+	async function saveTextAsFile() {
+        await FileDeleteOnServer("/config/config.ini", domainname);
+        var textToSave = document.getElementById("inputTextToSave").value;
+        if (!await FileSendContent(textToSave, "/config/config.ini", domainname)) {
+            firework.launch('Configuration could not be saved!', 'danger', 10000);
+            return;
+        }
 
 		firework.launch('Configuration saved. It will get applied after the next reboot!<br><br>\n<a id="reboot_button" onclick="doReboot()">reboot now</a>', 'success', 5000);
 	}
@@ -84,7 +89,7 @@
 		window.location.replace(stringota);
 	}
 	
-	LoadConfigNeu();
+	LoadConfigNeu().catch(function (error) { console.error('Could not load configuration editor:', error); });
 	
 	</script>