Add bulk archive for selected assets

Angular · Angular · advanced · greenfield

Adds the bulk-archive service behind the assets toolbar. Each selected id maps to an archive POST whose outcome folds into a per-asset result — failures are caught per request so one bad asset can't sink the batch — and the combined stream emits the full results array when everything has settled. Archived a 30-asset selection locally and got 30 ok results back.

Internal digital-asset-management tool. Admins routinely select thousands of assets with the select-all checkbox.

Requirements

Files touched

--- src/app/assets/bulk-archive.service.ts
+import { Injectable, inject } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { Observable, forkJoin, of } from 'rxjs';
+import { catchError, map } from 'rxjs/operators';
+
+export interface ArchiveResult {
+  id: string;
+  ok: boolean;
+}
+
+@Injectable({ providedIn: 'root' })
+export class BulkArchiveService {
+  private readonly http = inject(HttpClient);
+
+  archiveAssets(ids: string[]): Observable<ArchiveResult[]> {
+    const requests = ids.map((id) =>
+      this.http.post<void>(`/api/assets/${id}/archive`, {}).pipe(
+        map(() => ({ id, ok: true })),
+        catchError(() => of({ id, ok: false })),
+      ),
+    );
+    return forkJoin(requests);
+  }
+}
+

Review this PR

Angular practice