Rafael M. Martins 7 months ago
commit 569fb7d87a
  1. 338
      Data/Pilgatan/archive/listofsensores_separatescarss.json
  2. 1
      py/Boards/Charlie/test1.json
  3. 1
      py/Boards/Charlie/test2.json
  4. 1
      py/Boards/Charlie/test3.json
  5. 1
      py/Boards/Pilgatan/2222222.json
  6. 1
      py/Boards/Pilgatan/dddd.json
  7. 1
      py/Boards/Pilgatan/ee.json
  8. 1
      py/Boards/Pilgatan/rr.json
  9. 2
      web-html/config/config.js
  10. 6
      web-html/config/datamap.js
  11. 106
      web-html/css/dash.css
  12. 213
      web-html/dash.html
  13. 21
      web-html/home.html
  14. 422
      web-html/js/dash.js

@ -0,0 +1,338 @@
{
"Hus_Pilgatan_card_v1": [
"Date",
"Time",
"SCv1.SCv1-1-Temp.celsius",
"SCv1.SCv1-2-Counter.Counter",
"SCv1.SCv1-3-Temp.celsius",
"SCv1.SCv1-4-Hum.percentRH",
"SCv1.SCv1-5-Pressure.hPa",
"WS.WS-01-Speed.mXs",
"WS.WS-01-Gust.mXs",
"WS.WS-03-Temp.celsius",
"WS.WS-03-Wind.deg",
"WS.WS-05-Hum.percentRH",
"WS.WS-05-Rain (d).mm",
"WS.WS-07-Rain (h).mmXh",
"WS.WS-07-Air pressure.hPa",
"WS.WS-09-UV index.none",
"WS.WS-09-Sun.none",
"W1.W1-01-Temp.celsius",
"W1.W1-01-Hum.percentRH",
"W1.W1-02-Temp.celsius",
"W1.W1-02-Hum.percentRH",
"W1.W1-03-Temp.celsius",
"W1.W1-03-Hum.percentRH",
"W1.W1-04-Temp.celsius",
"W1.W1-04-Hum.percentRH",
"W1.W1-05-Temp.celsius",
"W1.W1-05-Hum.percentRH",
"W1.W1-06-Temp.celsius",
"W1.W1-06-Hum.percentRH",
"W1.W1-07-Temp.celsius",
"W1.W1-07-Hum.percentRH",
"W1.W1-08-Temp.celsius",
"W1.W1-08-Hum.percentRH",
"W1.W1-09-Temp.celsius",
"W1.W1-09-Hum.percentRH",
"W1.W1-10-Temp.celsius",
"W1.W1-10-Hum.percentRH",
"W1.W1-11-Temp.celsius",
"W1.W1-11-Hum.percentRH",
"W1.W1-12-Temp.celsius",
"W1.W1-12-Hum.percentRH",
"W1.W1-intern-Temp.celsius",
"W1.W1-intern-Hum.percentRH",
"W1.intern-intern-Pressure.hPa",
"W1.W1-intern-Runtime.min",
"W2.W2-01-Temp.celsius",
"W2.W2-01-Hum.percentRH",
"W2.W2-02-Temp.celsius",
"W2.W2-02-Hum.percentRH",
"W2.W2-03-Temp.celsius",
"W2.W2-03-Hum.percentRH",
"W2.W2-04-Temp.celsius",
"W2.W2-04-Hum.percentRH",
"W2.W2-05-Temp.celsius",
"W2.W2-05-Hum.percentRH",
"W2.W2-06-Temp.celsius",
"W2.W2-06-Hum.percentRH",
"W2.W2-07-Temp.celsius",
"W2.W2-07-Hum.percentRH",
"W2.W2-08-Temp.celsius",
"W2.W2-08-Hum.percentRH",
"W2.W2-09-Temp.celsius",
"W2.W2-09-Hum.percentRH",
"W2.W2-10-Temp.celsius",
"W2.W2-10-Hum.percentRH",
"W2.W2-11-Temp.celsius",
"W2.W2-11-Hum.percentRH",
"W2.W2-12-Temp.celsius",
"W2.W2-12-Hum.percentRH",
"W2.W2-intern-Temp.celsius",
"W2.W2-intern-Hum.percentRH",
"W2.intern-intern-Pressure.hPa",
"W2.W2-intern-Runtime.min",
"W3.W3-01-Temp.celsius",
"W3.W3-01-Hum.percentRH",
"W3.W3-02-Temp.celsius",
"W3.W3-02-Hum.percentRH",
"W3.W3-03-Temp.celsius",
"W3.W3-03-Hum.percentRH",
"W3.W3-04-Temp.celsius",
"W3.W3-04-Hum.percentRH",
"W3.W3-05-Temp.celsius",
"W3.W3-05-Hum.percentRH",
"W3.W3-06-Temp.celsius",
"W3.W3-06-Hum.percentRH",
"W3.W3-07-Temp.celsius",
"W3.W3-07-Hum.percentRH",
"W3.W3-08-Temp.celsius",
"W3.W3-08-Hum.percentRH",
"W3.W3-09-Temp.celsius",
"W3.W3-09-Hum.percentRH",
"W3.W3-10-Temp.celsius",
"W3.W3-10-Hum.percentRH",
"W3.W3-11-Temp.celsius",
"W3.W3-11-Hum.percentRH",
"W3.W3-12-Temp.celsius",
"W3.W3-12-Hum.percentRH",
"W3.W3-intern-Temp.celsius",
"W3.W3-intern-Hum.percentRH",
"W3.intern-intern-Pressure.hPa",
"W3.W3-intern-Runtime.min",
"W4.W4-01-Temp.celsius",
"W4.W4-01-Hum.percentRH",
"W4.W4-02-Temp.celsius",
"W4.W4-02-Hum.percentRH",
"W4.W4-03-Temp.celsius",
"W4.W4-03-Hum.percentRH",
"W4.W4-04-Temp.celsius",
"W4.W4-04-Hum.percentRH",
"W4.W4-05-Temp.celsius",
"W4.W4-05-Hum.percentRH",
"W4.W4-06-Temp.celsius",
"W4.W4-06-Hum.percentRH",
"W4.W4-07-Temp.celsius",
"W4.W4-07-Hum.percentRH",
"W4.W4-08-Temp.celsius",
"W4.W4-08-Hum.percentRH",
"W4.W4-09-Temp.celsius",
"W4.W4-09-Hum.percentRH",
"W4.W4-10-Temp.celsius",
"W4.W4-10-Hum.percentRH",
"W4.W4-11-Temp.celsius",
"W4.W4-11-Hum.percentRH",
"W4.W4-12-Temp.celsius",
"W4.W4-12-Hum.percentRH",
"W4.W4-intern-Temp.celsius",
"W4.W4-intern-Hum.percentRH",
"W4.intern-intern-Pressure.hPa",
"W4.W4-intern-Runtime.min",
"S2.S2-01-Temp.celsius",
"S2.S2-01-Hum.percentRH",
"S2.S2-02-Temp.celsius",
"S2.S2-02-Hum.percentRH",
"S2.S2-03-Temp.celsius",
"S2.S2-03-Hum.percentRH",
"S3.S2-01-Temp.celsius",
"S3.S2-01-Hum.percentRH",
"S3.S2-02-Temp.celsius",
"S3.S2-02-Hum.percentRH",
"S3.S2-03-Temp.celsius",
"S3.S2-03-Hum.percentRH",
"S1.S2-01-Temp.celsius",
"S1.S2-01-Hum.percentRH",
"S1.S2-02-Temp.celsius",
"S1.S2-02-Hum.percentRH",
"S1.S2-03-Temp.celsius",
"S1.S2-03-Hum.percentRH",
"S4.S2-01-Temp.celsius",
"S4.S2-01-Hum.percentRH",
"S4.S2-02-Temp.celsius",
"S4.S2-02-Hum.percentRH",
"S4.S2-03-Temp.celsius",
"S4.S2-03-Hum.percentRH",
"S4.S2-intern-Temp.celsius",
"S4.S2-intern-Hum.percentRH",
"S4.intern-intern-Pressure.hPa",
"S4.S2-intern-Runtime.min",
"S6.S6-01-Temp.celsius",
"S6.S6-01-Hum.percentRH",
"S6.S6-02-Temp.celsius",
"S6.S6-02-Hum.percentRH",
"S6.S6-03-Temp.celsius",
"S6.S6-03-Hum.percentRH",
"S7.S6-01-Temp.celsius",
"S7.S6-01-Hum.percentRH",
"S7.S6-02-Temp.celsius",
"S7.S6-02-Hum.percentRH",
"S7.S6-03-Temp.celsius",
"S7.S6-03-Hum.percentRH",
"S5.S6-01-Temp.celsius",
"S5.S6-01-Hum.percentRH",
"S5.S6-02-Temp.celsius",
"S5.S6-02-Hum.percentRH",
"S5.S6-03-Temp.celsius",
"S5.S6-03-Hum.percentRH",
"S8.S6-01-Temp.celsius",
"S8.S6-01-Hum.percentRH",
"S8.S6-02-Temp.celsius",
"S8.S6-02-Hum.percentRH",
"S8.S6-03-Temp.celsius",
"S8.S6-03-Hum.percentRH",
"S8.S6-intern-Temp.celsius",
"S8.S6-intern-Hum.percentRH",
"S8.intern-intern-Pressure.hPa",
"S8.S6-intern-Runtime.min"
],
"Hus_Pilgatan_card_v6": [
"Date",
"Time",
"SCv6.SCv6-01-Temp.celsius",
"SCv6.SCv6-02-Counter.Counter",
"SCv6.SCv6-03-Temp.celsius",
"SCv6.SCv6-04-Hum.percentRH",
"SCv6.SCv6-05-Pressure.hPa",
"W5.W5-01-Temp.celsius",
"W5.W5-01-Hum.percentRH",
"W5.W5-02-Temp.celsius",
"W5.W5-02-Hum.percentRH",
"W5.W5-03-Temp.celsius",
"W5.W5-03-Hum.percentRH",
"W5.W5-04-Temp.celsius",
"W5.W5-04-Hum.percentRH",
"W5.W5-05-Temp.celsius",
"W5.W5-05-Hum.percentRH",
"W5.W5-06-Temp.celsius",
"W5.W5-06-Hum.percentRH",
"W5.W5-07-Temp.celsius",
"W5.W5-07-Hum.percentRH",
"W5.W5-08-Temp.celsius",
"W5.W5-08-Hum.percentRH",
"W5.W5-09-Temp.celsius",
"W5.W5-09-Hum.percentRH",
"W5.W5-10-Temp.celsius",
"W5.W5-10-Hum.percentRH",
"W5.W5-11-Temp.celsius",
"W5.W5-11-Hum.percentRH",
"W5.W5-12-Temp.celsius",
"W5.W5-12-Hum.percentRH",
"W5.W5-intern-Temp.celsius",
"W5.W5-intern-Hum.percentRH",
"W5.intern-intern-Pressure.hPa",
"W5.W5-intern-Runtime.min",
"W6.W6-01-Temp.celsius",
"W6.W6-01-Hum.percentRH",
"W6.W6-02-Temp.celsius",
"W6.W6-02-Hum.percentRH",
"W6.W6-03-Temp.celsius",
"W6.W6-03-Hum.percentRH",
"W6.W6-04-Temp.celsius",
"W6.W6-04-Hum.percentRH",
"W6.W6-05-Temp.celsius",
"W6.W6-05-Hum.percentRH",
"W6.W6-06-Temp.celsius",
"W6.W6-06-Hum.percentRH",
"W6.W6-07-Temp.celsius",
"W6.W6-07-Hum.percentRH",
"W6.W6-08-Temp.celsius",
"W6.W6-08-Hum.percentRH",
"W6.W6-09-Temp.celsius",
"W6.W6-09-Hum.percentRH",
"W6.W6-10-Temp.celsius",
"W6.W6-10-Hum.percentRH",
"W6.W6-11-Temp.celsius",
"W6.W6-11-Hum.percentRH",
"W6.W6-12-Temp.celsius",
"W6.W6-12-Hum.percentRH",
"W6.W6-intern-Temp.celsius",
"W6.W6-intern-Hum.percentRH",
"W6.intern-intern-Pressure.hPa",
"W6.W6-intern-Runtime.min",
"W7.W7-01-Temp.celsius",
"W7.W7-01-Hum.percentRH",
"W7.W7-02-Temp.celsius",
"W7.W7-02-Hum.percentRH",
"W7.W7-03-Temp.celsius",
"W7.W7-03-Hum.percentRH",
"W7.W7-04-Temp.celsius",
"W7.W7-04-Hum.percentRH",
"W7.W7-05-Temp.celsius",
"W7.W7-05-Hum.percentRH",
"W7.W7-06-Temp.celsius",
"W7.W7-06-Hum.percentRH",
"W7.W7-07-Temp.celsius",
"W7.W7-07-Hum.percentRH",
"W7.W7-08-Temp.celsius",
"W7.W7-08-Hum.percentRH",
"W7.W7-09-Temp.celsius",
"W7.W7-09-Hum.percentRH",
"W7.W7-10-Temp.celsius",
"W7.W7-10-Hum.percentRH",
"W7.W7-11-Temp.celsius",
"W7.W7-11-Hum.percentRH",
"W7.W7-12-Temp.celsius",
"W7.W7-12-Hum.percentRH",
"W7.W7-intern-Temp.celsius",
"W7.W7-intern-Hum.percentRH",
"W7.intern-intern-Pressure.hPa",
"W7.W7-intern-Runtime.min",
"W8.W8-01-Temp.celsius",
"W8.W8-01-Hum.percentRH",
"W8.W8-02-Temp.celsius",
"W8.W8-02-Hum.percentRH",
"W8.W8-03-Temp.celsius",
"W8.W8-03-Hum.percentRH",
"W8.W8-04-Temp.celsius",
"W8.W8-04-Hum.percentRH",
"W8.W8-05-Temp.celsius",
"W8.W8-05-Hum.percentRH",
"W8.W8-06-Temp.celsius",
"W8.W8-06-Hum.percentRH",
"W8.W8-07-Temp.celsius",
"W8.W8-07-Hum.percentRH",
"W8.W8-08-Temp.celsius",
"W8.W8-08-Hum.percentRH",
"W8.W8-09-Temp.celsius",
"W8.W8-09-Hum.percentRH",
"W8.W8-10-Temp.celsius",
"W8.W8-10-Hum.percentRH",
"W8.W8-11-Temp.celsius",
"W8.W8-11-Hum.percentRH",
"W8.W8-12-Temp.celsius",
"W8.W8-12-Hum.percentRH",
"W8.W8-intern-Temp.celsius",
"W8.W8-intern-Hum.percentRH",
"W8.intern-intern-Pressure.hPa",
"W8.W8-intern-Runtime.min",
"R1.R1-01-Temp.celsius",
"R1.R1-01-Hum.percentRH",
"R1.R1-02-Temp.celsius",
"R1.R1-02-Hum.percentRH",
"R1.R1-03-Temp.celsius",
"R1.R1-03-Hum.percentRH",
"R1.R1-04-Temp.celsius",
"R1.R1-04-Hum.percentRH",
"R1.R1-05-Temp.celsius",
"R1.R1-05-Hum.percentRH",
"R1.R1-06-Temp.celsius",
"R1.R1-06-Hum.percentRH",
"R2.R1-01-Temp.celsius",
"R2.R1-01-Hum.percentRH",
"R2.R1-02-Temp.celsius",
"R2.R1-02-Hum.percentRH",
"R2.R1-03-Temp.celsius",
"R2.R1-03-Hum.percentRH",
"R2.R1-04-Temp.celsius",
"R2.R1-04-Hum.percentRH",
"R2.R1-05-Temp.celsius",
"R2.R1-05-Hum.percentRH",
"R2.R1-06-Temp.celsius",
"R2.R1-06-Hum.percentRH",
"R2.R1-intern-Temp.celsius",
"R2.R1-intern-Hum.percentRH",
"R2.intern-intern-Pressure.hPa",
"R2.R1-intern-Runtime.min"
]
}

