feat: Fetch all data, add spinner, display full results
Browse files- index.html +68 -31
- style.css +34 -0
index.html
CHANGED
@@ -292,7 +292,10 @@
|
|
292 |
</select>
|
293 |
</div>
|
294 |
|
295 |
-
<div id="loading">
|
|
|
|
|
|
|
296 |
<div id="error" style="display: none;"></div>
|
297 |
|
298 |
<!-- KPI Section -->
|
@@ -391,6 +394,7 @@
|
|
391 |
const footer = document.getElementById('footer');
|
392 |
const dataSourceUrlElement = document.getElementById('data-source-url');
|
393 |
const lastUpdatedElement = document.getElementById('last-updated');
|
|
|
394 |
const requestsCountFooter = document.getElementById('requests-count-footer');
|
395 |
const modelSelector = document.getElementById('modelSelector');
|
396 |
const inspectorModal = document.getElementById('inspectorModal');
|
@@ -406,11 +410,14 @@
|
|
406 |
const modelDetailTableContainerDiv = document.getElementById('modelDetailTableContainer');
|
407 |
|
408 |
|
409 |
-
|
|
|
|
|
410 |
|
411 |
let allRows = []; // Store all fetched rows globally
|
412 |
let currentFilteredRows = []; // Store currently filtered rows
|
413 |
let uniqueModels = [];
|
|
|
414 |
|
415 |
// Plotly layout defaults (same as before)
|
416 |
const baseLayout = {
|
@@ -523,35 +530,65 @@
|
|
523 |
});
|
524 |
|
525 |
|
526 |
-
// ---
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
|
554 |
-
// --- KPI Calculation Function
|
555 |
function calculateAndDisplayKPIs(rows, selectedModelId) {
|
556 |
const context = selectedModelId === 'all' ? 'Overall' : `(${selectedModelId.split('/').pop()})`; // Shorten model name for title
|
557 |
|
@@ -897,4 +934,4 @@
|
|
897 |
</script>
|
898 |
|
899 |
</body>
|
900 |
-
</html>
|
|
|
292 |
</select>
|
293 |
</div>
|
294 |
|
295 |
+
<div id="loading">
|
296 |
+
<div class="spinner"></div>
|
297 |
+
<div id="loading-message">Loading data... Please wait.</div>
|
298 |
+
</div>
|
299 |
<div id="error" style="display: none;"></div>
|
300 |
|
301 |
<!-- KPI Section -->
|
|
|
394 |
const footer = document.getElementById('footer');
|
395 |
const dataSourceUrlElement = document.getElementById('data-source-url');
|
396 |
const lastUpdatedElement = document.getElementById('last-updated');
|
397 |
+
const loadingMessage = document.getElementById('loading-message'); // Get loading message element
|
398 |
const requestsCountFooter = document.getElementById('requests-count-footer');
|
399 |
const modelSelector = document.getElementById('modelSelector');
|
400 |
const inspectorModal = document.getElementById('inspectorModal');
|
|
|
410 |
const modelDetailTableContainerDiv = document.getElementById('modelDetailTableContainer');
|
411 |
|
412 |
|
413 |
+
// Base URL without offset/length for display
|
414 |
+
const baseApiUrlDisplay = "https://datasets-server.huggingface.co/rows?dataset=victor%2Fproviders-metrics&config=default&split=train";
|
415 |
+
dataSourceUrlElement.href = baseApiUrlDisplay; // Set link href
|
416 |
|
417 |
let allRows = []; // Store all fetched rows globally
|
418 |
let currentFilteredRows = []; // Store currently filtered rows
|
419 |
let uniqueModels = [];
|
420 |
+
const rowsPerFetch = 100; // How many rows to fetch per API call
|
421 |
|
422 |
// Plotly layout defaults (same as before)
|
423 |
const baseLayout = {
|
|
|
530 |
});
|
531 |
|
532 |
|
533 |
+
// --- Fetching Logic ---
|
534 |
+
function fetchAllRows(offset = 0) {
|
535 |
+
const apiUrl = `https://datasets-server.huggingface.co/rows?dataset=victor%2Fproviders-metrics&config=default&split=train&offset=${offset}&length=${rowsPerFetch}`;
|
536 |
+
loadingMessage.textContent = `Fetching rows ${offset + 1} - ${offset + rowsPerFetch}... (Total: ${allRows.length})`;
|
537 |
+
|
538 |
+
fetch(apiUrl)
|
539 |
+
.then(response => {
|
540 |
+
if (!response.ok) {
|
541 |
+
// Handle specific errors if needed, e.g., 404 might mean end of data for some APIs
|
542 |
+
throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);
|
543 |
+
}
|
544 |
+
return response.json();
|
545 |
+
})
|
546 |
+
.then(data => {
|
547 |
+
const fetchedRows = data.rows.map((item, index) => ({ ...item.row, originalIndex: offset + index }));
|
548 |
+
allRows = allRows.concat(fetchedRows); // Append new rows
|
549 |
+
|
550 |
+
console.log(`Fetched ${fetchedRows.length} rows. Total rows: ${allRows.length}`);
|
551 |
+
|
552 |
+
// Check if we got fewer rows than requested, or zero rows, indicating the end
|
553 |
+
if (fetchedRows.length < rowsPerFetch || fetchedRows.length === 0) {
|
554 |
+
console.log("Finished fetching all rows.");
|
555 |
+
lastUpdatedElement.textContent = new Date().toLocaleString();
|
556 |
+
loadingDiv.style.display = 'none'; // Hide loading indicator
|
557 |
+
kpiContainer.style.display = 'grid';
|
558 |
+
dashboardContainer.style.display = 'grid';
|
559 |
+
footer.style.display = 'block';
|
560 |
+
|
561 |
+
populateModelSelector(); // Populate dropdown *after* all data is fetched
|
562 |
+
updateDashboard('all'); // Initial load with all models
|
563 |
+
} else {
|
564 |
+
// Fetch the next batch
|
565 |
+
fetchAllRows(offset + rowsPerFetch);
|
566 |
+
}
|
567 |
+
})
|
568 |
+
.catch(error => {
|
569 |
+
console.error('Error fetching data:', error);
|
570 |
+
loadingDiv.style.display = 'none'; // Hide loading on error
|
571 |
+
errorDiv.textContent = `Error fetching data at offset ${offset}: ${error.message}. Displaying partial data (${allRows.length} rows). Please check console.`;
|
572 |
+
errorDiv.style.display = 'block';
|
573 |
+
|
574 |
+
// Optionally, display the dashboard with partial data
|
575 |
+
if (allRows.length > 0) {
|
576 |
+
console.log("Displaying dashboard with partial data.");
|
577 |
+
lastUpdatedElement.textContent = new Date().toLocaleString() + " (Partial Data)";
|
578 |
+
kpiContainer.style.display = 'grid';
|
579 |
+
dashboardContainer.style.display = 'grid';
|
580 |
+
footer.style.display = 'block';
|
581 |
+
populateModelSelector();
|
582 |
+
updateDashboard('all');
|
583 |
+
}
|
584 |
+
});
|
585 |
+
}
|
586 |
+
|
587 |
+
// --- Start the fetching process ---
|
588 |
+
fetchAllRows();
|
589 |
+
|
590 |
|
591 |
+
// --- KPI Calculation Function ---
|
592 |
function calculateAndDisplayKPIs(rows, selectedModelId) {
|
593 |
const context = selectedModelId === 'all' ? 'Overall' : `(${selectedModelId.split('/').pop()})`; // Shorten model name for title
|
594 |
|
|
|
934 |
</script>
|
935 |
|
936 |
</body>
|
937 |
+
</html>
|
style.css
CHANGED
@@ -26,3 +26,37 @@ p {
|
|
26 |
.card p:last-child {
|
27 |
margin-bottom: 0;
|
28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
.card p:last-child {
|
27 |
margin-bottom: 0;
|
28 |
}
|
29 |
+
|
30 |
+
/* Spinner Styles */
|
31 |
+
#loading {
|
32 |
+
display: flex;
|
33 |
+
flex-direction: column; /* Stack spinner and message */
|
34 |
+
align-items: center;
|
35 |
+
justify-content: center;
|
36 |
+
min-height: 150px; /* Give it some space */
|
37 |
+
text-align: center;
|
38 |
+
font-size: 1.2em;
|
39 |
+
color: var(--muted-text-color);
|
40 |
+
}
|
41 |
+
.spinner {
|
42 |
+
border: 4px solid rgba(0, 0, 0, 0.1);
|
43 |
+
width: 36px;
|
44 |
+
height: 36px;
|
45 |
+
border-radius: 50%;
|
46 |
+
border-left-color: var(--primary-color);
|
47 |
+
margin-bottom: 15px; /* Space between spinner and text */
|
48 |
+
|
49 |
+
animation: spin 1s ease infinite;
|
50 |
+
}
|
51 |
+
#loading-message {
|
52 |
+
font-size: 1rem; /* Slightly smaller message */
|
53 |
+
}
|
54 |
+
|
55 |
+
@keyframes spin {
|
56 |
+
0% {
|
57 |
+
transform: rotate(0deg);
|
58 |
+
}
|
59 |
+
100% {
|
60 |
+
transform: rotate(360deg);
|
61 |
+
}
|
62 |
+
}
|