23 changed files with 407 additions and 282 deletions
@ -1,67 +0,0 @@ |
|||
// @flow
|
|||
|
|||
import React, { PureComponent } from 'react' |
|||
import { translate } from 'react-i18next' |
|||
import logger from 'logger' |
|||
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
|||
|
|||
import type { Device, T } from 'types/common' |
|||
|
|||
import installFinalFirmware from 'commands/installFinalFirmware' |
|||
|
|||
import Box, { Card } from 'components/base/Box' |
|||
import Button from 'components/base/Button' |
|||
|
|||
type Props = { |
|||
t: T, |
|||
device: Device, |
|||
deviceInfo: DeviceInfo, |
|||
} |
|||
|
|||
type State = {} |
|||
|
|||
class FirmwareFinalUpdate extends PureComponent<Props, State> { |
|||
componentDidMount() {} |
|||
|
|||
componentWillUnmount() { |
|||
this._unmounting = true |
|||
} |
|||
|
|||
_unmounting = false |
|||
|
|||
installFinalFirmware = async () => { |
|||
try { |
|||
const { device, deviceInfo } = this.props |
|||
const { success } = await installFinalFirmware |
|||
.send({ |
|||
devicePath: device.path, |
|||
deviceInfo, |
|||
}) |
|||
.toPromise() |
|||
if (success) { |
|||
this.setState() |
|||
} |
|||
} catch (err) { |
|||
logger.log(err) |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
const { t, ...props } = this.props |
|||
|
|||
return ( |
|||
<Box flow={4} {...props}> |
|||
<Box color="dark" ff="Museo Sans" fontSize={6}> |
|||
{t('app:manager.firmware.update')} |
|||
</Box> |
|||
<Card flow={2} {...props}> |
|||
<Box horizontal align="center" flow={2}> |
|||
<Button onClick={this.installFinalFirmware}>Install Final Firmware</Button> |
|||
</Box> |
|||
</Card> |
|||
</Box> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default translate()(FirmwareFinalUpdate) |
@ -1,50 +0,0 @@ |
|||
// @flow
|
|||
import React, { PureComponent } from 'react' |
|||
|
|||
import type { Device } from 'types/common' |
|||
import installMcu from 'commands/installMcu' |
|||
|
|||
import type { DeviceInfo } from 'helpers/devices/getDeviceInfo' |
|||
|
|||
type Props = { |
|||
device: Device, |
|||
deviceInfo: DeviceInfo, |
|||
} |
|||
|
|||
type State = { |
|||
flashing: boolean, |
|||
} |
|||
|
|||
class FlashMcu extends PureComponent<Props, State> { |
|||
state = { |
|||
flashing: false, |
|||
} |
|||
|
|||
flashMCU = async () => { |
|||
const { device, deviceInfo } = this.props |
|||
const { flashing } = this.state |
|||
|
|||
if (!flashing) { |
|||
this.setState({ flashing: true }) |
|||
await installMcu |
|||
.send({ |
|||
devicePath: device.path, |
|||
targetId: deviceInfo.targetId, |
|||
version: deviceInfo.seVersion, |
|||
}) |
|||
.toPromise() |
|||
this.setState({ flashing: false }) |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
return ( |
|||
<div> |
|||
<h1>{'Flashing MCU'}</h1> |
|||
<button onClick={this.flashMCU}>{'flash'}</button> |
|||
</div> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default FlashMcu |
@ -0,0 +1,19 @@ |
|||
// @flow
|
|||
import network from 'api/network' |
|||
|
|||
import { GET_MCUS } from 'helpers/urls' |
|||
|
|||
export default async (): Promise<*> => { |
|||
try { |
|||
const { data } = await network({ |
|||
method: 'GET', |
|||
url: GET_MCUS, |
|||
}) |
|||
|
|||
return data |
|||
} catch (err) { |
|||
const error = Error(err.message) |
|||
error.stack = err.stack |
|||
throw err |
|||
} |
|||
} |
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
Loading…
Reference in new issue