mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-24 18:17:56 +01:00
Merge branch 'feature/printerprofiles' into develop
Conflicts: js_src/gcodeGenerating.js
This commit is contained in:
commit
9b802ceea9
@ -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',
|
||||
|
76
js_src/PrinterPanel.js
Normal file
76
js_src/PrinterPanel.js
Normal file
@ -0,0 +1,76 @@
|
||||
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);
|
||||
});
|
||||
|
||||
var gcodePanel = element.find("#gcodePanel");
|
||||
gcodePanel.coolfieldset({collapsed:true});
|
||||
}
|
||||
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");
|
||||
@ -345,30 +347,6 @@ function SettingsWindow() {
|
||||
//console.log(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() {
|
||||
$.ajax({
|
||||
|
@ -260,26 +260,14 @@ 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;
|
||||
}
|
||||
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,7 +284,7 @@ function subsituteVariables(gcode) {
|
||||
switch (printerType) {
|
||||
case "makerbot_replicator2": printerType = "r2x"; break; //FIXME: this should be r2, with a separate type for r2x
|
||||
case "makerbot_thingomatic": printerType = "t6"; break;
|
||||
default: printerType = "r2"; break;
|
||||
case "makerbot_generic": printerType = "r2"; break;
|
||||
}
|
||||
|
||||
gcode = gcode.replace(/{printingTemp}/gi ,temperature);
|
||||
|
57
js_src/libs/jquery-coolfieldset.js
vendored
Normal file
57
js_src/libs/jquery-coolfieldset.js
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* jQuery Plugin for creating collapsible fieldset
|
||||
* @requires jQuery 1.2 or later
|
||||
*
|
||||
* Copyright (c) 2010 Lucky <bogeyman2007@gmail.com>
|
||||
* Licensed under the GPL license:
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* "animation" and "speed" options are added by Mitch Kuppinger <dpneumo@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
function hideFieldsetContent(obj, options){
|
||||
if(options.animation==true)
|
||||
obj.find('div').slideUp(options.speed);
|
||||
else
|
||||
obj.find('div').hide();
|
||||
|
||||
obj.removeClass("expanded");
|
||||
obj.addClass("collapsed");
|
||||
}
|
||||
|
||||
function showFieldsetContent(obj, options){
|
||||
if(options.animation==true)
|
||||
obj.find('div').slideDown(options.speed);
|
||||
else
|
||||
obj.find('div').show();
|
||||
|
||||
obj.removeClass("collapsed");
|
||||
obj.addClass("expanded");
|
||||
}
|
||||
|
||||
$.fn.coolfieldset = function(options){
|
||||
var setting={collapsed:false, animation:true, speed:'medium'};
|
||||
$.extend(setting, options);
|
||||
|
||||
this.each(function(){
|
||||
var fieldset=$(this);
|
||||
fieldset.addClass("collapsible");
|
||||
var legend=fieldset.children('legend');
|
||||
|
||||
if(setting.collapsed==true){
|
||||
hideFieldsetContent(fieldset, setting);
|
||||
} else {
|
||||
showFieldsetContent(fieldset, setting);
|
||||
}
|
||||
|
||||
legend.bind('touchstart mousedown', function() {
|
||||
if(fieldset.hasClass("collapsed")) {
|
||||
showFieldsetContent(fieldset, setting);
|
||||
} else {
|
||||
hideFieldsetContent(fieldset, setting);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
@ -35,10 +35,34 @@ form fieldset fieldset{
|
||||
clear: left;
|
||||
float: left;
|
||||
}
|
||||
form fieldset.collapsed {
|
||||
border-radius: 0;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-width: 1px 0 0 0;
|
||||
float:none;
|
||||
}
|
||||
form fieldset.collapsible {
|
||||
padding: 0;
|
||||
}
|
||||
form fieldset.collapsible div{
|
||||
margin: 8px;
|
||||
}
|
||||
form fieldset legend {
|
||||
margin-left: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
form fieldset.collapsible legend {
|
||||
padding-left: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
form fieldset.expanded legend {
|
||||
background: transparent url(../img/buttons/expanded.gif) no-repeat center left;
|
||||
}
|
||||
form fieldset.collapsed legend {
|
||||
background: transparent url(../img/buttons/collapsed.gif) no-repeat center left;
|
||||
}
|
||||
|
||||
form label {
|
||||
min-width: 150px;
|
||||
display: block;
|
||||
|
BIN
www/img/buttons/collapsed.gif
Normal file
BIN
www/img/buttons/collapsed.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 B |
BIN
www/img/buttons/expanded.gif
Normal file
BIN
www/img/buttons/expanded.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 107 B |
@ -134,6 +134,7 @@
|
||||
<!--<script src="js/libs/imagesloaded-pkgd.min.js"></script>-->
|
||||
<!--<script src="../js_src/libs/jquery-joyride-2-1.js"></script>-->
|
||||
<script src="js/libs/jquery-joyride-2-1.min.js"></script>
|
||||
<script src="js/libs/jquery-coolfieldset.min.js"></script>
|
||||
<!--<script src="js/doodle3d-client.js"></script>-->
|
||||
<script src="js/doodle3d-client.min.js"></script>
|
||||
|
||||
|
@ -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,29 @@
|
||||
</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>
|
||||
<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>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="printersettings">
|
||||
@ -133,49 +156,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