Update index.html
ignore CSV summary rows in analyzer improve mobile layout
This commit is contained in:
1 parent
653a5e3e79
commit
5bf31efd28
1 file changed
+56
-10
@@ -77,6 +77,7 @@
|
|||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -94,7 +95,6 @@
|
|||||||
color: #6d4aff;
|
color: #6d4aff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
th:last-child, td:last-child { border-right: none; }
|
|
||||||
tbody tr:hover { background: #faf9fc; }
|
tbody tr:hover { background: #faf9fc; }
|
||||||
.sort-button {
|
.sort-button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -125,14 +125,17 @@
|
|||||||
}
|
}
|
||||||
.sort-button[aria-sort="ascending"] .sort-indicator,
|
.sort-button[aria-sort="ascending"] .sort-indicator,
|
||||||
.sort-button[aria-sort="descending"] .sort-indicator { opacity: 1; }
|
.sort-button[aria-sort="descending"] .sort-indicator { opacity: 1; }
|
||||||
|
#summaryMetrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
.metric-card {
|
.metric-card {
|
||||||
display: inline-block;
|
|
||||||
background: linear-gradient(135deg, #6d4aff 0%, #8b5cf6 100%);
|
background: linear-gradient(135deg, #6d4aff 0%, #8b5cf6 100%);
|
||||||
color: white;
|
color: white;
|
||||||
padding: 20px 30px;
|
padding: 20px 24px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
margin: 10px;
|
min-width: 0;
|
||||||
min-width: 180px;
|
|
||||||
box-shadow: 0 4px 15px rgba(109,74,255,0.3);
|
box-shadow: 0 4px 15px rgba(109,74,255,0.3);
|
||||||
}
|
}
|
||||||
.metric-value { font-size: 1.8rem; font-weight: bold; margin-bottom: 5px; }
|
.metric-value { font-size: 1.8rem; font-weight: bold; margin-bottom: 5px; }
|
||||||
@@ -175,6 +178,33 @@
|
|||||||
}
|
}
|
||||||
.status-error { background: #f8d7da; color: #721c24; }
|
.status-error { background: #f8d7da; color: #721c24; }
|
||||||
.status-success { background: #d4edda; color: #155724; }
|
.status-success { background: #d4edda; color: #155724; }
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
body { padding: 10px; }
|
||||||
|
header { margin-bottom: 18px; }
|
||||||
|
header h1 { font-size: 1.55rem; }
|
||||||
|
header p { font-size: 0.95rem; }
|
||||||
|
.upload-section, .report-section { padding: 18px; border-radius: 10px; }
|
||||||
|
.upload-area { padding: 36px 14px; }
|
||||||
|
.upload-area > div:first-child { font-size: 2.4rem !important; }
|
||||||
|
button.analyze-btn { width: 100%; padding: 13px 18px; }
|
||||||
|
h2 { font-size: 1.25rem; margin: 24px 0 14px; }
|
||||||
|
.table-wrapper { margin: 14px 0; }
|
||||||
|
table { min-width: 560px; font-size: 0.88rem; }
|
||||||
|
th, td { padding: 10px 9px; }
|
||||||
|
.sort-button { gap: 6px; }
|
||||||
|
.metric-card { padding: 16px 18px; }
|
||||||
|
.metric-value { font-size: 1.45rem; }
|
||||||
|
.finding-box, .warning-box, .success-box { padding: 12px 14px; }
|
||||||
|
.privacy-note { font-size: 0.82rem; padding: 12px; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 420px) {
|
||||||
|
#summaryMetrics { grid-template-columns: 1fr 1fr; gap: 10px; }
|
||||||
|
.metric-card { padding: 13px 12px; }
|
||||||
|
.metric-value { font-size: 1.2rem; }
|
||||||
|
.metric-label { font-size: 0.78rem; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -298,12 +328,27 @@
|
|||||||
const headers = parseCSVLine(lines[0]);
|
const headers = parseCSVLine(lines[0]);
|
||||||
const data = [];
|
const data = [];
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
|
let summaryRowsSkipped = 0;
|
||||||
|
|
||||||
for (let i = 1; i < lines.length; i++) {
|
for (let i = 1; i < lines.length; i++) {
|
||||||
const line = lines[i];
|
const line = lines[i].trim();
|
||||||
if (line.includes('Total Records') || line.trim() === '') continue;
|
if (!line) continue;
|
||||||
|
|
||||||
const values = parseCSVLine(line);
|
const values = parseCSVLine(line);
|
||||||
|
const firstValue = (values[0] || '').trim();
|
||||||
|
|
||||||
|
// PPQ exports append summary rows such as:
|
||||||
|
// Total Records,1057,,,,,,
|
||||||
|
// Total Input Tokens,100746995,,,,,,
|
||||||
|
// Total Output Tokens,1469460,,,,,,
|
||||||
|
// Total Cost (USD),6.02,,,,,,
|
||||||
|
// Ignore those rows so only request data reaches the report.
|
||||||
|
if (firstValue.toLowerCase().startsWith('total ')) {
|
||||||
|
summaryRowsSkipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (values.every(value => !value.trim())) continue;
|
||||||
|
|
||||||
if (values.length !== headers.length) {
|
if (values.length !== headers.length) {
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
@@ -320,7 +365,7 @@
|
|||||||
data.push(row);
|
data.push(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(`Parsed ${data.length} rows${errors ? `, ${errors} rows skipped` : ''}`);
|
log(`Parsed ${data.length} request rows${errors ? `, ${errors} malformed rows skipped` : ''}${summaryRowsSkipped ? `, ${summaryRowsSkipped} summary rows ignored` : ''}.`);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +422,7 @@
|
|||||||
|
|
||||||
csvData = parseCSV(rawData);
|
csvData = parseCSV(rawData);
|
||||||
if (csvData.length === 0) {
|
if (csvData.length === 0) {
|
||||||
showStatus('Could not read any data from the file.', true);
|
showStatus('Could not read any request data from the file.', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +510,8 @@
|
|||||||
let sortDirection = defaultSort.direction;
|
let sortDirection = defaultSort.direction;
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
const sortedRows = sortRows(rows, sortKey, columns.find(c => c.key === sortKey).type, sortDirection);
|
const activeColumn = columns.find(c => c.key === sortKey) || columns[0];
|
||||||
|
const sortedRows = sortRows(rows, sortKey, activeColumn.type, sortDirection);
|
||||||
|
|
||||||
let html = `<div class="table-wrapper"><table id="${tableId}"><thead><tr>`;
|
let html = `<div class="table-wrapper"><table id="${tableId}"><thead><tr>`;
|
||||||
columns.forEach(column => {
|
columns.forEach(column => {
|
||||||
Reference in new issue
Block a user