refactor: Update API calls in Dashboard component to use countOnly parameter for improved data handling and simplify response processing
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 5m50s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 5m50s
This commit is contained in:
@@ -80,9 +80,9 @@ function Dashboard() {
|
||||
try {
|
||||
// Загружаем данные с обработкой ошибок для каждого endpoint
|
||||
const results = await Promise.allSettled([
|
||||
axios.get('/api/domains-new', { params: { offset: 0, limit: 1 } }),
|
||||
axios.get('/api/ip-ranges', { params: { offset: 0, limit: 1 } }),
|
||||
axios.get('/api/asns', { params: { offset: 0, limit: 1 } }),
|
||||
axios.get('/api/domains-new', { params: { countOnly: true } }),
|
||||
axios.get('/api/ip-ranges', { params: { countOnly: true } }),
|
||||
axios.get('/api/asns', { params: { countOnly: true } }),
|
||||
axios.get('/api/servers'),
|
||||
axios.get('/api/servers/availability', { params: { ttlSeconds: 60 } }),
|
||||
axios.get('/api/s3/last-modified')
|
||||
@@ -97,15 +97,9 @@ function Dashboard() {
|
||||
const s3Res = results[5];
|
||||
|
||||
// Получаем данные серверов для подсчета дополнительной статистики
|
||||
const domains = domainsRes.status === 'fulfilled'
|
||||
? (Array.isArray(domainsRes.value.data?.items) ? domainsRes.value.data.items : domainsRes.value.data)
|
||||
: [];
|
||||
const ipRanges = ipRangesRes.status === 'fulfilled'
|
||||
? (Array.isArray(ipRangesRes.value.data?.items) ? ipRangesRes.value.data.items : ipRangesRes.value.data)
|
||||
: [];
|
||||
const asns = asnsRes.status === 'fulfilled'
|
||||
? (Array.isArray(asnsRes.value.data?.items) ? asnsRes.value.data.items : asnsRes.value.data)
|
||||
: [];
|
||||
const domains = [];
|
||||
const ipRanges = [];
|
||||
const asns = [];
|
||||
const servers = serversRes.status === 'fulfilled' ? serversRes.value.data : [];
|
||||
setRaw({ domains, ipRanges, asns, servers });
|
||||
const countries = new Set(servers.map(server => server.country).filter(Boolean));
|
||||
@@ -119,13 +113,13 @@ function Dashboard() {
|
||||
|
||||
const domainsCount = domainsRes.status === 'fulfilled' && typeof domainsRes.value.data?.total === 'number'
|
||||
? domainsRes.value.data.total
|
||||
: domains.length;
|
||||
: 0;
|
||||
const ipRangesCount = ipRangesRes.status === 'fulfilled' && typeof ipRangesRes.value.data?.total === 'number'
|
||||
? ipRangesRes.value.data.total
|
||||
: ipRanges.length;
|
||||
: 0;
|
||||
const asnsCount = asnsRes.status === 'fulfilled' && typeof asnsRes.value.data?.total === 'number'
|
||||
? asnsRes.value.data.total
|
||||
: asns.length;
|
||||
: 0;
|
||||
|
||||
setStats({
|
||||
domainsCount,
|
||||
|
||||
Reference in New Issue
Block a user