Skip to content

Show total size of selected files in maintenance cards (#220) - #223

Merged
StudioNirin merged 4 commits into
StudioNirin:mainfrom
DeLo1585:feat/220-selected-size
Oct 6, 2026
Merged

StudioNirin merged 4 commits into
StudioNirin:mainfrom
DeLo1585:feat/220-selected-size

Conversation

@DeLo1585

@DeLo1585 DeLo1585 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #220

Analyzed, written and tested together with Claude Sonnet 5.5 (Anthropic).

What changed

Commit 1 – Show the combined size next to the "Selected: N" counter on Untracked Files, Backup Cleanup and Duplicates (e.g. "Selected: 47 · 31.68 GB").

  • Sizes come from the existing per-row data-size values.
  • Group rows in Untracked Files carry the whole group's size in data-size (used for sorting) and their checkbox also selects the children. They now expose their own file in a new data-file-size attribute, so children are not counted twice (as @Brandon-Haney pointed out).
  • Duplicate file rows get a data-size attribute (it was missing).
  • formatBytes() mirrors core.system_utils.format_bytes (1024-based, 2 decimals), so the number matches the operation pill once the action runs.

Commit 2 (optional, independent of commit 1, easy to drop) – Layout of the selection bar on all three cards: action buttons on the first line, the selection summary on its own line below in slightly larger type, spacing above the buttons and below the summary balanced.

On Duplicates, "Sonarr/Radarr integration active" moves next to "Scanned …", and the left and right button groups are top-aligned. The button order and the buttons themselves are unchanged. I know you'd rather not change the button position on one card alone, so this changes all three identically; if you'd rather keep the current layout, just drop commit 2.

Testing

  • Rendered the real audit_results.html with sample data (groups with sidecars, a 94-file group, single files, backups) and ran the real selection script against it in jsdom: single group, single child, select-all, group + file and backups all give the expected totals, and the group is counted once.
  • Live on my instance (running older maintenance templates from April, so I adapted the same change to the older field names): Untracked 57 files in 5 groups = 37.98 GB, matching the sum of the group sizes; Duplicates 2 files = 567.64 MB, matching the two file sizes. Backup Cleanup was empty on my instance, so that card is covered by the jsdom test only.
  • Not yet tested against a current main build in a browser.

UNSELECTED UNTRACKED FILES

grafik

UNSELECTED DUPLICATE FILES

grafik

SELECTED UNTRACKED FILES

grafik

SELECTED DUPLICATE FILES

grafik

Untracked Files, Backup Cleanup and Duplicates now show the combined
size next to the Selected: N counter, so the amount of data an action
will touch is visible before clicking.

Sizes come from the rows' existing data-size attributes. Group rows in
Untracked Files carry the whole group's size in data-size (used for
sorting) and their children are selected too, so group rows expose their
own file in a new data-file-size attribute to avoid counting children
twice. Duplicate file rows get a data-size attribute. formatBytes()
mirrors core.system_utils.format_bytes so the figure matches the
operation pill.
…ree cards

Untracked Files, Backup Cleanup and Duplicates now show the action
buttons on the first line and the "Selected: N · size" summary on its own
line below them, in a slightly larger type. This gives the summary room
and keeps the three cards identical. Spacing above the buttons and below
the summary is balanced.

On the Duplicates card the "Sonarr/Radarr integration active" notice moves
next to "Scanned ..." in the badge row, which frees the line above the
buttons, and the left and right button groups are top-aligned.

Purely visual and independent of the size display in the previous commit;
it can be dropped without affecting it.
@Brandon-Haney

Copy link
Copy Markdown
Collaborator

Thanks, this is nicely done. I rendered both commits against current main with some sample data (a group with sidecars, single files, backups and duplicates) and the totals come out right on all three cards, with the group's sidecars counted once. The data-file-size on group rows is a clean way to handle that.

I was going to ask you to drop commit 2, but seeing it side by side changed my mind. The selection line is much easier to read on its own row than squeezed in next to the buttons, all three cards change the same way, and moving the Sonarr/Radarr line up next to "Scanned" saves the line you add. Happy to keep both.

Commit 1 only vs commit 1 + 2, all three maintenance cards

One small thing: could formatBytes() go in web/static/js/app.js instead of maintenance/index.html? It's loaded on every page, so other pages can use the same one rather than each carrying its own copy (settings/cache.html already has a separate one).

Once that's in, this looks good to merge from my side.

Brandon-Haney added a commit to Brandon-Haney/PlexCache-R that referenced this pull request Oct 3, 2026
@DeLo1585

DeLo1585 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Small note on the base and on other open PRs: the branch is based on current main (6bc18fe, the #219 merge), but that doesn't matter for this PR. Between e2010d6 (#222) and 6bc18fe only web/static/css/custom.css changed. The three templates this PR touches (maintenance/index.html, partials/audit_results.html, partials/duplicate_card.html) are identical in both, so it applies cleanly on either, and it doesn't depend on #219.

It also doesn't overlap with #218: that PR only changes web/static/css/custom.css and web/templates/base.html, while this one only touches the three maintenance templates above and uses inline styles instead of custom.css. No shared files, so the two can be merged in any order without conflicts.

As suggested in review: app.js is loaded on every page, so other pages can
use the same helper instead of carrying their own copy. It mirrors
core.system_utils.format_bytes.

settings/cache.html declares its own GB/TB-only formatBytes() before app.js
loads, so the shared one is only defined when no page has declared one
already; that page keeps its current output.
@DeLo1585

DeLo1585 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

give me some moments ... i will comment if i updated everything to final

If formatBytes() is not available (for example a browser still using a cached
app.js from before the helper moved there), setSelectedSize() threw inside the
checkbox handler, so selecting a group no longer selected its children and the
count was wrong. Catch it and just show no size.
@DeLo1585

DeLo1585 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks! I pushed two small follow-ups. Feel free to have a look @Brandon-Haney @StudioNirin

1. formatBytes() now lives in app.js. One catch: settings/cache.html has its own GB/TB-only version, which a plain declaration would have overwritten (changing that page's output). So app.js only defines it if nothing else has. cache.html is untouched.

2. The size display can no longer break the selection. While testing I ended up with the new index.html but an old app.js without formatBytes. The size call then threw inside the checkbox handler, so ticking a group no longer selected its children (I got "Selected: 3" instead of 36). Now it's wrapped in a try/catch: worst case there's simply no size, and the selection keeps working.

Easy to check: keep an old app.js without the formatBytes block and tick a group in Untracked Files. Before the second commit the count stays at the number of groups, now it's correct and only the size is missing.

Heads-up for testing/updating: if the size doesn't show up after an update, please clear the browser cache for app.js once. A private window did not help me, but clearing the cached files in the browser settings did, after which three groups show "Selected: 36 · 21.80 GB", which matches the group sizes.

@Brandon-Haney Brandon-Haney left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both follow-ups look good, thanks. Approving from my side.

@StudioNirin
StudioNirin merged commit 00a7715 into StudioNirin:main Oct 6, 2026
2 checks passed
@DeLo1585
DeLo1585 deleted the feat/220-selected-size branch October 6, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Show total size of selected untracked files

3 participants