diff --git a/src/octoprint/server/api/timelapse.py b/src/octoprint/server/api/timelapse.py index 33b3bddd..872b204f 100644 --- a/src/octoprint/server/api/timelapse.py +++ b/src/octoprint/server/api/timelapse.py @@ -66,7 +66,8 @@ def getTimelapseData(): config = dict(type="timed", postRoll=timelapse.post_roll, fps=timelapse.fps, - interval=timelapse.interval) + interval=timelapse.interval, + capturePostRoll=timelapse.capture_post_roll) else: config = dict(type="off") @@ -204,6 +205,16 @@ def setTimelapseConfig(): else: return make_response("Invalid value for interval: %d" % interval) + if "capturePostRoll" in data: + config["options"]["capturePostRoll"] = True + try: + capturePostRoll = bool(data["capturePostRoll"]) + except ValueError: + return make_response("Invalid value for capturePostRoll: %r" % data["capturePostRoll"]) + else: + config["options"]["capturePostRoll"] = capturePostRoll + + if "retractionZHop" in request.values: config["options"] = { "retractionZHop": 0 @@ -219,6 +230,7 @@ def setTimelapseConfig(): else: return make_response("Invalid value for retraction Z-Hop: %d" % retractionZHop) + if admin_permission.can() and "save" in data and data["save"] in valid_boolean_trues: octoprint.timelapse.configure_timelapse(config, True) else: diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index bf0ac119..ddf5aabd 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -166,7 +166,8 @@ default_settings = { "type": "off", "options": {}, "postRoll": 0, - "fps": 25 + "fps": 25, + "capturePostRoll": True }, "cleanTmpAfterDays": 7 }, diff --git a/src/octoprint/static/js/app/viewmodels/timelapse.js b/src/octoprint/static/js/app/viewmodels/timelapse.js index a7230d89..f50b6da1 100644 --- a/src/octoprint/static/js/app/viewmodels/timelapse.js +++ b/src/octoprint/static/js/app/viewmodels/timelapse.js @@ -10,12 +10,14 @@ $(function() { self.defaultPostRoll = 0; self.defaultInterval = 10; self.defaultRetractionZHop = 0; + self.defaultCapturePostroll = true; self.timelapseType = ko.observable(undefined); self.timelapseTimedInterval = ko.observable(self.defaultInterval); self.timelapsePostRoll = ko.observable(self.defaultPostRoll); self.timelapseFps = ko.observable(self.defaultFps); self.timelapseRetractionZHop = ko.observable(self.defaultRetractionZHop); + self.timelapseCapturePostRoll = ko.observable(self.defaultCapturePostRoll); self.persist = ko.observable(false); self.isDirty = ko.observable(false); @@ -61,6 +63,9 @@ $(function() { self.timelapseRetractionZHop.subscribe(function(newValue) { self.isDirty(true); }); + self.timelapseCapturePostRoll.subscribe(function() { + self.isDirty(true); + }); // initialize list helper self.listHelper = new ItemListHelper( @@ -167,6 +172,12 @@ $(function() { self.timelapseFps(self.defaultFps); } + if (config.capturePostRoll != undefined){ + self.timelapseCapturePostRoll(config.capturePostRoll); + } else { + self.timelapseCapturePostRoll(self.defaultCapturePostRoll); + } + self.persist(false); self.isDirty(false); }; @@ -214,6 +225,7 @@ $(function() { if (self.timelapseType() == "timed") { payload["interval"] = self.timelapseTimedInterval(); + payload["capturePostRoll"] = self.timelapseCapturePostRoll(); } if (self.timelapseType() == "zchange") { diff --git a/src/octoprint/templates/tabs/timelapse.jinja2 b/src/octoprint/templates/tabs/timelapse.jinja2 index 041c3bc3..e01f4ebe 100644 --- a/src/octoprint/templates/tabs/timelapse.jinja2 +++ b/src/octoprint/templates/tabs/timelapse.jinja2 @@ -24,6 +24,12 @@ {{ _('sec') }} +