[ACA-4681] Added file auto download feature to DocumentList component (#8423)

* [ACA-4681] Added feature in DocumentListComponent to auto download a file if it exceeds a pre defined file size threshold

* [ACA-4681] Added test cases for file auto download feature in document list (NOT WORKING)

* [ACA-4681] Fixed unit tests for file auto download feature of document list

* [ACA-4681] Removed unused variables from app.config.json

* [ACA-4681] Resolved code review findings. Local constants are no longer upper case only (used camelCase instead). FileAutoDownload component template now uses mat-dialog provided directives and components. Removed file-auto-download.component.scss. Removed unused methods from file-auto-download.component.ts

* [ACA-4681] Added licence info to file-auto-download-actions.enum.ts

* [ACA-4681] Added license info to file-auto-download.component.ts

* [ACA-4681] Removed empty constructor

* [ACA-4681] Updated appConfig property name from "preview-config" to "viewer".

* [ACA-4681] Added JSDoc for FileAutoDownloadActionsEnum

* [ACA-4681] Updated ADF demo shell application to use "viewer" appConfig object instead of "preview-config"

* [ACA-4681] Resolved lint issues

* [ACA-4681] Removed dependency from NodeActionsService inside DocumentListComponent. FileAutoDownload component now directly triggers the file download, instead of emitting FileAutoDownloadActionsEnum.Download.

* [ACA-4681] Removed unused async. Updated import statement

* [ACA-4681] Added FileAutoDownloadComponent to public-api.ts
This commit is contained in:
swapnil-verma-gl
2023-04-04 13:01:23 +05:30
committed by GitHub
parent 2bd72f71d5
commit fc3ad78004
12 changed files with 247 additions and 7 deletions

View File

@@ -66,6 +66,10 @@ import { LockService } from '../services/lock.service';
import { DocumentLoaderNode } from '../models/document-folder.model';
import { takeUntil } from 'rxjs/operators';
import { ADF_DOCUMENT_PARENT_COMPONENT } from './document-list.token';
import { MatDialog } from '@angular/material/dialog';
import { FileAutoDownloadComponent } from './file-auto-download/file-auto-download.component';
const BYTES_TO_MB_CONVERSION_VALUE = 1048576;
@Component({
selector: 'adf-document-list',
@@ -367,7 +371,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
private alfrescoApiService: AlfrescoApiService,
private nodeService: NodesApiService,
private dataTableService: DataTableService,
private lockService: LockService) {
private lockService: LockService,
private dialog: MatDialog) {
this.nodeService.nodeUpdated.subscribe((node) => {
this.dataTableService.rowUpdate.next({id: node.id, obj: {entry: node}});
@@ -758,7 +763,16 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
onPreviewFile(node: NodeEntry) {
if (node) {
this.preview.emit(new NodeEntityEvent(node));
const sizeInMB = node.entry?.content?.sizeInBytes / BYTES_TO_MB_CONVERSION_VALUE;
const fileAutoDownloadFlag: boolean = this.appConfig.get('viewer.enableFileAutoDownload', true);
const sizeThreshold: number = this.appConfig.get('viewer.fileAutoDownloadSizeThresholdInMB', 15);
if (fileAutoDownloadFlag && sizeInMB && sizeInMB > sizeThreshold) {
this.dialog.open(FileAutoDownloadComponent, { disableClose: true, data: node });
} else {
this.preview.emit(new NodeEntityEvent(node));
}
}
}