calculation
This commit is contained in:
@@ -1088,6 +1088,7 @@
|
||||
const value = String(getCookie('mining_checker_report_currency') || '').toUpperCase();
|
||||
return /^[A-Z0-9]{3,10}$/.test(value) ? value : '';
|
||||
});
|
||||
const [nowTimestamp, setNowTimestamp] = useState(() => Date.now());
|
||||
const [targetForm, setTargetForm] = useState({
|
||||
label: '',
|
||||
target_amount_fiat: '',
|
||||
@@ -1359,17 +1360,24 @@
|
||||
const preferredOfferRequiredFiatValue = Number.isFinite(preferredOfferRequiredCoins)
|
||||
? convertCurrencyValue(preferredOfferRequiredCoins, currentMiningCurrency, reportCurrency)
|
||||
: null;
|
||||
const preferredOfferRemainingDays = preferredOfferRemainingCoins !== null
|
||||
const preferredOfferRemainingDaysAtUpload = preferredOfferRemainingCoins !== null
|
||||
&& Number(latest?.doge_per_day_interval) > 0
|
||||
? (preferredOfferRemainingCoins / Number(latest.doge_per_day_interval))
|
||||
: null;
|
||||
const preferredOfferEta = preferredOfferRemainingDays !== null
|
||||
? (
|
||||
preferredOfferRemainingDays <= 0
|
||||
? new Date().toISOString()
|
||||
: new Date(Date.now() + (preferredOfferRemainingDays * 86400000)).toISOString()
|
||||
)
|
||||
const preferredOfferUploadTimestamp = latest?.measured_at ? Date.parse(latest.measured_at) : NaN;
|
||||
const preferredOfferEtaTimestamp = preferredOfferRemainingDaysAtUpload !== null && Number.isFinite(preferredOfferUploadTimestamp)
|
||||
? preferredOfferUploadTimestamp + (preferredOfferRemainingDaysAtUpload * 86400000)
|
||||
: NaN;
|
||||
const preferredOfferRemainingDays = Number.isFinite(preferredOfferEtaTimestamp)
|
||||
? Math.max(0, (preferredOfferEtaTimestamp - nowTimestamp) / 86400000)
|
||||
: null;
|
||||
const preferredOfferEta = Number.isFinite(preferredOfferEtaTimestamp)
|
||||
? new Date(preferredOfferEtaTimestamp).toISOString()
|
||||
: null;
|
||||
const remainingDaysUntil = (timestamp) => {
|
||||
const etaTimestamp = timestamp ? new Date(timestamp).getTime() : NaN;
|
||||
return Number.isFinite(etaTimestamp) ? Math.max(0, (etaTimestamp - nowTimestamp) / 86400000) : null;
|
||||
};
|
||||
const speedUnits = ['kH/s', 'MH/s'];
|
||||
const fiatCurrencies = currencies.filter((currency) => !currency.is_crypto);
|
||||
const cryptoCurrencies = currencies.filter((currency) => !!currency.is_crypto);
|
||||
@@ -1520,6 +1528,11 @@
|
||||
}
|
||||
}, [reportCurrencyOverride]);
|
||||
|
||||
useEffect(() => {
|
||||
const intervalId = window.setInterval(() => setNowTimestamp(Date.now()), 60000);
|
||||
return () => window.clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedMinerScenarioId === null) {
|
||||
return;
|
||||
@@ -3176,6 +3189,8 @@
|
||||
const reinvestedCapital = latest ? convertMeasurementMoney(latest, latest.reinvested_capital, reportCurrency) : null;
|
||||
const walletValue = latest ? convertMeasurementMoney(latest, latest.wallet_value, reportCurrency) : null;
|
||||
const totalHoldingsValue = latest ? convertMeasurementMoney(latest, latest.total_holdings_value, reportCurrency) : null;
|
||||
const earnedValue = latest ? convertMeasurementMoney(latest, latest.earned_value, reportCurrency) : null;
|
||||
const settledCryptoSpendValue = latest ? convertMeasurementMoney(latest, latest.settled_crypto_spend_value, reportCurrency) : null;
|
||||
const totalEarnedOverall = latest && latest.growth_since_baseline !== null && latest.growth_since_baseline !== undefined
|
||||
? Number(latest.growth_since_baseline)
|
||||
: null;
|
||||
@@ -3298,14 +3313,15 @@
|
||||
}),
|
||||
h(StatCard, {
|
||||
key: 'value',
|
||||
label: 'Aktueller Gegenwert',
|
||||
value: totalHoldingsValue !== null ? fmtMoney(totalHoldingsValue, reportCurrency) : 'n/a',
|
||||
label: 'Bisheriger Wert',
|
||||
value: earnedValue !== null ? fmtMoney(earnedValue, reportCurrency) : 'n/a',
|
||||
sub: [
|
||||
holdingsCurrentAsset !== null && holdingsCurrentAsset !== undefined
|
||||
? `Gesamtbestand ${fmtNumber(holdingsCurrentAsset, 6)} ${currentCoinCurrency}`
|
||||
: null,
|
||||
latestValue !== null ? `Miner ${fmtMoney(latestValue, reportCurrency)}` : null,
|
||||
walletValue !== null ? `Wallet ${fmtMoney(walletValue, reportCurrency)}` : null,
|
||||
settledCryptoSpendValue !== null ? `Ausgegeben ${fmtMoney(settledCryptoSpendValue, reportCurrency)}` : null,
|
||||
latestPrice !== null
|
||||
? `Kurs ${fmtNumber(latestPrice, 6)} ${reportCurrency}${latest && latest.price_is_fallback ? ' · Fallback aus letztem Kurs' : ''}`
|
||||
: null,
|
||||
@@ -3327,6 +3343,9 @@
|
||||
preferredOfferRemainingCoins !== null
|
||||
? `Rest ${fmtNumber(preferredOfferRemainingCoins, 4)} ${currentMiningCurrency}`
|
||||
: null,
|
||||
latest?.doge_per_day_interval !== null && latest?.doge_per_day_interval !== undefined
|
||||
? `Basis ${fmtNumber(latest.doge_per_day_interval, 4)} ${currentMiningCurrency}/Tag ab Upload`
|
||||
: null,
|
||||
preferredOfferEta ? `ETA ${fmtDate(preferredOfferEta)}` : null,
|
||||
].filter(Boolean).join(' · '),
|
||||
}),
|
||||
@@ -3368,7 +3387,7 @@
|
||||
yLabel: `Kurs ${reportCurrency}`,
|
||||
})),
|
||||
]),
|
||||
panel('Zielmonitor', `Rest-${currentCoinCurrency} und Resttage werden gegen den letzten verfuegbaren Kurs je Zielwaehrung berechnet.`,
|
||||
panel('Zielmonitor', `Die ETA wird ab dem letzten Upload mit dessen durchschnittlicher Tagesrate berechnet; die Restzeit laeuft bis zum naechsten Upload weiter.`,
|
||||
h('div', { className: 'mc-target-grid' },
|
||||
currentTargets.map((target, index) => h('div', {
|
||||
key: index,
|
||||
@@ -3383,7 +3402,7 @@
|
||||
h('div', { key: 'price' }, `Letzter Kurs: ${target.latest_price_for_currency ? fmtNumber(target.latest_price_for_currency, 6) + ' ' + target.currency : 'n/a'}`),
|
||||
h('div', { key: 'doge' }, `Benoetigte ${currentCoinCurrency}: ${fmtNumber(target.required_doge, 6)}`),
|
||||
h('div', { key: 'remaining' }, `Rest-${currentCoinCurrency}: ${fmtNumber(target.remaining_doge, 6)}`),
|
||||
h('div', { key: 'days' }, `Resttage: ${fmtNumber(target.remaining_days, 4)}`),
|
||||
h('div', { key: 'days' }, `Resttage: ${fmtNumber(remainingDaysUntil(target.target_eta_at), 4)}`),
|
||||
]),
|
||||
]))
|
||||
)
|
||||
@@ -3529,7 +3548,7 @@
|
||||
]);
|
||||
}))
|
||||
: h('div', { className: 'mc-empty' }, 'Noch keine Wallet-Assets erkannt.')),
|
||||
panel('Wallet-Transfers', 'Transfers zum hier verfolgten Wallet erhoehen den Wallet-Bestand und reduzieren den sichtbaren Miner-Bestand. Reinvestierte Krypto-Minerkaeufe werden davon automatisch wieder abgezogen.', [
|
||||
panel('Wallet-Transfers', 'Auszahlungen aus dem Mining-Tool erhoehen den Wallet-Bestand automatisch. Ein Screenshot setzt den Bestand zum Screenshot-Zeitpunkt verbindlich. Krypto-Minerkaeufe ziehen Coins wieder ab und bleiben zum Kaufkurs festgeschrieben.', [
|
||||
h('div', { key: 'actions', className: 'mc-inline-row' }, [
|
||||
h('button', {
|
||||
key: 'transfer-all',
|
||||
@@ -4065,7 +4084,7 @@
|
||||
h('div', { key: 'currency-main' }, target.effective_currency || target.currency),
|
||||
target.linked_offer_label ? h('div', { key: 'currency-offer', className: 'mc-kicker' }, `Angebot ${target.linked_offer_label}`) : null,
|
||||
]),
|
||||
h('td', { key: 'days' }, target.remaining_days !== null && target.remaining_days !== undefined ? fmtNumber(target.remaining_days, 2) : 'n/a'),
|
||||
h('td', { key: 'days' }, remainingDaysUntil(target.target_eta_at) !== null ? fmtNumber(remainingDaysUntil(target.target_eta_at), 2) : 'n/a'),
|
||||
h('td', { key: 'eta' }, target.target_eta_at ? fmtDateTime(target.target_eta_at) : 'n/a'),
|
||||
h('td', { key: 'sort' }, String(target.sort_order ?? 0)),
|
||||
h('td', { key: 'active' }, target.is_active ? 'ja' : 'nein'),
|
||||
|
||||
Reference in New Issue
Block a user