Add visual feedback to save button, add user agent

This commit is contained in:
Djuri Baars 2023-08-23 21:19:34 +02:00
parent 96a48576c5
commit 1e6ed38ce5
4 changed files with 13 additions and 1 deletions

View file

@ -62,6 +62,7 @@
</div>
<footer>
<button type="submit" class="btn btn-primary">Show Text</button>
<button type="button" class="btn btn-secondary" id="restartBtn">Restart</button>
</footer>
</form>
<hr>
@ -186,7 +187,7 @@
<h3>Screens</h3>
<div id="outputScreens"></div>
<button type="submit" class="btn btn-secondary">Reset</button>
<button type="submit" class="btn btn-primary">Save</button>
<button type="submit" class="btn btn-primary" id="saveSettingsBtn">Save</button>
</form>
</div>

View file

@ -80,11 +80,17 @@ settingsForm.onsubmit = (event) => {
method: "post"
}).then(() => {
console.log('Submitted');
document.getElementById('saveSettingsBtn')?.classList.add('btn-success');
});
return false;
}
document.getElementById('restartBtn').onclick = (event) => {
fetch('/api/restart');
return false;
}
var ledsForm = document.querySelector('#ledsForm');
ledsForm.onsubmit = (event) => {

View file

@ -35,6 +35,8 @@ void checkBitcoinBlock(void *pvParameters)
http.begin(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT));
http.addHeader("Content-Type", "application/json");
http.addHeader("User-Agent", "BTClock/1.0");
String payload = "{\"jsonrpc\":\"1.0\",\"id\":\"current_block_height\",\"method\":\"getblockcount\",\"params\":[]}";
String auth = preferences.getString("rpcUser", BITCOIND_RPC_USER) + ":" + preferences.getString("rpcPass", BITCOIND_RPC_PASS);
String authEncoded = base64::encode(auth);
@ -57,6 +59,7 @@ void checkBitcoinBlock(void *pvParameters)
else
{
http.begin("https://mempool.bitcoin.nl/api/blocks/tip/height");
http.addHeader("User-Agent", "BTClock/1.0");
int httpCode = http.GET();
if (httpCode > 0 && httpCode == HTTP_CODE_OK)

View file

@ -18,6 +18,8 @@ void taskGetPrice(void *pvParameters)
{
// Send HTTP request to CoinDesk API
http.begin(apiUrl);
http.addHeader("User-Agent", "BTClock/1.0");
int httpCode = http.GET();
// Parse JSON response and extract average price