Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICBM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
detectors
DSSC
ICBM
Commits
ecac1388
Commit
ecac1388
authored
6 months ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Add simple status webpage
parent
745d13cc
No related branches found
No related tags found
No related merge requests found
Pipeline
#148502
passed
6 months ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
panel.hpp
+44
-0
44 additions, 0 deletions
panel.hpp
rest.cpp
+10
-3
10 additions, 3 deletions
rest.cpp
rest.hpp
+1
-1
1 addition, 1 deletion
rest.hpp
with
55 additions
and
4 deletions
panel.hpp
0 → 100644
+
44
−
0
View file @
ecac1388
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
;
}
This diff is collapsed.
Click to expand it.
rest.cpp
+
10
−
3
View file @
ecac1388
#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"
,
p
ollMPODChan
nel
);
restServer
.
on
(
"/send"
,
sendSNMP
);
restServer
.
on
(
"/poll"
,
p
a
nel
);
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
\"
:
\"
"
;
...
...
This diff is collapsed.
Click to expand it.
rest.hpp
+
1
−
1
View file @
ecac1388
...
...
@@ -9,4 +9,4 @@ void identify(); // /idn
void
notFound
();
// 404
void
restart
();
// /restart
void
sendSNMP
();
// /send?output=on
void
p
ollMPODChannel
();
//mock the hardcoded mpod channel 0
void
p
anel
();
//show a status page
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment