fix error

This commit is contained in:
Jay
2017-04-10 17:56:08 +08:00
parent 5c02a34897
commit 6e0f6faa25
3 changed files with 45 additions and 17 deletions
@@ -1,11 +1,11 @@
import React from 'react';
import {Table} from 'semantic-ui-react';
import {convertTime} from '../../../../tools';
import {convertTime, padding} from '../../../../tools';
const ListItem = ({i18n, data}) => {
return (
<Table.Row>
<Table.Row style={{color: padding(data.timestamp, 13, 1, '0') < (Date.now() - 60000) ? '#f00' : 'inherit'}}>
<Table.Cell>{data.wristband}</Table.Cell>
<Table.Cell>{data.name}</Table.Cell>
<Table.Cell>{data.locname}</Table.Cell>
@@ -1,10 +1,14 @@
import React from 'react';
import {Grid, Header, Container, Segment, List, Label} from 'semantic-ui-react';
import {getRequest} from '../../../../actions';
import {padding} from '../../../../tools'
class LocStatusWloc extends React.Component {
state = {
loc: []
loc: [],
ui: {
colLoading: false
}
}
tick = null
@@ -30,6 +34,10 @@ class LocStatusWloc extends React.Component {
this.setState({
loc: json.data.record || []
}, ()=>{
this.setState({
ui:{
colLoading: true
}}, ()=>{})
this.getStatus();
this.tick = setInterval(this.runTick, 5000);
})
@@ -38,6 +46,7 @@ class LocStatusWloc extends React.Component {
getStatus = () => {
let {toggleLoading, showDialog} = this.props;
fetch('/api/wristband/getstatus', getRequest())
.then(response=>response.json())
.then(json => {
@@ -58,7 +67,10 @@ class LocStatusWloc extends React.Component {
}
this.setState({
loc: locs
loc: locs,
ui:{
colLoading: false
}
})
})
}
@@ -72,20 +84,21 @@ class LocStatusWloc extends React.Component {
this.state.loc.map((t,idx) => (
<Grid.Column key={idx} className="clearfix" >
<Header as="h5" content={t.name} />
<Segment style={{height: '400px', overflow: 'auto'}}>
<Segment style={{height: '400px', overflow: 'auto'}} loading={this.state.ui.colLoading}>
<List>
{
t.list ?
t.list.map((tt, idx) => (
<List.Item key={idx}>
t.list.map((tt, idx) => {
let isExpire = padding(tt.timestamp, 13, 1, '0') < (Date.now() - 60000) ? true : false;
return (<List.Item key={idx}>
{
tt.name ? (
<Label basic color="blue" size="tiny" content={tt.name}/>
<Label basic color={isExpire ? 'red' : 'blue'} size="tiny" content={tt.name}/>
) : null
}
<Label basic color="teal" size="tiny" content={tt.mac}/>
</List.Item>
))
<Label basic color={isExpire ? 'red' : 'teal'} size="tiny" content={tt.mac}/>
</List.Item>)
})
: null
}
</List>