@ -0,0 +1 @@
{"Name": "test1", "Description": "this is a test", "Hus": "Charlie", "col-left": [{"order": 0, "id": "P-txt-723017", "text": "eeeeeeee", "api_url": null}, {"order": 1, "id": "parallel-4286811", "text": "", "api_url": "parallel/daily?hus=Charlie&family=MP1_1&type=celsius&day=2022-12-15"}], "col-center": [{"order": 0, "id": "G-txt-910177", "text": "err we", "api_url": null}, {"order": 1, "id": "grid-438525", "text": "", "api_url": "grid/yearly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023"}], "col-right": [{"order": 0, "id": "H-txt-974001", "text": "rerer er re", "api_url": null}, {"order": 1, "id": "horizon-487744", "text": "", "api_url": "horizon/daily?hus=Charlie&family=MP1_1&type=celsius&day=2023-02-07"}]}

@ -0,0 +1 @@
{"Name": "test2", "Description": "this is exactly like test1", "Hus": "Charlie", "col-left": [{"order": 0, "id": "P-txt-723017", "text": "eeeeeeeeeeeeeeee", "api_url": null}, {"order": 1, "id": "parallel-4286811", "text": "", "api_url": "parallel/daily?hus=Charlie&family=MP1_1&type=celsius&day=2022-12-15"}], "col-center": [{"order": 0, "id": "G-txt-910177", "text": "err weerr we", "api_url": null}, {"order": 1, "id": "grid-438525", "text": "", "api_url": "grid/yearly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023"}], "col-right": [{"order": 0, "id": "H-txt-974001", "text": "rerer er rererer er re", "api_url": null}, {"order": 1, "id": "horizon-487744", "text": "", "api_url": "horizon/daily?hus=Charlie&family=MP1_1&type=celsius&day=2023-02-07"}]}

