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: [
|
||||
'js_src/SettingsWindow.js',
|
||||
'js_src/UpdatePanel.js',
|
||||
'js_src/PrinterPanel.js',
|
||||
'js_src/Help.js',
|
||||
'js_src/d3dServerInterfacing.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.updatePanel = new UpdatePanel();
|
||||
this.printerPanel = new PrinterPanel();
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -109,7 +110,7 @@ function SettingsWindow() {
|
||||
|
||||
self.loadSettings();
|
||||
|
||||
self.printerSelector = self.form.find("#printerType");
|
||||
|
||||
var btnAP = self.form.find("label[for='ap']");
|
||||
var btnClient = self.form.find("label[for='client']");
|
||||
var btnRefresh = self.form.find("#refreshNetworks");
|
||||
@ -118,8 +119,6 @@ function SettingsWindow() {
|
||||
var networkSelector = self.form.find("#network");
|
||||
self.apFieldSet = self.form.find("#apSettings");
|
||||
self.clientFieldSet = self.form.find("#clientSettings");
|
||||
self.gcodeSettings = self.form.find("#gcodeSettings");
|
||||
self.x3gSettings = self.form.find("#x3gSettings");
|
||||
self.btnRestoreSettings = self.form.find("#restoreSettings");
|
||||
|
||||
btnAP.on('touchstart mousedown',self.showAPSettings);
|
||||
@ -127,14 +126,18 @@ function SettingsWindow() {
|
||||
btnRefresh.on('touchstart mousedown',self.refreshNetworks);
|
||||
btnConnect.on('touchstart mousedown',self.connectToNetwork);
|
||||
btnCreate.on('touchstart mousedown',self.createAP);
|
||||
self.printerSelector.change(self.printerSelectorChanged);
|
||||
networkSelector.change(self.networkSelectorChanged);
|
||||
self.btnRestoreSettings.on('touchstart mousedown',self.resetSettings);
|
||||
|
||||
|
||||
// update panel
|
||||
var $updatePanelElement = self.form.find("#updatePanel");
|
||||
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) {
|
||||
@ -185,7 +188,7 @@ function SettingsWindow() {
|
||||
console.log("Settings:loadSettings response: ",response);
|
||||
settings = response.data;
|
||||
console.log(" settings: ",settings);
|
||||
self.fillForm();
|
||||
self.fillForm(settings);
|
||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||
if(complete) complete();
|
||||
}
|
||||
@ -198,16 +201,16 @@ function SettingsWindow() {
|
||||
this.refreshNetworks();
|
||||
this.retrieveNetworkStatus(false);
|
||||
}
|
||||
this.fillForm = function() {
|
||||
console.log("SettingsWindow:fillForm");
|
||||
this.fillForm = function(settings,form) {
|
||||
if(!form) form = this.form; // if no form specified, fill whole form
|
||||
|
||||
//fill form with loaded settings
|
||||
var selects = this.form.find("select");
|
||||
var selects = form.find("select");
|
||||
selects.each( function(index,element) {
|
||||
var element = $(element);
|
||||
element.val(settings[element.attr('name')]);
|
||||
});
|
||||
var inputs = this.form.find("input");
|
||||
var inputs = form.find("input");
|
||||
inputs.each( function(index,element) {
|
||||
var element = $(element);
|
||||
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
||||
@ -221,13 +224,12 @@ function SettingsWindow() {
|
||||
break;
|
||||
}
|
||||
});
|
||||
var textareas = this.form.find("textarea");
|
||||
var textareas = form.find("textarea");
|
||||
textareas.each( function(index,element) {
|
||||
var element = $(element);
|
||||
var value = settings[element.attr('name')];
|
||||
element.val(value);
|
||||
});
|
||||
self.printerSelectorChanged();
|
||||
}
|
||||
|
||||
this.saveSettings = function(newSettings,complete) {
|
||||
@ -288,7 +290,7 @@ function SettingsWindow() {
|
||||
} else {
|
||||
settings = response.data;
|
||||
console.log(" settings: ",settings);
|
||||
self.fillForm();
|
||||
self.fillForm(settings);
|
||||
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
|
||||
|
||||
self.btnRestoreSettings.removeAttr("disabled");
|
||||
@ -346,30 +348,6 @@ function SettingsWindow() {
|
||||
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() {
|
||||
$.ajax({
|
||||
url: self.wifiboxCGIBinURL + "/network/signin",
|
||||
|
@ -261,12 +261,7 @@ function generate_gcode() {
|
||||
function generateStartCode() {
|
||||
var printerType = settings["printer.type"];
|
||||
|
||||
var startCode = "";
|
||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
||||
startCode = settings["printer.startcode.marlin"];
|
||||
} else {
|
||||
startCode = settings["printer.startcode.x3g"];
|
||||
}
|
||||
var startCode = settings["printer.startcode"];
|
||||
startCode = subsituteVariables(startCode);
|
||||
startCode = startCode.split("\n");
|
||||
return startCode;
|
||||
@ -274,12 +269,7 @@ function generateStartCode() {
|
||||
function generateEndCode() {
|
||||
var printerType = settings["printer.type"];
|
||||
|
||||
var endCode = "";
|
||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
||||
endCode = settings["printer.endcode.marlin"];
|
||||
} else {
|
||||
endCode = settings["printer.endcode.x3g"];
|
||||
}
|
||||
var endCode = settings["printer.endcode"];
|
||||
endCode = subsituteVariables(endCode);
|
||||
endCode = endCode.split("\n");
|
||||
return endCode;
|
||||
@ -296,6 +286,7 @@ function subsituteVariables(gcode) {
|
||||
switch (printerType) {
|
||||
case "makerbot_replicator2": printerType = "r2x"; break;
|
||||
case "makerbot_thingomatic": printerType = "t6"; break;
|
||||
case "makerbot_generic": printerType = "r2"; break;
|
||||
}
|
||||
|
||||
gcode = gcode.replace(/{printingTemp}/gi ,temperature);
|
||||
|
@ -12,7 +12,7 @@
|
||||
<body>
|
||||
<div class="settingsContainer">
|
||||
<form id="settingsForm">
|
||||
<fieldset>
|
||||
<fieldset id="printerPanel">
|
||||
<legend>3D printer</legend>
|
||||
<label for="printerType">Type:</label>
|
||||
<select id="printerType" name="printer.type">
|
||||
@ -52,6 +52,27 @@
|
||||
</select><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>
|
||||
<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 id="printersettings">
|
||||
@ -133,49 +154,6 @@
|
||||
<small id="updateInfo"></small>
|
||||
</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">
|
||||
<legend>Debug</legend>
|
||||
<input type="button" onclick="settingsWindow.downloadlogs()" name="downloadlogs" value="Download logs" class="button" id="downloadlogs"/>
|
||||
|
Loading…
Reference in New Issue
Block a user