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