Skip to content

Commit e7a7bca

Browse files
committed
feat: enhance dataset size and episode display in selection panel
- Update methods to calculate and format total file size and episode count for selected datasets. - Modify UI elements to display formatted HTML strings for better visual clarity. - Adjust CSS for filter stats to improve layout and spacing.
1 parent 50ae891 commit e7a7bca

3 files changed

Lines changed: 71 additions & 12 deletions

File tree

docs/css/filter/filter-control-bar.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@
223223
/* Stats */
224224
.filter-stats-inline {
225225
display: flex;
226-
gap: 1.5rem;
226+
flex-direction: column;
227+
gap: 0.25rem;
227228
font-size: 0.875rem;
228229
color: var(--color-text-secondary);
229230
margin-left: 1rem;

docs/js/modules/selection-panel.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export class SelectionPanelManager {
5858
}
5959

6060
/**
61-
* Calculate and format total file size for selected datasets
62-
* @returns {string} Formatted size string (e.g., " repos, 1.5GB")
61+
* Calculate and format total file size and episodes for selected datasets
62+
* @returns {string} Formatted HTML string (e.g., " repos, <strong style='color: var(--color-primary-light)'>1234 eps</strong>, <strong style='color: var(--color-primary-light)'>1.5GB</strong>")
6363
*/
6464
_calculateSelectedTotalSize() {
6565
if (this.selectedDatasets.size === 0) {
@@ -71,14 +71,43 @@ export class SelectionPanelManager {
7171
.map(path => this.datasetMap.get(path))
7272
.filter(ds => ds !== undefined);
7373

74+
// Calculate total episodes
75+
let totalEpisodes = 0;
76+
datasets.forEach(ds => {
77+
if (ds && ds.statistics && typeof ds.statistics.total_episodes === 'number') {
78+
totalEpisodes += ds.statistics.total_episodes;
79+
}
80+
});
81+
7482
const totalBytes = ConfigManager.calculateTotalSizeFromDatasets(datasets);
7583

7684
if (totalBytes === null) {
85+
// If no size info, still show episodes if available
86+
if (totalEpisodes > 0) {
87+
const epsNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${totalEpisodes.toLocaleString()}</strong>`;
88+
return ` repos, ${epsNum} eps`;
89+
}
7790
return ' repos';
7891
}
7992

8093
const formattedSize = ConfigManager.formatFileSize(totalBytes);
81-
return ` repos, ${formattedSize}`;
94+
// Extract number and unit from formatted size (e.g., "3.7TB" -> "3.7" and "TB")
95+
const sizeMatch = formattedSize.match(/^([\d.]+)([A-Z]+)$/);
96+
let sizeHtml;
97+
if (sizeMatch) {
98+
const sizeNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${sizeMatch[1]}</strong>`;
99+
sizeHtml = `${sizeNum}${sizeMatch[2]}`;
100+
} else {
101+
// Fallback if format doesn't match expected pattern
102+
sizeHtml = formattedSize;
103+
}
104+
105+
// Format: " repos, <num> eps, <file size>"
106+
if (totalEpisodes > 0) {
107+
const epsNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${totalEpisodes.toLocaleString()}</strong>`;
108+
return ` repos, ${epsNum} eps, ${sizeHtml}`;
109+
}
110+
return ` repos, ${sizeHtml}`;
82111
}
83112

84113
/**
@@ -93,7 +122,7 @@ export class SelectionPanelManager {
93122
}
94123

95124
if (selectedInfoEl) {
96-
selectedInfoEl.textContent = this._calculateSelectedTotalSize();
125+
selectedInfoEl.innerHTML = this._calculateSelectedTotalSize();
97126
}
98127

99128
const list = document.getElementById('selectionList');

docs/js/modules/ui-utils.js

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,52 @@ export class UIUtils {
245245
}
246246

247247
/**
248-
* Calculate and format total file size for datasets
248+
* Calculate and format total file size and episodes for datasets
249249
* @param {Dataset[]} datasets - Array of datasets
250-
* @returns {string} Formatted size string (e.g., " repos, 1.5GB")
250+
* @returns {string} Formatted HTML string (e.g., " repos, <strong style='color: var(--color-primary-light)'>1234 eps</strong>, <strong style='color: var(--color-primary-light)'>1.5GB</strong>")
251251
*/
252252
calculateTotalSize(datasets) {
253253
if (!datasets || datasets.length === 0) {
254254
return ' repos';
255255
}
256256

257+
// Calculate total episodes
258+
let totalEpisodes = 0;
259+
datasets.forEach(ds => {
260+
if (ds && ds.statistics && typeof ds.statistics.total_episodes === 'number') {
261+
totalEpisodes += ds.statistics.total_episodes;
262+
}
263+
});
264+
257265
const totalBytes = ConfigManager.calculateTotalSizeFromDatasets(datasets);
258266

259267
if (totalBytes === null) {
268+
// If no size info, still show episodes if available
269+
if (totalEpisodes > 0) {
270+
const epsNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${totalEpisodes.toLocaleString()}</strong>`;
271+
return ` repos, ${epsNum} eps`;
272+
}
260273
return ' repos';
261274
}
262275

263276
const formattedSize = ConfigManager.formatFileSize(totalBytes);
264-
return ` repos, ${formattedSize}`;
277+
// Extract number and unit from formatted size (e.g., "3.7TB" -> "3.7" and "TB")
278+
const sizeMatch = formattedSize.match(/^([\d.]+)([A-Z]+)$/);
279+
let sizeHtml;
280+
if (sizeMatch) {
281+
const sizeNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${sizeMatch[1]}</strong>`;
282+
sizeHtml = `${sizeNum}${sizeMatch[2]}`;
283+
} else {
284+
// Fallback if format doesn't match expected pattern
285+
sizeHtml = formattedSize;
286+
}
287+
288+
// Format: " repos, <num> eps, <file size>"
289+
if (totalEpisodes > 0) {
290+
const epsNum = `<strong style="color: var(--color-primary-light); font-weight: 600;">${totalEpisodes.toLocaleString()}</strong>`;
291+
return ` repos, ${epsNum} eps, ${sizeHtml}`;
292+
}
293+
return ` repos, ${sizeHtml}`;
265294
}
266295

267296
/**
@@ -280,14 +309,14 @@ export class UIUtils {
280309
if (filteredEl) filteredEl.textContent = filteredCount;
281310
if (selectedEl) selectedEl.textContent = selectedCount;
282311

283-
// Calculate and display total file size for filtered datasets
312+
// Calculate and display total file size and episodes for filtered datasets
284313
if (filteredInfoEl) {
285-
filteredInfoEl.textContent = this.calculateTotalSize(filteredDatasets);
314+
filteredInfoEl.innerHTML = this.calculateTotalSize(filteredDatasets);
286315
}
287316

288-
// Calculate and display total file size for selected datasets
317+
// Calculate and display total file size and episodes for selected datasets
289318
if (selectedInfoEl) {
290-
selectedInfoEl.textContent = this.calculateTotalSize(selectedDatasets);
319+
selectedInfoEl.innerHTML = this.calculateTotalSize(selectedDatasets);
291320
}
292321
}
293322

0 commit comments

Comments
 (0)