@ -0,0 +1 @@
{"Name": "test3", "Description": "test2 has TXT+Diagram -> 1+2, 1+2 and 1+2", "Hus": "Charlie", "col-left": [{"order": 0, "id": "P-txt-723017", "text": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "api_url": null}, {"order": 1, "id": "parallel-4286811", "text": "", "api_url": "parallel/daily?hus=Charlie&family=MP1_1&type=celsius&day=2022-12-15"}, {"order": 2, "id": "parallel-8519775", "text": "", "api_url": "parallel/yearly?hus=Charlie&family=MP1_1&type=celsius&year=2023"}], "col-center": [{"order": 0, "id": "G-txt-910177", "text": "err weerr weerr weerr we", "api_url": null}, {"order": 1, "id": "grid-438525", "text": "", "api_url": "grid/yearly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023"}, {"order": 2, "id": "grid-628976", "text": "", "api_url": "grid/monthly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023&month=01"}], "col-right": [{"order": 0, "id": "H-txt-974001", "text": "rerer er rererer er rererer er rererer er re", "api_url": null}, {"order": 1, "id": "horizon-487744", "text": "", "api_url": "horizon/daily?hus=Charlie&family=MP1_1&type=celsius&day=2023-02-07"}, {"order": 2, "id": "horizon-138015", "text": "", "api_url": "horizon/weekly?hus=Charlie&family=MP1_1&type=celsius&year=2023&week=14"}]}

@ -0,0 +1 @@
{"Name": "2222222", "Description": "333333333", "Hus": "Pilgatan", "col-left": [], "col-center": [], "col-right": []}

@ -0,0 +1 @@
{"Name": "dddd", "Description": "fff", "Hus": "Pilgatan", "col-left": [], "col-center": [], "col-right": []}

