-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathuptime.js
More file actions
70 lines (61 loc) · 1.41 KB
/
uptime.js
File metadata and controls
70 lines (61 loc) · 1.41 KB
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
import os from 'os'
import React from 'react'
import Component from 'hyper/component'
import formatUptime from '../utils/time'
import SvgIcon from '../utils/svg-icon'
class PluginIcon extends Component {
render() {
return (
<SvgIcon>
<g fill="none" fillRule="evenodd">
<g
className='uptime-icon'
transform="translate(1.000000, 1.000000)"
>
<g>
<path d="M0,0 L14,0 L14,14 L0,14 L0,0 Z M1,1 L13,1 L13,13 L1,13 L1,1 Z" />
<path d="M6,2 L7,2 L7,7 L6,7 L6,2 Z M6,7 L10,7 L10,8 L6,8 L6,7 Z" />
</g>
</g>
</g>
<style jsx>{`
.uptime-icon {
fill: #fff;
}
`}</style>
</SvgIcon>
)
}
}
export default class Uptime extends Component {
static displayName() {
return 'uptime'
}
constructor(props) {
super(props)
this.state = {
uptime: this.getUptime()
}
}
componentDidMount() {
const uptime = this.getUptime()
// Recheck every 5 minutes
setInterval(() => this.setState({ uptime }), 60000 * 5)
}
getUptime() {
return formatUptime(os.uptime())
}
render() {
return (
<div className='wrapper'>
<PluginIcon /> {this.state.uptime}
<style jsx>{`
.wrapper {
display: flex;
align-items: center;
}
`}</style>
</div>
)
}
}