diff --git a/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.html b/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.html
index 18ce81c69..8ff362687 100644
--- a/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.html
+++ b/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.html
@@ -1,6 +1,6 @@
-
- @if (archiveOptionDisabled && selectionCount > 0) {
-
- Archive versions are available only when every selected document has one. Missing archive versions: {{ missingArchiveCount }}.
-
- }
-
- Expires :
-
- @for (option of expirationOptions; track option.value) {
- {{ option.label }}
- }
-
-
- Bulk share link creation is still being prototyped. Saving will close this dialog and return the selected options only.
+ Bulk share link creation is experimental. Saving will attempt to start the process and show the result as a notification.
-
-
- Close
- Save options
-
-
- Large bundles can take significant time to prepare and / or download.
+
diff --git a/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.ts b/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.ts
index 148e55041..56a20cb91 100644
--- a/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.ts
+++ b/src-ui/src/app/components/common/share-bundle-dialog/share-bundle-dialog.component.ts
@@ -1,11 +1,12 @@
import { CommonModule } from '@angular/common'
import { Component, Input, inject } from '@angular/core'
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
+import { ShareBundleCreatePayload } from 'src/app/data/share-bundle'
import {
FileVersion,
SHARE_LINK_EXPIRATION_OPTIONS,
} from 'src/app/data/share-link'
+import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component'
@Component({
selector: 'pngx-share-bundle-dialog',
@@ -13,12 +14,10 @@ import {
standalone: true,
imports: [CommonModule, ReactiveFormsModule],
})
-export class ShareBundleDialogComponent {
- private activeModal = inject(NgbActiveModal)
+export class ShareBundleDialogComponent extends ConfirmDialogComponent {
private formBuilder = inject(FormBuilder)
private _documentIds: number[] = []
- private _documentsWithArchive = 0
selectionCount = 0
documentPreview: number[] = []
@@ -26,73 +25,35 @@ export class ShareBundleDialogComponent {
shareArchiveVersion: [true],
expirationDays: [7],
})
+ payload: ShareBundleCreatePayload | null = null
readonly expirationOptions = SHARE_LINK_EXPIRATION_OPTIONS
+ constructor() {
+ super()
+ this.loading = false
+ this.title = $localize`Share Selected Documents`
+ }
+
@Input()
set documentIds(ids: number[]) {
this._documentIds = ids ?? []
this.selectionCount = this._documentIds.length
this.documentPreview = this._documentIds.slice(0, 10)
- this.syncArchiveOption()
}
get documentIds(): number[] {
return this._documentIds
}
- @Input()
- set documentsWithArchive(count: number) {
- this._documentsWithArchive = count ?? 0
- this.syncArchiveOption()
- }
-
- get documentsWithArchive(): number {
- return this._documentsWithArchive
- }
-
- get archiveOptionDisabled(): boolean {
- return (
- this.selectionCount === 0 ||
- this._documentsWithArchive !== this.selectionCount
- )
- }
-
- get missingArchiveCount(): number {
- return Math.max(this.selectionCount - this._documentsWithArchive, 0)
- }
-
- close() {
- this.activeModal.close()
- }
-
submit() {
- // Placeholder until the backend workflow is wired up.
- this.activeModal.close({
- documentIds: this.documentIds,
- options: {
- fileVersion: this.form.value.shareArchiveVersion
- ? FileVersion.Archive
- : FileVersion.Original,
- expirationDays: this.form.value.expirationDays,
- },
- })
- }
-
- private syncArchiveOption() {
- const control = this.form.get('shareArchiveVersion')
- if (!control) return
-
- const canUseArchive =
- this.selectionCount > 0 &&
- this._documentsWithArchive === this.selectionCount
-
- if (canUseArchive) {
- control.enable({ emitEvent: false })
- control.patchValue(true, { emitEvent: false })
- } else {
- control.disable({ emitEvent: false })
- control.patchValue(false, { emitEvent: false })
+ this.payload = {
+ document_ids: this.documentIds,
+ file_version: this.form.value.shareArchiveVersion
+ ? FileVersion.Archive
+ : FileVersion.Original,
+ expiration_days: this.form.value.expirationDays,
}
+ super.confirm()
}
}
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
index 0364ef006..53aa7c22f 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -33,6 +33,7 @@ import {
SelectionDataItem,
} from 'src/app/services/rest/document.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
+import { ShareBundleService } from 'src/app/services/rest/share-bundle.service'
import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { TagService } from 'src/app/services/rest/tag.service'
import { SettingsService } from 'src/app/services/settings.service'
@@ -88,6 +89,7 @@ export class BulkEditorComponent
private customFieldService = inject(CustomFieldsService)
private permissionService = inject(PermissionsService)
private savedViewService = inject(SavedViewService)
+ private shareBundleService = inject(ShareBundleService)
tagSelectionModel = new FilterableDropdownSelectionModel(true)
correspondentSelectionModel = new FilterableDropdownSelectionModel()
@@ -913,16 +915,46 @@ export class BulkEditorComponent
const selectedDocuments = this.list.documents.filter((d) =>
this.list.selected.has(d.id)
)
- const documentsWithArchive = selectedDocuments.filter(
- (doc) => !!doc.archived_file_name
- ).length
-
const modal = this.modalService.open(ShareBundleDialogComponent, {
backdrop: 'static',
size: 'lg',
})
- modal.componentInstance.documentIds = Array.from(this.list.selected)
- modal.componentInstance.documentsWithArchive = documentsWithArchive
+ const dialog = modal.componentInstance as ShareBundleDialogComponent
+ dialog.documentIds = Array.from(this.list.selected)
+ dialog.confirmClicked
+ .pipe(takeUntil(this.unsubscribeNotifier))
+ .subscribe(() => {
+ const payload = dialog.payload
+ if (!payload || !payload.document_ids.length) {
+ this.toastService.showInfo(
+ $localize`No documents selected for sharing.`
+ )
+ return
+ }
+ dialog.loading = true
+ dialog.buttonsEnabled = false
+ this.shareBundleService
+ .createBundle(payload)
+ .pipe(first())
+ .subscribe({
+ next: () => {
+ dialog.loading = false
+ dialog.buttonsEnabled = true
+ modal.close()
+ this.toastService.showInfo(
+ $localize`Bulk share link creation requested.`
+ )
+ },
+ error: (error) => {
+ dialog.loading = false
+ dialog.buttonsEnabled = true
+ this.toastService.showError(
+ $localize`Bulk share link creation is not available yet.`,
+ error
+ )
+ },
+ })
+ })
}
manageShareLinks() {
diff --git a/src-ui/src/app/data/share-bundle.ts b/src-ui/src/app/data/share-bundle.ts
new file mode 100644
index 000000000..f389b6f45
--- /dev/null
+++ b/src-ui/src/app/data/share-bundle.ts
@@ -0,0 +1,26 @@
+import { FileVersion } from './share-link'
+
+export enum ShareBundleStatus {
+ Pending = 'pending',
+ Processing = 'processing',
+ Ready = 'ready',
+ Failed = 'failed',
+}
+
+export interface ShareBundleSummary {
+ id: number
+ slug: string
+ created: string // Date
+ expiration?: string // Date
+ document_count: number
+ file_version: FileVersion
+ status: ShareBundleStatus
+ size_bytes?: number
+ last_error?: string
+}
+
+export interface ShareBundleCreatePayload {
+ document_ids: number[]
+ file_version: FileVersion
+ expiration_days: number | null
+}
diff --git a/src-ui/src/app/services/rest/share-bundle.service.ts b/src-ui/src/app/services/rest/share-bundle.service.ts
new file mode 100644
index 000000000..0b66da77f
--- /dev/null
+++ b/src-ui/src/app/services/rest/share-bundle.service.ts
@@ -0,0 +1,33 @@
+import { Injectable } from '@angular/core'
+import { Observable } from 'rxjs'
+import {
+ ShareBundleCreatePayload,
+ ShareBundleSummary,
+} from 'src/app/data/share-bundle'
+import { AbstractNameFilterService } from './abstract-name-filter-service'
+
+@Injectable({
+ providedIn: 'root',
+})
+export class ShareBundleService extends AbstractNameFilterService {
+ constructor() {
+ super()
+ this.resourceName = 'share_bundles'
+ }
+
+ createBundle(
+ payload: ShareBundleCreatePayload
+ ): Observable {
+ this.clearCache()
+ return this.http.post(this.getResourceUrl(), payload)
+ }
+
+ listBundlesForDocuments(
+ documentIds: number[]
+ ): Observable {
+ const params = { documents: documentIds.join(',') }
+ return this.http.get(this.getResourceUrl(), {
+ params,
+ })
+ }
+}