feat: erweitere Bambu-Credentials mit AutoSend-Wartezeit und aktualisiere die Benutzeroberfläche
This commit is contained in:
parent
c1733848d3
commit
e4825d2905
@ -76,7 +76,7 @@
|
|||||||
const code = document.getElementById('bambuCode').value;
|
const code = document.getElementById('bambuCode').value;
|
||||||
const autoSend = document.getElementById('autoSend').checked;
|
const autoSend = document.getElementById('autoSend').checked;
|
||||||
|
|
||||||
fetch(`/api/bambu?bambu_ip=${encodeURIComponent(ip)}&bambu_serialnr=${encodeURIComponent(serial)}&bambu_accesscode=${encodeURIComponent(code)}&autoSend=${autoSend}`)
|
fetch(`/api/bambu?bambu_ip=${encodeURIComponent(ip)}&bambu_serialnr=${encodeURIComponent(serial)}&bambu_accesscode=${encodeURIComponent(code)}&autoSend=${autoSend}$autoSendTime=${autoSendTime}`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.healthy) {
|
if (data.healthy) {
|
||||||
@ -122,13 +122,18 @@
|
|||||||
<label for="bambuCode">Access Code:</label>
|
<label for="bambuCode">Access Code:</label>
|
||||||
<input type="text" id="bambuCode" placeholder="Access Code vom Drucker" value="{{bambuCode}}">
|
<input type="text" id="bambuCode" placeholder="Access Code vom Drucker" value="{{bambuCode}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<hr>
|
||||||
If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool.
|
<p>If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool.</p>
|
||||||
<label for="autoSend">Auto Send to Bambu:</label>
|
<div class="input-group" style="display: flex; margin-bottom: 0;">
|
||||||
<input type="checkbox" id="autoSend" {{autoSendToBambu}}>
|
<label for="autoSend" style="width: 250px; margin-right: 5px;">Auto Send to Bambu:</label>
|
||||||
|
<label for="autoSendTime" style="width: 250px; margin-right: 5px;">Wait time in Seconds:</label>
|
||||||
|
</div>
|
||||||
|
<div class="input-group" style="display: flex;">
|
||||||
|
<input type="checkbox" id="autoSend" {{autoSendToBambu}} style="width: 190px; margin-right: 10px;">
|
||||||
|
<input type="text" id="autoSendTime" placeholder="Time to wait for new Spool" value="{{autoSendTime}}" style="width: 100px;">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button onclick="saveBambuCredentials()">Save Bambu Credentials</button>
|
<button style="margin: 0;" onclick="saveBambuCredentials()">Save Bambu Credentials</button>
|
||||||
<p id="bambuStatusMessage"></p>
|
<p id="bambuStatusMessage"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +32,7 @@ int ams_count = 0;
|
|||||||
String amsJsonData; // Speichert das fertige JSON für WebSocket-Clients
|
String amsJsonData; // Speichert das fertige JSON für WebSocket-Clients
|
||||||
AMSData ams_data[MAX_AMS]; // Definition des Arrays;
|
AMSData ams_data[MAX_AMS]; // Definition des Arrays;
|
||||||
|
|
||||||
bool saveBambuCredentials(const String& ip, const String& serialnr, const String& accesscode, bool autoSend) {
|
bool saveBambuCredentials(const String& ip, const String& serialnr, const String& accesscode, bool autoSend, const String& autoSendTime) {
|
||||||
if (BambuMqttTask) {
|
if (BambuMqttTask) {
|
||||||
vTaskDelete(BambuMqttTask);
|
vTaskDelete(BambuMqttTask);
|
||||||
}
|
}
|
||||||
@ -42,6 +42,7 @@ bool saveBambuCredentials(const String& ip, const String& serialnr, const String
|
|||||||
doc["bambu_accesscode"] = accesscode;
|
doc["bambu_accesscode"] = accesscode;
|
||||||
doc["bambu_serialnr"] = serialnr;
|
doc["bambu_serialnr"] = serialnr;
|
||||||
doc["autoSendToBambu"] = autoSend;
|
doc["autoSendToBambu"] = autoSend;
|
||||||
|
doc["autoSendTime"] = (autoSendTime != "") ? autoSendTime.toInt() : autoSetBambuAmsCounter;
|
||||||
|
|
||||||
if (!saveJsonValue("/bambu_credentials.json", doc)) {
|
if (!saveJsonValue("/bambu_credentials.json", doc)) {
|
||||||
Serial.println("Fehler beim Speichern der Bambu-Credentials.");
|
Serial.println("Fehler beim Speichern der Bambu-Credentials.");
|
||||||
@ -53,6 +54,7 @@ bool saveBambuCredentials(const String& ip, const String& serialnr, const String
|
|||||||
bambu_accesscode = accesscode.c_str();
|
bambu_accesscode = accesscode.c_str();
|
||||||
bambu_serialnr = serialnr.c_str();
|
bambu_serialnr = serialnr.c_str();
|
||||||
autoSendToBambu = autoSend;
|
autoSendToBambu = autoSend;
|
||||||
|
autoSetBambuAmsCounter = autoSendTime.toInt();
|
||||||
|
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
if (!setupMqtt()) return false;
|
if (!setupMqtt()) return false;
|
||||||
@ -67,7 +69,8 @@ bool loadBambuCredentials() {
|
|||||||
String ip = doc["bambu_ip"].as<String>();
|
String ip = doc["bambu_ip"].as<String>();
|
||||||
String code = doc["bambu_accesscode"].as<String>();
|
String code = doc["bambu_accesscode"].as<String>();
|
||||||
String serial = doc["bambu_serialnr"].as<String>();
|
String serial = doc["bambu_serialnr"].as<String>();
|
||||||
autoSendToBambu = doc["autoSendToBambu"].as<bool>();
|
if (doc["autoSendToBambu"].is<bool>()) autoSendToBambu = doc["autoSendToBambu"].as<bool>();
|
||||||
|
if (doc["autoSendTime"].is<int>()) autoSetBambuAmsCounter = doc["autoSendTime"].as<int>();
|
||||||
|
|
||||||
ip.trim();
|
ip.trim();
|
||||||
code.trim();
|
code.trim();
|
||||||
|
@ -286,17 +286,19 @@ void setupWebserver(AsyncWebServer &server) {
|
|||||||
String bambu_serialnr = request->getParam("bambu_serialnr")->value();
|
String bambu_serialnr = request->getParam("bambu_serialnr")->value();
|
||||||
String bambu_accesscode = request->getParam("bambu_accesscode")->value();
|
String bambu_accesscode = request->getParam("bambu_accesscode")->value();
|
||||||
bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false;
|
bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false;
|
||||||
|
String autoSendTime = request->getParam("autoSendTime")->value();
|
||||||
Serial.println(autoSend);
|
Serial.println(autoSend);
|
||||||
bambu_ip.trim();
|
bambu_ip.trim();
|
||||||
bambu_serialnr.trim();
|
bambu_serialnr.trim();
|
||||||
bambu_accesscode.trim();
|
bambu_accesscode.trim();
|
||||||
|
autoSendTime.trim();
|
||||||
|
|
||||||
if (bambu_ip.length() == 0 || bambu_serialnr.length() == 0 || bambu_accesscode.length() == 0) {
|
if (bambu_ip.length() == 0 || bambu_serialnr.length() == 0 || bambu_accesscode.length() == 0) {
|
||||||
request->send(400, "application/json", "{\"success\": false, \"error\": \"Empty parameter\"}");
|
request->send(400, "application/json", "{\"success\": false, \"error\": \"Empty parameter\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = saveBambuCredentials(bambu_ip, bambu_serialnr, bambu_accesscode, autoSend);
|
bool success = saveBambuCredentials(bambu_ip, bambu_serialnr, bambu_accesscode, autoSend, autoSendTime);
|
||||||
|
|
||||||
request->send(200, "application/json", "{\"healthy\": " + String(success ? "true" : "false") + "}");
|
request->send(200, "application/json", "{\"healthy\": " + String(success ? "true" : "false") + "}");
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user