mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +01:00
First version of new PrinterPanel.
This commit is contained in:
parent
d92a2bcb3c
commit
965119de33
@ -18,6 +18,7 @@ module.exports = function(grunt) {
|
|||||||
src: [
|
src: [
|
||||||
'js_src/SettingsWindow.js',
|
'js_src/SettingsWindow.js',
|
||||||
'js_src/UpdatePanel.js',
|
'js_src/UpdatePanel.js',
|
||||||
|
'js_src/PrinterPanel.js',
|
||||||
'js_src/Help.js',
|
'js_src/Help.js',
|
||||||
'js_src/d3dServerInterfacing.js',
|
'js_src/d3dServerInterfacing.js',
|
||||||
'js_src/verticalShapes.js',
|
'js_src/verticalShapes.js',
|
||||||
|
73
js_src/PrinterPanel.js
Normal file
73
js_src/PrinterPanel.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
function PrinterPanel() {
|
||||||
|
this.wifiboxURL;
|
||||||
|
this.element;
|
||||||
|
|
||||||
|
this.retryDelay = 1000;
|
||||||
|
this.retryDelayer; // setTimout instance
|
||||||
|
//this.timeoutTime = 3000;
|
||||||
|
|
||||||
|
this.printerType;
|
||||||
|
this.printerSettingsNames;
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.init = function(wifiboxURL,element) {
|
||||||
|
self.wifiboxURL = wifiboxURL;
|
||||||
|
self.element = element;
|
||||||
|
|
||||||
|
self.printerSelector = element.find("#printerType");
|
||||||
|
self.printerSelector.change(self.printerSelectorChanged);
|
||||||
|
|
||||||
|
var formElements = element.find("[name]");
|
||||||
|
self.printerSettingsNames = [];
|
||||||
|
formElements.each( function(index,element) {
|
||||||
|
self.printerSettingsNames.push(element.name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.printerSelectorChanged = function(e) {
|
||||||
|
console.log("PrinterPanel:printerSelectorChanged");
|
||||||
|
console.log("self: ", self);
|
||||||
|
self.printerType = self.printerSelector.find("option:selected").val();
|
||||||
|
self.savePrinterType(self.loadPrinterSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.savePrinterType = function(complete) {
|
||||||
|
console.log("PrinterPanel:savePrinterType");
|
||||||
|
var postData = {};
|
||||||
|
postData[self.printerSelector.attr("name")] = self.printerType;
|
||||||
|
console.log("postData: ",postData);
|
||||||
|
$.ajax({
|
||||||
|
url: self.wifiboxURL + "/config/",
|
||||||
|
type: "POST",
|
||||||
|
dataType: 'json',
|
||||||
|
data: postData,
|
||||||
|
success: function(response){
|
||||||
|
console.log("PrinterPanel:savePrinterType response: ",response);
|
||||||
|
if(complete) complete();
|
||||||
|
}
|
||||||
|
}).fail(function() {
|
||||||
|
console.log("PrinterPanel:savePrinterType: failed");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.loadPrinterSettings = function() {
|
||||||
|
console.log("PrinterPanel:loadPrinterSettings");
|
||||||
|
console.log(" self.printerSettingsNames: ",self.printerSettingsNames);
|
||||||
|
var getData = {};
|
||||||
|
$.each(self.printerSettingsNames, function(key, val) {
|
||||||
|
getData[val] = "";
|
||||||
|
});
|
||||||
|
console.log("getData: ",getData);
|
||||||
|
$.ajax({
|
||||||
|
url: self.wifiboxURL + "/config/",
|
||||||
|
dataType: 'json',
|
||||||
|
data: getData,
|
||||||
|
success: function(response){
|
||||||
|
console.log("PrinterPanel:loadPrinterSettings response: ",response);
|
||||||
|
|
||||||
|
self.fillForm(response.data,self.element);
|
||||||
|
}
|
||||||
|
}).fail(function() {
|
||||||
|
console.log("PrinterPanel:loadPrinterSettings: failed");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -90,6 +90,7 @@ function SettingsWindow() {
|
|||||||
this.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
this.networkMode = SettingsWindow.NETWORK_MODE_NEITHER;
|
||||||
|
|
||||||
this.updatePanel = new UpdatePanel();
|
this.updatePanel = new UpdatePanel();
|
||||||
|
this.printerPanel = new PrinterPanel();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ function SettingsWindow() {
|
|||||||
|
|
||||||
self.loadSettings();
|
self.loadSettings();
|
||||||
|
|
||||||
self.printerSelector = self.form.find("#printerType");
|
|
||||||
var btnAP = self.form.find("label[for='ap']");
|
var btnAP = self.form.find("label[for='ap']");
|
||||||
var btnClient = self.form.find("label[for='client']");
|
var btnClient = self.form.find("label[for='client']");
|
||||||
var btnRefresh = self.form.find("#refreshNetworks");
|
var btnRefresh = self.form.find("#refreshNetworks");
|
||||||
@ -118,8 +119,6 @@ function SettingsWindow() {
|
|||||||
var networkSelector = self.form.find("#network");
|
var networkSelector = self.form.find("#network");
|
||||||
self.apFieldSet = self.form.find("#apSettings");
|
self.apFieldSet = self.form.find("#apSettings");
|
||||||
self.clientFieldSet = self.form.find("#clientSettings");
|
self.clientFieldSet = self.form.find("#clientSettings");
|
||||||
self.gcodeSettings = self.form.find("#gcodeSettings");
|
|
||||||
self.x3gSettings = self.form.find("#x3gSettings");
|
|
||||||
self.btnRestoreSettings = self.form.find("#restoreSettings");
|
self.btnRestoreSettings = self.form.find("#restoreSettings");
|
||||||
|
|
||||||
btnAP.on('touchstart mousedown',self.showAPSettings);
|
btnAP.on('touchstart mousedown',self.showAPSettings);
|
||||||
@ -127,14 +126,18 @@ function SettingsWindow() {
|
|||||||
btnRefresh.on('touchstart mousedown',self.refreshNetworks);
|
btnRefresh.on('touchstart mousedown',self.refreshNetworks);
|
||||||
btnConnect.on('touchstart mousedown',self.connectToNetwork);
|
btnConnect.on('touchstart mousedown',self.connectToNetwork);
|
||||||
btnCreate.on('touchstart mousedown',self.createAP);
|
btnCreate.on('touchstart mousedown',self.createAP);
|
||||||
self.printerSelector.change(self.printerSelectorChanged);
|
|
||||||
networkSelector.change(self.networkSelectorChanged);
|
networkSelector.change(self.networkSelectorChanged);
|
||||||
self.btnRestoreSettings.on('touchstart mousedown',self.resetSettings);
|
self.btnRestoreSettings.on('touchstart mousedown',self.resetSettings);
|
||||||
|
|
||||||
|
|
||||||
// update panel
|
// update panel
|
||||||
var $updatePanelElement = self.form.find("#updatePanel");
|
var $updatePanelElement = self.form.find("#updatePanel");
|
||||||
self.updatePanel.init(wifiboxURL,$updatePanelElement);
|
self.updatePanel.init(wifiboxURL,$updatePanelElement);
|
||||||
|
|
||||||
|
// printer panel
|
||||||
|
var $printerPanelElement = self.form.find("#printerPanel");
|
||||||
|
self.printerPanel.init(wifiboxURL,$printerPanelElement);
|
||||||
|
self.printerPanel.fillForm = self.fillForm;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.submitwindow = function(e) {
|
this.submitwindow = function(e) {
|
||||||
@ -185,7 +188,7 @@ function SettingsWindow() {
|
|||||||
console.log("Settings:loadSettings response: ",response);
|
console.log("Settings:loadSettings response: ",response);
|
||||||
settings = response.data;
|
settings = response.data;
|
||||||
console.log(" settings: ",settings);
|
console.log(" settings: ",settings);
|
||||||
self.fillForm();
|
self.fillForm(settings);
|
||||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||||
if(complete) complete();
|
if(complete) complete();
|
||||||
}
|
}
|
||||||
@ -198,16 +201,16 @@ function SettingsWindow() {
|
|||||||
this.refreshNetworks();
|
this.refreshNetworks();
|
||||||
this.retrieveNetworkStatus(false);
|
this.retrieveNetworkStatus(false);
|
||||||
}
|
}
|
||||||
this.fillForm = function() {
|
this.fillForm = function(settings,form) {
|
||||||
console.log("SettingsWindow:fillForm");
|
if(!form) form = this.form; // if no form specified, fill whole form
|
||||||
|
|
||||||
//fill form with loaded settings
|
//fill form with loaded settings
|
||||||
var selects = this.form.find("select");
|
var selects = form.find("select");
|
||||||
selects.each( function(index,element) {
|
selects.each( function(index,element) {
|
||||||
var element = $(element);
|
var element = $(element);
|
||||||
element.val(settings[element.attr('name')]);
|
element.val(settings[element.attr('name')]);
|
||||||
});
|
});
|
||||||
var inputs = this.form.find("input");
|
var inputs = form.find("input");
|
||||||
inputs.each( function(index,element) {
|
inputs.each( function(index,element) {
|
||||||
var element = $(element);
|
var element = $(element);
|
||||||
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
||||||
@ -221,13 +224,12 @@ function SettingsWindow() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var textareas = this.form.find("textarea");
|
var textareas = form.find("textarea");
|
||||||
textareas.each( function(index,element) {
|
textareas.each( function(index,element) {
|
||||||
var element = $(element);
|
var element = $(element);
|
||||||
var value = settings[element.attr('name')];
|
var value = settings[element.attr('name')];
|
||||||
element.val(value);
|
element.val(value);
|
||||||
});
|
});
|
||||||
self.printerSelectorChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveSettings = function(newSettings,complete) {
|
this.saveSettings = function(newSettings,complete) {
|
||||||
@ -288,7 +290,7 @@ function SettingsWindow() {
|
|||||||
} else {
|
} else {
|
||||||
settings = response.data;
|
settings = response.data;
|
||||||
console.log(" settings: ",settings);
|
console.log(" settings: ",settings);
|
||||||
self.fillForm();
|
self.fillForm(settings);
|
||||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||||
|
|
||||||
self.btnRestoreSettings.removeAttr("disabled");
|
self.btnRestoreSettings.removeAttr("disabled");
|
||||||
@ -345,30 +347,6 @@ function SettingsWindow() {
|
|||||||
//console.log(settings);
|
//console.log(settings);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.printerSelectorChanged = function(e) {
|
|
||||||
var selectedOption = self.printerSelector.find("option:selected");
|
|
||||||
if(self.isMarlinPrinter(selectedOption.val())) {
|
|
||||||
self.x3gSettings.hide();
|
|
||||||
self.gcodeSettings.show();
|
|
||||||
} else {
|
|
||||||
self.gcodeSettings.hide();
|
|
||||||
self.x3gSettings.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isMarlinPrinter = function(printer) {
|
|
||||||
switch(printer) {
|
|
||||||
case "makerbot_generic":
|
|
||||||
case "makerbot_replicator2":
|
|
||||||
case "makerbot_thingomatic":
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.signin = function() {
|
this.signin = function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -261,12 +261,7 @@ function generate_gcode() {
|
|||||||
function generateStartCode() {
|
function generateStartCode() {
|
||||||
var printerType = settings["printer.type"];
|
var printerType = settings["printer.type"];
|
||||||
|
|
||||||
var startCode = "";
|
var startCode = settings["printer.startcode"];
|
||||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
|
||||||
startCode = settings["printer.startcode.marlin"];
|
|
||||||
} else {
|
|
||||||
startCode = settings["printer.startcode.x3g"];
|
|
||||||
}
|
|
||||||
startCode = subsituteVariables(startCode);
|
startCode = subsituteVariables(startCode);
|
||||||
startCode = startCode.split("\n");
|
startCode = startCode.split("\n");
|
||||||
return startCode;
|
return startCode;
|
||||||
@ -274,12 +269,7 @@ function generateStartCode() {
|
|||||||
function generateEndCode() {
|
function generateEndCode() {
|
||||||
var printerType = settings["printer.type"];
|
var printerType = settings["printer.type"];
|
||||||
|
|
||||||
var endCode = "";
|
var endCode = settings["printer.endcode"];
|
||||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
|
||||||
endCode = settings["printer.endcode.marlin"];
|
|
||||||
} else {
|
|
||||||
endCode = settings["printer.endcode.x3g"];
|
|
||||||
}
|
|
||||||
endCode = subsituteVariables(endCode);
|
endCode = subsituteVariables(endCode);
|
||||||
endCode = endCode.split("\n");
|
endCode = endCode.split("\n");
|
||||||
return endCode;
|
return endCode;
|
||||||
@ -296,6 +286,7 @@ function subsituteVariables(gcode) {
|
|||||||
switch (printerType) {
|
switch (printerType) {
|
||||||
case "makerbot_replicator2": printerType = "r2x"; break;
|
case "makerbot_replicator2": printerType = "r2x"; break;
|
||||||
case "makerbot_thingomatic": printerType = "t6"; break;
|
case "makerbot_thingomatic": printerType = "t6"; break;
|
||||||
|
case "makerbot_generic": printerType = "r2"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcode = gcode.replace(/{printingTemp}/gi ,temperature);
|
gcode = gcode.replace(/{printingTemp}/gi ,temperature);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="settingsContainer">
|
<div class="settingsContainer">
|
||||||
<form id="settingsForm">
|
<form id="settingsForm">
|
||||||
<fieldset>
|
<fieldset id="printerPanel">
|
||||||
<legend>3D printer</legend>
|
<legend>3D printer</legend>
|
||||||
<label for="printerType">Type:</label>
|
<label for="printerType">Type:</label>
|
||||||
<select id="printerType" name="printer.type">
|
<select id="printerType" name="printer.type">
|
||||||
@ -52,6 +52,27 @@
|
|||||||
</select><br/>
|
</select><br/>
|
||||||
<label for="printerBedWidth">Bed width:</label><input id="printerBedWidth" type="number" class="small" name="printer.bed.width">mm<br>
|
<label for="printerBedWidth">Bed width:</label><input id="printerBedWidth" type="number" class="small" name="printer.bed.width">mm<br>
|
||||||
<label for="printerBedHeight">Bed height:</label><input id="printerBedHeight" type="number" class="small" name="printer.bed.height">mm<br>
|
<label for="printerBedHeight">Bed height:</label><input id="printerBedHeight" type="number" class="small" name="printer.bed.height">mm<br>
|
||||||
|
<fieldset id="gcodePanel">
|
||||||
|
<legend>GCODE settings</legend>
|
||||||
|
<div class="startgcode_left">
|
||||||
|
<label for="startgcode">Start:</label><br/>
|
||||||
|
<textarea id="startgcode" class="gcode" name="printer.startcode"></textarea>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="endgcode">End:</label><br/>
|
||||||
|
<textarea id="endgcode" class="gcode" name="printer.endcode"></textarea>
|
||||||
|
</div>
|
||||||
|
<small>
|
||||||
|
The following texts are replaced:
|
||||||
|
<dl>
|
||||||
|
<dt>{printingTemp}</dt><dd>Printing temperature</dd>
|
||||||
|
<dt>{printingBedTemp}</dt><dd>Printing bed temperature</dd>
|
||||||
|
<dt>{preheatTemp}</dt><dd>Preheat temperature</dd>
|
||||||
|
<dt>{preheatBedTemp}</dt><dd>Preheat bed temperature</dd>
|
||||||
|
<dt>{printerType}</dt><dd>Printer type</dd>
|
||||||
|
</dl>
|
||||||
|
</small>
|
||||||
|
</fieldset>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="printersettings">
|
<fieldset id="printersettings">
|
||||||
@ -133,49 +154,6 @@
|
|||||||
<small id="updateInfo"></small>
|
<small id="updateInfo"></small>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="gcodeSettings">
|
|
||||||
<legend>GCODE settings</legend>
|
|
||||||
<small class="intro">GCode settings for all printers that use Marlin firmware</small>
|
|
||||||
<div class="startgcode_left">
|
|
||||||
<label for="startgcodeMarlin">Start:</label><br/>
|
|
||||||
<textarea id="startgcodeMarlin" class="gcode" name="printer.startcode.marlin"></textarea>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="endgcodeMarlin">End:</label><br/>
|
|
||||||
<textarea id="endcodeMarlin" class="gcode" name="printer.endcode.marlin"></textarea>
|
|
||||||
</div>
|
|
||||||
<small>
|
|
||||||
The following texts are replaced:
|
|
||||||
<dl>
|
|
||||||
<dt>{printingTemp}</dt><dd>Printing temperature</dd>
|
|
||||||
<dt>{printingBedTemp}</dt><dd>Printing bed temperature</dd>
|
|
||||||
<dt>{preheatTemp}</dt><dd>Preheat temperature</dd>
|
|
||||||
<dt>{preheatBedTemp}</dt><dd>Preheat bed temperature</dd>
|
|
||||||
</dl>
|
|
||||||
</small>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset id="x3gSettings">
|
|
||||||
<legend>GCODE settings</legend>
|
|
||||||
<small class="intro">GCODE settings for Makerbots.</small>
|
|
||||||
<div class="startgcode_left">
|
|
||||||
<label for="startgcodeX3G">Start:</label><br/>
|
|
||||||
<textarea id="startcodeX3G" class="gcode" name="printer.startcode.x3g"></textarea>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="endgcodeX3G">End:</label><br/>
|
|
||||||
<textarea id="endcodeX3G" class="gcode" name="printer.endcode.x3g"></textarea>
|
|
||||||
</div>
|
|
||||||
<small>
|
|
||||||
The following texts are replaced:
|
|
||||||
<dl>
|
|
||||||
<dt>{printingTemp}</dt><dd>Printing temperature</dd>
|
|
||||||
<dt>{printingBedTemp}</dt><dd>Printing bed temperature</dd>
|
|
||||||
<dt>{preheatTemp}</dt><dd>Preheat temperature</dd>
|
|
||||||
<dt>{preheatBedTemp}</dt><dd>Preheat bed temperature</dd>
|
|
||||||
<dt>{printerType}</dt><dd>Printer type</dd>
|
|
||||||
</dl>
|
|
||||||
</small>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset id="debugPanel">
|
<fieldset id="debugPanel">
|
||||||
<legend>Debug</legend>
|
<legend>Debug</legend>
|
||||||
<input type="button" onclick="settingsWindow.downloadlogs()" name="downloadlogs" value="Download logs" class="button" id="downloadlogs"/>
|
<input type="button" onclick="settingsWindow.downloadlogs()" name="downloadlogs" value="Download logs" class="button" id="downloadlogs"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user