From 0cc8187c135da96808cf896f2d30aa3c9e6138df Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Mon, 3 Apr 2023 15:39:59 +0530 Subject: [PATCH 1/9] [ACA-4679] Added docker variables, app.config.json.tpl config and additional code for enabling non-responsive file preview download and file auto download features in ACA --- Dockerfile | 6 +++++ app/src/app.config.json.tpl | 8 ++++++ .../favorites/favorites.component.ts | 7 ++--- .../lib/components/files/files.component.ts | 7 ++--- .../recent-files/recent-files.component.ts | 7 ++--- .../search-results-row.component.ts | 14 ++++++++-- .../search-results.component.ts | 7 ++--- .../shared-files/shared-files.component.ts | 8 +++--- .../toolbar/view-node/view-node.component.ts | 21 +++++++++------ .../document-base-page.component.ts | 26 ++++++++++++------ .../aca-file-auto-download.service.ts | 27 +++++++++++++++++++ projects/aca-shared/src/public-api.ts | 1 + 12 files changed, 105 insertions(+), 34 deletions(-) create mode 100644 projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts diff --git a/Dockerfile b/Dockerfile index 7d11cc96b2..6660b7dbea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,12 @@ ENV APP_CONFIG_PLUGIN_FOLDER_RULES=true ENV APP_CONFIG_PLUGIN_CONTENT_SERVICE=true ENV APP_CONFIG_ENABLE_MOBILE_APP_SWITCH=true ENV APP_CONFIG_SESSION_TIME_FOR_OPEN_APP_DIALOG_DISPLAY_IN_HOURS="12" +ENV APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG=true +ENV APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS=true +ENV APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS=50 +ENV APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS=30 +ENV APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD=true +ENV APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB=15 COPY docker/default.conf.template /etc/nginx/templates/ COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/ diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json.tpl index 824efb2f9b..343a83fbbe 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json.tpl @@ -1187,5 +1187,13 @@ "cm:taggable", "app:inlineeditable", "cm:geographic", "exif:exif", "audio:audio", "cm:indexControl", "dp:restrictable", "smf:customConfigSmartFolder", "smf:systemConfigSmartFolder"], "ai": ["ai:products", "ai:dates", "ai:places", "ai:events", "ai:organizations", "ai:people", "ai:things", "ai:quantities", "ai:creativeWorks", "ai:labels", "ai:textLines"] + }, + "viewer": { + "enableNonResponsiveDialog": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG}, + "enableNonResponsiveDialogReminders": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS}, + "nonResponsivePreviewInitialTimerInSeconds": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS}, + "nonResponsivePreviewReminderTimerInSeconds": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS}, + "enableFileAutoDownload": ${APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD}, + "fileAutoDownloadSizeThresholdInMB": ${APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB} } } diff --git a/projects/aca-content/src/lib/components/favorites/favorites.component.ts b/projects/aca-content/src/lib/components/favorites/favorites.component.ts index 17ce0aac5b..ef942f1113 100644 --- a/projects/aca-content/src/lib/components/favorites/favorites.component.ts +++ b/projects/aca-content/src/lib/components/favorites/favorites.component.ts @@ -22,7 +22,7 @@ * from Hyland Software. If not, see <http://www.gnu.org/licenses/>. */ -import { AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared'; +import { AcaFileAutoDownloadService, AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared'; import { AppStore } from '@alfresco/aca-shared/store'; import { UploadService } from '@alfresco/adf-content-services'; import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, PathInfo } from '@alfresco/js-api'; @@ -49,9 +49,10 @@ export class FavoritesComponent extends PageComponent implements OnInit { private contentApi: ContentApiService, content: ContentManagementService, private uploadService: UploadService, - private breakpointObserver: BreakpointObserver + private breakpointObserver: BreakpointObserver, + fileAutoDownloadService: AcaFileAutoDownloadService ) { - super(store, extensions, content); + super(store, extensions, content, fileAutoDownloadService); } ngOnInit() { diff --git a/projects/aca-content/src/lib/components/files/files.component.ts b/projects/aca-content/src/lib/components/files/files.component.ts index d3723c4366..91116719d7 100644 --- a/projects/aca-content/src/lib/components/files/files.component.ts +++ b/projects/aca-content/src/lib/components/files/files.component.ts @@ -29,7 +29,7 @@ import { Store } from '@ngrx/store'; import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElement, PathElementEntity } from '@alfresco/js-api'; import { ContentManagementService } from '../../services/content-management.service'; import { NodeActionsService } from '../../services/node-actions.service'; -import { AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared'; +import { AcaFileAutoDownloadService, AppExtensionService, ContentApiService, PageComponent } from '@alfresco/aca-shared'; import { SetCurrentFolderAction, isAdmin, AppStore, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { debounceTime, takeUntil } from 'rxjs/operators'; @@ -61,9 +61,10 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { private uploadService: UploadService, content: ContentManagementService, extensions: AppExtensionService, - private breakpointObserver: BreakpointObserver + private breakpointObserver: BreakpointObserver, + fileAutoDownloadService: AcaFileAutoDownloadService ) { - super(store, extensions, content); + super(store, extensions, content, fileAutoDownloadService); } ngOnInit() { diff --git a/projects/aca-content/src/lib/components/recent-files/recent-files.component.ts b/projects/aca-content/src/lib/components/recent-files/recent-files.component.ts index e5ad0e78ef..140ee9e0ed 100644 --- a/projects/aca-content/src/lib/components/recent-files/recent-files.component.ts +++ b/projects/aca-content/src/lib/components/recent-files/recent-files.component.ts @@ -31,7 +31,7 @@ import { AppStore } from '@alfresco/aca-shared/store'; import { UploadService } from '@alfresco/adf-content-services'; import { debounceTime } from 'rxjs/operators'; import { Router } from '@angular/router'; -import { AppExtensionService, PageComponent } from '@alfresco/aca-shared'; +import { AcaFileAutoDownloadService, AppExtensionService, PageComponent } from '@alfresco/aca-shared'; import { DocumentListPresetRef } from '@alfresco/adf-extensions'; @Component({ @@ -48,9 +48,10 @@ export class RecentFilesComponent extends PageComponent implements OnInit { content: ContentManagementService, private uploadService: UploadService, private breakpointObserver: BreakpointObserver, - private router: Router + private router: Router, + fileAutoDownloadService: AcaFileAutoDownloadService ) { - super(store, extensions, content); + super(store, extensions, content, fileAutoDownloadService); } ngOnInit() { diff --git a/projects/aca-content/src/lib/components/search/search-results-row/search-results-row.component.ts b/projects/aca-content/src/lib/components/search/search-results-row/search-results-row.component.ts index b14fba8912..ed1e006cdc 100644 --- a/projects/aca-content/src/lib/components/search/search-results-row/search-results-row.component.ts +++ b/projects/aca-content/src/lib/components/search/search-results-row/search-results-row.component.ts @@ -30,6 +30,7 @@ import { BehaviorSubject, Subject } from 'rxjs'; import { NodesApiService } from '@alfresco/adf-content-services'; import { takeUntil } from 'rxjs/operators'; import { Router } from '@angular/router'; +import { AcaFileAutoDownloadService } from '@alfresco/aca-shared'; @Component({ selector: 'aca-search-results-row', @@ -49,7 +50,12 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy { name$ = new BehaviorSubject<string>(''); title$ = new BehaviorSubject<string>(''); - constructor(private store: Store<any>, private nodesApiService: NodesApiService, private router: Router) {} + constructor( + private store: Store<any>, + private nodesApiService: NodesApiService, + private router: Router, + private fileAutoDownloadService: AcaFileAutoDownloadService + ) {} ngOnInit() { this.updateValues(); @@ -93,7 +99,11 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy { showPreview(event: Event) { event.stopPropagation(); - this.store.dispatch(new ViewNodeAction(this.node.entry.id, { location: this.router.url })); + if (this.fileAutoDownloadService.shouldFileAutoDownload(this.node.entry.content.sizeInBytes)) { + this.fileAutoDownloadService.autoDownloadFile(this.node); + } else { + this.store.dispatch(new ViewNodeAction(this.node.entry.id, { location: this.router.url })); + } } navigate(event: Event) { diff --git a/projects/aca-content/src/lib/components/search/search-results/search-results.component.ts b/projects/aca-content/src/lib/components/search/search-results/search-results.component.ts index 9bde3ce1f2..6bdafe2771 100644 --- a/projects/aca-content/src/lib/components/search/search-results/search-results.component.ts +++ b/projects/aca-content/src/lib/components/search/search-results/search-results.component.ts @@ -40,7 +40,7 @@ import { import { ContentManagementService } from '../../../services/content-management.service'; import { TranslationService } from '@alfresco/adf-core'; import { combineLatest, Observable } from 'rxjs'; -import { AppExtensionService, PageComponent } from '@alfresco/aca-shared'; +import { AcaFileAutoDownloadService, AppExtensionService, PageComponent } from '@alfresco/aca-shared'; import { SearchSortingDefinition } from '@alfresco/adf-content-services/lib/search/models/search-sorting-definition.interface'; import { takeUntil } from 'rxjs/operators'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; @@ -70,9 +70,10 @@ export class SearchResultsComponent extends PageComponent implements OnInit { content: ContentManagementService, private translationService: TranslationService, private router: Router, - private breakpointObserver: BreakpointObserver + private breakpointObserver: BreakpointObserver, + fileAutoDownloadService: AcaFileAutoDownloadService ) { - super(store, extensions, content); + super(store, extensions, content, fileAutoDownloadService); queryBuilder.paging = { skipCount: 0, diff --git a/projects/aca-content/src/lib/components/shared-files/shared-files.component.ts b/projects/aca-content/src/lib/components/shared-files/shared-files.component.ts index 7a1db295bc..408b494225 100644 --- a/projects/aca-content/src/lib/components/shared-files/shared-files.component.ts +++ b/projects/aca-content/src/lib/components/shared-files/shared-files.component.ts @@ -30,9 +30,8 @@ import { debounceTime } from 'rxjs/operators'; import { UploadService } from '@alfresco/adf-content-services'; import { Router } from '@angular/router'; import { MinimalNodeEntity } from '@alfresco/js-api'; -import { AppExtensionService, AppHookService, PageComponent } from '@alfresco/aca-shared'; +import { AcaFileAutoDownloadService, AppExtensionService, AppHookService, PageComponent } from '@alfresco/aca-shared'; import { DocumentListPresetRef } from '@alfresco/adf-extensions'; - @Component({ templateUrl: './shared-files.component.html' }) @@ -48,9 +47,10 @@ export class SharedFilesComponent extends PageComponent implements OnInit { private appHookService: AppHookService, private uploadService: UploadService, private breakpointObserver: BreakpointObserver, - private router: Router + private router: Router, + fileAutoDownloadService: AcaFileAutoDownloadService ) { - super(store, extensions, content); + super(store, extensions, content, fileAutoDownloadService); } ngOnInit() { diff --git a/projects/aca-content/src/lib/components/toolbar/view-node/view-node.component.ts b/projects/aca-content/src/lib/components/toolbar/view-node/view-node.component.ts index 8420dcd8d5..53d207b44b 100644 --- a/projects/aca-content/src/lib/components/toolbar/view-node/view-node.component.ts +++ b/projects/aca-content/src/lib/components/toolbar/view-node/view-node.component.ts @@ -28,6 +28,7 @@ import { AppStore, ViewNodeAction, getAppSelection } from '@alfresco/aca-shared/ import { Router } from '@angular/router'; import { take } from 'rxjs/operators'; import { SharedLinkEntry } from '@alfresco/js-api'; +import { AcaFileAutoDownloadService } from '@alfresco/aca-shared'; @Component({ selector: 'app-view-node', @@ -53,22 +54,26 @@ import { SharedLinkEntry } from '@alfresco/js-api'; export class ViewNodeComponent { @Input() data: { title?: string; menuButton?: boolean; iconButton?: boolean }; - constructor(private store: Store<AppStore>, private router: Router) {} + constructor(private store: Store<AppStore>, private router: Router, private fileAutoDownloadService: AcaFileAutoDownloadService) {} onClick() { this.store .select(getAppSelection) .pipe(take(1)) .subscribe((selection) => { - let id: string; - - if (selection.file.entry.nodeType === 'app:filelink') { - id = selection.file.entry.properties['cm:destination']; + if (this.fileAutoDownloadService.shouldFileAutoDownload(selection.file.entry?.content?.sizeInBytes)) { + this.fileAutoDownloadService.autoDownloadFile(selection.file); } else { - id = (selection.file as SharedLinkEntry).entry.nodeId || (selection.file as any).entry.guid || selection.file.entry.id; - } + let id: string; - this.store.dispatch(new ViewNodeAction(id, { location: this.router.url })); + if (selection.file.entry.nodeType === 'app:filelink') { + id = selection.file.entry.properties['cm:destination']; + } else { + id = (selection.file as SharedLinkEntry).entry.nodeId || (selection.file as any).entry.guid || selection.file.entry.id; + } + + this.store.dispatch(new ViewNodeAction(id, { location: this.router.url })); + } }); } } diff --git a/projects/aca-shared/src/lib/components/document-base-page/document-base-page.component.ts b/projects/aca-shared/src/lib/components/document-base-page/document-base-page.component.ts index 1e5abbbcd1..010b4c4614 100644 --- a/projects/aca-shared/src/lib/components/document-base-page/document-base-page.component.ts +++ b/projects/aca-shared/src/lib/components/document-base-page/document-base-page.component.ts @@ -45,6 +45,7 @@ import { } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '../../services/app.extension.service'; import { isLibrary, isLocked } from '../../utils/node.utils'; +import { AcaFileAutoDownloadService } from '../../services/aca-file-auto-download.service'; /* eslint-disable @angular-eslint/directive-class-suffix */ @Directive() @@ -70,7 +71,12 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { protected subscriptions: Subscription[] = []; - protected constructor(protected store: Store<AppStore>, protected extensions: AppExtensionService, protected content: DocumentBasePageService) {} + protected constructor( + protected store: Store<AppStore>, + protected extensions: AppExtensionService, + protected content: DocumentBasePageService, + private fileAutoDownloadService: AcaFileAutoDownloadService = null + ) {} ngOnInit() { this.sharedPreviewUrl$ = this.store.select(getSharedUrl); @@ -125,15 +131,19 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { showPreview(node: MinimalNodeEntity, extras?: ViewNodeExtras) { if (node && node.entry) { - let id: string; - - if (node.entry.nodeType === 'app:filelink') { - id = node.entry.properties['cm:destination']; + if (this.fileAutoDownloadService?.shouldFileAutoDownload(node.entry?.content?.sizeInBytes)) { + this.fileAutoDownloadService.autoDownloadFile(node); } else { - id = (node as any).entry.nodeId || (node as any).entry.guid || node.entry.id; - } + let id: string; - this.store.dispatch(new ViewNodeAction(id, extras)); + if (node.entry.nodeType === 'app:filelink') { + id = node.entry.properties['cm:destination']; + } else { + id = (node as any).entry.nodeId || (node as any).entry.guid || node.entry.id; + } + + this.store.dispatch(new ViewNodeAction(id, extras)); + } } } diff --git a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts new file mode 100644 index 0000000000..99d70c311a --- /dev/null +++ b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { AppConfigService } from '@alfresco/adf-core'; +import { NodeEntry } from '@alfresco/js-api'; +import { FileAutoDownloadComponent } from '@alfresco/adf-content-services'; + +const BYTES_TO_MB_CONVERSION_VALUE = 1048576; + +@Injectable({ + providedIn: 'root' +}) +export class AcaFileAutoDownloadService { + constructor(private dialog: MatDialog, private appConfig: AppConfigService) {} + + public shouldFileAutoDownload(fileSizeInBytes: number): boolean { + const sizeInMB = fileSizeInBytes / BYTES_TO_MB_CONVERSION_VALUE; + + const fileAutoDownloadFlag: boolean = this.appConfig.get('viewer.enableFileAutoDownload', true); + const sizeThreshold: number = this.appConfig.get('viewer.fileAutoDownloadSizeThresholdInMB', 15); + + return fileAutoDownloadFlag && sizeInMB && sizeInMB > sizeThreshold; + } + + public autoDownloadFile(node: NodeEntry) { + this.dialog.open(FileAutoDownloadComponent, { disableClose: true, data: node }); + } +} diff --git a/projects/aca-shared/src/public-api.ts b/projects/aca-shared/src/public-api.ts index b0fed0587a..b54edf65cf 100644 --- a/projects/aca-shared/src/public-api.ts +++ b/projects/aca-shared/src/public-api.ts @@ -60,6 +60,7 @@ export * from './lib/services/app.extension.service'; export * from './lib/services/router.extension.service'; export * from './lib/services/app-hook.service'; export * from './lib/services/alfresco-office-extension.service'; +export * from './lib/services/aca-file-auto-download.service'; export * from './lib/utils/node.utils'; export * from './lib/shared.module'; From b44f47e22bd01b80448cb593702dac2c369e29a8 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Tue, 18 Apr 2023 17:19:34 +0530 Subject: [PATCH 2/9] [ACA-4679] Added defaults for downloadPrompt for viewer and fileAutoDownload features. Updated variable names from 'nonResponsiveDialog' to 'downloadPrompt' --- app/src/app.config.json.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json.tpl index 343a83fbbe..1d62be1a86 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json.tpl @@ -1189,10 +1189,10 @@ "ai": ["ai:products", "ai:dates", "ai:places", "ai:events", "ai:organizations", "ai:people", "ai:things", "ai:quantities", "ai:creativeWorks", "ai:labels", "ai:textLines"] }, "viewer": { - "enableNonResponsiveDialog": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG}, - "enableNonResponsiveDialogReminders": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS}, - "nonResponsivePreviewInitialTimerInSeconds": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS}, - "nonResponsivePreviewReminderTimerInSeconds": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS}, + "enableDownloadPrompt": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG}, + "enableDownloadPromptReminder": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS}, + "downloadPromptDelay": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS}, + "downloadPromptReminderDelay": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS}, "enableFileAutoDownload": ${APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD}, "fileAutoDownloadSizeThresholdInMB": ${APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB} } From 33505a30859494d9ac3580a62648ded95b26a041 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Tue, 18 Apr 2023 17:55:12 +0530 Subject: [PATCH 3/9] [ACA-4679] Added unit test cases for FileAutoDownloadService --- .../aca-file-auto-download.service.spec.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts diff --git a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts new file mode 100644 index 0000000000..b568180756 --- /dev/null +++ b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts @@ -0,0 +1,58 @@ +import { TestBed } from '@angular/core/testing'; +import { AcaFileAutoDownloadService, initialState, LibTestingModule } from '@alfresco/aca-shared'; +import { MatDialog } from '@angular/material/dialog'; +import { AppConfigService } from '@alfresco/adf-core'; +import { FileAutoDownloadComponent } from '@alfresco/adf-content-services'; +import { provideMockStore } from '@ngrx/store/testing'; + +describe('AcaFileAutoDownloadService', () => { + let service: AcaFileAutoDownloadService; + let appConfig: AppConfigService; + + const mockDialogRef = { + open: jasmine.createSpy('open') + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [LibTestingModule], + providers: [provideMockStore({ initialState }), { provide: MatDialog, useValue: mockDialogRef }] + }); + + service = TestBed.inject(AcaFileAutoDownloadService); + appConfig = TestBed.inject(AppConfigService); + }); + + it('shouldFileAutoDownload should return true if fileSize exceeds configured threshold and file auto download is enabled', () => { + appConfig.config.viewer = { + enableFileAutoDownload: true, + fileAutoDownloadSizeThresholdInMB: 10 + }; + const shouldAutDownloadFlag = service.shouldFileAutoDownload(11000000); + expect(shouldAutDownloadFlag).toBe(true); + }); + + it('shouldFileAutoDownload should return false if fileSize does not exceeds configured threshold and file auto download is enabled', () => { + appConfig.config.viewer = { + enableFileAutoDownload: true, + fileAutoDownloadSizeThresholdInMB: 10 + }; + const shouldAutDownloadFlag = service.shouldFileAutoDownload(500000); + expect(shouldAutDownloadFlag).toBe(false); + }); + + it('shouldFileAutoDownload should return false if fileSize exceeds configured threshold but file auto download is disabled', () => { + appConfig.config.viewer = { + enableFileAutoDownload: false, + fileAutoDownloadSizeThresholdInMB: 10 + }; + const shouldAutDownloadFlag = service.shouldFileAutoDownload(11000000); + expect(shouldAutDownloadFlag).toBe(false); + }); + + it('autoDownloadFile should open FileAutoDownload dialog when called', () => { + const nodeEntity: any = { entry: { isFile: true } }; + service.autoDownloadFile(nodeEntity); + expect(mockDialogRef.open).toHaveBeenCalledWith(FileAutoDownloadComponent, { disableClose: true, data: nodeEntity }); + }); +}); From 62b6e46c4c651b850fe4a25dff5f0211741ab98f Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Tue, 18 Apr 2023 17:59:16 +0530 Subject: [PATCH 4/9] [ACA-4679] Updated env variable references from NonResponsiveDialog to DownloadPrompt --- Dockerfile | 8 ++++---- app/src/app.config.json.tpl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6660b7dbea..774c79da00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,10 +38,10 @@ ENV APP_CONFIG_PLUGIN_FOLDER_RULES=true ENV APP_CONFIG_PLUGIN_CONTENT_SERVICE=true ENV APP_CONFIG_ENABLE_MOBILE_APP_SWITCH=true ENV APP_CONFIG_SESSION_TIME_FOR_OPEN_APP_DIALOG_DISPLAY_IN_HOURS="12" -ENV APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG=true -ENV APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS=true -ENV APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS=50 -ENV APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS=30 +ENV APP_CONFIG_ENABLE_DOWNLOAD_PROMPT=true +ENV APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS=true +ENV APP_CONFIG_DOWNLOAD_PROMPT_DELAY=50 +ENV APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY=30 ENV APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD=true ENV APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB=15 diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json.tpl index 1d62be1a86..ccc0b1132b 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json.tpl @@ -1189,10 +1189,10 @@ "ai": ["ai:products", "ai:dates", "ai:places", "ai:events", "ai:organizations", "ai:people", "ai:things", "ai:quantities", "ai:creativeWorks", "ai:labels", "ai:textLines"] }, "viewer": { - "enableDownloadPrompt": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG}, - "enableDownloadPromptReminder": ${APP_CONFIG_ENABLE_NON_RESPONSIVE_DIALOG_REMINDERS}, - "downloadPromptDelay": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_TIMER_IN_SECONDS}, - "downloadPromptReminderDelay": ${APP_CONFIG_NON_RESPONSIVE_DIALOG_REMINDER_TIMER_IN_SECONDS}, + "enableDownloadPrompt": ${APP_CONFIG_ENABLE_DOWNLOAD_PROMPT}, + "enableDownloadPromptReminder": ${APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS}, + "downloadPromptDelay": ${APP_CONFIG_DOWNLOAD_PROMPT_DELAY}, + "downloadPromptReminderDelay": ${APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY}, "enableFileAutoDownload": ${APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD}, "fileAutoDownloadSizeThresholdInMB": ${APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB} } From a0387736191717f575b4a2cba77bc79cdf6f4d1b Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Wed, 19 Apr 2023 12:04:20 +0530 Subject: [PATCH 5/9] [ACA-4679] Added missing licence header on new files --- .../aca-file-auto-download.service.spec.ts | 24 +++++++++++++++++++ .../aca-file-auto-download.service.ts | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts index b568180756..8f262ee9a0 100644 --- a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts +++ b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.spec.ts @@ -1,3 +1,27 @@ +/*! + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Alfresco Example Content Application + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * from Hyland Software. If not, see <http://www.gnu.org/licenses/>. + */ + import { TestBed } from '@angular/core/testing'; import { AcaFileAutoDownloadService, initialState, LibTestingModule } from '@alfresco/aca-shared'; import { MatDialog } from '@angular/material/dialog'; diff --git a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts index 99d70c311a..cae72d2af5 100644 --- a/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts +++ b/projects/aca-shared/src/lib/services/aca-file-auto-download.service.ts @@ -1,3 +1,27 @@ +/*! + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Alfresco Example Content Application + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * from Hyland Software. If not, see <http://www.gnu.org/licenses/>. + */ + import { Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { AppConfigService } from '@alfresco/adf-core'; From 7f35de65a19ebb55498b2c53f72b73e9b9c43175 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Wed, 19 Apr 2023 12:36:21 +0530 Subject: [PATCH 6/9] [ACA-4679] Added env variable configuration for GithubActions jobs --- .github/actions/run-e2e/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/run-e2e/action.yml b/.github/actions/run-e2e/action.yml index ba96bb3e06..a3603f1b65 100644 --- a/.github/actions/run-e2e/action.yml +++ b/.github/actions/run-e2e/action.yml @@ -37,6 +37,12 @@ runs: echo "APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/" echo "APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/" echo "APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI={protocol}//{hostname}{:port}/assets/silent-refresh.html" + echo "APP_CONFIG_ENABLE_DOWNLOAD_PROMPT=true" + echo "APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS=true" + echo "APP_CONFIG_DOWNLOAD_PROMPT_DELAY=50" + echo "APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY=30" + echo "APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD=true" + echo "APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB=15" } >> .env npm start > /dev/null &\ From d3187647b132fd17bbcef88bbc4998d5bc2a866c Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Wed, 19 Apr 2023 13:26:03 +0530 Subject: [PATCH 7/9] [ACA-4679] Added env variable configuration for GithubActions jobs --- .github/workflows/pull-request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0d6f25ee32..433742131c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,6 +30,12 @@ env: APP_CONFIG_OAUTH2_REDIRECT_LOGOUT: / APP_CONFIG_OAUTH2_REDIRECT_LOGIN: / APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI: "{protocol}//{hostname}{:port}/assets/silent-refresh.html" + APP_CONFIG_ENABLE_DOWNLOAD_PROMPT: true + APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS: true + APP_CONFIG_DOWNLOAD_PROMPT_DELAY: 50 + APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY: 30 + APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD: true + APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB: 15 jobs: lint: From 8934014921a1a2eafd9bf65f11feacb85d7daf9e Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Wed, 19 Apr 2023 14:24:17 +0530 Subject: [PATCH 8/9] [ACA-4679] Removed unneeded env variable configuration for GithubActions jobs --- .github/actions/run-e2e/action.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/actions/run-e2e/action.yml b/.github/actions/run-e2e/action.yml index a3603f1b65..ba96bb3e06 100644 --- a/.github/actions/run-e2e/action.yml +++ b/.github/actions/run-e2e/action.yml @@ -37,12 +37,6 @@ runs: echo "APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/" echo "APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/" echo "APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI={protocol}//{hostname}{:port}/assets/silent-refresh.html" - echo "APP_CONFIG_ENABLE_DOWNLOAD_PROMPT=true" - echo "APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS=true" - echo "APP_CONFIG_DOWNLOAD_PROMPT_DELAY=50" - echo "APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY=30" - echo "APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD=true" - echo "APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB=15" } >> .env npm start > /dev/null &\ From 958ba89890dd0881047b04bddd0c26bd2a7cbc51 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" <swapnil.verma@globallogic.com> Date: Thu, 20 Apr 2023 14:23:14 +0530 Subject: [PATCH 9/9] [ACA-4679] Updated .env file configuration in README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 5a6e818e05..6a27877b82 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,15 @@ APP_CONFIG_OAUTH2_SILENT_LOGIN=true APP_CONFIG_OAUTH2_REDIRECT_LOGOUT=/ APP_CONFIG_OAUTH2_REDIRECT_LOGIN=/ APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI="{protocol}//{hostname}{:port}/assets/silent-refresh.html" + + # Download Prompt configurations +APP_CONFIG_ENABLE_DOWNLOAD_PROMPT=true +APP_CONFIG_ENABLE_DOWNLOAD_PROMPT_REMINDERS=true +APP_CONFIG_DOWNLOAD_PROMPT_DELAY=<time> +APP_CONFIG_DOWNLOAD_PROMPT_REMINDER_DELAY=<time> +APP_CONFIG_ENABLE_FILE_AUTO_DOWNLOAD=true +APP_CONFIG_FILE_AUTO_DOWNLOAD_SIZE_THRESHOLD_IN_MB=<file-size> + ``` Where `<URL>` is the address of the ACS.