Ready for the SAVE dashboard mplementation

Rafael
jaume-nualart 8 months ago
parent dd3ed74a9c
commit 8d2e25add4
  1. 59
      web-html/dash.html
  2. 175
      web-html/js/dash.js

@ -58,7 +58,6 @@
}
.mysvg {
/* Set the width of each div */
min-height: 190px; /* Set the height 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;
@ -143,15 +142,12 @@
<div class="frame">
<div id="col-left" class="col resizable-column">
<button type="button" class="btn btn-danger rounded-pill" data-bs-toggle="modal" data-bs-target="#parallelModal">new Parallel</button>
<div id="hidden-left"></div>
</div>
<div id="col-center" class="col resizable-column">
<button type="button" class="btn btn-info rounded-pill" data-bs-toggle="modal" data-bs-target="#gridModal">new Grid</button>
<div id="hidden-center"></div>
</div>
<div id="col-right" class="col resizable-column">
<button type="button" class="btn btn-warning rounded-pill" data-bs-toggle="modal" data-bs-target="#horizonModal">new Horizon</button>
<div id="hidden-right"></div>
</div>
</div>
@ -162,36 +158,23 @@
TODO:
> RAFA: API: not no sensors in the query:
http://localhost:5000/horizon/monthly?family=MP1_3&type=celsius&year=2022&week=44
> ors validation/field required:
https://getbootstrap.com/docs/5.0/forms/validation/#how-it-works
> HIDE most of Time fields in forms!!!!
> Add button -> EDIT diagram:
1- when submit form -> write a hidden DIV after the diagram's DIV with the form values
2- When click edit button -> open the form -> Make the option SEÑECTED -> Fill in the values from the hidden DIV.
2- When click save dashboart -> function getApiUrls()
> OPEN diagrams in new window!! -> Add button to the form [In a new window]
)
DIAGRAMS:
> Parallel: tooltip -> use multi d3js version modules.
> Grid:
>> Check calendar wiew ad other views
>> Add "axis" nemes
> Horizon:
-> Tooltip!!!!!
-> Try also multiselect individual sensors
-> Add horizontal-axis values
-->
<!-- DIALOGS FOR GENERATION DIAGRAMS (HTML) -->
<!-- ##################### -->
<!-- parallelModal -->
<div class="modal fade" id="parallelModal" tabindex="-1" aria-labelledby="parallelModalLabel" aria-hidden="true">
@ -295,11 +278,6 @@ https://getbootstrap.com/docs/5.0/forms/validation/#how-it-works
</select>
</div>
<!-- <div id="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="PYYearMonth" name="PYYearMonth" type="text" class="span2">
</div> -->
<!-- TIME SELECT -->
<p>&nbsp;</p>
<div class="form-group col-md-12">
@ -424,36 +402,7 @@ https://getbootstrap.com/docs/5.0/forms/validation/#how-it-works
</div>
<p>&nbsp;</p>
<!-- WEEKDAY SELECT
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="monday" value="monday">
<label class="form-check-label" for="inlineRadio1">Monday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="tuesday" value="tuesday">
<label class="form-check-label" for="inlineRadio1">Tuesday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="wednesday" value="wednesday">
<label class="form-check-label" for="inlineRadio1">Wednesday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="thursday" value="thursday">
<label class="form-check-label" for="inlineRadio1">Thursday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="friday" value="friday">
<label class="form-check-label" for="inlineRadio1">Friday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="saturday" value="saturday">
<label class="form-check-label" for="inlineRadio1">Saturday</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="PMWeekday" id="sunday" value="sunday">
<label class="form-check-label" for="inlineRadio1">Sunday</label>
</div> -->
<!-- TIME SELECT -->
<div class="form-group col-md-8">
<label for="time">Time</label>
@ -631,6 +580,8 @@ https://getbootstrap.com/docs/5.0/forms/validation/#how-it-works
<option value="2022">2022</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
</select>
</div>
@ -875,6 +826,8 @@ https://getbootstrap.com/docs/5.0/forms/validation/#how-it-works
<option value="2022">2022</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
</select>
</div>

@ -212,27 +212,20 @@ function openPopupCanvas(button) {
// get the number/order of the config selected element
if (houses.xname = myParam) {myNumber = count;}
count++;
// console.log("houses.name: "+houses.xname);
});
// console.log("houses.name: "+projectList);
// console.log("!projectList.includes(myParam): "+!projectList.includes(myParam));
////////////////////////////////////////////////////
////// GO BACK OR CONTINUE IN DASHBOARD:
// if (fileName == "dash.html") {
if (!myParam || !projectList.includes(myParam)) {
alert("Välj ett projekt från hemsidan.\nPlease choose a project from the home page.")
window.location.replace('home.html');
}
// }
////////////////////////////////////////////////////
// DEFAULT INTERFACE BUILDING
document.getElementById("myProject").innerHTML = "My Numner "+myNumber;
// cl(PROJECTS.items[myNumber])
var myHouse = PROJECTS.items[myNumber];
////////////////////////////////////////////////////
// DEFAULT INTERFACE BUILDING
document.getElementById("myProject").innerHTML = "My Numner "+myNumber;
var myHouse = PROJECTS.items[myNumber];
// Adding HTML navbar
document.getElementById("navbar").innerHTML = HTML_navBar;
@ -289,29 +282,6 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
document.getElementById("myhouse").innerHTML = card;
/////////////////////////////////////////////////
// Main functions to create diagrams.
// Schema:
// SUBMIT button from diagram forms
// (click) -> call:
// 1) writeInTXT(myColumn) just for adding rick text -> Adds the text and extends.
// 2) writeIn(formId, formData) -> for diagrams
//
// For all the 4 options:
// -> call createMyDiv(...)
//
// And then -> they call:
// > createParallel(...)
// > createGrid(...)
// > createHorizon(...)
// > createTXT(...) -> And here this ends.
// For the 3 create* diagrams functions:
// -> request API -> builds diagram with do_parallel(...), do_grid(...), do_horizon_row(...)
//
//-----------------------------
// writeIn and writeInTXT
@ -344,7 +314,7 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
async function writeInTXT(formId, textData) {
var myColumn = getName(formId[0])
var myid = formId[0]+"-txt-"+Math.floor(Math.random() * 1000000);
await createMyDiv(myid, myColumn);
await createMyDiv(myid, myColumn, "");
createTXT(myid, textData);
}
@ -368,18 +338,8 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
}
document.getElementById(myColumn).appendChild(node);
document.getElementById(myid).innerHTML = myButtons+myTitle;
// Adding the hidden div with a json formated string:
//document.getElementById("hidden-"+myColumn.split("-")[1]).innerHTML = "<p>TEST DATA TEST DATA</p>";
}
function addFormData(myid, apiUrl) {
// Save form data in a hidden div:
const mainDiv = document.getElementById(myid);
const hiddenDiv = mainDiv.querySelector("hiddenData");
hiddenDiv.innerHTML = "<p>TEST "+apiUrl+"</p>";
}
//-----------------------------
// createParallel
async function createParallel(myid,formId, myFormData) {
@ -490,14 +450,6 @@ function addFormData(myid, apiUrl) {
var type = document.getElementById("GYParameter").value;
var apiUrl = "grid/monthly?sensor="+sensor+"&type="+type+"&year="+year;
makeApiRequest(formId, apiUrl, myid, myTitle, sensor, type, year);
// Your array of values for each day of the year (365 values)
// var myData = [27.94, 20.84, 28.80, 28.90, 27.89, 27.87, 27.80, 27.83, 27.83, 27.89, 27.90, 27.89, 27.89, 27.94, 27.84, 27.89, 27.83, 27.79, 27.91, 27.81, 27.86, 27.83, 27.81, 27.83, 27.90, 27.90, 27.83, 27.86, 27.83, 27.84, 27.90];
// var year = "2023";
// do_grid_yearly(myid, year, myData);
break;
}
@ -1058,16 +1010,6 @@ function do_horizon_row(data, myid, title, myDates) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -1076,38 +1018,6 @@ function do_horizon_row(data, myid, title, myDates) {
////////////////////////////////////////////////////////////////
////////////////////////
// function to get the selected collection of items in the Horizon forms
// function handleSelectedOptions(selectId) {
// // Get a reference to the select element
// const selectElement = document.getElementById(selectId);
// // Initialize an array to store selected options
// const selectedOptions = [];
// // Function to update the selected options array
// function updateSelectedOptions() {
// selectedOptions.length = 0;
// for (let i = 0; i < selectElement.options.length; i++) {
// const option = selectElement.options[i];
// if (option.selected) {
// selectedOptions.push(option.value);
// }
// }
// }
// // Add an event listener to the select element to listen for changes
// selectElement.addEventListener("change", updateSelectedOptions);
// // Call the update function initially to capture existing selections
// updateSelectedOptions();
// // Return the selected options array
// return selectedOptions;
// }
///////////////////////////////
// Template 3 columns 100%
const colLeft = document.getElementById("col-left");
@ -1156,13 +1066,15 @@ document.querySelectorAll('button[type="submit"]').forEach(button => {
// Is it a diagram or a text?
if (formId.substring(1)=="Text") {
var fromEditor = document.getElementById(formId[0]+"editor").innerHTML;
//// FIXME -> get the inside HTML from the rich editor using th Quill class (l methiods!!!!
// Get the contents of the selected element
var regex = /<div class="ql-editor" [^>]*?data-lt-tmp-id="([^"]+)".*?<\/div>/g;
var match = fromEditor.match(regex);
// Extracted substring
var textData = match; // ? match[1] : '';
// Parsing the text:
var parser = new DOMParser();
var doc = parser.parseFromString(fromEditor, 'text/html');
var div = doc.querySelector('div[data-lt-tmp-id^="lt-"]');
var textData = div ? div.innerHTML : 'No div found';
writeInTXT(formId, textData);
cl("Addtext:");
cl(fromEditor);
cl(textData);
} else {
writeIn(formId, formData);
}
@ -1250,60 +1162,6 @@ const columns = document.querySelectorAll('.resizable-column');
initialWidth = null;
});
////////////////////////////////////////////7
// Form Multiselect JS combo
// Function to initialize double select
// function initializeDoubleSelect(selectableId, selectedId, moveRightId, moveLeftId) {
// const selectableItemsSelect = document.getElementById(selectableId);
// const selectedItemsSelect = document.getElementById(selectedId);
// const moveRightButton = document.getElementById(moveRightId);
// const moveLeftButton = document.getElementById(moveLeftId);
// // Enable or disable buttons based on selection
// selectableItemsSelect.addEventListener("change", function () {
// const selectedOptions = Array.from(selectableItemsSelect.selectedOptions);
// moveRightButton.disabled = selectedOptions.length === 0;
// });
// selectedItemsSelect.addEventListener("change", function () {
// const selectedOptions = Array.from(selectedItemsSelect.selectedOptions);
// moveLeftButton.disabled = selectedOptions.length === 0;
// });
// // Move selected items between selects
// moveRightButton.addEventListener("click", function () {
// const selectedOptions = Array.from(selectableItemsSelect.selectedOptions);
// selectedOptions.forEach((option) => {
// selectedItemsSelect.appendChild(option.cloneNode(true));
// option.remove();
// });
// moveRightButton.disabled = true;
// });
// moveLeftButton.addEventListener("click", function () {
// const selectedOptions = Array.from(selectedItemsSelect.selectedOptions);
// selectedOptions.forEach((option) => {
// selectableItemsSelect.appendChild(option.cloneNode(true));
// option.remove();
// });
// moveLeftButton.disabled = true;
// });
// }
// // Initialize the first set of double select
// initializeDoubleSelect("selectableItems1", "selectedItems1", "moveRight1", "moveLeft1");
// // Initialize the second set of double select
// initializeDoubleSelect("selectableItems2", "selectedItems2", "moveRight2", "moveLeft2");
// // Initialize the second set of double select
// initializeDoubleSelect("selectableItems3", "selectedItems3", "moveRight3", "moveLeft3");
// You can add more sets by calling initializeDoubleSelect with the appropriate IDs
// END of Multiselect JS
//////////////////////////////////////////7
//////////////////////////////////////////////////////
// Simple funcion to handle DiagramType <-> columns
@ -1532,7 +1390,7 @@ function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) {
var myCol = getName(formId[0]).split("-")[1];
cl("myCol");
cl(myCol);
document.getElementById("hidden-"+myCol).insertAdjacentHTML("beforeend", apiUrl+"@@");
document.getElementById(myid).setAttribute("apiurl", apiUrl);
fetch(apiRequest)
.then((response) => {
@ -1592,7 +1450,4 @@ async function createHiddenVauesDiv(myid, dataName, data) {
var data2 = JSON.stringify(data);
lastValueElement.innerHTML = data2;
// childDiv.appendChild(lastValueElement);
// mainDiv.appendChild(childDiv);
}
}
Loading…
Cancel
Save