generated from JuliaPluto/static-export-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added buttons to change the intents state at the intent table page, they only get activated if the operation is possible - Restructured the whole communication between notebook and MINDFulPluto: A cell can now receive commands and send them to MINDFulPluto -> All HTML elements can now use `onchange` and `onclick` events and trigger Julia code to be run instead of having @Bind macros. Main site doesnt use @Bind macros anymore which opens many new possibilities with the new javascript -> julia communication. Notebook file is also waaay smaller now Minor changes: - autoload all js scripts in data/scripts - finally removed alternative gui button - moved a lot of js into js files
- Loading branch information
Showing
6 changed files
with
239 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function createIntent() { | ||
//find domain_selection_select and get value | ||
const domain_1 = document.querySelector("#domain_selection_1").value; | ||
const domain_2 = document.querySelector("#domain_selection_2").value; | ||
const node_1 = document.querySelector("#node_selection_1").value; | ||
const node_2 = document.querySelector("#node_selection_2").value; | ||
const topology = document.querySelector("#topology_select").value; | ||
|
||
sendIntentCommand(`create_intent ${domain_1} ${domain_2} ${node_1} ${node_2} ${topology}`) | ||
} | ||
|
||
function updateDomainList() { | ||
const topology = document.querySelector("#topology_select").value; | ||
|
||
sendIntentCommand(`update_domain_list ${topology}`) | ||
} | ||
|
||
function updateNodeList(node_number) { | ||
const domain = document.querySelector(`#domain_selection_${node_number}`).value; | ||
const topology = document.querySelector("#topology_select").value; | ||
|
||
sendIntentCommand(`update_node_list ${topology} ${domain} ${node_number}`) | ||
} | ||
|
||
function drawIntent() { | ||
const intent_index = document.querySelector("#intent_selection_select").selectedIndex; | ||
const plottingType = document.querySelector("#plot_selection_select").value; | ||
const position = document.querySelector("#wanted_pos_select").value; | ||
|
||
sendIntentCommand(`draw_intent ${intent_index} ${plottingType} ${position}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function sendIntentCommand(command) { | ||
const intentCommandTextField = document.getElementById('intentCommandTextField'); | ||
|
||
intentCommandTextField.value = command; | ||
intentCommandTextField.dispatchEvent(new CustomEvent("input")); | ||
|
||
console.log("Sent intent command: " + command); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
function updateIntentTable(intent_names, intent_configs, intent_toplogies, intent_states) { | ||
const buttonStates = { | ||
"uncompiled": { | ||
"remove": "", | ||
"compile": "", | ||
"uncompile": "disabled", | ||
"install": "disabled", | ||
"uninstall": "disabled" | ||
}, | ||
"compiled": { | ||
"remove": "disabled", | ||
"compile": "disabled", | ||
"uncompile": "", | ||
"install": "", | ||
"uninstall": "disabled" | ||
}, | ||
"installed": { | ||
"remove": "disabled", | ||
"compile": "disabled", | ||
"uncompile": "disabled", | ||
"install": "disabled", | ||
"uninstall": "" | ||
} | ||
} | ||
|
||
|
||
|
||
//find intent list | ||
let intent_list = document.querySelector("#intent_selection_select"); | ||
|
||
//find out which option was selected in intent_list | ||
let selected_value = intent_list.value; | ||
|
||
//clear intent list except first option | ||
while (intent_list.options.length > 1) { | ||
intent_list.remove(1); | ||
} | ||
|
||
//add intents to intent list | ||
intent_names.forEach((intent, i) => { | ||
let option = document.createElement("option"); | ||
option.value = intent; | ||
option.innerHTML = intent; | ||
//check if intent was selected | ||
if (selected_value != undefined) { | ||
if (selected_value == intent) { | ||
option.selected = true; | ||
} | ||
} | ||
intent_list.appendChild(option); | ||
}); | ||
console.log("updated intent list with selected intent: " + selected_value); | ||
|
||
//---------update intent-table--------- | ||
|
||
console.log(intent_states); | ||
let intent_table = document.querySelector(".table > tbody"); | ||
|
||
//clear all <tr> except first one | ||
while (intent_table.childElementCount > 0) { | ||
intent_table.removeChild(intent_table.lastChild); | ||
} | ||
|
||
//add new <tr> for each intent | ||
intent_names.forEach((intent_name, index) => { | ||
let new_row = document.createElement("tr"); | ||
new_row.innerHTML = ` | ||
<th scope="row">${index + 1}</th> | ||
<td>${intent_name}</td> | ||
<td>${intent_toplogies[index]}</td> | ||
<td>${intent_configs[index]}</td> | ||
<td>${intent_states[index]}</td> | ||
<td class="action-buttons"> | ||
<button class='btn btn-outline-light btn-sm ${buttonStates[intent_states[index]].remove}' onclick='sendIntentCommand("remove_intent ${index + 1}")'> | ||
Remove | ||
</button> | ||
<button class='btn btn-outline-light btn-sm ${buttonStates[intent_states[index]].compile}' onclick='sendIntentCommand("compile_intent ${index + 1}")'> | ||
Compile | ||
</button> | ||
<button class='btn btn-outline-light btn-sm ${buttonStates[intent_states[index]].uncompile}' onclick='sendIntentCommand("uncompile_intent ${index + 1}")'> | ||
Uncompile | ||
</button> | ||
<button class='btn btn-outline-light btn-sm ${buttonStates[intent_states[index]].install}' onclick='sendIntentCommand("install_intent ${index + 1}")'> | ||
Install | ||
</button> | ||
<button class='btn btn-outline-light btn-sm ${buttonStates[intent_states[index]].uninstall}' onclick='sendIntentCommand("uninstall_intent ${index + 1}")'> | ||
Uninstall | ||
</button> | ||
</td> | ||
`; | ||
intent_table.appendChild(new_row); | ||
}); | ||
|
||
|
||
} |
Oops, something went wrong.