|
@ -33,28 +33,38 @@ class RepairDeviceButton extends PureComponent<Props, State> { |
|
|
progress: 0, |
|
|
progress: 0, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
|
|
|
if (this.timeout) { |
|
|
|
|
|
clearTimeout(this.timeout) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
open = () => this.setState({ opened: true, error: null }) |
|
|
open = () => this.setState({ opened: true, error: null }) |
|
|
|
|
|
|
|
|
sub: * |
|
|
sub: * |
|
|
|
|
|
timeout: * |
|
|
|
|
|
|
|
|
close = () => { |
|
|
close = () => { |
|
|
if (this.sub) this.sub.unsubscribe() |
|
|
if (this.sub) this.sub.unsubscribe() |
|
|
|
|
|
if (this.timeout) clearTimeout(this.timeout) |
|
|
this.setState({ opened: false, isLoading: false, error: null, progress: 0 }) |
|
|
this.setState({ opened: false, isLoading: false, error: null, progress: 0 }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
repair = (version = null) => { |
|
|
repair = (version = null) => { |
|
|
if (this.state.isLoading) return |
|
|
if (this.state.isLoading) return |
|
|
const { push } = this.props |
|
|
const { push } = this.props |
|
|
this.setState({ isLoading: true }) |
|
|
this.timeout = setTimeout(() => this.setState({ isLoading: true }), 500) |
|
|
this.sub = firmwareRepair.send({ version }).subscribe({ |
|
|
this.sub = firmwareRepair.send({ version }).subscribe({ |
|
|
next: patch => { |
|
|
next: patch => { |
|
|
this.setState(patch) |
|
|
this.setState(patch) |
|
|
}, |
|
|
}, |
|
|
error: error => { |
|
|
error: error => { |
|
|
logger.critical(error) |
|
|
logger.critical(error) |
|
|
|
|
|
if (this.timeout) clearTimeout(this.timeout) |
|
|
this.setState({ error, isLoading: false, progress: 0 }) |
|
|
this.setState({ error, isLoading: false, progress: 0 }) |
|
|
}, |
|
|
}, |
|
|
complete: () => { |
|
|
complete: () => { |
|
|
|
|
|
if (this.timeout) clearTimeout(this.timeout) |
|
|
this.setState({ opened: false, isLoading: false, progress: 0 }, () => { |
|
|
this.setState({ opened: false, isLoading: false, progress: 0 }, () => { |
|
|
push('/manager') |
|
|
push('/manager') |
|
|
}) |
|
|
}) |
|
|