add access to grid.local device list from inside kiri
This commit is contained in:
parent
545c8a86cd
commit
f9e147eb9f
6 changed files with 107 additions and 41 deletions
84
js/kiri.js
84
js/kiri.js
|
|
@ -2092,17 +2092,13 @@ self.kiri.license = exports.LICENSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function modalShowing() {
|
function modalShowing() {
|
||||||
var showing = false;
|
var showing = $('modal').style.display !== 'none';
|
||||||
["modal","catalog","devices","tools"].forEach(function(dialog) {
|
|
||||||
var state = UI[dialog].style.display
|
|
||||||
showing = showing || state !== 'none';
|
|
||||||
});
|
|
||||||
return showing || UC.isPopped();
|
return showing || UC.isPopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showModal(which) {
|
function showModal(which) {
|
||||||
UI.modal.style.display = 'block';
|
UI.modal.style.display = 'block';
|
||||||
["print","help"].forEach(function(modal) {
|
["print","help","local"].forEach(function(modal) {
|
||||||
UI[modal].style.display = (modal === which ? 'block' : 'none');
|
UI[modal].style.display = (modal === which ? 'block' : 'none');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2267,6 +2263,37 @@ self.kiri.license = exports.LICENSE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showLocal() {
|
||||||
|
$('local-close').onclick = hideModal;
|
||||||
|
showModal('local');
|
||||||
|
fetch("/api/grid_local")
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(j => {
|
||||||
|
let bind = [];
|
||||||
|
let html = ['<table>'];
|
||||||
|
html.push(`<thead><tr><th>device</th><th>type</th><th>status</th><th></th></tr></thead>`);
|
||||||
|
html.push(`<tbody>`);
|
||||||
|
for (let k in j) {
|
||||||
|
let r = j[k].stat;
|
||||||
|
bind.push({uuid: r.device.uuid, host: r.device.addr[0], post: r.device.port});
|
||||||
|
html.push(`<tr>`);
|
||||||
|
html.push(`<td>${r.device.name}</td>`);
|
||||||
|
html.push(`<td>${r.device.mode}</td>`);
|
||||||
|
html.push(`<td>${r.state}</td>`);
|
||||||
|
html.push(`<td><button id="${r.device.uuid}">admin</button></td>`);
|
||||||
|
html.push(`</tr>`);
|
||||||
|
}
|
||||||
|
html.push(`</tbody>`);
|
||||||
|
html.push(`</table>`);
|
||||||
|
$('local-dev').innerHTML = html.join('');
|
||||||
|
bind.forEach(rec => {
|
||||||
|
$(rec.uuid).onclick = () => {
|
||||||
|
window.open(`http://${rec.host}:${rec.port||4080}/`);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function takeFocus(el) {
|
function takeFocus(el) {
|
||||||
DOC.activeElement.blur();
|
DOC.activeElement.blur();
|
||||||
el = [ el || DOC.body, UI.ctrlLeft, UI.container, UI.assets, UI.control, UI.modeFDM, UI.reverseZoom, UI.viewModelOpacity, DOC.body ];
|
el = [ el || DOC.body, UI.ctrlLeft, UI.container, UI.assets, UI.control, UI.modeFDM, UI.reverseZoom, UI.viewModelOpacity, DOC.body ];
|
||||||
|
|
@ -2412,6 +2439,7 @@ self.kiri.license = exports.LICENSE;
|
||||||
control: control,
|
control: control,
|
||||||
modal: $('modal'),
|
modal: $('modal'),
|
||||||
print: $('print'),
|
print: $('print'),
|
||||||
|
local: $('local'),
|
||||||
help: $('help'),
|
help: $('help'),
|
||||||
|
|
||||||
alert: {
|
alert: {
|
||||||
|
|
@ -2514,7 +2542,10 @@ self.kiri.license = exports.LICENSE;
|
||||||
UC.newButton("Devices", showDevices, {modes:FDM_CAM})
|
UC.newButton("Devices", showDevices, {modes:FDM_CAM})
|
||||||
],[
|
],[
|
||||||
UI.setupTools =
|
UI.setupTools =
|
||||||
UC.newButton('Tools', showTools, {modes:CAM}),
|
UC.newButton("Tools", showTools, {modes:CAM})
|
||||||
|
],[
|
||||||
|
UI.localButton =
|
||||||
|
UC.newButton("Local", showLocal, {modes:FDM_CAM})
|
||||||
],[
|
],[
|
||||||
UI.helpButton =
|
UI.helpButton =
|
||||||
UC.newButton("Help", showHelp)
|
UC.newButton("Help", showHelp)
|
||||||
|
|
@ -2748,6 +2779,24 @@ self.kiri.license = exports.LICENSE;
|
||||||
showSlices();
|
showSlices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function inputHasFocus() {
|
||||||
|
var active = DOC.activeElement;
|
||||||
|
return active && (active.nodeName === "INPUT" || active.nodeName === "TEXTAREA");
|
||||||
|
}
|
||||||
|
|
||||||
|
function textAreaHasFocus() {
|
||||||
|
var active = DOC.activeElement;
|
||||||
|
return active && active.nodeName === "TEXTAREA";
|
||||||
|
}
|
||||||
|
|
||||||
|
function inputSize() {
|
||||||
|
return parseInt(DOC.activeElement.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cca(c) {
|
||||||
|
return c.charCodeAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
function keyUpHandler(evt) {
|
function keyUpHandler(evt) {
|
||||||
switch (evt.keyCode) {
|
switch (evt.keyCode) {
|
||||||
// escape
|
// escape
|
||||||
|
|
@ -2767,20 +2816,6 @@ self.kiri.license = exports.LICENSE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function inputHasFocus() {
|
|
||||||
var active = DOC.activeElement;
|
|
||||||
return active && (active.nodeName === "INPUT" || active.nodeName === "TEXTAREA");
|
|
||||||
}
|
|
||||||
|
|
||||||
function textAreaHasFocus() {
|
|
||||||
var active = DOC.activeElement;
|
|
||||||
return active && active.nodeName === "TEXTAREA";
|
|
||||||
}
|
|
||||||
|
|
||||||
function inputSize() {
|
|
||||||
return parseInt(DOC.activeElement.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyDownHandler(evt) {
|
function keyDownHandler(evt) {
|
||||||
if (modalShowing()) return false;
|
if (modalShowing()) return false;
|
||||||
var move = evt.altKey ? 5 : 0,
|
var move = evt.altKey ? 5 : 0,
|
||||||
|
|
@ -2852,10 +2887,6 @@ self.kiri.license = exports.LICENSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cca(c) {
|
|
||||||
return c.charCodeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyHandler(evt) {
|
function keyHandler(evt) {
|
||||||
var handled = true,
|
var handled = true,
|
||||||
style, sel, i, m, bb,
|
style, sel, i, m, bb,
|
||||||
|
|
@ -2949,6 +2980,9 @@ self.kiri.license = exports.LICENSE;
|
||||||
case cca('o'): // tools
|
case cca('o'): // tools
|
||||||
showTools();
|
showTools();
|
||||||
break;
|
break;
|
||||||
|
case cca('c'): // local devices
|
||||||
|
showLocal();
|
||||||
|
break;
|
||||||
case cca('v'): // toggle single slice view mode
|
case cca('v'): // toggle single slice view mode
|
||||||
UI.layerRange.checked = !UI.layerRange.checked;
|
UI.layerRange.checked = !UI.layerRange.checked;
|
||||||
showSlices();
|
showSlices();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<button id="help-close">X</button>
|
<button id="help-close" class="modal-x">X</button>
|
||||||
|
|
||||||
<center><b>Quick Start</b></center>
|
<center><b>Quick Start</b></center>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@
|
||||||
<div id="help"></div>
|
<div id="help"></div>
|
||||||
<!-- changeable print dialog -->
|
<!-- changeable print dialog -->
|
||||||
<div id="print"></div>
|
<div id="print"></div>
|
||||||
|
<!-- local devices dialog -->
|
||||||
|
<div id="local" class="dialog">
|
||||||
|
<button id="local-close" class="modal-x">X</button>
|
||||||
|
<center><b><u>Grid.Local Devices</u></b></center>
|
||||||
|
<br>
|
||||||
|
<div id="local-dev" class="flow-col"></div>
|
||||||
|
</div>
|
||||||
<!-- hidden file input loader -->
|
<!-- hidden file input loader -->
|
||||||
<input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/>
|
<input id="load-file" type="file" name="loadme" style="display:none" accept=".stl,.gcode,.nc"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<button id="print-close">X</button>
|
<button id="print-close" class="modal-x">X</button>
|
||||||
|
|
||||||
<span id="print-title">output options</span>
|
<span id="print-title">output options</span>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<button id="print-close">X</button>
|
<button id="print-close" class="modal-x">X</button>
|
||||||
|
|
||||||
<span>output options</span>
|
<span>output options</span>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,43 @@ select {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-x {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 200;
|
||||||
|
right: 3px;
|
||||||
|
top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** LOCAL DIALOG */
|
||||||
|
|
||||||
|
#local {
|
||||||
|
position: fixed;
|
||||||
|
-webkit-transform: translate(-50%, 0);
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
text-align: center;
|
||||||
|
top: 50px;
|
||||||
|
left: 50%;
|
||||||
|
color: black;
|
||||||
|
border: 10px solid #ddd;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: rgba(255,255,255,0.9);
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
#local-dev table {
|
||||||
|
border-color: separate;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
#local-dev td,th {
|
||||||
|
padding: 5px !important;
|
||||||
|
}
|
||||||
|
#local-dev thead th {
|
||||||
|
width: 100%;
|
||||||
|
border-bottom: 1px solid #888;
|
||||||
|
}
|
||||||
|
#local-dev tbody tr:hover {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
/** PRINT DIALOG */
|
/** PRINT DIALOG */
|
||||||
|
|
||||||
#print {
|
#print {
|
||||||
|
|
@ -138,12 +175,6 @@ select {
|
||||||
#print button {
|
#print button {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
#print-close {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 200;
|
|
||||||
right: 3px;
|
|
||||||
top: 3px;
|
|
||||||
}
|
|
||||||
#print > div {
|
#print > div {
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
|
@ -254,12 +285,6 @@ select {
|
||||||
background-color: rgba(255,255,255,0.9);
|
background-color: rgba(255,255,255,0.9);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
#help-close {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 200;
|
|
||||||
right: 3px;
|
|
||||||
top: 3px;
|
|
||||||
}
|
|
||||||
#help a {
|
#help a {
|
||||||
color: #68d;
|
color: #68d;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue