0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-26 02:23:48 +01:00

save settings

This commit is contained in:
Rick Companje 2017-05-16 11:02:29 +02:00
parent e9da8a91f0
commit f486bd1777
3 changed files with 77 additions and 33 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This file is part of the Doodle3D project (http://doodle3d.com). * This file is part of the Doodle3D project (http://doodle3d.com).
* *
* Copyright (c) 2013, Doodle3D * Copyright (c) 2013-2017, Doodle3D
* This software is licensed under the terms of the GNU GPL v2 or later. * This software is licensed under the terms of the GNU GPL v2 or later.
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details. * See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
*/ */
@ -25,9 +25,8 @@
var _self = this; var _self = this;
function updateFields() { function showOrHideFields() {
var isHeatedBed = $("#chkBed").prop("checked"); if ($("#chkBed").prop("checked")) {
if (isHeatedBed) {
$("#grpBedTemp").show(); $("#grpBedTemp").show();
} else { } else {
$("#grpBedTemp").hide(); $("#grpBedTemp").hide();
@ -42,17 +41,60 @@
$("#divSettings").hide(); $("#divSettings").hide();
d3d.util.showLoader(); d3d.util.showLoader();
$("#chkBed").on("change", function(data) { $("#lstPrinters").on("change", function(data) {
updateFields(); var printerType = $(this).val();
_configAPI.savePrinterType(printerType,function(successData) {
refreshSettings();
},function(failData) {
console.log("savePrinterType fail",failData);
});
});
$("#nozzleTemperature").on('slidestop', function( event ) {
_configAPI.save({"printer.temperature":$(this).val()});
});
$("#nozzleTemperature").on('focusout', function( event ) {
_configAPI.save({"printer.temperature":$(this).val()});
});
$("#bedTemperature").on('slidestop', function( event ) {
_configAPI.save({"printer.bed.temperature":$(this).val()});
});
$("#bedTemperature").on('focusout', function( event ) {
_configAPI.save({"printer.bed.temperature":$(this).val()});
}); });
$("#filamentThickness").on("change", function(data) { $("#filamentThickness").on("change", function(data) {
console.log("filamentThickness change",$(this).val()); _configAPI.save({"printer.filamentThickness":$(this).val()});
}); });
$("#bedTemperature").on("change", function(data) { $("#dimensionsX").on("change", function(data) {
console.log("bedTemperature change",$(this).val()); _configAPI.save({"printer.dimensions.x":$(this).val()});
}); });
$("#dimensionsY").on("change", function(data) {
_configAPI.save({"printer.dimensions.y":$(this).val()});
});
$("#dimensionsZ").on("change", function(data) {
_configAPI.save({"printer.dimensions.z":$(this).val()});
});
$('#startgcode').on("change", function(data) {
_configAPI.save({"printer.startcode":$(this).val()});
});
$('#endgcode').on("change", function(data) {
_configAPI.save({"printer.end":$(this).val()});
});
$("#chkBed").on("change", function(data) {
showOrHideFields();
});
}); });
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) { $.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
@ -68,7 +110,14 @@
_configAPI.init(boxURL); _configAPI.init(boxURL);
_printerAPI.init(boxURL); _printerAPI.init(boxURL);
refreshSettings();
});
$.mobile.document.on( "pagebeforehide", PAGE_ID, function( event, data ) {
});
function refreshSettings() {
_configAPI.loadAll(function(successData) { _configAPI.loadAll(function(successData) {
var printerType = successData["printer.type"]; var printerType = successData["printer.type"];
var printerStartGCode = successData["printer.startcode"]; var printerStartGCode = successData["printer.startcode"];
@ -93,7 +142,6 @@
$('#nozzleTemperature').val(nozzleTemperature); $('#nozzleTemperature').val(nozzleTemperature);
_printerAPI.listAll(function(printers) { _printerAPI.listAll(function(printers) {
console.log(PAGE_ID,'page init',data);
$("#lstPrinters").empty(); $("#lstPrinters").empty();
@ -106,9 +154,13 @@
$("#divSettings").show(); $("#divSettings").show();
d3d.util.hideLoader(); d3d.util.hideLoader();
showOrHideFields();
},function(failData) { //_printerAPI.listAll $("#bedTemperature").slider("refresh");
console.log(PAGE_ID,'FAIL _printerAPI.listall',data); $("#nozzleTemperature").slider("refresh");
},function(failData) {
console.log(PAGE_ID,'FAIL _printerAPI.listAll');
$.mobile.changePage("#boxes"); $.mobile.changePage("#boxes");
return; return;
}); });
@ -118,12 +170,7 @@
$.mobile.changePage("#boxes"); $.mobile.changePage("#boxes");
return; return;
}); });
}
});
$.mobile.document.on( "pagebeforehide", PAGE_ID, function( event, data ) {
});
})(window); })(window);

View File

@ -83,15 +83,22 @@ function ConfigAPI() {
success: function(response){ success: function(response){
//console.log("ConfigAPI:save response: ",response); //console.log("ConfigAPI:save response: ",response);
if(response.status == "error" || response.status == "fail") { if(response.status == "error" || response.status == "fail") {
if(failedHandler) failedHandler(response); if (failedHandler) failedHandler(response);
} else { } else {
completeHandler(response.data); console.log("ConfigAPI.save",newSettings,response.data);
if (completeHandler) completeHandler(response.data);
} }
} }
}).fail(function() { }).fail(function() {
if(failedHandler) failedHandler(); if(failedHandler) failedHandler();
}); });
}; };
this.savePrinterType = function(printerType,completeHandler,failedHandler) {
var settings = {"printer.type": printerType};
this.save(settings,completeHandler,failedHandler);
};
this.resetAll = function(completeHandler,failedHandler) { this.resetAll = function(completeHandler,failedHandler) {
//console.log("ConfigAPI:resetAll"); //console.log("ConfigAPI:resetAll");
$.ajax({ $.ajax({

View File

@ -279,17 +279,7 @@
</div><!-- /header --> </div><!-- /header -->
<div id="divSettings" role="main" class="ui-content"> <div id="divSettings" role="main" class="ui-content">
<!-- <p class="intro">test</p> --> <p class="intro">Use this page to select which 3D-printer is connected to your Doodle3D WiFi-Box. By selecting a printer the default settings for this printer will be loaded. Values are saved automatically.</p>
<a href="index.html" data-icon="check" data-role="button" data-inline="true" data-theme="c">Save settings</a>
<!-- <div align="right"> -->
<!-- <a href="index.html" data-role="button" class="ui-btn-right ui-btn-inline">Save</a> -->
<!-- </div> -->
<!-- data-theme="a" data-inline="true" -->
<!-- <a href="#" class="ui-btn-right ui-btn-inline">Login</a> -->
<div data-role="collapsible" data-collapsed="false"> <div data-role="collapsible" data-collapsed="false">
@ -328,7 +318,7 @@
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<label for="name">Filament thickness (mm):</label> <label for="name">Filament thickness (mm):</label>
<input type="number" id="filamentThickness" name="filamentThickness" data-mini="true"/> <input type="number" id="filamentThickness" name="filamentThickness" data-mini="true" step=".01" min="1.75" max="3.3"/>
</div> </div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">