mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 05:36:34 +00:00
Implement ImageWriterService.reset()
This function allows the client to easily reset the progress state without breaking encapsulation.
This commit is contained in:
parent
3705d0fc3a
commit
e30de45707
@ -52,7 +52,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
|
|||||||
this.restart = function() {
|
this.restart = function() {
|
||||||
console.debug('Restarting');
|
console.debug('Restarting');
|
||||||
this.selection.clear();
|
this.selection.clear();
|
||||||
this.writer.setProgress(0);
|
this.writer.reset();
|
||||||
this.scanner.start(2000).on('scan', function(drives) {
|
this.scanner.start(2000).on('scan', function(drives) {
|
||||||
|
|
||||||
// Notice we only autoselect the drive if there is an image,
|
// 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
|
* @summary Check if currently burning
|
||||||
* @function
|
* @function
|
||||||
|
@ -51,7 +51,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState
|
|||||||
this.restart = function() {
|
this.restart = function() {
|
||||||
console.debug('Restarting');
|
console.debug('Restarting');
|
||||||
this.selection.clear();
|
this.selection.clear();
|
||||||
this.writer.setProgress(0);
|
this.writer.reset();
|
||||||
this.scanner.start(2000).on('scan', function(drives) {
|
this.scanner.start(2000).on('scan', function(drives) {
|
||||||
|
|
||||||
// Notice we only autoselect the drive if there is an image,
|
// Notice we only autoselect the drive if there is an image,
|
||||||
|
@ -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
|
* @summary Check if currently burning
|
||||||
* @function
|
* @function
|
||||||
|
@ -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('.burn()', function() {
|
||||||
|
|
||||||
describe('given a succesful write', function() {
|
describe('given a succesful write', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user