@ -0,0 +1 @@
{"Name": "ee", "Description": "ee", "Hus": "Pilgatan", "col-left": [{"order": 0, "id": "parallel-5047360", "text": "", "api_url": "parallel/daily?hus=Pilgatan&family=SCv1&type=celsius&day=2023-06-06"}], "col-center": [{"order": 0, "id": "grid-175161", "text": "", "api_url": "grid/monthly?hus=Pilgatan&sensor=SCv1-1-Temp&type=celsius&year=2023&month=01"}], "col-right": [{"order": 0, "id": "horizon-970414", "text": "", "api_url": "horizon/daily?hus=Pilgatan&family=SCv1&type=celsius&day=2023-06-05"}]}

@ -0,0 +1 @@
{"Name": "rr", "Description": "rr", "Hus": "Pilgatan", "col-left": [], "col-center": [], "col-right": []}

@ -4,7 +4,7 @@ homePagageUrl = "./home.html";
h1_title = "Welcome to the TräHus flexyboard";
subtitle = 'This application is a flexyboard that enables monitorization of time-series sensors.';
x1 = "...";
base_url_API = "http://localhost:5000";
x2 = "...";
credits = "Infravis.se (LNU node)";

File diff suppressed because one or more lines are too long

@ -1,107 +1,3 @@
/* Horizon graph stules*/
.horizon {
border-top: solid 1px #000;
border-bottom: solid 1px #000;
overflow: hidden;
position: relative;
}
.horizon + .horizon {
border-top: none;
}
.horizon canvas {
display: block;
image-rendering: pixelated;
}
.horizon .title,
.horizon .value {
bottom: 0;
line-height: 30px;
margin: 0 6px;
position: absolute;
font-family: sans-serif;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
white-space: nowrap;
}
.horizon .title {
left: 0;
}
.horizon .value {
right: 0;
}
.color {
width:70px;
height: 70px;
margin:2px;
float:left;
}
/* ***************************************** */
/* Style for the right upper corner div */
.corner-div {
position: relative;
border: 1px solid #ccc;
padding: 20px;
margin-bottom: 20px; /* Add some spacing between divs */
}
/* Style for the close button */
.corner-close {
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
}
/* Style for the pop-up button */
.corner-popup {
position: absolute;
top: 5px;
right: 40px;
cursor: pointer;
}
/* Style for the print button */
.corner-print {
position: absolute;
top: 5px;
right: 75px;
cursor: pointer;
}
/*Grid monthly styles*/
/* Add your CSS styles here */
.heatmap rect {
stroke: #fff;
}
#tooltip {
padding: 5px;
background: rgba(0, 0, 0, 0.7);
color: white;
border-radius: 1px;
}
.year-label {
text-anchor: end;
font-size: 1.5em;
font-weight: bold;
margin-right: 20px;
}
/* ------------------ */
.c3-grid-lines {
width:100%;
}
.card-img-top {
width:150px;
}
@ -176,4 +72,4 @@ font-size: 12px;
fill: none;
font-size: 10px;
shape-rendering: crispEdges;
}
}

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<title>TräHus dashboard</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="imgs/infravis.ico" type="image/x-icon">
<!-- Required meta tags -->
<!-- required placeholder="Required" meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
@ -18,84 +18,9 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- <link href="./css/dash.css" rel="stylesheet"> -->
<link href="./css/dash.css" rel="stylesheet">
<style>
.card-img-top {
width:150px;
}
#myhouse {
background-color: #3e3e3e;
color:#ffffff;
padding:1.5em;
}
#templates {
margin-top:10px;
margin-bottom:10px;
}
.frama {
margin-top:20px;
width:100%;
}
.col {
border-right: 1rem solid #3e3e3e;
padding: 3px;
overflow: auto;
width: 30%;
float:left;
resize:horizontal
}
.frame div:hover {
border-bottom:1px dashed #c51313;
}
.resizable-column {
overflow: auto;
}
.resizable-column:hover {
cursor: col-resize;
}
div span, h5, h4, svg, canvas, .col div {
cursor: default;
}
.mysvg {
/* Set the width of each div */
margin: 10px; /* Set the margin to create space between divs */
background-color: #dddcdc; /* Optional background color for clarity */
border-bottom: 4px solid #7f7f81;
display:block;
}
div svg {
display:block;
}
.myheight {
height:360px;
}
div.sortable-item {
cursor:move;
}
#tooltip {
display: block;
position: absolute;
background-color: white;
padding: 5px;
border: 1px solid #ccc;
}
/*------------------*/
.tooltip {
position: absolute;
background-color: rgba(255, 255, 255, 0.8);
padding: 5px;
border: 1px solid #ddd;
border-radius: 3px;
pointer-events: none;
font-size: 12px;
}
.axis {
fill: none;
font-size: 10px;
shape-rendering: crispEdges;
}
</style>
<!-- JS libs-->
@ -112,16 +37,12 @@
<script src="./js/d3-horizon-chart0.0.5.js"></script>
<script src="./config/config.js"></script>
<script src="./config/datamap.js"></script>
</head>
<body>
<div class="container" style="max-width:90%">
<!-- Navbar-->
<nav id ="navbar" class="navbar navbar-dark bg-primary navbar-expand-lg navbar-light bg-light">
</nav>
@ -133,9 +54,9 @@
<div id="myhouse">
</div>
<div id="templates">Manage board:&nbsp;&nbsp;
<button id="saveDash" class="btn btn-outline-success" onclick="getApiUrls();"><i class="fa fa-upload"></i>Save</button>
<button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#saveBoardModal"><i class="fa fa-upload"></i>Save Board</button>
&nbsp;&nbsp;
<button id="loadDashList" class="btn btn-outline-success" onclick="loadBoards();"><i class="fa fa-folder-open-o"></i>List</button>
<button id="loadListBoardsButton" type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#loadBoardModal"><i class="fa fa-folder-open-o"></i>Load Board</button>
<span class="float-end">Templates:&nbsp;&nbsp;
<button id="button2" class="btn btn-outline-success"><i class="fa fa-map"></i> 33 %</button>
&nbsp;&nbsp;
@ -154,6 +75,50 @@
</div>
</div>
<!-- ##################### -->
<!-- Save Board Modal -->
<div class="modal fade" id="saveBoardModal" tabindex="-1" aria-labelledby="saveBoardModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<div class="tab-pane fade show" id="saveBoard-pills-default" role="tabpanel" aria-labelledby="pills-default-tab">
<p>You can save this board. Just fill it up the below form:</p>
<form id="saveBoardForm" class="addtext">
<div class="mb-3">
<label for="boardNameLabel" class="form-label">Board name</label>
<input required placeholder="required" type="email" class="form-control" id="boardName" placeholder="name@example.com">
</div>
<div class="mb-3">
<label for="boardDescLabel" class="form-label">Description</label>
<textarea class="form-control" id="boardDesc" rows="3"></textarea>
</div>
<!-- SUBMIT BUTTON -->
<p>&nbsp;</p>
<div class="col-auto">
<button ID="submitBoard" type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Load Board Modal -->
<div class="modal fade" id="loadBoardModal" tabindex="-1" aria-labelledby="loadBoardModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<div class="tab-pane fade show" id="loadBoard-pills-default" role="tabpanel" aria-labelledby="pills-default-tab">
</div>
</div>
</div>
</div>
</div>
<!-- ##################### -->
<!-- parallelModal -->
@ -288,7 +253,7 @@
<p>Select Month and Year:</p>
<div id="SelectYearMonth1" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="PMYearMonth" name="PMYearMonth" type="text" class="span2">
<input required placeholder="Required" id="PMYearMonth" name="PMYearMonth" type="text" class="span2">
</div>
<p>&nbsp;</p>
@ -339,7 +304,7 @@
<div id="parallelSelectYearMonthWeek" class="input-group date">
<label for="time">Select a week,<br />(clicking in a Monday)</label>
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="PWWeekMonday" name="PWWeekMonday" type="text" class="span2">
<input required placeholder="Required" id="PWWeekMonday" name="PWWeekMonday" type="text" class="span2">
</div>
<p>&nbsp;</p>
@ -391,9 +356,8 @@
<!-- DD/MM/YYYY SELECT -->
<div id="SelectYearMonthDay" class="input-group date">
<label style="width:100%;" for="day">Select Day, Month, Year</label>
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="PDYearMonthDay" name="PDYearMonthDay" type="text" class="span2">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input required placeholder="Required" id="PDYearMonthDay" name="PDYearMonthDay" type="text" class="span2">
</div>
<!-- TIME SELECT -->
<p>&nbsp;</p>
@ -411,7 +375,6 @@
</div>
</form>
</div>
</div>
</div>
</div>
@ -481,7 +444,6 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="GYSensor" name="GYSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -489,16 +451,13 @@
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="GYParameter" name="GYParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
</select>
</div>
<p>&nbsp;</p>
<div id="gridSelectYear" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<select id="GYYear" name="GYYear" class="form-select" aria-label="grid-yearly-select">
<select id="GYYear" name="GYYear" class="form-select" aria-label="grid-yearly-select">
</select>
</div>
<!-- TIME SELECT -->
<p>&nbsp;</p>
@ -538,15 +497,13 @@
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="GMParameter" name="GMParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
</select>
</div>
<p>&nbsp;</p>
<div id="grid-SelectYearMonth" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="GMYearMonth" name="GMYearMonth" type="text" class="span2">
<input required placeholder="Required" id="GMYearMonth" name="GMYearMonth" type="text" class="span2">
</div>
<p>&nbsp;</p>
@ -579,15 +536,13 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="GWSensor" name="GWSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
<p>Select parameter:</p>
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="GWParameter" name="GWParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
<select id="GWParameter" name="GWParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -596,7 +551,7 @@
<!-- Monday/MM/YYYY -> week selecting a Monday -->
<div id="SelectYearMonthWeek" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="GWYearMonthMonday" name="GWYearMonthMonday" type="text" class="span2">
<input required placeholder="Required" id="GWYearMonthMonday" name="GWYearMonthMonday" type="text" class="span2">
</div>
<!-- TIME SELECT -->
<p>&nbsp;</p>
@ -614,7 +569,6 @@
</div>
</form>
</div>
</div>
</div>
</div>
@ -681,7 +635,7 @@
<form id="HY">
<div>
<span class="col-md-3">Diagram title: </span>
<input id="HYTitle" name="HYTitle" type="text" class="span2">
<input required placeholder="Required" id="HYTitle" name="HYTitle" type="text" class="span2">
</div>
<p>&nbsp;</p>
@ -689,12 +643,10 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HYFamSensor" name="HYFamSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Select parameter:</p>
<div class="input-group date">
@ -707,7 +659,6 @@
<div id="horizon-optionMonthly" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<select id="HYYear" name="HYYear" class="form-select" aria-label="horizon-yearly-select">
</select>
</div>
@ -717,7 +668,7 @@
<label for="time">Time</label>
<div class="input-group date" id="timePicker">
<span class="input-group-text input-group-addon"><i class="bi bi-clock" aria-hidden="true"></i></span>
<input id="HYTime" disabled name="HYTime" type="text" class="timePicker span2">
<input required placeholder="Required" id="HYTime" disabled name="HYTime" type="text" class="timePicker span2">
</div>
</div>
<!-- SUBMIT BUTTON -->
@ -744,7 +695,6 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HMFamSensor" name="HMFamSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -755,14 +705,13 @@
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HMParameter" name="HMParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
</select>
</div>
<p>&nbsp;</p>
<div id="horizon-SelectYearMonth" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="HMYearMonth" name="GMYearMonth" type="text" class="span2">
<input required placeholder="Required" id="HMYearMonth" name="GMYearMonth" type="text" class="span2">
</div>
<p>&nbsp;</p>
@ -801,7 +750,6 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HWFamSensor" name="HWFamSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -812,7 +760,6 @@
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HWParameter" name="HWParameter" class="form-select col-md-3 span2" aria-label="grid-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -822,7 +769,7 @@
<div id="horizonSelectYearMonthWeek" class="input-group date">
<label for="time">Select a week,<br />(clicking in a Monday)</label>
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="HWWeek" name="HWWeek" type="text" class="span2">
<input required placeholder="Required" id="HWWeek" name="HWWeek" type="text" class="span2">
</div>
<!-- TIME SELECT -->
<p>&nbsp;</p>
@ -855,7 +802,6 @@
<div id="SelectSensor" class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HDFamSensor" name="HDFamSensor" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -863,7 +809,6 @@
<div class="input-group date">
<span class="input-group-text input-group-addon"><i class="bi bi-list-ul" aria-hidden="true"></i></span>
<select id="HDParameter" name="HDParameter" class="form-select col-md-3 span2" aria-label="parallel-family-select">
</select>
</div>
<p>&nbsp;</p>
@ -873,7 +818,7 @@
<label style="width:100%;" for="day">Select Day, Month, Year</label>
<span class="input-group-text input-group-addon"><i class="bi bi-calendar3" aria-hidden="true"></i></span>
<input id="HDYearMonthDay" name="HDYearMonthDay" type="text" class="span2">
<input required placeholder="Required" id="HDYearMonthDay" name="HDYearMonthDay" type="text" class="span2">
</div>
<!-- TIME SELECT -->
<p>&nbsp;</p>
@ -881,7 +826,7 @@
<label for="time">Time</label>
<div class="input-group date" id="timePicker">
<span class="input-group-text input-group-addon"><i class="bi bi-clock" aria-hidden="true"></i></span>
<input placeholder="Disabled Input" disabled id="PDTime" disabled name="PDTime" type="text" class="timePicker span2">
<input placeholder="Disabled Input" disabled id="PDTime" disabled name="PDTime" type="text" class="timePicker span2">
</div>
</div>
<!-- SUBMIT BUTTON -->
@ -891,13 +836,16 @@
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="fixed-bottom bg-dark text-light text-center py-2">
<!-- Footer content -->
This is the fixed footer.
</footer>
</div> <!-- Closing MODAL dialog -->
@ -908,27 +856,16 @@
<!-- Add the tooltip element here -->
<div id="tooltip_gm"></div>
</div> <!-- main body container closing-->
<!-- //////////////////////////////////////// -->
<!-- //////////////////////////////////////// -->
<!-- rich text editor -->
<!-- rich text editor -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
</script>
<script src="//cdn.quilljs.com/1.0.0/quill.js"></script>
<!-- // Main dash JS code -->
<script src="./js/dash.js"></script>
<!-- // Main dash JS code -->
<script src="./js/dash.js"></script>
<!-- // Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

