Added confirmation dialog and different logo for print job restart

Closes #98
master
Gina Häußge 2013-04-10 16:37:12 +02:00
parent 46173bc35e
commit 34a860efda
2 changed files with 39 additions and 27 deletions

View File

@ -200,6 +200,42 @@ function PrinterStateViewModel() {
self._processZData = function(data) {
self.currentHeight(data);
}
self.print = function() {
var printAction = function() {
$.ajax({
url: AJAX_BASEURL + "control/print",
type: "POST",
dataType: "json"
});
}
if (self.isPaused()) {
$("#confirmation_dialog .confirmation_dialog_message").text("This will restart the print job from the beginning.");
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(function(e) {e.preventDefault(); $("#confirmation_dialog").modal("hide"); printAction(); });
$("#confirmation_dialog").modal("show");
} else {
printAction();
}
}
self.pause = function() {
$("#job_pause").button("toggle");
$.ajax({
url: AJAX_BASEURL + "control/pause",
type: "POST",
dataType: "json"
});
}
self.cancel = function() {
$.ajax({
url: AJAX_BASEURL + "control/cancel",
type: "POST",
dataType: "json"
});
}
}
function TemperatureViewModel(settingsViewModel) {
@ -1487,30 +1523,6 @@ $(function() {
//~~ Print job control
$("#job_print").click(function() {
$.ajax({
url: AJAX_BASEURL + "control/print",
type: "POST",
dataType: "json",
success: function(){}
})
})
$("#job_pause").click(function() {
$("#job_pause").button("toggle");
$.ajax({
url: AJAX_BASEURL + "control/pause",
type: "POST",
dataType: "json"
})
})
$("#job_cancel").click(function() {
$.ajax({
url: AJAX_BASEURL + "control/cancel",
type: "POST",
dataType: "json"
})
})
//~~ Temperature control (should really move to knockout click binding)
$("#temp_newTemp_set").click(function() {

View File

@ -90,9 +90,9 @@
</div>
<div class="row-fluid print-control">
<button class="btn btn-primary span4" data-bind="enable: isOperational() && isReady() && !isPrinting(), css: {'btn-danger': isPaused()}" id="job_print"><i class="icon-print icon-white"></i> <span data-bind="text: (isPaused() ? 'Restart' : 'Print')">Print</span></button>
<button class="btn span4" id="job_pause" data-bind="css: {active: isPaused}"><i class="icon-pause"></i> <span>Pause</span></button>
<button class="btn span4" id="job_cancel"><i class="icon-stop"></i> Cancel</button>
<button class="btn btn-primary span4" data-bind="click: print, enable: isOperational() && isReady() && !isPrinting(), css: {'btn-danger': isPaused()}" id="job_print"><i class="icon-white" data-bind="css: {'icon-print': !isPaused(), 'icon-undo': isPaused()}"></i> <span data-bind="text: (isPaused() ? 'Restart' : 'Print')">Print</span></button>
<button class="btn span4" id="job_pause" data-bind="click: pause, enable: isPrinting() || isPaused(), css: {active: isPaused()}"><i class="icon-pause"></i> <span>Pause</span></button>
<button class="btn span4" id="job_cancel" data-bind="click: cancel, enable: isPrinting() || isPaused()"><i class="icon-stop"></i> Cancel</button>
</div>
</div>
</div>