From b3dde830833e8f7d26eba2d9959d25d69554f51f Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 19 Jan 2016 09:42:57 -0400 Subject: [PATCH 1/2] Implement removeDrive and removeImage in selection service --- build/browser/app.js | 24 +++++++++++++++++++ lib/browser/modules/selection-state.js | 24 +++++++++++++++++++ tests/browser/modules/selection-state.spec.js | 21 ++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/build/browser/app.js b/build/browser/app.js index 806df0db..cd95ccf5 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -669,6 +669,30 @@ selectionState.service('SelectionStateService', function() { return !!self.getImage(); }; + /** + * @summary Remove drive + * @function + * @public + * + * @example + * SelectionStateService.removeDrive(); + */ + this.removeDrive = function() { + self.setDrive(undefined); + }; + + /** + * @summary Remove image + * @function + * @public + * + * @example + * SelectionStateService.removeImage(); + */ + this.removeImage = function() { + self.setImage(undefined); + }; + /** * @summary Clear all selections * @function diff --git a/lib/browser/modules/selection-state.js b/lib/browser/modules/selection-state.js index 8b7b1788..567db922 100644 --- a/lib/browser/modules/selection-state.js +++ b/lib/browser/modules/selection-state.js @@ -123,6 +123,30 @@ selectionState.service('SelectionStateService', function() { return !!self.getImage(); }; + /** + * @summary Remove drive + * @function + * @public + * + * @example + * SelectionStateService.removeDrive(); + */ + this.removeDrive = function() { + self.setDrive(undefined); + }; + + /** + * @summary Remove image + * @function + * @public + * + * @example + * SelectionStateService.removeImage(); + */ + this.removeImage = function() { + self.setImage(undefined); + }; + /** * @summary Clear all selections * @function diff --git a/tests/browser/modules/selection-state.spec.js b/tests/browser/modules/selection-state.spec.js index 6f7a2140..f409ad50 100644 --- a/tests/browser/modules/selection-state.spec.js +++ b/tests/browser/modules/selection-state.spec.js @@ -78,6 +78,17 @@ describe('Browser: SelectionState', function() { }); + describe('.removeDrive()', function() { + + it('should clear the drive', function() { + SelectionStateService.removeDrive(); + var drive = SelectionStateService.getDrive(); + m.chai.expect(drive).to.be.undefined; + }); + + }); + + }); describe('given no drive', function() { @@ -128,6 +139,16 @@ describe('Browser: SelectionState', function() { }); + describe('.removeImage()', function() { + + it('should clear the image', function() { + SelectionStateService.removeImage(); + var image = SelectionStateService.getImage(); + m.chai.expect(image).to.be.undefined; + }); + + }); + }); describe('given no image', function() { From 8026cef1dfa2631f5b606e77c7f7b77db5ede85e Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 19 Jan 2016 09:44:48 -0400 Subject: [PATCH 2/2] Allow to re-select the first two step selections You can click on the selected image/drive label to select them again. The re-selection is disabled if there is a burning in process. Fixes: https://github.com/resin-io/resin-etcher/issues/90 --- build/browser/app.js | 23 +++++++++++++++++++++++ lib/browser/app.js | 23 +++++++++++++++++++++++ lib/index.html | 4 ++-- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/build/browser/app.js b/build/browser/app.js index cd95ccf5..b47084c1 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -93,6 +93,29 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState console.debug('Drive selected: ' + drive.device); }; + this.reselectImage = function() { + if (self.writer.isBurning()) { + return; + } + + // Reselecting an image automatically + // de-selects the current drive, if any. + // This is made so the user effectively + // "returns" to the first step. + self.selection.clear(); + + console.debug('Reselecting image'); + }; + + this.reselectDrive = function() { + if (self.writer.isBurning()) { + return; + } + + self.selection.removeDrive(); + console.debug('Reselecting drive'); + }; + this.burn = function(image, drive) { // Stop scanning drives when burning diff --git a/lib/browser/app.js b/lib/browser/app.js index d0450ef6..dad82f44 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -92,6 +92,29 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState console.debug('Drive selected: ' + drive.device); }; + this.reselectImage = function() { + if (self.writer.isBurning()) { + return; + } + + // Reselecting an image automatically + // de-selects the current drive, if any. + // This is made so the user effectively + // "returns" to the first step. + self.selection.clear(); + + console.debug('Reselecting image'); + }; + + this.reselectDrive = function() { + if (self.writer.isBurning()) { + return; + } + + self.selection.removeDrive(); + console.debug('Reselecting drive'); + }; + this.burn = function(image, drive) { // Stop scanning drives when burning diff --git a/lib/index.html b/lib/index.html index b28190e5..ffa9fa03 100644 --- a/lib/index.html +++ b/lib/index.html @@ -30,7 +30,7 @@ Select image
- +
@@ -67,7 +67,7 @@ -
+