Skip to content

Commit

Permalink
Merge remote-tracking branch 'ewowi/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Aug 18, 2024
2 parents 8db45e2 + 0886757 commit fc15112
Show file tree
Hide file tree
Showing 9 changed files with 795 additions and 666 deletions.
2 changes: 1 addition & 1 deletion data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
variable.json = commandJson.json;
}

if (commandJson.hasOwnProperty("file")) { //json send html nodes cannot process, store in jsonValues array
if (commandJson.hasOwnProperty("file")) {
console.log("changeHTML file requested", variable.id, rowNr, commandJson);

//we need to send a request which the server can handle using request variable
Expand Down
1 change: 0 additions & 1 deletion data/newui/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="width=device-width, initial-scale=1" name="viewport" /> <!-- needed for navbar-->
<meta name="author" content="MoonModules and its contributors">
<title>StarBase💫 by MoonModules 🌔</title>
<link rel="icon" href="https://ewowi.github.io/StarDocs/assets/images/ui/starbase/favicon-16x16.png">
<script src="index.js"></script>
<script src="theme.js"></script>
Expand Down
11 changes: 3 additions & 8 deletions data/newui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Controller {
mainNav = null

onLoad() {
document.title = appName() + "💫 by MoonModules 🌔"
if (window.location.href.includes("127.0.0.1"))
this.fetchModelForLiveServer();
else
Expand Down Expand Up @@ -178,19 +179,14 @@ class Controller {

requestJson(command) {
if (window.location.href.includes("127.0.0.1")) { //Live Server

// after a short delay (ws roundtrip)
//find variable
//create class of variable
//generate data for variable

// Live server generates data every second
} else {

if (!this.ws) return;

let req = JSON.stringify(command);

console.log("requestJson", command);
// console.log("requestJson", command);

this.ws.send(req);
}
Expand All @@ -204,7 +200,6 @@ class Controller {

let variable = this.modules.findVar(key);
if (variable) {
variable.fun = -2; // request processed
let variableClass = varJsonToClass(variable);
variableClass.receiveData(value)
} // if variable
Expand Down
18 changes: 12 additions & 6 deletions data/newui/mainnav.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ class MainNav {
})

// Update the page content
// TODO: Real code needed: done: this.#moduleFun
if (this.#moduleFun) {
if (this.#createHTMLFun) {
document.getElementById('page').innerHTML =
`<div class="d-flex flex-column h-100 overflow-hidden">
<div class="flex-shrink-0">
<h1 class="title">${this.#activeModuleJson.id}</h1>
</div>
<div class="overflow-y-auto">` + this.#moduleFun(this.#activeModuleJson) +
<div class="overflow-y-auto">` + this.#createHTMLFun(this.#activeModuleJson) +
`</div>
</div>`
}
//done after innerHTML as it needs to find the nodes. tbd: createHTMLFun adds to dom directly
if (this.#setDefaultValuesFun) {
this.#setDefaultValuesFun(this.#activeModuleJson)
}
} //set activeModuleJson(moduleJson)

/**
Expand Down Expand Up @@ -171,9 +174,11 @@ class MainNav {
* Update the UI
*/
//updateUI is made after all modules have been fetched, how to adapt to add one module?
updateUI(moduleJson, fun) {
updateUI(moduleJson, createHTMLFun, setDefaultValuesFun) {

this.#moduleFun = fun //sets the function which displays a module
//functions called when selecting a module
this.#createHTMLFun = createHTMLFun
this.#setDefaultValuesFun = setDefaultValuesFun

this.#updateMainMenu();
this.#updateSecondaryMenu();
Expand All @@ -195,5 +200,6 @@ class MainNav {
#activeModuleJson = ''

//stores the function to execute to display one module
#moduleFun = null;
#createHTMLFun = null;
#setDefaultValuesFun = null;
}
6 changes: 6 additions & 0 deletions data/newui/modules.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ label {
color: var(--text-color);
font-size: 8px; /*var(--font-size-s) not working for some reason */
}

.ndiv {
/* border: 2px solid black; */
margin-left: 20px;
/* border-radius: 12px; */
}

Loading

0 comments on commit fc15112

Please sign in to comment.