From 3705d0fc3a56b6b632a3a40a7a2cd31136a0b295 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 1 Jan 2016 16:13:29 -0400 Subject: [PATCH] Namespace ImageWriter progress in state object This change allows us to scale the state information to more properties than just the percentage. --- build/browser/app.js | 22 +++++++++++++--------- lib/browser/modules/image-writer.js | 22 +++++++++++++--------- lib/index.html | 16 ++++++++-------- tests/browser/modules/image-writer.spec.js | 6 +++--- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/build/browser/app.js b/build/browser/app.js index 15ad827d..36d5f843 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -343,12 +343,16 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { var self = this; var burning = false; - /** - * @summary Progress percentage - * @type Number - * @public - */ - this.progress = 0; + this.state = { + + /** + * @summary Progress percentage + * @type Number + * @public + */ + progress: 0 + + }; /** * @summary Set progress percentage @@ -364,8 +368,8 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { // Safely bring the state to the world of Angular $timeout(function() { - self.progress = Math.floor(progress); - console.debug('Progress: ' + self.progress); + self.state.progress = Math.floor(progress); + console.debug('Progress: ' + self.state.progress); }); }; @@ -431,7 +435,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * @public * * @description - * This function will update `.progress` with the current writing percentage. + * This function will update `state.progress` with the current writing percentage. * * @param {String} image - image path * @param {Object} drive - drive diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js index 86120e40..6fd3ef72 100644 --- a/lib/browser/modules/image-writer.js +++ b/lib/browser/modules/image-writer.js @@ -35,12 +35,16 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { var self = this; var burning = false; - /** - * @summary Progress percentage - * @type Number - * @public - */ - this.progress = 0; + this.state = { + + /** + * @summary Progress percentage + * @type Number + * @public + */ + progress: 0 + + }; /** * @summary Set progress percentage @@ -56,8 +60,8 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { // Safely bring the state to the world of Angular $timeout(function() { - self.progress = Math.floor(progress); - console.debug('Progress: ' + self.progress); + self.state.progress = Math.floor(progress); + console.debug('Progress: ' + self.state.progress); }); }; @@ -123,7 +127,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * @public * * @description - * This function will update `.progress` with the current writing percentage. + * This function will update `state.progress` with the current writing percentage. * * @param {String} image - image path * @param {Object} drive - drive diff --git a/lib/index.html b/lib/index.html index bae6774a..3bf32e5b 100644 --- a/lib/index.html +++ b/lib/index.html @@ -19,7 +19,7 @@
-
+
@@ -76,21 +76,21 @@ 3
- - Finishing... - Burn! - Starting... - + Finishing... + Burn! + Starting... +
-
+

Burn Complete!

diff --git a/tests/browser/modules/image-writer.spec.js b/tests/browser/modules/image-writer.spec.js index fb5651cd..774ab1d2 100644 --- a/tests/browser/modules/image-writer.spec.js +++ b/tests/browser/modules/image-writer.spec.js @@ -23,7 +23,7 @@ describe('Browser: ImageWriter', function() { })); it('should set progress to zero by default', function() { - m.chai.expect(ImageWriterService.progress).to.equal(0); + m.chai.expect(ImageWriterService.state.progress).to.equal(0); }); describe('.isBurning()', function() { @@ -66,13 +66,13 @@ describe('Browser: ImageWriter', function() { it('should be able to set the progress', function() { ImageWriterService.setProgress(50); $timeout.flush(); - m.chai.expect(ImageWriterService.progress).to.equal(50); + m.chai.expect(ImageWriterService.state.progress).to.equal(50); }); it('should floor the percentage', function() { ImageWriterService.setProgress(49.9999); $timeout.flush(); - m.chai.expect(ImageWriterService.progress).to.equal(49); + m.chai.expect(ImageWriterService.state.progress).to.equal(49); }); });