sensor list

This commit is contained in:
insanity 2017-06-11 18:32:37 +09:00
parent cc9360b1c2
commit 895b113359

View File

@ -13,7 +13,7 @@ export class Sensors extends React.Component<any, any> {
super(props, context);
this.state = {
sensors: [],
test: {},
sensorItems: {},
};
}
@ -56,31 +56,32 @@ export class Sensors extends React.Component<any, any> {
getSensorItems(sensor: any) {
var nested = Array();
let os: OFRest = new OFRest("SensorItemMapping", "List", sensor);
var that: any = this;
os.Call().then(function (res) {
return res.json();
}).then(function (json) {
var list = JSON.parse(json.resultStr);
if (list.length !== 0) {
that.sensorMap[sensor.id] = list;
that.setState({
test: that.sensorMap,
sensorItems: that.sensorMap,
});
}
}).catch(function (err) {
console.log(err);
});
}
getItems = (sensor:any) => {
getItems = (sensor: any) => {
let arr = Array();
let list = this.state.test[sensor.id];
if(list === undefined || list.length === 0 || list === null) {
let list = this.state.sensorItems[sensor.id];
if (list === undefined || list.length === 0 || list === null) {
return arr;
}
for(var i=0;i<list.length;i++){
console.log(list[i]);
arr.push(<ListItem key={i} primaryText={list[i].sensorItem.name}/>);
for (var i = 0; i < list.length; i++) {
arr.push(<ListItem key={i} primaryText={list[i].sensorItem.name} />);
}
return arr;