Преглед на файлове

Load GPIO profile after configuration initialization

SybexXx преди 1 ден
родител
ревизия
0a48beef45
променени са 1 файла, в които са добавени 11 реда и са изтрити 4 реда
  1. 11 4
      sd-card/html/edit_config_template.html

+ 11 - 4
sd-card/html/edit_config_template.html

@@ -2963,8 +2963,9 @@ function openDescription() {
 }
 
 openDescription();
-LoadConfigNeu().catch(function (error) {
+window.CONFIG_LOAD_PROMISE = LoadConfigNeu().catch(function (error) {
     console.error('Could not initialize configuration editor:', error);
+    throw error;
 });
 
 /*
@@ -3132,7 +3133,13 @@ window.GPIO_AVAILABLE_PINS = [];
     }
 
     unavailable("Loading the active board profile…");
-    fetch("/GPIO?capabilities=1", { method: "GET", cache: "no-store" })
+    window.CONFIG_LOAD_PROMISE
+        .then(function () {
+            if (!param || !category) {
+                throw new Error("Configuration is not available");
+            }
+            return fetch("/GPIO?capabilities=1", { method: "GET", cache: "no-store" });
+        })
         .then(function (response) {
             if (!response.ok) throw new Error("HTTP " + response.status);
             return response.json();
@@ -3194,8 +3201,8 @@ window.GPIO_AVAILABLE_PINS = [];
             setVisible("GPIO_item", !!category.GPIO.enabled);
         })
         .catch(function (error) {
-            unavailable("Could not read the firmware board profile (" + error.message +
-                "). GPIO stays locked for safety.");
+            unavailable("Could not initialize the configuration or read the firmware board profile (" +
+                error.message + "). GPIO stays locked for safety.");
         });
 })();;