-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost_pricing.php
More file actions
103 lines (103 loc) · 4.38 KB
/
Copy pathhost_pricing.php
File metadata and controls
103 lines (103 loc) · 4.38 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
<?php
require_once 'bootstrap.php';
include_once 'include/graph.php';
$graphConfigs = require 'include/graph_configs.php';
require_once 'include/layout.php';
require_once 'include/components/stat_card.php';
require_once 'include/components/host_pricing_trends.php';
use Siagraph\Utils\Formatter;
use Siagraph\Utils\ApiClient;
use Siagraph\Utils\CurrencyDisplay;
$months = 6; // default visible range; slider will cover all data
$data = ApiClient::fetchJson('/api/v1/daily/host_prices');
$currencyCookie = CurrencyDisplay::selectedCurrency();
$dataError = !is_array($data);
$latest = $dataError ? [] : end($data);
$asOf = !$dataError && isset($latest['date']) ? $latest['date'] : null;
$ratesByDate = $asOf ? CurrencyDisplay::loadDailyRates($asOf, $asOf) : [];
?>
<?php render_header('SiaGraph - Host Pricing'); ?>
<section id="main-content" class="sg-container">
<h1 class="sg-container__heading text-center mb-2"><i class="bi bi-currency-dollar me-2"></i>Host Pricing</h1>
<form class="mb-3">
<!-- range dropdown removed -->
</form>
<?php if ($dataError): ?>
<p class="text-center text-muted">Host pricing data 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-fill',
'label' => 'Average Storage Price',
'value' => isset($latest['avg_storage_price'])
? CurrencyDisplay::formatMonetary([
'scValue' => ((float) $latest['avg_storage_price'] / 1e12) * 4320,
'currency' => $currencyCookie,
'date' => $asOf,
'ratesByDate' => $ratesByDate,
'decimals' => 2,
'scDecimals' => 2,
'suffix' => '/TB/Month',
])
: '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-upload',
'label' => 'Average Upload Price',
'value' => isset($latest['avg_upload_price'])
? CurrencyDisplay::formatMonetary([
'scValue' => (float) $latest['avg_upload_price'] / 1e12,
'currency' => $currencyCookie,
'date' => $asOf,
'ratesByDate' => $ratesByDate,
'decimals' => 2,
'scDecimals' => 2,
'suffix' => '/TB',
])
: '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-download',
'label' => 'Average Download Price',
'value' => isset($latest['avg_download_price'])
? CurrencyDisplay::formatMonetary([
'scValue' => (float) $latest['avg_download_price'] / 1e12,
'currency' => $currencyCookie,
'date' => $asOf,
'ratesByDate' => $ratesByDate,
'decimals' => 2,
'scDecimals' => 2,
'suffix' => '/TB',
])
: 'N/A',
'context' => $asOf ? ('Daily snapshot as of ' . $asOf) : 'Daily snapshot',
]);
?>
</div>
</div>
</div>
<div class="sg-container__row">
<div class="sg-container__row-content">
<div class="sg-container__column">
<section class="card">
<h2 class="card__heading">Pricing Trends</h2>
<?php render_host_pricing_trends('host-price-trend', $months, $currencyCookie, ['hideDownload' => false]); ?>
</section>
</div>
</div>
</div>
</section>
<?php render_footer(); ?>