@ -16,11 +16,30 @@
padding: 1rem;
border: 1px solid black;
margin: 1rem;
max-height: 390px;
scroll-behavior: auto;
overflow-y: scroll;
}
.card-img-top {
max-height:110px;
width:150px;
}
.card-body {
position: relative;
height: 390px; /*Set the desired height of the container*/
}
.card-text {
max-height: 100px;
overflow-y:auto;
}
.card-text:-webkit-scrollbar {
width: 8px;
}
.homeButtons {
position: absolute;
bottom: 0
}
</style>
<!-- JS libs-->
@ -62,7 +81,7 @@
<a href="${houses.map_url}" target="map of ${houses.hname}"><img src="${houses.map}" class="card-img-top" alt="..."></a>
<h5 class="${houses.name}">${houses.hname}</h5>
<p class="card-text">${houses.subtitle}</p>
<p>Open dashboard
<p class="homeButtons">Open dashboard
<a href="dash.html?h=${houses.xname}" class="btn btn-primary">inthis window</a>
<a href="dash.html?h=${houses.xname}" target="_${houses.name}" class="btn btn-primary">In a new window</a>
</p>

@ -32,7 +32,7 @@
// DEFAULT INTERFACE BUILDING
var myHouse = PROJECTS.items[myNumber];
var myHouseXname = PROJECTS.items[myNumber].xname;
cl(myHouseXname);
//cl(myHouseXname);
document.getElementById("h1_title").innerHTML = h1_title;
document.getElementById("subtitle").innerHTML = subtitle;
@ -41,7 +41,6 @@ document.getElementById("subtitle").innerHTML = subtitle;
// Get and apply the range of time for the data.
//////////////////////////////////
// LIST OF SENSOR NAME and Families.
// Get the list of sensors, amnd the range_years_month from config/datamap.js
@ -51,7 +50,7 @@ var range_year_month;
for (var i = 0; i < PROJECTS.items.length; i++) {
if (PROJECTS.items[i].xname === projectName) {
range_year_month = PROJECTS.items[i].range_years_month;
listSensors = PROJECTS.items[i].families[0].listOfSensors;
listSensors = PROJECTS.items[i].listOfSensors;
break;
}
}
@ -195,9 +194,9 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
//-----------------------------
// writeIn and writeInTXT
async function writeIn(formId, formData) {
async function writeIn(formId, formData) {//, apiUrl, myid) {
var myColumn = getName(formId[0])
var myTitle = document.getElementById(formId+"Title").value;
var myTitle = document.getElementById(formId[0]+"Text").value;
// cl("formId[0]: "+formId[0]);
// cl("myColumn: "+myColumn);
@ -324,7 +323,6 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
// BUILDING API query
var apiUrl = "grid/weekly?hus="+myHouseXname+"&sensor="+sensor+"&type="+type+"&year="+year+"&week="+week;
makeApiRequest(formId, apiUrl, myid, myTitle, sensor, type, inDate);
break;
//-------------------------------
case "GM":
@ -441,7 +439,7 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
// Parallel
function do_parallel(myid, myxs, mycolumns, inMyTitle) {
cl(myxs);
//cl(myxs);
c3.generate({
bindto: myid,
data: {
@ -479,7 +477,6 @@ function do_parallel(myid, myxs, mycolumns, inMyTitle) {
`;
var myTitle = "<h2>"+inMyTitle+"</h2>";
my = myid.replace('#', '')
var mainDiv = document.getElementById(my);
mainDiv.insertAdjacentHTML("afterbegin", myButtons+myTitle);
@ -1313,89 +1310,6 @@ function do_horizon_row(data, myid, title, myDates) {
// FUNCTIONS /////////////////////////////////////////////////
// Function interactions
////////////////////////////////////////////////////////////////
////////////////////////////////
// SAVE DASHBOARF :: export diagrams + texts to the API
function getApiUrls() {
var apiUrlsLeft = [];
var apiUrlsCenter = [];
var apiUrlsRight = [];
document.querySelectorAll('#col-left div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var order = apiUrlsLeft.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsLeft.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.innerText.trim() : '';
apiUrlsLeft.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
document.querySelectorAll('#col-center div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var text = element.innerHTML.trim(); // Assuming the text is the innerHTML of the element
var order = apiUrlsCenter.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsCenter.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.myLen.trim() : '';
apiUrlsCenter.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
document.querySelectorAll('#col-right div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var text = element.innerHTML.trim(); // Assuming the text is the innerHTML of the element
var order = apiUrlsRight.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsRight.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.innerText.trim() : '';
apiUrlsRight.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
// Similar modifications for #col-center and #col-right
var result = {
// FIXME : boardName will be entered in the save board form
"boardName" : "my Form name test",
"name": boardName,
"hus": myParam,
"description": myHouse.subtitle,
"col-left": apiUrlsLeft,
"col-center": apiUrlsCenter,
"col-right": apiUrlsRight
};
return alert(JSON.stringify(result));
}
@ -1570,8 +1484,6 @@ document.querySelectorAll('button[type="submit"]').forEach(button => {
const formId = event.target.closest('form').id;
// Get the form data based on the form ID
const formData = getFormData(formId);
// Display or use the form data
//cl(`Form Data for ${formId}:`, formData);
// Is it a diagram or a text?
if (formId.substring(1)=="Text") {
var fromEditor = document.getElementById(formId[0]+"editor").innerHTML;
@ -1581,9 +1493,13 @@ document.querySelectorAll('button[type="submit"]').forEach(button => {
var div = doc.querySelector('div[data-lt-tmp-id^="lt-"]');
var textData = div ? div.innerHTML : 'No div found';
writeInTXT(formId, textData);
} if (formId == "saveBoardForm") {
var boardName = document.getElementById("boardName").value;
var boardDesc = document.getElementById("boardDesc").value
getCurrentBoardData(boardName, boardDesc);
} else {
writeIn(formId, formData);
}
}
});
});
@ -1635,6 +1551,11 @@ const editorContent = editor.innerHTML;
console.log(editorContent);
}
///////////////////
// FORMS Check validator required fields:
//
// ...
//////////////////////ç//
@ -1814,35 +1735,243 @@ var firstOpen = true;
// > makeApiRequiest
// > submit nuttons listener
function getValueByKeyFrrmUrl(key, apiurl) {
const keyValuePairs = apiurl.split("&");
for (let i = 0; i < keyValuePairs.length; i++) {
const [currentKey, value] = keyValuePairs[i].split("=");
if (currentKey === key) {
return value;
}
}
return null; // Return null if the key is not found
}
function getFormattedDateFromWeek(week, year) {
const date = new Date(year, 0, 1 + (week - 1) * 7); // January 1st + (week - 1) * 7 days
const day = date.getDate();
const month = date.getMonth() + 1; // Months are zero-based, so we add 1
const formattedDate = `${day.toString().padStart(2, '0')}-${month.toString().padStart(2, '0')}-${year}`;
return formattedDate;
}
// Checking if any variable for the API query is null and NaN
function checkEmptyVariable(str) {
const queryString = str.split("?")[1];
if (!queryString) {
console.log("No variables found after the '?' symbol");
return false;
}
const variables = queryString.split("&");
for (let variable of variables) {
const [key, value] = variable.split("=");
if (key !== "hus" && (!value || value.trim() === "undefined" || value.toString().includes("undefined"))) {
var missedVar = `Variable "${key}" is empty, undefined, or NaN`;
console.log(missedVar);
console.log(str);
return missedVar;
}
}
console.log("No empty, undefined, or NaN variables found");
return false;
}
////////////////////////////////////////
// BOARDS:
////////////////////////////////
// SAVE BOARD :: export diagrams + texts to the API
// Function to get all the vurrent data from the board.
function getCurrentBoardData(boardName, boardDesc) {
var apiUrlsLeft = [];
var apiUrlsCenter = [];
var apiUrlsRight = [];
document.querySelectorAll('#col-left div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var order = apiUrlsLeft.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsLeft.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.innerText.trim() : '';
apiUrlsLeft.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
document.querySelectorAll('#col-center div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var text = element.innerHTML.trim(); // Assuming the text is the innerHTML of the element
var order = apiUrlsCenter.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsCenter.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.myLen.trim() : '';
apiUrlsCenter.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
document.querySelectorAll('#col-right div').forEach(function(element, index) {
var apiUrl = element.getAttribute('apiurl');
var id = element.id;
var text = element.innerHTML.trim(); // Assuming the text is the innerHTML of the element
var order = apiUrlsRight.length;
if (apiUrl === 'txt') {
var clone = element.cloneNode(true);
clone.querySelectorAll('span').forEach(function(span) {
span.parentNode.removeChild(span);
});
var innerText = clone.innerText.trim();
apiUrlsRight.push({ order: order, id: id, text: innerText, api_url: null });
} else if (apiUrl) {
var h2Element = element.querySelector('h2');
text = h2Element ? h2Element.innerText.trim() : '';
apiUrlsRight.push({ order: order, id: id, text: text, api_url: apiUrl });
}
});
var result = {
// FIXME : boardName will be entered in the save board form
"Name" : boardName,
"Description": boardDesc,
"Hus": myParam,
"col-left": apiUrlsLeft,
"col-center": apiUrlsCenter,
"col-right": apiUrlsRight
};
//alert(JSON.stringify(result));
return sendDataToAPI(JSON.stringify(result));
}
// function to send and save the collected data from the current borad to the server thriugh the API
function sendDataToAPI(myJSON) {
const form = document.getElementById("saveBoardForm"); // Get the form element
const inputField = document.getElementById("boardName"); // Get the input field element
form.addEventListener("submit", function(event) {
if (inputField.value.trim() === "") { // Check if the input field is empty after trimming whitespace
event.preventDefault(); // Prevent form submission
console.log("Empty field detected. Form submission blocked.");
} else {
base_url_API = "http://localhost:5000";
const myApiUrl = base_url_API+"/boards/save"; // Replace with your API URL
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: myJSON //.stringify(myJSON)
};
fetch(myApiUrl, requestOptions)
//.then(response => response.json())
.then(data => {
console.log("Response from API:", myJSON);
// Handle the response from the API as needed
const myModal = new bootstrap.Modal(document.getElementById("saveBoardModal"));
const submitBtn = document.getElementById("submitBoard");
submitBtn.addEventListener("click", function() {
myModal.hide();
});
alert("Board saved!");
})
.catch(error => {
console.error("Error:", error);
});
}
});
}
//function to prepare the tha API request upon a board JSON
function getFormId(api_url) {return api_url[0].toUpperCase() + api_url.split("/")[1][0].toUpperCase();};
function loadBoards() {
//JAUME
// Test JSON Board:
myJSON = {"name":"Charlie","hus":"Charlie","description":"Lorem <a href=\"#\">Ipsum is</a> simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.","col-left":[{"order":0,"id":"P-txt-728265","text":"Here a text","api_url":null},{"order":1,"id":"parallel-8001586","text":"","api_url":"parallel/monthly?hus=Charlie&family=MP1_1&type=celsius&year=2020&month=1"}],"col-center":[{"order":0,"id":"G-txt-956767","text":"Here a text","api_url":null},{"order":1,"id":"grid-190619","text":"","api_url":"grid/monthly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023&month=01"}],"col-right":[{"order":0,"id":"H-txt-518613","text":"Here a text","api_url":null},{"order":1,"id":"horizon-986338","text":"","api_url":"horizon/daily?hus=Charlie&family=MP1_1&type=celsius&day=2023-04-12"}]};
////////////////////////////////
// LOAD BOARD
// button listener to get the BOARD LIST from the server
const buttonElement = document.getElementById("loadListBoardsButton");
buttonElement.addEventListener("click", function() {
fetchDataAndGenerateHTML(myParam);
});
// Function to generate the already loaded JSON data of a board.
async function loadBoards(myJSON) {
//myJSON = {"Name":"dddd","Description":" f fa af ffsdfsdfs fsd","Hus":"Charlie","col-left":[],"col-center":[{"order":0,"id":"grid-710994","text":"","api_url":"grid/weekly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023&week=23"}],"col-right":[]};
var cols = ["col-left", "col-center", "col-right"];
cols.forEach(col => {
if (col.length > 0) {
myJSON[col].forEach(element => {
myJSON[col].forEach(async element => {
// Get necessary variables:
var myTitle = myTitle ? nuull : "";
var myColumn = col;
var myid = element.id;
var myTitle = element.text;
// Create DIV
createMyDiv(myid, myColumn, myTitle);
await createMyDiv(myid, myColumn, myTitle);
// setTimeout(function() {
// console.log("After 2 seconds");
// // Code to be executed after the delay
// }, 2000);
// Check if is TXT or Diagram:
if (element.text == "" ) {
cl(element["api_url"]);
var apiUrl = element["api_url"];
var formId = getFormId(apiUrl);
//createParallel(myid, formId, formData);
makeApiRequest(formId, apiUrl, myid);
if (element.api_url != null ) {
var apiurl = element.api_url;
var formId = getFormId(apiurl);
var sensor = getValueByKeyFrrmUrl("sensor", apiurl);
var type = getValueByKeyFrrmUrl("type", apiurl);
var year = getValueByKeyFrrmUrl("year", apiurl);
switch (formId) {
case "PD":
var family = getValueByKeyFrrmUrl("family", apiurl);
var day = getValueByKeyFrrmUrl("day", apiurl);
// cl("PD LoadBoards:");
// cl(formId+" - "+apiurl+" - "+myid+" - "+myTitle+" - "+family+" - "+type+" - "+day);
makeApiRequest(formId, apiurl, myid, myTitle, family, type, day);
break;
case "GW":
var week = getValueByKeyFrrmUrl("week", apiurl);
// Trans for week and year to DD-MM-YYYY
var startingDate = getFormattedDateFromWeek(week, year);
//cl("startingDate: "+startingDate+" -formId - "+formId+" -apiurl: "+apiurl+" -myid: "+myid+" -myTitle: "+myTitle+" -semsor: "+sensor+" -type: "+type+" -week: "+week+" -year: "+year);
makeApiRequest(formId, apiurl, myid, myTitle, sensor, type, startingDate);
break;
case "GM":
var month = getValueByKeyFrrmUrl("month", apiurl);
makeApiRequest(formId, apiurl, myid, myTitle, sensor, type, year, month);
break;
case "GY":
makeApiRequest(formId, apiurl, myid, myTitle, sensor, type, year);;
break;
default:
makeApiRequest(formId, apiurl, myid);
break;
}
} else {
var formId = "TXT";
createTXT(myid, element.text);
@ -1851,19 +1980,80 @@ function loadBoards() {
}
});
//Prepara the variables:
// formId, apiUrl, myid, myTitle, ...args
}
// function to load THE LIST OF boards FOR AN SPECIFIC hOUSE
function fetchDataAndGenerateHTML(husName) {
base_url_API = "http://localhost:5000";
var apiUrl = base_url_API+"/boards?hus="+husName;
cl(apiUrl);
fetch(apiUrl)
.then(response => response.json())
.then(jsonData => {
const generatedHTML = generateHTML(jsonData);
document.getElementById("loadBoard-pills-default").innerHTML = generatedHTML;
})
.catch(error => {
console.error("Error:", error);
});
}
// function to load one boards JSON data
function fetchOneBoardData(husName, boardFilename) {
var apiUrl = base_url_API+"/boards/load?hus="+myParam+"&filename="+boardFilename;
fetch(apiUrl)
.then(response => response.json())
.then(jsonData1 => {
loadBoards(jsonData1);
})
.catch(error => {
console.error("Error:", error);
});
}
function generateHTML(jsonData) {
let html = '<h2>List of saved boards. Just click the one you want to load.:</h2><p>&nbsp:</p><ol>';
for (let i = 0; i < jsonData.length; i++) {
const item = jsonData[i];
html += `<li>${item.Name}</li>`;
html += '<ul>';
html += `<li>Description: ${item.Desc}</li>`;
html += '<p>&nbsp;</p>';
html += '<button onclick="fetchOneBoardData(\''+myParam+'\', \''+item.Filename+'\');" type="button" class="loadme btn btn-info"><i class="fa fa-bolt"></i>Load me!</button>';
html += '</ul>';
html += '<p>&nbsp;</p>';
}
html += '</ol>';
return html;
}
// for each entry of JSON: make calls: createDiv
// Check if is TXT or DIAGRANM: then call makeApiRequest
function checkElementExistence(myid, apiUrl) {
const element = document.getElementById(myid);
if (element) {
element.setAttribute("apiurl", apiUrl);
return
} else {
setTimeout(function() {
checkElementExistence(myid, apiUrl);
}, 1000); // Retry after 1 second (adjust the delay as needed)
}
}
///////////////////////////////////
// Server API:
// Define a function to make the API request
function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) {
// Check the variables on the query:
// var myMissedVar = checkEmptyVariable(apiUrl);
// if(myMissedVar!=false) {
// alert("There are variables with null or NaN values. "+myMissedVar);
// return;
// };
const myArgs = [];
// Store all arguments in an array
myTitle = myTitle || ""; // Define emty if undefined:
@ -1899,6 +2089,7 @@ function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) {
var sensor = myArgs[0];
var type = myArgs[1];
var inDate = myArgs[2];
break;
case "GM":
var sensor = myArgs[0];
@ -1939,13 +2130,18 @@ function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) {
var year = myArgs[2];
break;
}
}
// Make an AJAX request to your Flask API
var apiRequest = `http://localhost:5000/${apiUrl}`; ///parallel/daily?family=${family}&type=${type}&day=${day}`;
cl(apiRequest);
var myDiv_ = document.getElementById(myid);
var myCol = getName(formId[0]).split("-")[1];
document.getElementById(myid).setAttribute("apiurl", apiUrl);
//if (myDiv_ && myDiv_.hasAttribute("apiurl")) {
checkElementExistence(myid, apiUrl)
//document.getElementById(myid).setAttribute("apiurl", apiUrl);
//}
fetch(apiRequest)
.then((response) => {

Loading…
Cancel
Save