-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhosting.php
More file actions
120 lines (114 loc) · 5.13 KB
/
hosting.php
File metadata and controls
120 lines (114 loc) · 5.13 KB
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
<?php
require_once 'bootstrap.php';
require_once 'include/layout.php';
require_once 'include/components/stat_card.php';
include_once 'include/graph.php';
$graphConfigs = require 'include/graph_configs.php';
use Siagraph\Utils\ApiClient;
use Siagraph\Utils\Locale;
// fetch latest metrics for quick stats
$metricsEndpoint = '/api/v1/daily/metrics?start=' . date('Y-m-d', strtotime('-6 months'));
$latestData = ApiClient::fetchJson($metricsEndpoint);
$dataError = !is_array($latestData);
$latest = $dataError ? [] : end($latestData);
$asOf = !$dataError && isset($latest['date']) ? $latest['date'] : null;
render_header('SiaGraph - Hosting');
?>
<section id="main-content" class="sg-container">
<h1 class="sg-container__heading text-center mb-2"><i class="bi bi-hdd-network me-2"></i>Hosting</h1>
<?php if ($dataError): ?>
<p class="text-center text-muted">Latest metrics unavailable.</p>
<?php endif; ?>
<div class="sg-container__row mb-4">
<div class="sg-container__row-content sg-container__row-content--center">
<div class="sg-container__column sg-container__column--one-fourth">
<?php
render_stat_card([
'icon' => 'bi bi-hdd-network',
'label' => 'Active Hosts',
'value' => isset($latest['active_hosts']) ? Locale::integer($latest['active_hosts']) : 'N/A',
'context' => $asOf ? ('Daily snapshot as of ' . $asOf) : 'Daily snapshot',
]);
?>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<?php
render_stat_card([
'icon' => 'bi bi-hash',
'label' => 'Block Height',
'value' => isset($latest['block_height']) ? Locale::integer($latest['block_height']) : 'N/A',
'context' => $asOf ? ('Daily snapshot as of ' . $asOf) : 'Daily snapshot',
]);
?>
</div>
</div>
</div>
<div class="sg-container__row mb-4">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Host Counts</h2>
<div class="card__content">
<?php
renderGraph(
'host-count-trend',
[
$graphConfigs['active_hosts'],
$graphConfigs['total_hosts']
],
'date',
'/api/v1/daily/growth',
null,
'line',
'week',
true,
'true',
6,
'false',
null
);
?>
</div>
</section>
</div>
</div>
<!-- Cards grid commented out for later re-enable
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column sg-container__column--one-fourth">
<a href="host_overview" class="card">
<div class="card__icon"><i class="bi bi-diagram-3"></i></div>
<div class="card__heading">Host Overview</div>
<div class="card__content">Distribution and reliability charts.</div>
<div class="card__footer"><div class="card__view"></div></div>
</a>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<a href="host_explorer" class="card">
<div class="card__icon"><i class="bi bi-search"></i></div>
<div class="card__heading">Host Explorer</div>
<div class="card__content">Search and inspect a host.</div>
<div class="card__footer"><div class="card__view"></div></div>
</a>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<a href="host_troubleshooter" class="card">
<div class="card__icon"><i class="bi bi-wrench"></i></div>
<div class="card__heading">Host Troubleshooter</div>
<div class="card__content">Diagnose hosting issues.</div>
<div class="card__footer"><div class="card__view"></div></div>
</a>
</div>
<div class="sg-container__column sg-container__column--one-fourth">
<a href="host_pricing" class="card">
<div class="card__icon"><i class="bi bi-currency-dollar"></i></div>
<div class="card__heading">Host Pricing</div>
<div class="card__content">Historical price charts.</div>
<div class="card__footer"><div class="card__view"></div></div>
</a>
</div>
</div>
</div>
-->
</section>
<?php render_footer(); ?>