-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
100 lines (94 loc) · 2.19 KB
/
app.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
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
90
91
92
93
94
95
96
97
98
99
100
<template>
<v-app class="vapp-background">
<header-section :faucet-status="faucetStatus" :status-color="faucetStatusColor" :items="items"
v-model:selected="selected" />
<v-main class="main-container">
<v-container class="main-container">
<NuxtPage :selected="selected" />
</v-container>
</v-main>
<footer-section />
</v-app>
</template>
<script>
import HeaderSection from './components/HeaderSection.vue';
import FooterSection from './components/FooterSection.vue';
useHead({
title: 'Xion Testnet Faucet',
meta: [
{
name: 'description',
content: 'Xion Testnet Faucet',
},
{
name: 'keywords',
content: 'Xion, Testnet, Faucet',
},
],
});
export default {
name: 'DefaultLayout',
components: {
HeaderSection,
FooterSection,
},
data() {
return {
faucetStatus: '',
faucetStatusColor: '',
items: ['xion-testnet-1', "xion-testnet-2"],
selected: 'xion-testnet-2',
};
},
watch: {
selected(newValue) {
this.updateFaucetStatus();
},
selectedValue(newValue) {
this.$emit('update:selected', newValue);
}
},
mounted() {
this.startFaucetStatusPolling();
},
methods: {
async startFaucetStatusPolling() {
const interval = 30000;
await this.updateFaucetStatus();
setTimeout(() => {
this.startFaucetStatusPolling();
}, interval);
},
async updateFaucetStatus() {
try {
const status = await $fetch(`/api/status?chainId=${this.selected}`);
if (status.status === 'ok') {
this.faucetStatusColor = 'green';
this.faucetStatus = 'Operational';
return;
}
} catch (error) {
console.error('Error fetching status:', error);
}
this.faucetStatusColor = 'red';
this.faucetStatus = 'Down';
},
},
};
</script>
<style scoped>
.vapp-background {
background: url('./assets/img/bg4.png') no-repeat center center;
background-size: cover;
font-family: 'Nunito', sans-serif;
}
.main-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 75vh;
padding: 50px 0;
}
</style>