@ -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 ;
@ -440,7 +440,7 @@ document.getElementById("HDParameter").innerHTML = listParametersOptions;
// Parallel
function do _parallel ( myid , myxs , mycolumns , inMyTitle ) {
cl ( myxs ) ;
//cl(myxs);
c3 . generate ( {
bindto : myid ,
data : {
@ -478,7 +478,6 @@ function do_parallel(myid, myxs, mycolumns, inMyTitle) {
` ;
var myTitle = "<h2>" + inMyTitle + "</h2>" ;
my = myid . replace ( '#' , '' )
cl ( "my id -> " + my ) ;
var mainDiv = document . getElementById ( my ) ;
mainDiv . insertAdjacentHTML ( "afterbegin" , myButtons + myTitle ) ;
@ -1486,8 +1485,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 ;
@ -1500,7 +1497,6 @@ document.querySelectorAll('button[type="submit"]').forEach(button => {
} if ( formId == "saveBoardForm" ) {
var boardName = document . getElementById ( "boardName" ) . value ;
var boardDesc = document . getElementById ( "boardDesc" ) . value
cl ( boardName + " - " + boardDesc ) ;
getCurrentBoardData ( boardName , boardDesc ) ;
} else {
writeIn ( formId , formData ) ;
@ -1740,7 +1736,6 @@ function getValueByKeyFrrmUrl(key, apiurl) {
for ( let i = 0 ; i < keyValuePairs . length ; i ++ ) {
const [ currentKey , value ] = keyValuePairs [ i ] . split ( "=" ) ;
if ( currentKey === key ) {
cl ( "value: " + value ) ;
return value ;
}
}
@ -1775,7 +1770,6 @@ function getCurrentBoardData(boardName, boardDesc) {
var apiUrlsLeft = [ ] ;
var apiUrlsCenter = [ ] ;
var apiUrlsRight = [ ] ;
cl ( "here I am: getCurrentBoardData" ) ;
document . querySelectorAll ( '#col-left div' ) . forEach ( function ( element , index ) {
var apiUrl = element . getAttribute ( 'apiurl' ) ;
var id = element . id ;
@ -1841,7 +1835,7 @@ cl("here I am: getCurrentBoardData");
"col-center" : apiUrlsCenter ,
"col-right" : apiUrlsRight
} ;
alert ( JSON . stringify ( result ) ) ;
//alert(JSON.stringify(result));
return sendDataToAPI ( JSON . stringify ( result ) ) ;
}
@ -1863,17 +1857,22 @@ function sendDataToAPI(myJSON) {
. 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 => {
cl ( "myJSON" ) ;
cl ( myJSON ) ;
console . error ( "Error:" , error ) ;
// Handle any errors that occur during the request
} ) ;
}
//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 ( ) ; } ;
@ -1892,8 +1891,6 @@ buttonElement.addEventListener("click", function() {
// FIXME IT NEED THE BE CALLED WITH THE JSON AD ARGUMENT!!!
// Function to generate the already loaded JSON data of a board.
async function loadBoards ( myJSON ) {
cl ( "Here I am!!" ) ;
cl ( 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 => {
@ -1914,13 +1911,8 @@ async function loadBoards(myJSON) {
// Check if is TXT or Diagram:
if ( element . api _url != null ) {
cl ( "-> element.api_url: " ) ;
cl ( element . api _url ) ;
var apiurl = element . api _url ;
var formId = getFormId ( apiurl ) ;
cl ( "-> formId: " + formId ) ;
var sensor = getValueByKeyFrrmUrl ( "sensor" , apiurl ) ;
var type = getValueByKeyFrrmUrl ( "type" , apiurl ) ;
var year = getValueByKeyFrrmUrl ( "year" , apiurl ) ;
@ -1929,8 +1921,8 @@ 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 ) ;
// cl("PD LoadBoards:");
// cl(formId+" - "+apiurl+" - "+myid+" - "+myTitle+" - "+family+" - "+type+" - "+day);
makeApiRequest ( formId , apiurl , myid , myTitle , family , type , day ) ;
break ;
@ -1938,7 +1930,7 @@ async function loadBoards(myJSON) {
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 ) ;
//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" :
@ -1975,8 +1967,6 @@ function fetchDataAndGenerateHTML(husName) {
. then ( response => response . json ( ) )
. then ( jsonData => {
const generatedHTML = generateHTML ( jsonData ) ;
// cl("List Boards HTML:");
// console.log(generatedHTML);
document . getElementById ( "loadBoard-pills-default" ) . innerHTML = generatedHTML ;
} )
. catch ( error => {
@ -1991,12 +1981,9 @@ function fetchOneBoardData(husName, boardFilename) {
//http://localhost:5000/boards/load?hus=Charlie&filename=test1.json
var apiUrl = base _url _API + "/boards/load?hus=" + myParam + "&filename=" + boardFilename ;
cl ( "-> apiUrl: " + apiUrl ) ;
fetch ( apiUrl )
. then ( response => response . json ( ) )
. then ( jsonData1 => {
cl ( "List Boards JSON:" ) ;
console . log ( jsonData1 ) ;
loadBoards ( jsonData1 ) ;
} )
. catch ( error => {
@ -2074,8 +2061,6 @@ function makeApiRequest(formId, apiUrl, myid, myTitle, ...args) {
var sensor = myArgs [ 0 ] ;
var type = myArgs [ 1 ] ;
var inDate = myArgs [ 2 ] ;
cl ( "startingDate: " + startingDate + " -formId - " + formId + " -apiurl: " + apiurl + " -myid: " + myid + " -myTitle: " + myTitle + " -semsor: " + sensor + " -type: " + type + " -inDate: " ) ;
cl ( myArgs ) ;
break ;
case "GM" :