add send to moonraker option
This commit is contained in:
parent
9f74b8439a
commit
d51894fb75
4 changed files with 79 additions and 36 deletions
|
|
@ -192,6 +192,7 @@ function bindField(field, varname) {
|
|||
console.log('save', field, 'to', varname);
|
||||
localSet(varname, $(field).value.trim());
|
||||
};
|
||||
$(field).onchange = $(field).onblur;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -219,12 +220,7 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
codeproc = settings.device.gcodeProc,
|
||||
octo_host,
|
||||
octo_apik,
|
||||
grid_host,
|
||||
grid_apik,
|
||||
grid_target,
|
||||
grid_targets = {},
|
||||
grid_local,
|
||||
grid_uuid;
|
||||
octo_type;
|
||||
|
||||
// join gcode array into a string
|
||||
gcode = gcode.join('\r\n') + '\r\n';
|
||||
|
|
@ -240,13 +236,18 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
{type:"application/octet-stream"});
|
||||
}
|
||||
|
||||
function sendto_octoprint() {
|
||||
if (!(octo_host && octo_apik)) return;
|
||||
function printToHost() {
|
||||
sendToHost(true);
|
||||
}
|
||||
|
||||
function sendToHost(start) {
|
||||
if (!(octo_host && octo_apik && octo_type)) return;
|
||||
|
||||
let form = new FormData(),
|
||||
ajax = new XMLHttpRequest(),
|
||||
host = octo_host.value.toLowerCase(),
|
||||
apik = octo_apik.value;
|
||||
apik = octo_apik.value,
|
||||
type = octo_type.value;
|
||||
|
||||
if (host.indexOf("http") !== 0) {
|
||||
api.show.alert("host missing protocol (http:// or https://)");
|
||||
|
|
@ -259,26 +260,37 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
|
||||
localSet('octo-host', host.trim());
|
||||
localSet('octo-apik', apik.trim());
|
||||
localSet('octo-type', type.trim());
|
||||
|
||||
filename = $('print-filename').value;
|
||||
form.append("file", getBlob(), filename+"."+fileext);
|
||||
// moonraker upload params
|
||||
// form.append("root", "gcodes"); // optional but recommended
|
||||
// form.append("path", ""); // optional subfolder
|
||||
if (start) form.append("print", "true"); // <-- auto-start
|
||||
ajax.onreadystatechange = function() {
|
||||
console.log({ ajax_readyState: ajax.readyState });
|
||||
if (ajax.readyState === 4) {
|
||||
let status = ajax.status;
|
||||
api.stats.add(`ua_${api.mode.get_lower()}_print_octo_${status}`);
|
||||
api.stats.add(`ua_${api.mode.get_lower()}_print_send_${status}`);
|
||||
if (status >= 200 && status < 300) {
|
||||
api.modal.hide();
|
||||
} else {
|
||||
api.show.alert("octoprint error\nstatus: "+status+"\nmessage: "+ajax.responseText);
|
||||
api.show.alert("send error\nstatus: "+status+"\nmessage: "+ajax.responseText);
|
||||
}
|
||||
api.show.progress(0);
|
||||
}
|
||||
api.show.progress(0);
|
||||
};
|
||||
ajax.upload.addEventListener('progress', function(evt) {
|
||||
ajax.upload.addEventListener('progress', (evt) => {
|
||||
console.log({ ajax_progress: evt });
|
||||
api.show.progress(evt.loaded/evt.total, "sending");
|
||||
});
|
||||
ajax.open("POST", host+"/api/files/local");
|
||||
if (type === 'moonraker') {
|
||||
ajax.open("POST", host + "/server/files/upload");
|
||||
} else {
|
||||
ajax.open("POST", host + "/api/files/local");
|
||||
}
|
||||
if (apik) {
|
||||
ajax.setRequestHeader("X-Api-Key", apik);
|
||||
}
|
||||
|
|
@ -349,6 +361,7 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
// persist fields when changed
|
||||
bindField('octo-host', 'octo-host');
|
||||
bindField('octo-apik', 'octo-apik');
|
||||
bindField('octo-type', 'octo-type');
|
||||
|
||||
// in cam mode, show zip file option
|
||||
let downloadZip = $('print-zip');
|
||||
|
|
@ -550,21 +563,23 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
})
|
||||
};
|
||||
|
||||
// octoprint setup
|
||||
$('send-to-octohead').style.display = octo ? '' : 'none';
|
||||
$('send-to-octoprint').style.display = octo ? '' : 'none';
|
||||
// remote host (klipper fluidd / octoprint)
|
||||
$('send-remote-head').style.display = octo ? '' : 'none';
|
||||
$('send-remote-print').style.display = octo ? '' : 'none';
|
||||
if (octo) try {
|
||||
$('print-octoprint').onclick = sendto_octoprint;
|
||||
$('send-remote').onclick = sendToHost;
|
||||
$('print-remote').onclick = printToHost;
|
||||
octo_host = $('octo-host');
|
||||
octo_apik = $('octo-apik');
|
||||
octo_type = $('octo-type');
|
||||
if (MODE === MODES.CAM) {
|
||||
$('send-to-octohead').style.display = 'none';
|
||||
$('send-to-octoprint').style.display = 'none';
|
||||
$('send-remote-head').style.display = 'none';
|
||||
$('send-remote-print').style.display = 'none';
|
||||
} else {
|
||||
$('send-to-octohead').style.display = '';
|
||||
$('send-to-octoprint').style.display = '';
|
||||
$('send-remote-head').style.display = '';
|
||||
$('send-remote-print').style.display = '';
|
||||
}
|
||||
// hide octoprint when hard-coded in the url
|
||||
// hide remote host option when hard-coded in the url
|
||||
if (api.const.OCTO) {
|
||||
$('ophost').style.display = 'none';
|
||||
$('opapik').style.display = 'none';
|
||||
|
|
@ -572,6 +587,7 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
}
|
||||
octo_host.value = localGet('octo-host') || '';
|
||||
octo_apik.value = localGet('octo-apik') || '';
|
||||
octo_type.value = localGet('octo-type') || '';
|
||||
} catch (e) { console.log(e) }
|
||||
|
||||
// preview of the generated GCODE (first 64k max)
|
||||
|
|
|
|||
|
|
@ -308,9 +308,9 @@ export function init_input() {
|
|||
spaceRandoX: newBoolean(LANG.op_spcx_s, preferences.booleanSave, {title:LANG.op_spcx_l, show:isBelt}),
|
||||
spaceLayout: newInput(LANG.op_spcr_s, {title:LANG.op_spcr_l, convert:toFloat, size:3, units}),
|
||||
_____: newGroup(LANG.xp_menu, $('prefs-xpo'), {inline: true}),
|
||||
exportOcto: newBoolean(`OctoPrint`, preferences.booleanSave, {title:LANG.op_exop_l}),
|
||||
exportThumb: newBoolean(`Thumbnail`, preferences.booleanSave, {modes:FDM}),
|
||||
exportPreview: newBoolean(`Code Preview`, preferences.booleanSave),
|
||||
exportPreview: newBoolean(LANG.op_excp_s, preferences.booleanSave, {title:LANG.op_excp_l}),
|
||||
exportOcto: newBoolean(LANG.op_exop_s, preferences.booleanSave, {title:LANG.op_exop_l}),
|
||||
exportThumb: newBoolean(LANG.op_exth_s, preferences.booleanSave, {title:LANG.op_exth_l, modes:FDM}),
|
||||
_____: newGroup(LANG.pt_menu, $('prefs-prt'), {inline}),
|
||||
detail: newSelect(LANG.pt_qual_s, {title: LANG.pt_qual_l, action: preferences.detailSave}, "detail"),
|
||||
healMesh: newBoolean(LANG.pt_heal_s, preferences.booleanSave, {title: LANG.pt_heal_l}),
|
||||
|
|
|
|||
|
|
@ -678,19 +678,39 @@
|
|||
<label class="grow0 pad3">spool</label>
|
||||
<select id="print-bambu-spool"></select>
|
||||
<button id="print-bambu-1" class="grow" disabled>send</button>
|
||||
<button id="print-bambu-2" class="grow" disabled>send + print</button>
|
||||
<button id="print-bambu-2" class="grow" disabled>print</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="send-to-octohead" class="header"><label>octoprint</label></div>
|
||||
<div id="send-to-octoprint" class="f-col box">
|
||||
<div id="send-remote-head" class="header"><label>send to print</label></div>
|
||||
<div id="send-remote-print" class="f-col box">
|
||||
<div class="grow f-row">
|
||||
<div class="f-col grow">
|
||||
<div id="ophost"><label lk="ex_host">host</label><input id="octo-host" size="20" placeholder="http(s)://host:port" /></div>
|
||||
<div id="opapik"><label lk="ex_akey">key</label><input id="octo-apik" size="20" /></div>
|
||||
<div id="ophost">
|
||||
<label lk="ex_host">host</label>
|
||||
<input id="octo-host" size="20" placeholder="http(s)://host:port" />
|
||||
</div>
|
||||
<div id="opapik">
|
||||
<label lk="ex_akey">key</label>
|
||||
<input id="octo-apik" size="20" />
|
||||
</div>
|
||||
<div id="optype">
|
||||
<label lk="ex_type">type</label>
|
||||
<select id="octo-type">
|
||||
<option selected>moonraker</option>
|
||||
<option>octoprint</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button id="print-octoprint">send</button>
|
||||
<button id="send-remote">send</button>
|
||||
<button id="print-remote">print</button>
|
||||
</div>
|
||||
<div id="oph1nt">
|
||||
<label class="hint">
|
||||
check printer
|
||||
<a href="http://docs.octoprint.org/en/master/api/general.html?highlight=cors#cross-origin-requests" target="_help">CORS</a>
|
||||
settings
|
||||
</label>
|
||||
</div>
|
||||
<div id="oph1nt"><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 id="export-support" class="f-col">
|
||||
<a id="export-support-a" target="support">this project needs your support!</a>
|
||||
|
|
@ -757,3 +777,7 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<div id="opapik">
|
||||
<label lk="ex_akey">key</label>
|
||||
<input id="octo-apik" size="20" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -324,9 +324,12 @@ self.lang['en-us'] = {
|
|||
op_anim_l: ["animation mesh density","higher is more dense","takes more memory","and is slower"],
|
||||
op_mani_s: "manifold",
|
||||
op_mani_l: ["in stock indexed mode","use boolean visualiation","this is very expensive","and likely very slow"],
|
||||
op_exgl_l: ["show Grid:Local devices in export dialog","includes Grid:Bots and OctoPrint plugins"],
|
||||
op_exgh_l: ["legacy Grid:Host local network support"],
|
||||
op_exop_l: ["legacy OctoPrint local network support","Grid:Space OctoPrint plugin recommended"],
|
||||
op_exop_s: "remote host",
|
||||
op_exop_l: ["enable sending files to remote hosts","moonraker = klipper","octoprint"],
|
||||
op_excp_s: "code preview",
|
||||
op_excp_l: ["show start of gcode","in export dialog"],
|
||||
op_exth_s: "thumbnail",
|
||||
op_exth_l: ["embed print thumbnail in gcode"],
|
||||
|
||||
lo_menu: "layout",
|
||||
|
||||
|
|
@ -1014,7 +1017,7 @@ self.lang['en-us'] = {
|
|||
ex_gcpv: "gcode preview",
|
||||
ex_dwnl: "download",
|
||||
ex_bamb: "send to bambu",
|
||||
ex_octo: "octoprint",
|
||||
ex_octo: "remote host",
|
||||
ex_host: "host",
|
||||
ex_akey: "key",
|
||||
ex_rsnm: "resin used ML",
|
||||
|
|
|
|||
Loading…
Reference in a new issue