add enable/disable for export options

This commit is contained in:
Stewart Allen 2020-06-10 20:48:59 -04:00
commit cbf3e2ff1a
6 changed files with 92 additions and 52 deletions

View file

@ -544,7 +544,10 @@
freeLayout: true,
autoLayout: true,
alignTop: true,
units: "mm"
units: "mm",
exportOcto: true,
exportGhost: false,
exportLocal: false
},
// for passing temporary slice hints (topo currently)
synth: {},

View file

@ -427,52 +427,75 @@
$('output-time').value = [pad(hours),pad(mins),pad(secs)].join(':');
}
API.ajax("/kiri/output-gcode.html", function(html) {
fetch("/kiri/output-gcode.html").then(r => r.text()).then(html => {
UI.print.innerHTML = html;
let set = API.conf.get();
let fdm = MODE === MODES.FDM;
let octo = set.controller.exportOcto && MODE !== MODES.CAM;
let ghost = set.controller.exportGhost;
let local = set.controller.exportLocal;
$('print-download').onclick = download;
$('print-octoprint').onclick = sendto_octoprint;
$('print-gridhost').onclick = sendto_gridhost;
$('print-gridlocal').onclick = sendto_gridlocal;
$('admin-gridlocal').onclick = admin_gridlocal;
$('print-filament-head').style.display = MODE === MODES.FDM ? '' : 'none';
$('print-filament-info').style.display = MODE === MODES.FDM ? '' : 'none';
$('print-filament-head').style.display = fdm ? '' : 'none';
$('print-filament-info').style.display = fdm ? '' : 'none';
$('print-filename').value = filename;
$('print-filesize').value = UTIL.comma(currentPrint.bytes);
$('print-filament').value = Math.round(currentPrint.distance);
$('grid-host').onkeyup = gridhost_probe;
$('grid-apik').onkeyup = gridhost_probe;
calcTime();
if (MODE === MODES.FDM) {
if (fdm) {
calcWeight();
}
octo_host = $('octo-host');
octo_apik = $('octo-apik');
if (MODE === MODES.CAM) {
$('send-to-octohead').style.display = 'none';
$('send-to-octoprint').style.display = 'none';
} else {
$('send-to-octohead').style.display = '';
$('send-to-octoprint').style.display = '';
}
// hide octoprint when hard-coded in the url
if (API.const.OCTO) {
$('ophost').style.display = 'none';
$('opapik').style.display = 'none';
$('ophint').style.display = 'none';
$('send-to-gridhost').style.display = 'none';
}
octo_host.value = SDB['octo-host'] || '';
octo_apik.value = SDB['octo-apik'] || '';
grid_host = $('grid-host');
grid_apik = $('grid-apik');
grid_target = $('grid-target');
grid_target.onchange = function(ev) {
SDB['grid-target'] = grid_targets[grid_target.selectedIndex];
};
grid_host.value = SDB['grid-host'] || '';
grid_apik.value = SDB['grid-apik'] || '';
gridhost_probe();
gridlocal_probe();
// octoprint setup
$('send-to-octohead').style.display = octo ? '' : 'none';
$('send-to-octoprint').style.display = octo ? '' : 'none';
if (octo) try {
$('print-octoprint').onclick = sendto_octoprint;
octo_host = $('octo-host');
octo_apik = $('octo-apik');
if (MODE === MODES.CAM) {
$('send-to-octohead').style.display = 'none';
$('send-to-octoprint').style.display = 'none';
} else {
$('send-to-octohead').style.display = '';
$('send-to-octoprint').style.display = '';
}
// hide octoprint when hard-coded in the url
if (API.const.OCTO) {
$('ophost').style.display = 'none';
$('opapik').style.display = 'none';
$('ophint').style.display = 'none';
$('send-to-gridhost').style.display = 'none';
}
octo_host.value = SDB['octo-host'] || '';
octo_apik.value = SDB['octo-apik'] || '';
} catch (e) { console.log(e) }
// grid:host setup
$('send-to-hosthead').style.display = ghost ? '' : 'none';
$('send-to-gridhost').style.display = ghost ? '' : 'none';
if (ghost) try {
$('print-gridhost').onclick = sendto_gridhost;
$('grid-host').onkeyup = gridhost_probe;
$('grid-apik').onkeyup = gridhost_probe;
grid_host = $('grid-host');
grid_apik = $('grid-apik');
grid_target = $('grid-target');
grid_target.onchange = function(ev) {
SDB['grid-target'] = grid_targets[grid_target.selectedIndex];
};
grid_host.value = SDB['grid-host'] || '';
grid_apik.value = SDB['grid-apik'] || '';
gridhost_probe();
} catch (e) { console.log(e) }
// grid:local setup
if (local) try {
gridlocal_probe();
$('print-gridlocal').onclick = sendto_gridlocal;
$('admin-gridlocal').onclick = admin_gridlocal;
} catch (e) { console.log(e) }
// show dialog
API.modal.show('print');
});
}

View file

@ -90,6 +90,9 @@
control.reverseZoom = UI.reverseZoom.checked;
control.thinRender = UI.thinRender.checked;
control.dark = UI.dark.checked;
control.exportOcto = UI.exportOcto.checked;
control.exportGhost = UI.exportGhost.checked;
control.exportLocal = UI.exportLocal.checked;
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
platform.layout();
platform.update_stock();
@ -1234,17 +1237,22 @@
gcodePre: UC.newText(LANG.dv_head_s, {title:LANG.dv_head_l, modes:GCODE, size:14, height:3, area:gcode}),
gcodePost: UC.newText(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:GCODE, size:14, height:3, area:gcode}),
layout: UC.newGroup(LANG.op_menu, $('mod-prefs'), {inline: true}),
expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}),
dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}),
showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l, modes:GCODE}),
alignTop: UC.newBoolean(LANG.op_alig_s, booleanSave, {title:LANG.op_alig_l, modes:CAM}),
autoLayout: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}),
freeLayout: UC.newBoolean(LANG.op_free_s, booleanSave, {title:LANG.op_free_l, modes:ALL}),
reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l, modes:ALL}),
thinRender: UC.newBoolean(LANG.op_thin_s, booleanSave, {title:LANG.op_thin_l, modes:ALL}),
units: UC.newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, modes:CAM}, "units"),
prefadd: UC.checkpoint(),
layout: UC.newGroup(LANG.op_menu, $('prefs-gen'), {inline: true}),
expert: UC.newBoolean(LANG.op_xprt_s, booleanSave, {title:LANG.op_xprt_l}),
dark: UC.newBoolean(LANG.op_dark_s, booleanSave, {title:LANG.op_dark_l}),
showOrigin: UC.newBoolean(LANG.op_show_s, booleanSave, {title:LANG.op_show_l, modes:GCODE}),
alignTop: UC.newBoolean(LANG.op_alig_s, booleanSave, {title:LANG.op_alig_l, modes:CAM}),
autoLayout: UC.newBoolean(LANG.op_auto_s, booleanSave, {title:LANG.op_auto_l}),
freeLayout: UC.newBoolean(LANG.op_free_s, booleanSave, {title:LANG.op_free_l, modes:ALL}),
reverseZoom: UC.newBoolean(LANG.op_invr_s, booleanSave, {title:LANG.op_invr_l, modes:ALL}),
thinRender: UC.newBoolean(LANG.op_thin_s, booleanSave, {title:LANG.op_thin_l, modes:ALL}),
units: UC.newSelect(LANG.op_unit_s, {title: LANG.op_unit_l, modes:CAM}, "units"),
prefadd: UC.checkpoint(),
export: UC.newGroup(LANG.xp_menu, $('prefs-out'), {inline: true}),
exportOcto: UC.newBoolean(`OctoPrint`, booleanSave),
exportGhost: UC.newBoolean(`Grid:Host`, booleanSave),
exportLocal: UC.newBoolean(`Grid:Local`, booleanSave),
process: UC.newGroup(LANG.sl_menu, $('settings'), {modes:FDM_LASER}),
sliceHeight: UC.newInput(LANG.sl_lahi_s, {title:LANG.sl_lahi_l, convert:UC.toFloat, modes:FDM}),

View file

@ -288,7 +288,11 @@
</div>
</div>
</div>
<div id="mod-prefs" class="mdialog col"></div>
<div id="mod-prefs" class="mdialog row">
<div id="prefs-gen" class="col"></div>
<div class="t-pad2"></div>
<div id="prefs-out" class="col"></div>
</div>
<div id="mod-local" class="mdialog col"></div>
<div id="mod-print" class="mdialog col"></div>
<!-- hidden file input loader -->

View file

@ -134,6 +134,8 @@ kiri.lang['en-us'] = {
op_unit_s: "units",
op_unit_l: "workspace units affects\nspeeds and distances",
xp_menu: "export",
// LAYERS pop-menu
la_menu: "layers",
la_olin: "outline",

View file

@ -29,7 +29,7 @@
<div id="ophint"><label class="hint"><a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS support</a> must be enabled in API settings</label></div>
</div>
<div class="header"><label>grid:host</label></div>
<div id="send-to-hosthead" class="header"><label>grid:host</label></div>
<div id="send-to-gridhost" class="col box">
<div class="grow row">
<div class="col grow">