This repository has been archived by the owner on Jul 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Listitem.js
89 lines (77 loc) · 2.55 KB
/
Listitem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React, { Component } from 'react';
import Phone from './img/icons8-android.png';
import NodePict from './img/icons8-blockchain_technology.png';
import Arduinoicon from './img/icons8-arduino.png';
import './css/Dashboard.css'
var type;
var data;
class Listitem extends Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleChange2 = this.handleChange2.bind(this);
this.handleChange3 = this.handleChange3.bind(this);
if(this.props.type) type = this.props.type;
}
handleChange(e) {
this.props.onClick(this.props.dd[0]);
console.log(this.props.dd[0]);
}
handleChange2(e) {
this.props.onClick(this.props.nd[0]);
console.log(this.props.nd[0]);
}
handleChange3(e) {
this.props.onClick(this.props.hd);
console.log(this.props.hd);
}
render() {
switch(type) {
case "Device": data=(
<div onClick={this.handleChange} value={this.props.dd[1]} className="Device">
<a>
<img src={Phone} alt="Phone" />
<p>
<span>{this.props.dd[1]}</span>
<br/>
{this.props.dd[2].substr(1, 30)}...
</p>
</a>
</div>);
break;
case "Sensor": data=(
<div className="Sensor"><img src={Arduinoicon} alt="Arduino" />
<p>
<span>{this.props.sd}</span> <br />
SENSOR</p>
</div>);
break;
case "Node": data=(
<div onClick={this.handleChange2} className="Node">
<img src={NodePict} alt="Node" />
<p>
<a>
<span>{this.props.nd[1]}</span> <br />
{this.props.nd[2].substr(1, 30)}...
</a>
</p>
</div>);
break;
case "Tran" : data=(
<div onClick={this.handleChange3} className="Node">
<p>
<a>
<span>{this.props.hd}</span>
</a>
</p>
</div>);
break;
default:
data= (<div></div>);
}
return (
data
);
}
}
export default Listitem;