mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-18 16:56:32 +00:00
Add button to burn the same image again. Fixes #74
This commit is contained in:
parent
1f3baf3f4d
commit
6331ee4aa1
@ -51,9 +51,9 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
|
|||||||
this.writer = ImageWriterService;
|
this.writer = ImageWriterService;
|
||||||
this.scanner = DriveScannerService;
|
this.scanner = DriveScannerService;
|
||||||
|
|
||||||
this.restart = function() {
|
this.restart = function(options) {
|
||||||
LoggerService.debug('Restarting');
|
LoggerService.debug('Restarting');
|
||||||
this.selection.clear();
|
this.selection.clear(options);
|
||||||
this.writer.reset();
|
this.writer.reset();
|
||||||
this.scanner.start(2000).on('scan', function(drives) {
|
this.scanner.start(2000).on('scan', function(drives) {
|
||||||
|
|
||||||
@ -643,6 +643,7 @@ pathModule.filter('basename', function() {
|
|||||||
* @module ResinEtcher.selection-state
|
* @module ResinEtcher.selection-state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var _ = require('lodash');
|
||||||
var angular = require('angular');
|
var angular = require('angular');
|
||||||
var selectionState = angular.module('ResinEtcher.selection-state', []);
|
var selectionState = angular.module('ResinEtcher.selection-state', []);
|
||||||
|
|
||||||
@ -773,20 +774,30 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Clear all selections
|
* @summary Clear selections
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
|
* @param {Object} options - options
|
||||||
|
* @param {Boolean} [options.preserveImage] - preserve image
|
||||||
|
*
|
||||||
* @example
|
* @example
|
||||||
* SelectionStateService.clear();
|
* SelectionStateService.clear();
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* SelectionStateService.clear({ preserveImage: true });
|
||||||
*/
|
*/
|
||||||
this.clear = function() {
|
this.clear = function(options) {
|
||||||
selection = {};
|
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');
|
require('./ui-bootstrap-tpls');
|
||||||
module.exports = 'ui.bootstrap';
|
module.exports = 'ui.bootstrap';
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
|
|||||||
this.writer = ImageWriterService;
|
this.writer = ImageWriterService;
|
||||||
this.scanner = DriveScannerService;
|
this.scanner = DriveScannerService;
|
||||||
|
|
||||||
this.restart = function() {
|
this.restart = function(options) {
|
||||||
LoggerService.debug('Restarting');
|
LoggerService.debug('Restarting');
|
||||||
this.selection.clear();
|
this.selection.clear(options);
|
||||||
this.writer.reset();
|
this.writer.reset();
|
||||||
this.scanner.start(2000).on('scan', function(drives) {
|
this.scanner.start(2000).on('scan', function(drives) {
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* @module ResinEtcher.selection-state
|
* @module ResinEtcher.selection-state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var _ = require('lodash');
|
||||||
var angular = require('angular');
|
var angular = require('angular');
|
||||||
var selectionState = angular.module('ResinEtcher.selection-state', []);
|
var selectionState = angular.module('ResinEtcher.selection-state', []);
|
||||||
|
|
||||||
@ -148,15 +149,25 @@ selectionState.service('SelectionStateService', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Clear all selections
|
* @summary Clear selections
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
|
* @param {Object} options - options
|
||||||
|
* @param {Boolean} [options.preserveImage] - preserve image
|
||||||
|
*
|
||||||
* @example
|
* @example
|
||||||
* SelectionStateService.clear();
|
* SelectionStateService.clear();
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* SelectionStateService.clear({ preserveImage: true });
|
||||||
*/
|
*/
|
||||||
this.clear = function() {
|
this.clear = function(options) {
|
||||||
selection = {};
|
if (options && options.preserveImage) {
|
||||||
|
selection = _.pick(selection, 'image');
|
||||||
|
} else {
|
||||||
|
selection = {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,10 +15,8 @@
|
|||||||
<script src="../build/browser/app.js"></script>
|
<script src="../build/browser/app.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body ng-app="ResinEtcher" ng-controller="AppController as app" style="display: none">
|
<body ng-app="ResinEtcher" ng-controller="AppController as app" style="display: none">
|
||||||
|
|
||||||
<div class="content row middle-xs space-horizontal-large">
|
<div class="content row middle-xs space-horizontal-large">
|
||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
|
|
||||||
<div class="row around-xs space-bottom-huge" ng-hide="app.writer.state.progress == 100 && !app.writer.isBurning()">
|
<div class="row around-xs space-bottom-huge" ng-hide="app.writer.state.progress == 100 && !app.writer.isBurning()">
|
||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
<div class="box text-center">
|
<div class="box text-center">
|
||||||
@ -100,9 +98,13 @@
|
|||||||
<p class="soft">Safely ejected and ready for use</p>
|
<p class="soft">Safely ejected and ready for use</p>
|
||||||
|
|
||||||
<div class="space-vertical-large">
|
<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>
|
<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>
|
</hero-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -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;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user