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 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(data => {
|
||||
if (data.healthy) {
|
||||
@ -122,13 +122,18 @@
|
||||
<label for="bambuCode">Access Code:</label>
|
||||
<input type="text" id="bambuCode" placeholder="Access Code vom Drucker" value="{{bambuCode}}">
|
||||
</div>
|
||||
<div class="input-group">
|
||||
If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool.
|
||||
<label for="autoSend">Auto Send to Bambu:</label>
|
||||
<input type="checkbox" id="autoSend" {{autoSendToBambu}}>
|
||||
<hr>
|
||||
<p>If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool.</p>
|
||||
<div class="input-group" style="display: flex; margin-bottom: 0;">
|
||||
<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>
|
||||
|
||||
<button onclick="saveBambuCredentials()">Save Bambu Credentials</button>
|
||||
<button style="margin: 0;" onclick="saveBambuCredentials()">Save Bambu Credentials</button>
|
||||
<p id="bambuStatusMessage"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -32,7 +32,7 @@ int ams_count = 0;
|
||||
String amsJsonData; // Speichert das fertige JSON für WebSocket-Clients
|
||||
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) {
|
||||
vTaskDelete(BambuMqttTask);
|
||||
}
|
||||
@ -42,6 +42,7 @@ bool saveBambuCredentials(const String& ip, const String& serialnr, const String
|
||||
doc["bambu_accesscode"] = accesscode;
|
||||
doc["bambu_serialnr"] = serialnr;
|
||||
doc["autoSendToBambu"] = autoSend;
|
||||
doc["autoSendTime"] = (autoSendTime != "") ? autoSendTime.toInt() : autoSetBambuAmsCounter;
|
||||
|
||||
if (!saveJsonValue("/bambu_credentials.json", doc)) {
|
||||
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_serialnr = serialnr.c_str();
|
||||
autoSendToBambu = autoSend;
|
||||
autoSetBambuAmsCounter = autoSendTime.toInt();
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
if (!setupMqtt()) return false;
|
||||
@ -67,7 +69,8 @@ bool loadBambuCredentials() {
|
||||
String ip = doc["bambu_ip"].as<String>();
|
||||
String code = doc["bambu_accesscode"].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();
|
||||
code.trim();
|
||||
|
@ -286,17 +286,19 @@ void setupWebserver(AsyncWebServer &server) {
|
||||
String bambu_serialnr = request->getParam("bambu_serialnr")->value();
|
||||
String bambu_accesscode = request->getParam("bambu_accesscode")->value();
|
||||
bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false;
|
||||
String autoSendTime = request->getParam("autoSendTime")->value();
|
||||
Serial.println(autoSend);
|
||||
bambu_ip.trim();
|
||||
bambu_serialnr.trim();
|
||||
bambu_accesscode.trim();
|
||||
autoSendTime.trim();
|
||||
|
||||
if (bambu_ip.length() == 0 || bambu_serialnr.length() == 0 || bambu_accesscode.length() == 0) {
|
||||
request->send(400, "application/json", "{\"success\": false, \"error\": \"Empty parameter\"}");
|
||||
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") + "}");
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user