From 34a860efda3898b34654b080d633f2ac21b9ffe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 10 Apr 2013 16:37:12 +0200 Subject: [PATCH] Added confirmation dialog and different logo for print job restart Closes #98 --- octoprint/static/js/ui.js | 60 ++++++++++++++++++++-------------- octoprint/templates/index.html | 6 ++-- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/octoprint/static/js/ui.js b/octoprint/static/js/ui.js index 9009ce0..2164006 100644 --- a/octoprint/static/js/ui.js +++ b/octoprint/static/js/ui.js @@ -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() { diff --git a/octoprint/templates/index.html b/octoprint/templates/index.html index 2279c9c..dc370ee 100644 --- a/octoprint/templates/index.html +++ b/octoprint/templates/index.html @@ -90,9 +90,9 @@