forked from kvant-development/kvant-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
263 lines (241 loc) · 9.95 KB
/
index.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>KVANT Node GUI</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.1/css/all.css" integrity="sha384-O8whS3fhG2OnA5Kas0Y9l3cfpmYjapjI0E4theH4iuMD+pLhbf6JI0jIMfYcK3yZ" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>
<style>
.card {
margin-bottom: 20px;
}
html,body,.body,#app {
min-height: 100%;
}
.body {
padding-top: 15px;
}
.table {
margin-bottom: 0;
table-layout: fixed;
}
.card-header {
font-weight: bold;
}
.card-header {
padding-left: 12px;
}
.h {
width: 200px;
background-color: #f3f3f3;
border-right: 1px solid #ccc;
}
.bg-success, .bg-danger {
color: white;
}
.bg-danger {
border-color: #dc3545 !important;
}
.bg-success {
border-color: #28a745 !important;
}
.fa-check {
color: green;
}
.fa-exclamation-circle {
color: red;
}
</style>
</head>
<body style="background-color: #343a401a">
<div id="app">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<span class="navbar-brand mb-0 h1"><i class="fas fa-terminal"></i> KVANT Full Node Status</span>
</div>
</nav>
<div class="container body" v-if="error">
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Error while connecting to local node</h4>
<p class="mb-0">{{ error }}</p>
</div>
</div>
<div class="container body bg-white" v-if="status && !error">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
Node Info
</div>
<table class="table card-body">
<tbody>
<tr>
<td class="h">Moniker</td>
<td>{{ status.node_info.moniker }}</td>
</tr>
<tr>
<td class="h">Node ID</td>
<td>{{ status.node_info.id }}</td>
</tr>
<tr>
<td class="h">Network ID</td>
<td>{{ status.node_info.network }}</td>
</tr>
<tr>
<td class="h">KVANT Version</td>
<td>{{ version }}</td>
</tr>
<tr>
<td class="h">Tendermint Version</td>
<td>{{ status.node_info.version }}</td>
</tr>
</tbody>
</table>
</div>
<div class="card" v-if="net_info">
<div class="card-header">
Net Info
</div>
<table class="table card-body">
<tbody>
<tr>
<td class="h">Is Listening</td>
<td><i :class="{'fa-check': net_info.listening}" class="fas"></i></td>
</tr>
<tr>
<td class="h">Connected Peers</td>
<td>{{ net_info.n_peers }} <i :class="{'fa-exclamation-circle': net_info.n_peers < 1}" class="fas"></i></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Syncing Info
</div>
<table class="table card-body">
<tbody>
<tr>
<td class="h">Is Synced</td>
<td>
<span v-if="status.sync_info.catching_up">No</span>
<span v-if="!status.sync_info.catching_up">Yes</span>
<i :class="{'fa-check': !status.sync_info.catching_up, 'fa-exclamation-circle': status.sync_info.catching_up}" class="fas"></i></td>
</tr>
<tr>
<td class="h">Latest Block Height</td>
<td>
#{{ status.sync_info.latest_block_height }} <span v-if="masterStatus && status.node_info.network == masterStatus.tm_status.node_info.network && Number(status.sync_info.latest_block_height) <= Number(masterStatus.latest_block_height)" class="text-muted">of {{ masterStatus.latest_block_height }}</span>
</td>
</tr>
<tr>
<td class="h">Latest Block Time</td>
<td>
{{ status.sync_info.latest_block_time }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="card">
<div class="card-header">
Validator Info
</div>
<table class="table card-body">
<tbody>
<tr>
<td>Public Key</td>
<td>{{ validatorPubKey }}</td>
</tr>
<tr>
<td>Status</td>
<td>{{ validatorStatus }}</td>
</tr>
<tr>
<td>Total Stake</td>
<td>{{ stake }} KVANT</td>
</tr>
<tr>
<td>Voting Power</td>
<td>{{ niceNum(status.validator_info.voting_power) }} <span class="text-muted">of 100,000,000</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data: {
masterStatus: null,
status: null,
version: null,
net_info: null,
error: null,
validatorPubKey: '...',
validatorStatus: '...',
stake: '...'
},
mounted() {
this.refresh()
},
methods: {
niceNum(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
},
base64ToHex(base64) {
return CryptoJS.enc.Base64.parse(base64).toString()
},
refresh() {
axios.all([
axios.get("//" + window.location.hostname + ':12000/status'),
axios.get("//" + window.location.hostname + ':12000/net_info'),
]).then(axios.spread(function (status, net_info) {
this.error = null
this.status = status.data.result.tm_status
this.version = status.data.result.version
this.net_info = net_info.data.result
this.validatorPubKey = 'Kp' + this.base64ToHex(status.data.result.tm_status.validator_info.pub_key.value)
axios.all([
axios.get("//" + window.location.hostname + ':12000/validators'),
axios.get("//" + window.location.hostname + ':12000/candidate?pub_key=' + this.validatorPubKey),
]).then(axios.spread(function (validators, candidate) {
this.stake = Math.round(candidate.data.result.total_stake / Math.pow(10, 17)) / 10
if (validators.data.result.find(function(val) { return val.pub_key === this.validatorPubKey }.bind(this))) {
this.validatorStatus = 'Validating';
return
}
if (candidate.data.result.status === 2) {
this.validatorStatus = 'Candidate'
return
}
this.validatorStatus = 'Down';
}.bind(this))).catch(function() {
this.validatorStatus = 'Not declared';
this.stake = 0;
}.bind(this));
setTimeout(this.refresh, 1000)
}.bind(this))).catch(function (reason) {
this.error = reason.toString();
setTimeout(this.refresh, 1000)
}.bind(this))
axios.get("https://node-mainnet.kvant.io/status").then(function (masterStatus) {
this.masterStatus = masterStatus.data.result
}.bind(this))
}
}
})
</script>
</body>
</html>