Mediabibliotheek: verwijderen naar prullenbak in de UI, terugzetten, opruimen bevestigen, migratieplan, besluiten van Bryan in de docs
Continuous Integration / changes (pull_request) Successful in 14s
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 48s
Continuous Integration / compile-sites (pull_request) Canceled after 52s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 57s
Continuous Integration / changes (pull_request) Successful in 14s
Continuous Integration / config-sls (pull_request) Successful in 9s
Continuous Integration / config-asf (pull_request) Successful in 8s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 48s
Continuous Integration / compile-sites (pull_request) Canceled after 52s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 57s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -216,3 +216,29 @@ Text alternative: a module screen uses the picker, which either chooses a librar
|
||||
- Phase C: the existing `HeroImages` are copied as library records with the same ids, hashes and set hashes (design section 6), after which the Hero screen switches to the picker.
|
||||
- **Other modules** (gallery, mosaic, masonry) use the picker from the start, with their own use definition (`GalleryUses`) deciding the ratios and crops of the chosen photo.
|
||||
- **Rights and limits**: the same Owner and Administrator rights as the library; the hero upload rate limit (100 per user per hour) applies to the shared upload service.
|
||||
|
||||
## 11. Delete, trash and last use (built 2026-11-17, decisions 8, 10, 12, 21)
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
L[Library or Clean-up] -->|delete ids| C[MediaLibraryService]
|
||||
C -->|uses again| P[Usage provider]
|
||||
P -->|none, or confirmed twice| T[Module trash: detach and DeletedAt]
|
||||
T --> TR[(Trash 7 days)]
|
||||
TR -->|restore| P
|
||||
TR -->|after the period| R[Retired files, removed with the sets]
|
||||
classDef a fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
|
||||
classDef b fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
|
||||
classDef c fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
|
||||
class L a;
|
||||
class C,P b;
|
||||
class T,TR,R c;
|
||||
```
|
||||
|
||||
Text alternative: delete goes through the library service, which checks the usage again and asks the module to trash the photo; the trash keeps it for the trash period and can restore it; afterwards its files are retired and removed.
|
||||
|
||||
- API: `POST media-library/delete {ids, confirmedInUse}` and `POST media-library/restore {ids}` (at most 100 ids), `GET media-library/trash`; the answer lists a status per photo (`trashed`, `inUse`, `notFound`, `failed`).
|
||||
- Hero: `HeroImages.DeletedAt`, `LastUsedAt`, `OriginalFileName` (additive migration `AddMediaLibraryColumns`); a trashed image is left out of every Hero lookup, the renderer and slide validation; slides using it are removed when it is trashed; `HeroMediaCleanup` empties the trash after `Media:TrashDays`.
|
||||
- Last use: `LastUsedAt` is set when a hero save detaches the photo from its last slide, and when it is trashed while in use. The clean-up counts from there (assumption 29).
|
||||
- Frontend: `DeleteDialog` (first and second confirmation), trash view with Restore, the clean-up dialog now confirms into the same delete flow.
|
||||
- The migration to own tables is planned in `migration-plan.md` (not built).
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Migration plan: HeroImages to the library's own tables (decision 13)
|
||||
|
||||
Status: plan, not built, not run anywhere. Decided by Bryan 2026-11-17 (via SLP Software - SLS - Main): it may be built in the next step, **only after this plan with its back-up and rollback exists**, **rolled out to TEST only (never production)**, and **SLS-Main is told before anything is deployed to test**.
|
||||
|
||||
## Goal
|
||||
|
||||
Give every photo one library record that does not depend on the Hero: `MediaAsset` (the photo) and `MediaUse` (where it is used), with **the same ids, hashes, set hashes and public addresses** as today. Nothing in `/media/hero/<setHash>/...` changes, so ASF, SLS and the golden files stay as they are.
|
||||
|
||||
## Why expand then contract
|
||||
|
||||
| Phase | What | Reversible? |
|
||||
|---|---|---|
|
||||
| 0 Back-up | Back-up of the database and a listing of the media directory (below). | n/a |
|
||||
| 1 Expand | New tables `MediaAssets` and `MediaUses`, filled by copying `HeroImages` and `HeroSlides`. The Hero keeps reading and writing its own tables; the library reads the new tables behind a setting. | Yes: drop the two new tables, nothing else changed. |
|
||||
| 2 Switch | Hero reads photos from the library tables (setting on). New uploads write both (dual write) so the old tables stay complete. | Yes: switch the setting off; the old tables are complete. |
|
||||
| 3 Contract (a later release, after acceptance) | The Hero stops writing its own image columns; they are dropped in a separate migration. | Only from the back-up of that moment. Not part of the first rollout. |
|
||||
|
||||
Files are never moved or renamed: the migration changes rows only, so the media directory is the same before and after.
|
||||
|
||||
## Mapping
|
||||
|
||||
| `HeroImages` column | `MediaAssets` column | Note |
|
||||
|---|---|---|
|
||||
| `Id` | `Id` | Same id, so references keep working. |
|
||||
| `OriginalSha256`, `OriginalKey`, `SourceFormat`, `Width`, `Height`, `Bytes` | same | |
|
||||
| `FocusX`, `FocusY`, `Zoom` | `DefaultFocusX`, `DefaultFocusY`, `DefaultZoom` | The photo's default focus. |
|
||||
| `WideFocus*`, `TallFocus*` | `MediaUses` rows (one per slide use, ratios `wide` and `tall`) | The per-use crop; for a photo without a slide the default focus is enough. |
|
||||
| `SetHash`, `Variants` | `MediaUses.SetHash` (per use) | Unchanged values; computed by the existing formula. |
|
||||
| `CreatedAt`, `CreatedByUserId` | same | |
|
||||
| `OriginalFileName`, `LastUsedAt`, `DeletedAt` | same | Added in the media-library step (additive columns of the Hero). |
|
||||
|
||||
| `HeroSlides` | `MediaUses` |
|
||||
|---|---|
|
||||
| `Id`, `ImageId` | `Id`, `AssetId` (module `hero`, place kind `slide`, place id = slide id) |
|
||||
|
||||
## Back-up (before phase 1, every environment)
|
||||
|
||||
1. **Database**: a full dump of the Hero database (and of the CMS database if it is one), written to a dated file outside the deploy directory, for example `mysqldump --single-transaction <database> > hero-before-media-migration-YYYYMMDD.sql`. Keep it until the contract phase is accepted.
|
||||
2. **Media directory**: nothing is moved, but a listing with sizes and hashes is saved (`find <Media__Directory> -type f -exec sha256sum {} +` to a text file) so the directory can be compared afterwards. On the Raspberry Pi a copy of the directory is also a quick option (`cp -a`), if there is room.
|
||||
3. **Row counts** noted: `HeroImages`, `HeroSlides`, `HeroRetiredFiles`.
|
||||
|
||||
## Verification (right after phase 1, every environment)
|
||||
|
||||
The migration job compares and **aborts** (rolls its transaction back) on any difference:
|
||||
|
||||
- number of `MediaAssets` = number of `HeroImages` (all rows, also those in the trash);
|
||||
- every `HeroImages.Id`, `OriginalSha256` and `SetHash` has an identical `MediaAssets`/`MediaUses` counterpart;
|
||||
- number of `MediaUses` of module `hero` = number of `HeroSlides`;
|
||||
- a sample of ten public addresses (`/media/hero/<setHash>/<file>`) is requested before and after and gives the same bytes (checked by the smoke test).
|
||||
|
||||
## Rollback
|
||||
|
||||
| When | How |
|
||||
|---|---|
|
||||
| The verification fails | The migration runs in one transaction and rolls back by itself; nothing is left. |
|
||||
| After phase 1, before the switch | Drop `MediaUses` and `MediaAssets` (the EF `Down` migration). The Hero never read them. |
|
||||
| After the switch | Switch the setting back (`Media:Library:ReadFromLibrary=false`); the old tables are complete because of the dual write. Then drop the new tables if wanted. |
|
||||
| After the contract phase (later) | Restore the database dump taken before that migration and the media listing check. |
|
||||
|
||||
## Roll-out rules (from Bryan)
|
||||
|
||||
1. **Test only.** No production variables, no production deploy, no release branch.
|
||||
2. **Tell SLS-Main before deploying to test** (they run the deploy and the smoke test).
|
||||
3. Back-up first (above), on the test host too.
|
||||
4. Deploy with the setting **off**, check the verification result in the log, then switch it on, then the smoke test (hero markers, `/theme-init.js`, a sample of media addresses), then Bryan checks the admin.
|
||||
|
||||
## What is built first (next step, when this plan is accepted)
|
||||
|
||||
1. A new module `SlpModularCms.Modules.Media` with its own `DbContext`, the tables `MediaAssets` and `MediaUses` and an additive EF migration (no existing table touched), with tests.
|
||||
2. The copy-and-verify job (idempotent, safe to run twice) behind a setting; unit and in-memory tests, and a test against MariaDB.
|
||||
3. The library reading from the new tables behind `Media:Library:ReadFromLibrary` (default off).
|
||||
|
||||
Nothing in steps 1 to 3 runs without the setting, so a deploy of that code alone changes no data except the new, empty tables.
|
||||
@@ -39,9 +39,9 @@
|
||||
| ML-02 | **Usage indicator.** Per photo: "in use" or "not used", and where (module and place, for example "Hero, slide 3"). | Several uses are all listed; the indicator is computed from the modules' own data, not guessed; a photo used nowhere shows "Not used". |
|
||||
| ML-03 | **Keep everything.** No automatic removal of any photo or its files. | The Hero step that retires unattached images is switched off once the library owns the retention (see section 8, phase A: behind a setting, default decided in the assumptions); a test proves nothing is removed without a person's action. |
|
||||
| ML-04 | **Selection component** (own reusable component): checkboxes per photo, select all and clear, a range with shift-click, keyboard operation, a visible count, and a live-region announcement of the count. | Works for mouse, keyboard and screen reader; reused by the library and the clean-up; uses the shared `Checkbox` of the theme. |
|
||||
| ML-05 | **Bulk actions** on the selection, in the library itself. First action: **Delete**. The action bar is a separate component so more actions (tags, move) can be added without touching the list. | Delete asks for confirmation naming the number of photos and how many are in use; a failure of one photo does not stop the others and is reported per photo. |
|
||||
| ML-06 | **Delete rules.** A photo that is in use is not deleted unless the person explicitly confirms and the use is detached first. | Default: in-use photos are not selectable for delete in "Clean up" and are marked in the library; deleting an in-use photo from the library shows what will lose its image and requires a second confirmation; the host falls back as it does today for a slide without a set. |
|
||||
| ML-07 | **"Clean up" button.** Opens the overview of photos that would be cleaned: default everything older than 7 days, with a slider to look more or fewer days back, and a checkbox **Only unused photos**, default on (off = all photos in the period). | The list is newest first; all rows start selected; the person can deselect before confirming; confirming deletes exactly the selected rows; the summary shows the number and the bytes that will be freed. |
|
||||
| ML-05 | **Bulk actions** on the selection, in the library itself. First action: **Delete** (to the trash, ML-18). The action bar is a separate component so more actions (tags, move) can be added without touching the list. | Delete asks for confirmation naming the number of photos and how many are in use; a failure of one photo does not stop the others and is reported per photo. |
|
||||
| ML-06 | **Delete rules** (decision 10). A photo that is in use can be deleted after a **second confirmation that names the places**; the module detaches it first (Hero: its slides are removed). | The first confirmation says how many photos and how many are in use; the second names the places per photo; the server refuses a photo in use unless the request carries the confirmation and checks the usage again at that moment; one photo failing does not stop the others and is reported per photo. |
|
||||
| ML-07 | **"Clean up" button.** Opens the overview of photos that would be cleaned: default everything not used for more than 7 days (counted from the LAST USE, decision 8), with a slider to look more or fewer days back, and a checkbox **Only unused photos**, default on (off = all photos in the period). | The list is newest first; all rows start selected; the person can deselect before confirming; confirming deletes exactly the selected rows; the summary shows the number and the bytes that will be freed. |
|
||||
| ML-08 | **Clean-up is the same component as the library** (ML-04, ML-05) in a preselected view, not a second implementation. | One list/selection component, two entry points. |
|
||||
| ML-09 | **Storage usage and limit warning.** The screen shows the used space (originals plus variants), the configured limit, and a warning at a threshold and at the limit. | Used bytes are computed from the store and cached for a short time; the warning level is configurable (assumption: 80 percent); at the limit, uploads give a clear message instead of a failure; the existing `Media:MaxTotalBytes` (2 GB) is the limit. |
|
||||
| ML-10 | **Upload into the library** (single and multiple), with the same limits and checks as Hero today (type signature, size, megapixels, rate limit). | The Hero upload path and the library share one upload service; the same file is one photo (hash). |
|
||||
@@ -105,3 +105,12 @@
|
||||
| 8 (2026-11-17) Choose or upload in every part that needs an image | ML-17, design section 10 |
|
||||
| 7 Crop per use | ML-11, ML-12, design section 4 |
|
||||
| Boundary: addresses and set hashes | ML-14, NFR-ML-05 |
|
||||
|
||||
## 11. Added by decisions of 2026-11-17
|
||||
|
||||
| ID | Requirement | Acceptance criteria |
|
||||
|---|---|---|
|
||||
| ML-18 | **Trash** (decision 12). Delete means "to the trash": recoverable for 7 days (`Media:TrashDays`); a trash view lists the photos with Restore; after the period the files are removed by the existing retired-file mechanism. Uploading the same file again brings it back. | A trashed photo is hidden from the hero and from the renderer; restore returns it (without its old slides); the clean-up of the trash is idempotent; a photo is never removed while it is referenced. |
|
||||
| ML-19 | **Original file name** is stored at every upload (additive) and shown in the library; photos from before keep a neutral label. | The name is cleaned (no path, no control characters, at most 200 characters) and never used as a path. |
|
||||
| ML-20 | **Last use** per photo: the moment it was last detached from a slide (or trashed); the clean-up period counts from there, from the upload date for a photo that was never used. | See assumption 29. |
|
||||
| ML-21 | **Migration of the Hero photos** to the library's own tables, expand then contract, same ids, hashes and addresses; documented back-up and rollback first; test only; SLS-Main is told before a test deploy. | See `migration-plan.md`. |
|
||||
|
||||
Reference in New Issue
Block a user