Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added image preview for HomeKey Card Finish in Misc configuration page on HomeKey Card Finish click #114

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/assets/hk-finish-0.webp
Binary file not shown.
Binary file added data/assets/hk-finish-1.webp
Binary file not shown.
Binary file added data/assets/hk-finish-2.webp
Binary file not shown.
Binary file added data/assets/hk-finish-3.webp
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="misc.css"/>
<link rel="stylesheet" href="assets/misc.css"/>
<title>HK Configuration</title>
<style>
label {
Expand Down
52 changes: 35 additions & 17 deletions data/misc.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ <h3 style="margin-top: 0;text-align: center;">HomeKit</h3>
style="display:flex;flex-direction: column;border: 2px #8e8271 dashed;padding: 1rem;margin-bottom: 1rem;gap: 8px;">
<div style="display: flex;flex-direction: column;">
<label for="device-name">Device Name</label>
<input type="text" name="device-name" id="device-name" placeholder="HK" required value="%DEVICENAME%" style="width: fit-content;" />
<input type="text" name="device-name" id="device-name" placeholder="HK" required value="%DEVICENAME%"
style="width: fit-content;" />
</div>

<div style="display: flex;flex-direction: column;">
<label for="hk-setupcode">Setup Code</label>
<input type="number" name="hk-setupcode" id="hk-setupcode" placeholder="46637726" required value="%HKSETUPCODE%" style="width: fit-content;" />
<input type="number" name="hk-setupcode" id="hk-setupcode" placeholder="46637726" required
value="%HKSETUPCODE%" style="width: fit-content;" />
</div>

<div>
Expand All @@ -28,21 +30,36 @@ <h3 style="margin-top: 0;text-align: center;">HomeKit</h3>
</div>
<fieldset>
<legend>HomeKey Card Finish:</legend>
<div>
<label for="hk-tan">Tan</label>
<input type="radio" id="hk-finish-0" name="hk-hwfinish" value="0" />
</div>
<div>
<label for="hk-gold">Gold</label>
<input type="radio" id="hk-finish-1" name="hk-hwfinish" value="1" />
</div>
<div>
<label for="hk-silver">Silver</label>
<input type="radio" id="hk-finish-2" name="hk-hwfinish" value="2" />
</div>
<div>
<label for="hk-black">Black</label>
<input type="radio" id="hk-finish-3" name="hk-hwfinish" value="3" />
<div style="display: flex;justify-content: space-evenly;margin-bottom: 0;padding-bottom: 0;">
<div id="hkfinish"
style="background-image: url(assets/hk-finish-0.webp);background-size: contain;background-repeat: no-repeat;width: 9rem;">
</div>
<div style="display: flex;flex-direction: column;align-items: flex-end;">
<div>
<label id="tan" for="hk-tan">Tan</label>
<input type="radio" id="hk-finish-0"
onClick="document.getElementById('hkfinish').style.backgroundImage=`url(assets/hk-finish-0.webp)`"
name="hk-hwfinish" value="0" />
</div>
<div>
<label id="gold" for="hk-gold">Gold</label>
<input type="radio" id="hk-finish-1"
onClick="document.getElementById('hkfinish').style.backgroundImage=`url(assets/hk-finish-1.webp)`"
name="hk-hwfinish" value="1" />
</div>
<div>
<label id="silver" for="hk-silver">Silver</label>
<input type="radio" id="hk-finish-2"
onClick="document.getElementById('hkfinish').style.backgroundImage=`url(assets/hk-finish-2.webp)`"
name="hk-hwfinish" value="2" />
</div>
<div>
<label id="black" for="hk-black">Black</label>
<input type="radio" id="hk-finish-3"
onClick="document.getElementById('hkfinish').style.backgroundImage=`url(assets/hk-finish-3.webp)`"
name="hk-hwfinish" value="3" />
</div>
</div>
</div>
</fieldset>
</div>
Expand Down Expand Up @@ -91,6 +108,7 @@ <h3 style="margin-top: 0;text-align: center;">HomeSpan</h3>
document
.getElementById(`hk-finish-${hwfinish}`)
.setAttribute("checked", "");
document.getElementById('hkfinish').style.backgroundImage = `url(assets/hk-finish-${hwfinish}.webp)`;
if (nfcSuccessHL) {
document.getElementById("nfc-s-hl").setAttribute("checked", "");
}
Expand Down
26 changes: 7 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,26 +831,14 @@ String actionsProcess(const String& var) {
}
return "";
}

bool headersFix(AsyncWebServerRequest* request) { request->addInterestingHeader("ANY"); return true; };
void setupWeb() {
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/index.html", "text/html", false, indexProcess);
});
webServer.on("/misc.css", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/misc.css", "text/css", false, nullptr);
});
webServer.on("/info", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/info.html", "text/html", false, hkInfoHtmlProcess);
});
webServer.on("/mqtt", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/mqtt.html", "text/html", false, mqttHtmlProcess);
});
webServer.on("/misc", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/misc.html", "text/html", false, miscHtmlProcess);
});
webServer.on("/actions", HTTP_GET, [](AsyncWebServerRequest* request) {
request->send(LittleFS, "/actions.html", "text/html", false, actionsProcess);
});
webServer.serveStatic("/info", LittleFS, "/info.html").setTemplateProcessor(hkInfoHtmlProcess).setFilter(headersFix);
webServer.serveStatic("/mqtt", LittleFS, "/mqtt.html").setTemplateProcessor(mqttHtmlProcess).setFilter(headersFix);
webServer.serveStatic("/misc", LittleFS, "/misc.html").setTemplateProcessor(miscHtmlProcess).setFilter(headersFix);
webServer.serveStatic("/actions", LittleFS, "/actions.html").setTemplateProcessor(actionsProcess).setFilter(headersFix);
webServer.serveStatic("/assets", LittleFS, "/assets/").setFilter(headersFix);
webServer.serveStatic("/", LittleFS, "/").setDefaultFile("index.html").setTemplateProcessor(indexProcess).setFilter(headersFix);
webServer.on("/mqttconfig", HTTP_POST, [](AsyncWebServerRequest* request) {
const char* TAG = "mqttconfig";
int params = request->params();
Expand Down