mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-4679] Added code changes and env variables to enable DownloadPrompt and FileAutoDownload features on ACA (#3127)
* [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 * [ACA-4679] Added defaults for downloadPrompt for viewer and fileAutoDownload features. Updated variable names from 'nonResponsiveDialog' to 'downloadPrompt' * [ACA-4679] Added unit test cases for FileAutoDownloadService * [ACA-4679] Updated env variable references from NonResponsiveDialog to DownloadPrompt * [ACA-4679] Added missing licence header on new files * [ACA-4679] Added env variable configuration for GithubActions jobs * [ACA-4679] Added env variable configuration for GithubActions jobs * [ACA-4679] Removed unneeded env variable configuration for GithubActions jobs * [ACA-4679] Updated .env file configuration in README.md
This commit is contained in:
parent
f86c80d444
commit
9148ccc6a9
6
.github/workflows/pull-request.yml
vendored
6
.github/workflows/pull-request.yml
vendored
@ -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:
|
||||
|
@ -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_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
|
||||
|
||||
COPY docker/default.conf.template /etc/nginx/templates/
|
||||
COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/
|
||||
|
@ -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.
|
||||
|
@ -1184,5 +1184,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": {
|
||||
"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}
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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() {
|
||||
|
@ -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 }));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
@ -71,7 +72,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.extensions
|
||||
@ -133,15 +139,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*!
|
||||
* 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';
|
||||
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 });
|
||||
});
|
||||
});
|
@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* 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';
|
||||
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 });
|
||||
}
|
||||
}
|
@ -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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user