-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathstatus_indicator.vue
46 lines (43 loc) · 1.23 KB
/
status_indicator.vue
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
<template>
<span ref="dot"
@mouseenter="tooltipShow"
@mouseleave="tooltipHide"
></span>
</template>
<script>
import tlite from 'tlite';
import status from '../util/statuspage_status';
export default {
name: 'StatusIndicator',
props: {
pageId: String,
},
data () {
return {
status: null,
};
},
async mounted () {
// Fetch initial status
await this.updateStatus();
// Refresh every five minutes
setInterval(() => {
this.updateStatus();
}, 5 * 60 * 1000);
},
methods: {
async updateStatus () {
const data = await status(this.$props.pageId);
this.$data.status = data.status;
this.$refs.dot.className = `status-indicator status-indicator-${data.status.indicator}`;
},
tooltipShow (evt) {
evt.target.setAttribute('data-tlite', this.$data.status.description);
tlite.show(evt.target);
},
tooltipHide (evt) {
tlite.hide(evt.target);
},
},
};
</script>