aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
authorstubbfel <stubbfel@gmail.com>2021-06-28 23:20:20 +0200
committerGitHub <noreply@github.com>2021-06-28 23:20:20 +0200
commit68955dc1d3bff8ae0853fb8021cd6e28f31ac378 (patch)
treee6b8f39c503ace4dacc483f31fd30fdb20a7fbd4 /src/components
parent996011956b97566849167ccd6ec470ab38b0ec60 (diff)
downloadhomer-68955dc1d3bff8ae0853fb8021cd6e28f31ac378.tar.gz
homer-68955dc1d3bff8ae0853fb8021cd6e28f31ac378.tar.zst
homer-68955dc1d3bff8ae0853fb8021cd6e28f31ac378.zip
Add Ping services
a service (type) which check if the given url as available or not. if the service is available then set the status to enable other to disable
Diffstat (limited to 'src/components')
-rw-r--r--src/components/services/Ping.vue93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/components/services/Ping.vue b/src/components/services/Ping.vue
new file mode 100644
index 0000000..a9114a8
--- /dev/null
+++ b/src/components/services/Ping.vue
@@ -0,0 +1,93 @@
1<template>
2 <div>
3 <div class="card" :class="item.class">
4 <a :href="item.url" :target="item.target" rel="noreferrer">
5 <div class="card-content">
6 <div class="media">
7 <div v-if="item.logo" class="media-left">
8 <figure class="image is-48x48">
9 <img :src="item.logo" :alt="`${item.name} logo`" />
10 </figure>
11 </div>
12 <div v-if="item.icon" class="media-left">
13 <figure class="image is-48x48">
14 <i style="font-size: 35px" :class="['fa-fw', item.icon]"></i>
15 </figure>
16 </div>
17 <div class="media-content">
18 <p class="title is-4">{{ item.name }}</p>
19 <p class="subtitle is-6">
20 <template v-if="item.subtitle">
21 {{ item.subtitle }}
22 </template>
23 </p>
24 </div>
25 <div v-if="api" class="status" :class="api.status">
26 {{ api.status }}
27 </div>
28 </div>
29 <div class="tag" :class="item.tagstyle" v-if="item.tag">
30 <strong class="tag-text">#{{ item.tag }}</strong>
31 </div>
32 </div>
33 </a>
34 </div>
35 </div>
36</template>
37
38<script>
39export default {
40 name: "Ping",
41 props: {
42 item: Object,
43 },
44 data: () => ({
45 api: {
46 status: "",
47 },
48 }),
49 created() {
50 this.fetchStatus();
51 },
52 methods: {
53 fetchStatus: async function () {
54 const url = `${this.item.url}`;
55 this.api.status = await fetch(url)
56 .then((response) => "enabled")
57 .catch((e) => "disabled");
58 },
59 },
60};
61</script>
62
63<style scoped lang="scss">
64.media-left img {
65 max-height: 100%;
66}
67.status {
68 font-size: 0.8rem;
69 color: var(--text-title);
70
71 &.enabled:before {
72 background-color: #94e185;
73 border-color: #78d965;
74 box-shadow: 0 0 4px 1px #94e185;
75 }
76
77 &.disabled:before {
78 background-color: #c9404d;
79 border-color: #c42c3b;
80 box-shadow: 0 0 4px 1px #c9404d;
81 }
82
83 &:before {
84 content: " ";
85 display: inline-block;
86 width: 7px;
87 height: 7px;
88 margin-right: 10px;
89 border: 1px solid #000;
90 border-radius: 7px;
91 }
92}
93</style>