Alex Mikhalev
7 years ago
18 changed files with 124 additions and 34 deletions
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
import * as React from "react"; |
||||
import { Item, ItemImageProps } from "semantic-ui-react"; |
||||
|
||||
export default function DeviceImage(props: ItemImageProps) { |
||||
return <Item.Image {...props} src={require("@client/images/raspberry_pi.png")} />; |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
import { observer } from "mobx-react"; |
||||
import * as React from "react"; |
||||
import { Item } from "semantic-ui-react"; |
||||
|
||||
import { DeviceView } from "@client/components"; |
||||
import { AppState, injectState } from "@client/state"; |
||||
|
||||
class DevicesPage extends React.Component<{ appState: AppState }> { |
||||
render() { |
||||
const { appState } = this.props; |
||||
const { userData } = appState.userStore; |
||||
let deviceNodes: React.ReactNode; |
||||
if (!userData) { |
||||
deviceNodes = <span>Not logged in</span>; |
||||
} else if (!userData.devices || !userData.devices.length) { |
||||
deviceNodes = <span>You have no devices</span>; |
||||
} else { |
||||
deviceNodes = userData.devices.map((device) => ( |
||||
<DeviceView key={device.id} deviceId={device.id} inList /> |
||||
)); |
||||
} |
||||
return ( |
||||
<React.Fragment> |
||||
<h1>Devices</h1> |
||||
<Item.Group> |
||||
{deviceNodes} |
||||
</Item.Group> |
||||
</React.Fragment> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default injectState(observer(DevicesPage)); |
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
||||
import { IUser } from "@common/httpApi"; |
||||
import { observable } from "mobx"; |
||||
|
||||
export class UserStore { |
||||
@observable userData: any = null; |
||||
@observable userData: IUser | null = null; |
||||
} |
||||
|
Loading…
Reference in new issue