Files
2017-09-18 16:10:38 -05:00

35 lines
775 B
JavaScript

import React from 'react';
import {Channel} from './Channel';
export class Device extends React.Component {
constructor(props){
super(props);
this.state = {channels: []};
}
componentWillMount(){
// console.log(nextProps);
this.setState({channels: this.props.channelStarter});
}
render(){
let t = this;
const channelList = this.props.values.sort((a, b) => {
return this.state.channels[a.channel].order - this.state.channels[b.channel].order;
}).map(function(ch, i){
return <Channel key={t.props.deviceId + "_channel_" + i}
name={ch.name}
timestamp={ch.timestamp}
value={ch.value} />
});
return (
<tr>
<td>{this.props.name}</td>
{channelList}
</tr>
);
}
}