diff --git a/build/browser/app.js b/build/browser/app.js index 36d5f843..956669cc 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -52,7 +52,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState this.restart = function() { console.debug('Restarting'); this.selection.clear(); - this.writer.setProgress(0); + this.writer.reset(); this.scanner.start(2000).on('scan', function(drives) { // Notice we only autoselect the drive if there is an image, @@ -374,6 +374,18 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { }; + /** + * @summary Reset progress state + * @function + * @public + * + * @example + * ImageWriterService.reset(); + */ + this.reset = function() { + self.setProgress(0); + }; + /** * @summary Check if currently burning * @function diff --git a/lib/browser/app.js b/lib/browser/app.js index 556949d4..d0450ef6 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -51,7 +51,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState this.restart = function() { console.debug('Restarting'); this.selection.clear(); - this.writer.setProgress(0); + this.writer.reset(); this.scanner.start(2000).on('scan', function(drives) { // Notice we only autoselect the drive if there is an image, diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js index 6fd3ef72..c4048a54 100644 --- a/lib/browser/modules/image-writer.js +++ b/lib/browser/modules/image-writer.js @@ -66,6 +66,18 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { }; + /** + * @summary Reset progress state + * @function + * @public + * + * @example + * ImageWriterService.reset(); + */ + this.reset = function() { + self.setProgress(0); + }; + /** * @summary Check if currently burning * @function diff --git a/tests/browser/modules/image-writer.spec.js b/tests/browser/modules/image-writer.spec.js index 774ab1d2..b79a75e8 100644 --- a/tests/browser/modules/image-writer.spec.js +++ b/tests/browser/modules/image-writer.spec.js @@ -77,6 +77,19 @@ describe('Browser: ImageWriter', function() { }); + describe('.reset()', function() { + + it('should reset progress percentage to 0', function() { + ImageWriterService.setProgress(50); + $timeout.flush(); + m.chai.expect(ImageWriterService.state.progress).to.equal(50); + ImageWriterService.reset(); + $timeout.flush(); + m.chai.expect(ImageWriterService.state.progress).to.equal(0); + }); + + }); + describe('.burn()', function() { describe('given a succesful write', function() {