Skip to content
Snippets Groups Projects
Commit ecac1388 authored by Cyril Danilevski's avatar Cyril Danilevski :scooter:
Browse files

Add simple status webpage

parent 745d13cc
No related branches found
No related tags found
No related merge requests found
Pipeline #148502 passed
String buildPanel(bool plc, bool iob, bool ups) {
String page = "<!DOCTYPE html><html lang=\"en\">\n";
page += "<head><meta name=\"viewport\" page=\"width=device-width, initial-scale=1.0\">\n";
page += "<meta http-equiv=\"refresh\" page=\"1\"/>\n";
page += "<title>ICBM</title>\n";
page += "<style>\n";
page += "body {font-family: Arial, sans-serif; display: flex; justify-page: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0;}\n";
page += ".container {background-color: white; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1);}\n";
page += "h1 {text-align: center; color: #333;}\n";
page += ".status-item {margin: 15px 0; padding: 10px; border-radius: 5px; display: flex; justify-page: space-between; align-items: center;}\n";
page += ".status-label {font-weight: bold; margin-right: 10px;}\n";
page += ".status-value {padding: 5px 10px; border-radius: 20px; color: white; font-weight: bold;}\n";
page += ".status-ok { background-color: #4CAF50; }\n";
page += ".status-warning { background-color: #FFC107; }\n";
page += ".status-error { background-color: #F44336; }\n";
page += "</style>";
page += "</head><body>\n";
page += "<div class=\"container\"><h1>INPUTS:</h1>\n";
page += "<div class=\"status-item\">\n";
page += "<span class=\"status-label\">PLC:</span>";
if (plc) { page += "<span class=\"status-value status-error\">Triggered</span>\n"; }
else { page += "<span class=\"status-value status-ok\">OK</span>\n"; }
page += "</div><div class=\"status-item\">\n";
page += "<span class=\"status-label\">IOB:</span>\n";
if (iob) { page += "<span class=\"status-value status-error\">Triggered</span>\n"; }
else { page += "<span class=\"status-value status-ok\">OK</span>\n"; }
page += "</div><div class=\"status-item\">\n";
page += "<span class=\"status-label\">UPS:</span>\n";
if (ups) { page += "<span class=\"status-value status-error\">Triggered</span>\n"; }
else { page += "<span class=\"status-value status-ok\">OK</span>\n"; }
page += "</div><h3>Last INT: ";
page += "5";
page += "</h3></div></body></html>";
return page;
}
#include "rest.hpp"
#include "mpod.hpp"
#include "panel.hpp"
#include <ETH.h>
#ifndef ICBM_GIT_VERSION
......@@ -14,10 +15,10 @@ WebServer restServer(80);
void initializeRoutes() {
restServer.on("/idn", identify);
restServer.on("/restart", restart);
restServer.on("/restart", restart);
restServer.onNotFound(notFound);
restServer.on("/send", sendSNMP);
restServer.on("/poll", pollMPODChannel);
restServer.on("/send", sendSNMP);
restServer.on("/poll", panel);
restServer.begin();
Serial.println("REST Server Started");
......@@ -67,6 +68,12 @@ void identify() {
restServer.send(200, "text/json", message);
}
void panel() {
String content = buildPanel(true, true, true);
restServer.send(200, "text/html", content);
}
void notFound() {
String message = "{\n";
message += "\"uri\":\"";
......
......@@ -9,4 +9,4 @@ void identify(); // /idn
void notFound(); // 404
void restart(); // /restart
void sendSNMP(); // /send?output=on
void pollMPODChannel(); //mock the hardcoded mpod channel 0
void panel(); //show a status page
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment