mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Messages! Showing info about buffering, connection to wifibox and printer
This commit is contained in:
parent
46d2ae4bfc
commit
10724b1746
@ -658,6 +658,39 @@ SETTINGS POPUP
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#message {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
padding: 0.4em 0.5em;
|
||||||
|
border-radius: 0 0 0 10px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
-webkit-box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65);
|
||||||
|
box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65);
|
||||||
|
color: #333;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message.error {
|
||||||
|
background: #EB313C;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message.warning {
|
||||||
|
background: #E9A86E;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message.notice {
|
||||||
|
background: #93CAF4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#message.info {
|
||||||
|
background: #97DD8A;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 480px),only screen and (max-width: 720px) and (min-device-pixel-ratio: 1.5),only screen and (max-width: 720px) and (-webkit-min-device-pixel-ratio: 1.5) {
|
@media only screen and (max-width: 480px),only screen and (max-width: 720px) and (min-device-pixel-ratio: 1.5),only screen and (max-width: 720px) and (-webkit-min-device-pixel-ratio: 1.5) {
|
||||||
/*
|
/*
|
||||||
TOP LOGO
|
TOP LOGO
|
||||||
|
2
css/styles.min.css
vendored
2
css/styles.min.css
vendored
File diff suppressed because one or more lines are too long
@ -79,6 +79,8 @@
|
|||||||
<img class="btnSettings btn" src="img/buttons/btnSettings.png">
|
<img class="btnSettings btn" src="img/buttons/btnSettings.png">
|
||||||
<img class="btnInfo btn" src="img/buttons/btnInfo.png">
|
<img class="btnInfo btn" src="img/buttons/btnInfo.png">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="message"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- center panel -->
|
<!-- center panel -->
|
||||||
@ -154,6 +156,7 @@
|
|||||||
<script src="js/Thermometer.js"></script>
|
<script src="js/Thermometer.js"></script>
|
||||||
<script src="js/utils.js"></script>
|
<script src="js/utils.js"></script>
|
||||||
<script src="js/sidebar.js"></script>
|
<script src="js/sidebar.js"></script>
|
||||||
|
<script src="js/message.js"></script>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -12,8 +12,9 @@ function setPrintprogress(val) {
|
|||||||
|
|
||||||
function Printer() {
|
function Printer() {
|
||||||
|
|
||||||
Printer.UNKNOWN_STATE = "unknown";
|
Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected";
|
||||||
Printer.DISCONNECTED_STATE = "disconnected";
|
Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet
|
||||||
|
Printer.DISCONNECTED_STATE = "disconnected"; // printer disconnected
|
||||||
Printer.IDLE_STATE = "idle"; // printer found, but idle
|
Printer.IDLE_STATE = "idle"; // printer found, but idle
|
||||||
Printer.BUFFERING_STATE = "buffering"; // printer is buffering (recieving) data, but not yet printing
|
Printer.BUFFERING_STATE = "buffering"; // printer is buffering (recieving) data, but not yet printing
|
||||||
Printer.PRINTING_STATE = "printing";
|
Printer.PRINTING_STATE = "printing";
|
||||||
@ -97,6 +98,7 @@ function Printer() {
|
|||||||
console.log("Printer:print");
|
console.log("Printer:print");
|
||||||
console.log(" gcode total # of lines: " + gcode.length);
|
console.log(" gcode total # of lines: " + gcode.length);
|
||||||
|
|
||||||
|
message.set("Sending doodle to printer...",Message.NOTICE);
|
||||||
self.addLeaveWarning();
|
self.addLeaveWarning();
|
||||||
|
|
||||||
/*for (i = 0; i < gcode.length; i++) {
|
/*for (i = 0; i < gcode.length; i++) {
|
||||||
@ -157,6 +159,7 @@ function Printer() {
|
|||||||
this.gcode = [];
|
this.gcode = [];
|
||||||
btnStop.css("display","block"); // hack
|
btnStop.css("display","block"); // hack
|
||||||
self.removeLeaveWarning();
|
self.removeLeaveWarning();
|
||||||
|
message.set("Doodle is send to printer...",Message.INFO,true);
|
||||||
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
||||||
} else {
|
} else {
|
||||||
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
|
||||||
@ -239,7 +242,7 @@ function Printer() {
|
|||||||
this.checkStatus = function() {
|
this.checkStatus = function() {
|
||||||
console.log("Printer:checkStatus");
|
console.log("Printer:checkStatus");
|
||||||
this.stateOverruled = false;
|
this.stateOverruled = false;
|
||||||
console.log(" stateOverruled: ",this.stateOverruled);
|
//console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
var self = this;
|
var self = this;
|
||||||
if (communicateWithWifibox) {
|
if (communicateWithWifibox) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -247,7 +250,7 @@ function Printer() {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
timeout: this.timeoutTime,
|
timeout: this.timeoutTime,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
//console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
||||||
|
|
||||||
self.handleStatusUpdate(response);
|
self.handleStatusUpdate(response);
|
||||||
|
|
||||||
@ -257,26 +260,27 @@ function Printer() {
|
|||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log("Printer:checkStatus: failed");
|
console.log("Printer:checkStatus: failed");
|
||||||
self.state = Printer.UNKNOWN_STATE;
|
self.state = Printer.WIFIBOX_DISCONNECTED_STATE;
|
||||||
clearTimeout(self.checkStatusDelay);
|
clearTimeout(self.checkStatusDelay);
|
||||||
clearTimeout(self.retryCheckStatusDelay);
|
clearTimeout(self.retryCheckStatusDelay);
|
||||||
self.retryCheckStatusDelay = setTimeout(function() { self.checkStatus() },self.retryDelay); // retry after delay
|
self.retryCheckStatusDelay = setTimeout(function() { self.checkStatus() },self.retryDelay); // retry after delay
|
||||||
|
$(document).trigger(Printer.UPDATE);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log ("Printer >> f:checkStatus() >> communicateWithWifibox is false, so not executing this function");
|
console.log ("Printer >> f:checkStatus() >> communicateWithWifibox is false, so not executing this function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handleStatusUpdate = function(response) {
|
this.handleStatusUpdate = function(response) {
|
||||||
console.log("Printer:handleStatusUpdate");
|
console.log("Printer:handleStatusUpdate response: ",response);
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
if(response.status != "success") {
|
if(response.status != "success") {
|
||||||
self.state = Printer.UNKNOWN_STATE;
|
self.state = Printer.UNKNOWN_STATE;
|
||||||
} else {
|
} else {
|
||||||
// state
|
// state
|
||||||
console.log(" stateOverruled: ",this.stateOverruled);
|
//console.log(" stateOverruled: ",this.stateOverruled);
|
||||||
if(!this.stateOverruled) {
|
if(!this.stateOverruled) {
|
||||||
self.state = data.state;
|
self.state = data.state;
|
||||||
console.log(" state > ",self.state);
|
//console.log(" state > ",self.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// temperature
|
// temperature
|
||||||
|
@ -49,7 +49,7 @@ function Progressbar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.update = function(part, total) {
|
this.update = function(part, total) {
|
||||||
console.log("Progressbar.update(" + part + "," + total + ")");
|
//console.log("Progressbar.update(" + part + "," + total + ")");
|
||||||
|
|
||||||
var pct = part / total;
|
var pct = part / total;
|
||||||
if (this.isInitted) {
|
if (this.isInitted) {
|
||||||
@ -59,7 +59,7 @@ function Progressbar() {
|
|||||||
var progress = part / total;
|
var progress = part / total;
|
||||||
progress = Math.min(progress, 1.0);
|
progress = Math.min(progress, 1.0);
|
||||||
progress = Math.max(progress, 0);
|
progress = Math.max(progress, 0);
|
||||||
console.log("progressbar >> f:update() >> progress: " + progress);
|
//console.log("progressbar >> f:update() >> progress: " + progress);
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
@ -317,10 +317,12 @@ function update() {
|
|||||||
progressbar.update(printer.currentLine, printer.totalLines);
|
progressbar.update(printer.currentLine, printer.totalLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setState(newState,newHasControl) { //TODO add hasControl
|
function setState(newState,newHasControl) {
|
||||||
if(newState == state && newHasControl == hasControl) return;
|
if(newState == state && newHasControl == hasControl) return;
|
||||||
|
|
||||||
console.log("setState: ",state," > ",newState," ( ",newHasControl,")");
|
prevState = state;
|
||||||
|
|
||||||
|
console.log("setState: ",prevState," > ",newState," ( ",newHasControl,")");
|
||||||
setDebugText("State: "+newState);
|
setDebugText("State: "+newState);
|
||||||
|
|
||||||
// print button
|
// print button
|
||||||
@ -347,12 +349,14 @@ function setState(newState,newHasControl) { //TODO add hasControl
|
|||||||
|
|
||||||
// thermometer
|
// thermometer
|
||||||
switch(newState) {
|
switch(newState) {
|
||||||
case Printer.UNKNOWN_STATE:
|
case Printer.IDLE_STATE:
|
||||||
case Printer.DISCONNECTED_STATE:
|
case Printer.BUFFERING_STATE:
|
||||||
thermometer.hide();
|
case Printer.PRINTING_STATE:
|
||||||
|
case Printer.STOPPING_STATE:
|
||||||
|
thermometer.show();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
thermometer.show();
|
thermometer.hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +370,17 @@ function setState(newState,newHasControl) { //TODO add hasControl
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
prevState = state;
|
if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
||||||
|
message.set("Lost connection to WiFi box",Message.ERROR);
|
||||||
|
} else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) {
|
||||||
|
message.set("Connected to WiFi box",Message.INFO,true);
|
||||||
|
} else if(newState == Printer.DISCONNECTED_STATE) {
|
||||||
|
message.set("Printer disconnected",Message.WARNING,true);
|
||||||
|
} else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE ||
|
||||||
|
prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE) {
|
||||||
|
message.set("Printer connected",Message.INFO,true);
|
||||||
|
}
|
||||||
|
|
||||||
state = newState;
|
state = newState;
|
||||||
hasControl = newHasControl;
|
hasControl = newHasControl;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ var printer = new Printer();
|
|||||||
var progressbar = new Progressbar();
|
var progressbar = new Progressbar();
|
||||||
var thermometer = new Thermometer();
|
var thermometer = new Thermometer();
|
||||||
var settingsWindow = new SettingsWindow();
|
var settingsWindow = new SettingsWindow();
|
||||||
|
var message = new Message();
|
||||||
|
|
||||||
var firstTimeSettingsLoaded = true;
|
var firstTimeSettingsLoaded = true;
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ $(function() {
|
|||||||
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
||||||
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
||||||
|
|
||||||
|
message.init($("#message"));
|
||||||
|
|
||||||
printer.init();
|
printer.init();
|
||||||
$(document).on(Printer.UPDATE,update);
|
$(document).on(Printer.UPDATE,update);
|
||||||
|
52
js/message.js
Normal file
52
js/message.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
function Message() {
|
||||||
|
|
||||||
|
Message.ERROR = "error";
|
||||||
|
Message.WARNING = "warning";
|
||||||
|
Message.NOTICE = "notice";
|
||||||
|
Message.INFO = "info";
|
||||||
|
|
||||||
|
this.mode = "";
|
||||||
|
|
||||||
|
this.$element;
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var autoHideDelay = 2000;
|
||||||
|
var autohideTimeout;
|
||||||
|
|
||||||
|
this.init = function($element) {
|
||||||
|
console.log("Message:init");
|
||||||
|
|
||||||
|
this.$element = $element;
|
||||||
|
console.log("$element: ",$element);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.set = function(text,mode,autoHide) {
|
||||||
|
console.log("Message:set: ",text,mode,autoHide);
|
||||||
|
self.hide(function() {
|
||||||
|
self.show();
|
||||||
|
self.clear();
|
||||||
|
|
||||||
|
self.$element.text(text);
|
||||||
|
self.$element.addClass(mode);
|
||||||
|
self.show();
|
||||||
|
|
||||||
|
self.mode = mode;
|
||||||
|
|
||||||
|
clearTimeout(autohideTimeout);
|
||||||
|
if(autoHide) {
|
||||||
|
autohideTimeout = setTimeout(function(){ self.hide()},autoHideDelay);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.clear = function($element) {
|
||||||
|
this.$element.text("");
|
||||||
|
this.$element.removeClass(this.mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.show = function() {
|
||||||
|
this.$element.fadeIn(200);
|
||||||
|
}
|
||||||
|
this.hide = function(complete) {
|
||||||
|
this.$element.fadeOut(200,complete);
|
||||||
|
}
|
||||||
|
}
|
30
less/message.less
Normal file
30
less/message.less
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#message {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
padding: 0.4em 0.5em;
|
||||||
|
border-radius: 0 0 0 10px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
font-weight: bold;
|
||||||
|
box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65);
|
||||||
|
|
||||||
|
color: #333;
|
||||||
|
white-space:nowrap;
|
||||||
|
|
||||||
|
display:none;
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
background: #EB313C;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
&.warning {
|
||||||
|
background: #E9A86E;
|
||||||
|
}
|
||||||
|
&.notice {
|
||||||
|
background: #93CAF4;
|
||||||
|
}
|
||||||
|
&.info {
|
||||||
|
background: #97DD8A;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
//@import "normalize.min.less";
|
//@import "normalize.min.less";
|
||||||
@import "base.less";
|
@import "base.less";
|
||||||
@import "settingsPopup.less";
|
@import "settingsPopup.less";
|
||||||
|
@import "message.less";
|
||||||
|
|
||||||
|
|
||||||
// MOBILE
|
// MOBILE
|
||||||
|
Loading…
Reference in New Issue
Block a user