|
|
@ -1,7 +1,7 @@ |
|
|
|
import * as classNames from "classnames"; |
|
|
|
import * as classNames from "classnames"; |
|
|
|
import { observer } from "mobx-react"; |
|
|
|
import { observer } from "mobx-react"; |
|
|
|
import * as React from "react"; |
|
|
|
import * as React from "react"; |
|
|
|
import { Grid, Header, Icon, Item } from "semantic-ui-react"; |
|
|
|
import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react"; |
|
|
|
|
|
|
|
|
|
|
|
import { injectState, StateBase } from "@app/state"; |
|
|
|
import { injectState, StateBase } from "@app/state"; |
|
|
|
import { ConnectionState as ConState, SprinklersDevice } from "@common/sprinklers"; |
|
|
|
import { ConnectionState as ConState, SprinklersDevice } from "@common/sprinklers"; |
|
|
@ -13,12 +13,21 @@ const ConnectionState = observer(({ connectionState, className }: |
|
|
|
const connected = connectionState.isConnected; |
|
|
|
const connected = connectionState.isConnected; |
|
|
|
const classes = classNames({ |
|
|
|
const classes = classNames({ |
|
|
|
connectionState: true, |
|
|
|
connectionState: true, |
|
|
|
connected: connected, /* tslint:disable-line:object-literal-shorthand */ |
|
|
|
connected: connected === true, |
|
|
|
disconnected: !connected, |
|
|
|
disconnected: connected === false, |
|
|
|
|
|
|
|
unknown: connected === null, |
|
|
|
}, className); |
|
|
|
}, className); |
|
|
|
let connectionText: string; |
|
|
|
let connectionText: string; |
|
|
|
|
|
|
|
let iconName: SemanticICONS = "unlinkify"; |
|
|
|
if (connected) { |
|
|
|
if (connected) { |
|
|
|
connectionText = "Connected"; |
|
|
|
connectionText = "Connected"; |
|
|
|
|
|
|
|
iconName = "linkify"; |
|
|
|
|
|
|
|
} else if (connected === null) { |
|
|
|
|
|
|
|
connectionText = "Unknown"; |
|
|
|
|
|
|
|
iconName = "question"; |
|
|
|
|
|
|
|
} else if (connectionState.noPermission) { |
|
|
|
|
|
|
|
connectionText = "No permission for this device"; |
|
|
|
|
|
|
|
iconName = "ban"; |
|
|
|
} else if (connectionState.serverToBroker) { |
|
|
|
} else if (connectionState.serverToBroker) { |
|
|
|
connectionText = "Device Disconnected"; |
|
|
|
connectionText = "Device Disconnected"; |
|
|
|
} else if (connectionState.clientToServer) { |
|
|
|
} else if (connectionState.clientToServer) { |
|
|
@ -28,7 +37,7 @@ const ConnectionState = observer(({ connectionState, className }: |
|
|
|
} |
|
|
|
} |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className={classes}> |
|
|
|
<div className={classes}> |
|
|
|
<Icon name={connected ? "linkify" : "unlinkify"}/> |
|
|
|
<Icon name={iconName}/> |
|
|
|
{connectionText} |
|
|
|
{connectionText} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
@ -64,7 +73,9 @@ class DeviceView extends React.Component<DeviceViewProps> { |
|
|
|
<Item.Meta> |
|
|
|
<Item.Meta> |
|
|
|
Raspberry Pi Grinklers Device |
|
|
|
Raspberry Pi Grinklers Device |
|
|
|
</Item.Meta> |
|
|
|
</Item.Meta> |
|
|
|
<SectionRunnerView sectionRunner={sectionRunner} sections={sections}/> |
|
|
|
{connectionState.isAvailable && |
|
|
|
|
|
|
|
<SectionRunnerView sectionRunner={sectionRunner} sections={sections}/>} |
|
|
|
|
|
|
|
{connectionState.isAvailable && |
|
|
|
<Grid> |
|
|
|
<Grid> |
|
|
|
<Grid.Column mobile="16" tablet="16" computer="8"> |
|
|
|
<Grid.Column mobile="16" tablet="16" computer="8"> |
|
|
|
<SectionTable sections={sections}/> |
|
|
|
<SectionTable sections={sections}/> |
|
|
@ -73,7 +84,10 @@ class DeviceView extends React.Component<DeviceViewProps> { |
|
|
|
<RunSectionForm device={this.device} uiStore={uiStore}/> |
|
|
|
<RunSectionForm device={this.device} uiStore={uiStore}/> |
|
|
|
</Grid.Column> |
|
|
|
</Grid.Column> |
|
|
|
</Grid> |
|
|
|
</Grid> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
{connectionState.isAvailable && |
|
|
|
<ProgramTable programs={programs} sections={sections}/> |
|
|
|
<ProgramTable programs={programs} sections={sections}/> |
|
|
|
|
|
|
|
} |
|
|
|
</Item.Content> |
|
|
|
</Item.Content> |
|
|
|
</Item> |
|
|
|
</Item> |
|
|
|
); |
|
|
|
); |
|
|
|