sensor list
This commit is contained in:
parent
cc9360b1c2
commit
895b113359
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user