BETA Version: some known bugs left. One feature oendingf (include time in several frmulars and API),... and several unknown bugs too ;-)

Rafael
jaume-nualart 7 months ago
parent 09c513c18f
commit f189c85110
  1. 1
      py/Boards/Charlie/GM.json
  2. 1
      py/Boards/Charlie/GY.json
  3. 1
      py/Boards/Charlie/HW.json
  4. 4
      web-html/dash.html
  5. 52
      web-html/js/dash.js

@ -0,0 +1 @@
{"Name": "GM", "Description": "", "Hus": "Charlie", "col-left": [], "col-center": [{"order": 0, "id": "grid-580160", "text": "", "api_url": "grid/monthly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023&month=01"}], "col-right": []}

@ -0,0 +1 @@
{"Name": "GY", "Description": "G Yearky", "Hus": "Charlie", "col-left": [], "col-center": [{"order": 0, "id": "grid-405229", "text": "", "api_url": "grid/yearly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023"}], "col-right": []}

@ -0,0 +1 @@
{"Name": "HW", "Description": "", "Hus": "Charlie", "col-left": [], "col-center": [], "col-right": [{"order": 0, "id": "horizon-876464", "text": "", "api_url": "horizon/weekly?hus=Charlie&family=MP1_1&type=celsius&year=2023&week=15"}]}

@ -86,7 +86,7 @@
<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">
<input id="boardName" required placeholder="required" type="email" class="form-control">
</div>
<div class="mb-3">
<label for="boardDescLabel" class="form-label">Description</label>
@ -96,7 +96,7 @@
<!-- SUBMIT BUTTON -->
<p>&nbsp;</p>
<div class="col-auto">
<button ID="submitBoard" type="submit" class="btn btn-primary">Submit</button>
<button id="submitBoard" type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>

@ -581,7 +581,7 @@ function do_grid_weekly(myid, startingDate, data) {
.style("top", (d3.event.pageY - 10) + "px")
.style("background-color", "#c3c3c3")
.style("opacity", 1)
.html("Value: " + d.toFixed(2));
//.html("Value: " + d.toFixed(2));
})
.on("mouseout", () => {
// Hide tooltip on mouseout
@ -1856,37 +1856,44 @@ function getCurrentBoardData(boardName, boardDesc) {
"col-center": apiUrlsCenter,
"col-right": apiUrlsRight
};
//alert(JSON.stringify(result));
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) {
//var myJSON = JSON.parse('{"Name":"YEAR","Description":"wwww","Hus":"Charlie","col-left":[],"col-center":[{"order":0,"id":"grid-996239","text":"","api_url":"grid/yearly?hus=Charlie&sensor=Temp_MP1_1_Pos1&type=celsius&year=2023"}],"col-right":[]}');
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
cl("inputField");
cl(inputField.value);
form.addEventListener("click", function(event) {
cl(inputField.value);
//JAUME
if (inputField.value.trim() === "") {
cl("It is null!!");
event.preventDefault();
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
//base_url_API = "http://localhost:5000";
const myApiUrl = base_url_API+"/boards/save";
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: myJSON //.stringify(myJSON)
headers: {"Content-Type": "application/json"},
body: myJSON
};
fetch(myApiUrl, requestOptions)
//.then(response => response.json())
.then(response => {
console.log("Response from API:", response);
return response.text();
})
.then(data => {
console.log("Response from API:", myJSON);
console.log("Response content:", data);
// 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() {
submitBtn.addEventListener("submit", function() {
myModal.hide();
});
alert("Board saved!");
@ -1918,6 +1925,12 @@ 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 => {
// First clen the three clumns:
const colLeftDiv = document.getElementById(col);
while (colLeftDiv.firstChild) {
colLeftDiv.firstChild.remove();
}
if (col.length > 0) {
myJSON[col].forEach(async element => {
// Get necessary variables:
@ -1927,12 +1940,6 @@ async function loadBoards(myJSON) {
var myTitle = element.text;
// Create DIV
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.api_url != null ) {
var apiurl = element.api_url;
@ -1945,8 +1952,6 @@ async function loadBoards(myJSON) {
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;
@ -1970,8 +1975,6 @@ async function loadBoards(myJSON) {
makeApiRequest(formId, apiurl, myid);
break;
}
} else {
var formId = "TXT";
createTXT(myid, element.text);
@ -1979,7 +1982,6 @@ async function loadBoards(myJSON) {
});
}
});
}
// function to load THE LIST OF boards FOR AN SPECIFIC hOUSE

Loading…
Cancel
Save