Skip to content

Commit

Permalink
Huge changes:
Browse files Browse the repository at this point in the history
- 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
Niels1006 committed Feb 6, 2024
1 parent 10af708 commit eeebbc5
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 108 deletions.
4 changes: 2 additions & 2 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1059,11 +1059,11 @@ version = "0.1.0"

[[deps.MINDFulPluto]]
deps = ["GraphIO", "Graphs", "HypertextLiteral", "Logging", "MINDFul", "MINDFulMakie", "MetaGraphs", "NestedGraphs", "NestedGraphsIO", "Pluto", "PlutoUI", "PrecompileTools", "Revise", "Unitful", "WGLMakie"]
git-tree-sha1 = "99a688d4059278a86cad4b141c7542dcee282471"
git-tree-sha1 = "ff12bbdc01aded8322ea4b1a8ffa70555dd6f17e"
repo-rev = "main"
repo-url = "https://github.com/UniStuttgart-IKR/MINDFulPluto.jl"
uuid = "2169b6f5-785b-460d-ad6a-2192ac02d426"
version = "0.1.1"
version = "0.1.2"

[[deps.MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl"]
Expand Down
31 changes: 31 additions & 0 deletions data/scripts/IntentCreation.js
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}`)
}
91 changes: 79 additions & 12 deletions data/scripts/SwitchViews.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function change_view_display(target, visible) {
function changeViewDisplay(target, visible) {
const display = visible ? 'block' : 'none';
const display_flex = visible ? 'flex' : 'none';

if (visible === true) {
change_view_display('visualisation', false);
change_view_display('intenttable', false);
change_view_display('devmode', false);
//hide everything
changeViewDisplay('visualisation', false);
changeViewDisplay('intenttable', false);
changeViewDisplay('devmode', false);
}

switch (target) {
Expand All @@ -16,9 +17,13 @@ function change_view_display(target, visible) {
});

//hide plotting cells
Array.prototype.slice.call(document.querySelectorAll('.code_folded'), -3).forEach((card, i) => {
Array.prototype.slice.call(document.querySelectorAll('.code_folded'), -2).forEach((card, i) => {
card.style.display = display;
});

if (visible === true) {
setVisualisationModeCellStyle();
}
break;

case "intenttable":
Expand All @@ -30,20 +35,82 @@ function change_view_display(target, visible) {

case "devmode":
//hide last 2 cells (dev mode)
var cells = document.querySelectorAll('.show_input ');
let cells = document.querySelectorAll('.show_input ');
cells = Array.prototype.slice.call(cells, -2);
cells.forEach((cell, i) => {
cell.style.display = display;
});
change_devmode_cell_style();

if (visible === true) {
setDevmodeCellStyle();
}

break;

default:
break;
}
}

function change_devmode_cell_style() {
function setVisualisationModeCellStyle() {
cells = document.querySelectorAll('.code_folded ');
cells = Array.prototype.slice.call(cells, -2);

cells.forEach((cell, i) => {
cell.querySelector('.cm-editor').style.background = 'transparent';

cell.style.display = 'inline-block';
cell.style.verticalAlign = 'top';
cell.style.width = '30vw';
cell.style.maxWidth = '30vw';
cell.style.height = '50vh';
cell.style.margin = '2.5%';
cell.style.textAlign = 'start';

cell.style.background = 'rgba(217, 147, 232, 0.1)';
cell.style.borderRadius = '16px';
cell.style.boxShadow = '0 4px 30px rgba(0, 0, 0, 0.1)';

cell.style.padding = '20px 20px 20px 20px';

//find element pluto-trafficlight
cell.querySelector('pluto-trafficlight').style.display = 'none';

let log_container = cell.querySelector('pluto-logs-container');
if (log_container != null) {
log_container.style.display = 'transparent';
}

//remove pluto-log-icon
let log_icon = cell.querySelector('pluto-log-icon');
if (log_icon != null) {
log_icon.style.display = 'none';
}

//find class=Stdout and change style
let stdout = cell.querySelector('pluto-log-dot')
if (stdout != null) {
stdout.style.background = 'transparent';
stdout.style.border = '2px solid #FFFFFF';
}

let rich_output = cell.querySelector('pluto-output');
if (rich_output != null) {
rich_output.style.borderRadius = '16px';
rich_output.style.background = 'black';
}


});

let p_nb = document.getElementsByTagName('pluto-notebook')[0];
p_nb.style.marginTop = '31vh';
p_nb.style.marginLeft = '20vw';
p_nb.style.marginRight = '-25vw';
p_nb.style.backgroundColor = 'transparent';
}

function setDevmodeCellStyle() {
//get last 3 cells
let cells = document.querySelectorAll('.show_input ');

Expand All @@ -69,19 +136,19 @@ function change_devmode_cell_style() {
//find element pluto-trafficlight
cell.querySelector('pluto-trafficlight').style.display = 'none';

var log_container = cell.querySelector('pluto-logs-container');
let log_container = cell.querySelector('pluto-logs-container');
if (log_container != null) {
log_container.style.display = 'transparent';
}

//remove pluto-log-icon
var log_icon = cell.querySelector('pluto-log-icon');
let log_icon = cell.querySelector('pluto-log-icon');
if (log_icon != null) {
log_icon.style.display = 'none';
}

//find class=Stdout and change style
var stdout = cell.querySelector('pluto-log-dot')
let stdout = cell.querySelector('pluto-log-dot')
if (stdout != null) {
stdout.style.background = 'transparent';
stdout.style.border = '2px solid #FFFFFF';
Expand All @@ -92,7 +159,7 @@ function change_devmode_cell_style() {
});

//change pluto-notebook style
var p_nb = document.getElementsByTagName('pluto-notebook')[0];
let p_nb = document.getElementsByTagName('pluto-notebook')[0];
p_nb.style.marginTop = '1.5vh';
p_nb.style.marginLeft = '20vw';
p_nb.style.marginRight = '-25vw';
Expand Down
8 changes: 8 additions & 0 deletions data/scripts/UpdateCommandCell.js
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);
}
95 changes: 95 additions & 0 deletions data/scripts/UpdateIntentTable.js
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);
});


}
Loading

0 comments on commit eeebbc5

Please sign in to comment.