]>
Commit | Line | Data |
---|---|---|
68955dc1 | 1 | <template> |
2ca4faad BW |
2 | <Generic :item="item"> |
3 | <template #indicator> | |
4 | <div v-if="status" class="status" :class="status"> | |
5 | {{ status }} | |
6 | </div> | |
7 | </template> | |
8 | </Generic> | |
68955dc1 | 9 | </template> |
10 | ||
11 | <script> | |
2fba0435 | 12 | import service from "@/mixins/service.js"; |
2ca4faad BW |
13 | import Generic from "./Generic.vue"; |
14 | ||
68955dc1 | 15 | export default { |
16 | name: "Ping", | |
2fba0435 | 17 | mixins: [service], |
68955dc1 | 18 | props: { |
19 | item: Object, | |
20 | }, | |
2ca4faad BW |
21 | components: { |
22 | Generic, | |
23 | }, | |
68955dc1 | 24 | data: () => ({ |
3a8fa151 | 25 | status: null, |
68955dc1 | 26 | }), |
27 | created() { | |
28 | this.fetchStatus(); | |
29 | }, | |
30 | methods: { | |
31 | fetchStatus: async function () { | |
6c083d6a IS |
32 | const method = typeof this.item.method === 'string' && this.item.method.toLowerCase() === "get" ? "GET" : "HEAD" |
33 | this.fetch("/", { method, cache: "no-cache" }, false) | |
2fba0435 | 34 | .then(() => { |
3a8fa151 BW |
35 | this.status = "online"; |
36 | }) | |
37 | .catch(() => { | |
38 | this.status = "offline"; | |
39 | }); | |
68955dc1 | 40 | }, |
41 | }, | |
42 | }; | |
43 | </script> | |
44 | ||
45 | <style scoped lang="scss"> | |
68955dc1 | 46 | .status { |
47 | font-size: 0.8rem; | |
48 | color: var(--text-title); | |
6c083d6a IS |
49 | white-space: nowrap; |
50 | margin-left: 0.25rem; | |
68955dc1 | 51 | |
3a8fa151 | 52 | &.online:before { |
68955dc1 | 53 | background-color: #94e185; |
54 | border-color: #78d965; | |
3a8fa151 | 55 | box-shadow: 0 0 5px 1px #94e185; |
68955dc1 | 56 | } |
57 | ||
3a8fa151 | 58 | &.offline:before { |
68955dc1 | 59 | background-color: #c9404d; |
60 | border-color: #c42c3b; | |
3a8fa151 | 61 | box-shadow: 0 0 5px 1px #c9404d; |
68955dc1 | 62 | } |
63 | ||
64 | &:before { | |
65 | content: " "; | |
66 | display: inline-block; | |
67 | width: 7px; | |
68 | height: 7px; | |
69 | margin-right: 10px; | |
70 | border: 1px solid #000; | |
71 | border-radius: 7px; | |
72 | } | |
73 | } | |
74 | </style> |