This commit is contained in:
1 parent
2ba21993c8
commit
f2c96bd9c5
7 files changed
+53
-6
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
function parseStorageAmount(html) {
|
||||||
|
const text = String(html).replace(/<[^>]*>/g, '').replace(/ | | /gi, ' ').trim();
|
||||||
|
const match = text.match(/^([\d.,]+)\s*(B|[KMGTPE]i?B)$/i);
|
||||||
|
if (!match) return null;
|
||||||
|
const value = Number(match[1].replace(',', '.'));
|
||||||
|
if (!Number.isFinite(value) || value < 0) return null;
|
||||||
|
return { value, unit: match[2].toUpperCase() };
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseVoeAccountStorage(html) {
|
||||||
|
const sidebar = String(html || '').match(/<nav\b[^>]*\bid\s*=\s*["']sidebarMenu["'][^>]*>([\s\S]*?)<\/nav\s*>/i)?.[1];
|
||||||
|
if (!sidebar) return null;
|
||||||
|
for (const match of sidebar.matchAll(/<small\b[^>]*>([\s\S]*?)<\/small\s*>/gi)) {
|
||||||
|
const spans = [...match[1].matchAll(/<span\b([^>]*)>([\s\S]*?)<\/span\s*>/gi)];
|
||||||
|
if (spans.length !== 2 || !/\bfloat-end\b/.test(spans[1][1])) continue;
|
||||||
|
const used = parseStorageAmount(spans[0][2]);
|
||||||
|
const total = parseStorageAmount(spans[1][2]);
|
||||||
|
if (used && total && total.value > 0) return { used, total };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { parseVoeAccountStorage };
|
||||||
+2
-1
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const { request } = require('undici');
|
const { request } = require('undici');
|
||||||
|
const { parseVoeAccountStorage } = require('./voe-account-storage');
|
||||||
|
|
||||||
const BASE_URL = 'https://voe.sx';
|
const BASE_URL = 'https://voe.sx';
|
||||||
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
|
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
|
||||||
@@ -152,7 +153,7 @@ class VoeUploader {
|
|||||||
throw new Error('VOE Upload: CSRF-Token nicht gefunden. Bist du eingeloggt?');
|
throw new Error('VOE Upload: CSRF-Token nicht gefunden. Bist du eingeloggt?');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { csrfToken };
|
return { csrfToken, storage: parseVoeAccountStorage(html) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1395,7 +1395,7 @@ async function checkVoeHealth(hosterConfig) {
|
|||||||
|
|
||||||
const uploader = new VoeUploader();
|
const uploader = new VoeUploader();
|
||||||
await uploader.login(username, password);
|
await uploader.login(username, password);
|
||||||
const { csrfToken } = await uploader._getUploadParams();
|
const { csrfToken, storage } = await uploader._getUploadParams();
|
||||||
|
|
||||||
if (!csrfToken) {
|
if (!csrfToken) {
|
||||||
return { status: 'error', message: 'Login ok, aber Upload-Seite liefert kein CSRF-Token' };
|
return { status: 'error', message: 'Login ok, aber Upload-Seite liefert kein CSRF-Token' };
|
||||||
@@ -1403,7 +1403,8 @@ async function checkVoeHealth(hosterConfig) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
message: 'Login ok, Upload-Seite bereit'
|
message: 'Login ok, Upload-Seite bereit',
|
||||||
|
storage
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,21 @@
|
|||||||
if (typeof api?.getSessionFailedAccounts === 'function') apply(await api.getSessionFailedAccounts());
|
if (typeof api?.getSessionFailedAccounts === 'function') apply(await api.getSessionFailedAccounts());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatAccountStorage(storage, locale = 'en-US') {
|
||||||
|
const formatAmount = amount => {
|
||||||
|
if (!amount || typeof amount.value !== 'number' || !Number.isFinite(amount.value) || amount.value < 0
|
||||||
|
|| !/^(B|[KMGTPE]I?B)$/.test(amount.unit || '')) return null;
|
||||||
|
const unit = amount.unit.replace('IB', 'iB');
|
||||||
|
return `${new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount.value)} ${unit}`;
|
||||||
|
};
|
||||||
|
const used = formatAmount(storage?.used);
|
||||||
|
const total = formatAmount(storage?.total);
|
||||||
|
if (!used || !total || storage.total.value <= 0) return null;
|
||||||
|
return `${used} ${String(locale).startsWith('de') ? 'von' : 'of'} ${total}`;
|
||||||
|
}
|
||||||
|
|
||||||
const accountStatus = {
|
const accountStatus = {
|
||||||
|
formatAccountStorage,
|
||||||
formatAccountPauseRemaining,
|
formatAccountPauseRemaining,
|
||||||
getAccountGroupStatus,
|
getAccountGroupStatus,
|
||||||
getAccountPausePresentation,
|
getAccountPausePresentation,
|
||||||
|
|||||||
+9
-3
@@ -6212,6 +6212,7 @@ async function executeHealthCheck(hosters, _mode, generations) {
|
|||||||
accountStatuses[key] = {
|
accountStatuses[key] = {
|
||||||
status: row.status || 'unchecked',
|
status: row.status || 'unchecked',
|
||||||
message: row.message || '',
|
message: row.message || '',
|
||||||
|
storage: row.storage || null,
|
||||||
checkedAt: row.checkedAt || checkedAt
|
checkedAt: row.checkedAt || checkedAt
|
||||||
};
|
};
|
||||||
if (row.accountId) updateAccountCard(row.accountId);
|
if (row.accountId) updateAccountCard(row.accountId);
|
||||||
@@ -7611,6 +7612,10 @@ function _buildAccountCardHtml(name, account, idx) {
|
|||||||
const toggleLabel = isDisabled ? 'Aktivieren' : 'Deaktivieren';
|
const toggleLabel = isDisabled ? 'Aktivieren' : 'Deaktivieren';
|
||||||
const priorityLabel = idx === 0 ? 'Primär' : `Fallback #${idx}`;
|
const priorityLabel = idx === 0 ? 'Primär' : `Fallback #${idx}`;
|
||||||
const checkLabel = statusPresentation.requiresOtp ? 'Neuen Code anfordern' : 'Prüfen';
|
const checkLabel = statusPresentation.requiresOtp ? 'Neuen Code anfordern' : 'Prüfen';
|
||||||
|
const storageText = name === 'voe.sx' ? window.AccountStatus.formatAccountStorage(st.storage, getUiLocale()) : null;
|
||||||
|
const storageHtml = storageText
|
||||||
|
? `<div class="account-card-storage">${escapeHtml(localizeUiText('Speicher'))}: ${escapeHtml(storageText)}</div>`
|
||||||
|
: '';
|
||||||
|
|
||||||
const sessionPauseKey = `${name}:${account.id}`;
|
const sessionPauseKey = `${name}:${account.id}`;
|
||||||
const sessionPause = _sessionFailedAccountStates.get(sessionPauseKey)
|
const sessionPause = _sessionFailedAccountStates.get(sessionPauseKey)
|
||||||
@@ -7632,6 +7637,7 @@ function _buildAccountCardHtml(name, account, idx) {
|
|||||||
<div class="account-card-info">
|
<div class="account-card-info">
|
||||||
<div class="account-card-title">${escapeHtml(getAccountDisplayName(name, account))} <span class="account-priority-badge">${priorityLabel}</span> ${sessionPausedBadge}</div>
|
<div class="account-card-title">${escapeHtml(getAccountDisplayName(name, account))} <span class="account-priority-badge">${priorityLabel}</span> ${sessionPausedBadge}</div>
|
||||||
<div class="account-card-subtitle" title="${escapeAttr(subtitleText)}">${escapeHtml(subtitleText)}${st.message && !isDisabled ? ` • ${escapeHtml(st.message)}` : ''}${checkedText}</div>
|
<div class="account-card-subtitle" title="${escapeAttr(subtitleText)}">${escapeHtml(subtitleText)}${st.message && !isDisabled ? ` • ${escapeHtml(st.message)}` : ''}${checkedText}</div>
|
||||||
|
${storageHtml}
|
||||||
${otpAction}
|
${otpAction}
|
||||||
</div>
|
</div>
|
||||||
<span class="account-status status-${statusClass}">
|
<span class="account-status status-${statusClass}">
|
||||||
@@ -8152,7 +8158,7 @@ async function checkSingleAccount(accountId) {
|
|||||||
const row = rows.find(r => r.accountId === accountId);
|
const row = rows.find(r => r.accountId === accountId);
|
||||||
const checkedAt = result?.checkedAt || new Date().toISOString();
|
const checkedAt = result?.checkedAt || new Date().toISOString();
|
||||||
nextStatus = row
|
nextStatus = row
|
||||||
? { status: row.status || 'error', message: row.message || '', checkedAt: row.checkedAt || checkedAt }
|
? { status: row.status || 'error', message: row.message || '', storage: row.storage || null, checkedAt: row.checkedAt || checkedAt }
|
||||||
: { status: 'error', message: 'Keine Antwort vom Hoster erhalten', checkedAt };
|
: { status: 'error', message: 'Keine Antwort vom Hoster erhalten', checkedAt };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
nextStatus = { status: 'error', message: err.message || 'Prüfung fehlgeschlagen', checkedAt: new Date().toISOString() };
|
nextStatus = { status: 'error', message: err.message || 'Prüfung fehlgeschlagen', checkedAt: new Date().toISOString() };
|
||||||
@@ -8197,7 +8203,7 @@ async function submitAccountOtp(accountId) {
|
|||||||
: null;
|
: null;
|
||||||
const checkedAt = result?.checkedAt || new Date().toISOString();
|
const checkedAt = result?.checkedAt || new Date().toISOString();
|
||||||
nextStatus = row
|
nextStatus = row
|
||||||
? { status: row.status || 'error', message: row.message || '', checkedAt: row.checkedAt || checkedAt }
|
? { status: row.status || 'error', message: row.message || '', storage: row.storage || null, checkedAt: row.checkedAt || checkedAt }
|
||||||
: { status: 'error', message: 'Keine Antwort vom Hoster erhalten', checkedAt };
|
: { status: 'error', message: 'Keine Antwort vom Hoster erhalten', checkedAt };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
nextStatus = { status: 'error', message: err.message || 'OTP-Prüfung fehlgeschlagen', checkedAt: new Date().toISOString() };
|
nextStatus = { status: 'error', message: err.message || 'OTP-Prüfung fehlgeschlagen', checkedAt: new Date().toISOString() };
|
||||||
@@ -8570,7 +8576,7 @@ function _applyCommittedAccount(persisted, validation) {
|
|||||||
const { accountId, candidateHosters, isEdit } = persisted;
|
const { accountId, candidateHosters, isEdit } = persisted;
|
||||||
config.hosters = candidateHosters;
|
config.hosters = candidateHosters;
|
||||||
_invalidateAccountStatusGeneration(accountId);
|
_invalidateAccountStatusGeneration(accountId);
|
||||||
accountStatuses[accountId] = { status: validation.status, message: validation.message || '', checkedAt: validation.checkedAt || new Date().toISOString() };
|
accountStatuses[accountId] = { status: validation.status, message: validation.message || '', storage: validation.storage || null, checkedAt: validation.checkedAt || new Date().toISOString() };
|
||||||
ensureAccountStatusEntries();
|
ensureAccountStatusEntries();
|
||||||
syncSelectedUploadHosters();
|
syncSelectedUploadHosters();
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
if (root) root.I18n = api;
|
if (root) root.I18n = api;
|
||||||
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
})(typeof window !== 'undefined' ? window : globalThis, function () {
|
||||||
const pairs = [
|
const pairs = [
|
||||||
|
['Speicher', 'Storage'],
|
||||||
['Alternative', 'Alternate'],
|
['Alternative', 'Alternate'],
|
||||||
['Arbeitsbereich', 'Workspace'],
|
['Arbeitsbereich', 'Workspace'],
|
||||||
['Accounts verwalten', 'Manage accounts'],
|
['Accounts verwalten', 'Manage accounts'],
|
||||||
|
|||||||
@@ -1531,6 +1531,7 @@ select.hs-input { max-width: none; width: auto; min-width: 140px; }
|
|||||||
}
|
}
|
||||||
.account-card:hover { background: var(--bg-card-hover); }
|
.account-card:hover { background: var(--bg-card-hover); }
|
||||||
.account-card-info { flex: 1; min-width: 0; }
|
.account-card-info { flex: 1; min-width: 0; }
|
||||||
|
.account-card-storage { font-size: 12px; color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }
|
||||||
.account-card-title { font-size: 14px; font-weight: 600; }
|
.account-card-title { font-size: 14px; font-weight: 600; }
|
||||||
.account-card-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.account-card-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
.account-otp-action { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
|
.account-otp-action { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
|
||||||
|
|||||||
Reference in new issue
Block a user