Add button to burn the same image again. Fixes #74

This commit is contained in:
Federico Martín Alconada Verzini 2016-01-18 15:21:29 -03:00 committed by Juan Cruz Viotti
parent 1f3baf3f4d
commit 6331ee4aa1
5 changed files with 67 additions and 15 deletions

View File

@ -51,9 +51,9 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.writer = ImageWriterService;
this.scanner = DriveScannerService;
this.restart = function() {
this.restart = function(options) {
LoggerService.debug('Restarting');
this.selection.clear();
this.selection.clear(options);
this.writer.reset();
this.scanner.start(2000).on('scan', function(drives) {
@ -643,6 +643,7 @@ pathModule.filter('basename', function() {
* @module ResinEtcher.selection-state
*/
var _ = require('lodash');
var angular = require('angular');
var selectionState = angular.module('ResinEtcher.selection-state', []);
@ -773,20 +774,30 @@ selectionState.service('SelectionStateService', function() {
};
/**
* @summary Clear all selections
* @summary Clear selections
* @function
* @public
*
* @param {Object} options - options
* @param {Boolean} [options.preserveImage] - preserve image
*
* @example
* SelectionStateService.clear();
*
* @example
* SelectionStateService.clear({ preserveImage: true });
*/
this.clear = function() {
selection = {};
this.clear = function(options) {
if (options && options.preserveImage) {
selection = _.pick(selection, 'image');
} else {
selection = {};
}
};
});
},{"angular":10}],7:[function(require,module,exports){
},{"angular":10,"lodash":11}],7:[function(require,module,exports){
require('./ui-bootstrap-tpls');
module.exports = 'ui.bootstrap';

View File

@ -50,9 +50,9 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
this.writer = ImageWriterService;
this.scanner = DriveScannerService;
this.restart = function() {
this.restart = function(options) {
LoggerService.debug('Restarting');
this.selection.clear();
this.selection.clear(options);
this.writer.reset();
this.scanner.start(2000).on('scan', function(drives) {

View File

@ -18,6 +18,7 @@
* @module ResinEtcher.selection-state
*/
var _ = require('lodash');
var angular = require('angular');
var selectionState = angular.module('ResinEtcher.selection-state', []);
@ -148,15 +149,25 @@ selectionState.service('SelectionStateService', function() {
};
/**
* @summary Clear all selections
* @summary Clear selections
* @function
* @public
*
* @param {Object} options - options
* @param {Boolean} [options.preserveImage] - preserve image
*
* @example
* SelectionStateService.clear();
*
* @example
* SelectionStateService.clear({ preserveImage: true });
*/
this.clear = function() {
selection = {};
this.clear = function(options) {
if (options && options.preserveImage) {
selection = _.pick(selection, 'image');
} else {
selection = {};
}
};
});

View File

@ -15,10 +15,8 @@
<script src="../build/browser/app.js"></script>
</head>
<body ng-app="ResinEtcher" ng-controller="AppController as app" style="display: none">
<div class="content row middle-xs space-horizontal-large">
<div class="col-xs">
<div class="row around-xs space-bottom-huge" ng-hide="app.writer.state.progress == 100 && !app.writer.isBurning()">
<div class="col-xs">
<div class="box text-center">
@ -100,9 +98,13 @@
<p class="soft">Safely ejected and ready for use</p>
<div class="space-vertical-large">
<hero-button ng-click="app.restart()">
<hero-button ng-click="app.restart({ preserveImage: true })">
<span class="glyphicon glyphicon-repeat" aria-hidden="true"></span>
Lets do it again
Burn image again
</hero-button>
<hero-button ng-click="app.restart()">
<span class="glyphicon glyphicon-cd" aria-hidden="true"></span>
Burn another image
</hero-button>
</div>
</div>

View File

@ -186,6 +186,34 @@ describe('Browser: SelectionState', function() {
});
describe('given the preserveImage option', function() {
beforeEach(function() {
SelectionStateService.clear({ preserveImage: true });
});
it('getDrive() should return undefined', function() {
var drive = SelectionStateService.getDrive();
m.chai.expect(drive).to.be.undefined;
});
it('getImage() should return the image', function() {
var image = SelectionStateService.getImage();
m.chai.expect(image).to.equal('foo.img');
});
it('hasDrive() should return false', function() {
var hasDrive = SelectionStateService.hasDrive();
m.chai.expect(hasDrive).to.be.false;
});
it('hasImage() should return true', function() {
var hasImage = SelectionStateService.hasImage();
m.chai.expect(hasImage).to.be.true;
});
});
});
});