refactor: enhance loading placeholder logic and error handling for network traffic data
This commit is contained in:
@@ -1516,10 +1516,10 @@
|
||||
const wasEmpty = !networkData || !networkData.interfaces || networkData.interfaces.length === 0;
|
||||
const hasExistingInterfaces = container && container.querySelectorAll('.chart-toggle').length > 0;
|
||||
|
||||
// Check if container shows the loading placeholder
|
||||
// Check if container shows the loading placeholder (skeleton loader)
|
||||
const showsPlaceholder = container && (
|
||||
container.querySelector('.border-dashed') !== null ||
|
||||
container.textContent.includes('Loading live network statistics')
|
||||
container.querySelector('.animate-pulse') !== null ||
|
||||
container.querySelector('.border-dashed') !== null
|
||||
);
|
||||
|
||||
networkData = data;
|
||||
@@ -1611,7 +1611,10 @@
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch live traffic data:', error);
|
||||
const container = document.getElementById('network-traffic-container');
|
||||
if (container && !container.querySelector('.bg-white dark:bg-gray-800')) {
|
||||
// Only show error if there's no existing network data (initial load failed)
|
||||
// Keep existing content if we already have data (refresh failed)
|
||||
const hasExistingContent = container && container.querySelectorAll('.chart-toggle').length > 0;
|
||||
if (container && !hasExistingContent) {
|
||||
container.innerHTML = `
|
||||
<div class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-6 text-center">
|
||||
<svg class="w-10 h-10 mx-auto text-red-400 mb-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
|
||||
Reference in New Issue
Block a user