mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-7679] Reduce the usage of AppConfigService in components and tests (#9563)
* remove unused app config setting * remove unused app config setting * remove unnecessary app config service reference * remove unnecessary app config service reference * remove unnecessary app config service reference * remove unnecessary app config service reference * remove unnecessary app config service reference * support input params for the viewer; optional configuration * remove useless imports [ci:force] * fix imports [ci:force]
This commit is contained in:
@@ -24,7 +24,6 @@ import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||
import { ClipboardService } from '../../../clipboard/clipboard.service';
|
||||
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
||||
import { MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
@@ -34,18 +33,11 @@ describe('CardViewDateItemComponent', () => {
|
||||
let loader: HarnessLoader;
|
||||
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
||||
let component: CardViewDateItemComponent;
|
||||
let appConfigService: AppConfigService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), CoreTestingModule]
|
||||
});
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
appConfigService.config.dateValues = {
|
||||
defaultDateFormat: 'shortDate',
|
||||
defaultDateTimeFormat: 'M/d/yy, h:mm a',
|
||||
defaultLocale: 'uk'
|
||||
};
|
||||
|
||||
fixture = TestBed.createComponent(CardViewDateItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -43,12 +43,14 @@ import { DownloadPromptDialogComponent } from './download-prompt-dialog/download
|
||||
import { AppConfigService } from '../../app-config';
|
||||
import { DownloadPromptActions } from '../models/download-prompt.actions';
|
||||
|
||||
const DEFAULT_NON_PREVIEW_CONFIG = {
|
||||
enableDownloadPrompt: false,
|
||||
enableDownloadPromptReminder: false,
|
||||
downloadPromptDelay: 50,
|
||||
downloadPromptReminderDelay: 30
|
||||
};
|
||||
export interface ViewerComponentConfig {
|
||||
enableDownloadPrompt?: boolean;
|
||||
enableDownloadPromptReminder?: boolean;
|
||||
downloadPromptDelay?: number;
|
||||
downloadPromptReminderDelay?: number;
|
||||
enableFileAutoDownload?: boolean;
|
||||
fileAutoDownloadSizeThresholdInMB?: number;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer',
|
||||
@@ -200,22 +202,26 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
||||
/**
|
||||
* Enable dialog box to allow user to download the previewed file, in case the preview is not responding for a set period of time.
|
||||
*/
|
||||
enableDownloadPrompt: boolean = false;
|
||||
@Input()
|
||||
enableDownloadPrompt = false;
|
||||
|
||||
/**
|
||||
* Enable reminder dialogs to prompt user to download the file, in case the preview is not responding for a set period of time.
|
||||
*/
|
||||
enableDownloadPromptReminder: boolean = false;
|
||||
@Input()
|
||||
enableDownloadPromptReminder = false;
|
||||
|
||||
/**
|
||||
* Initial time in seconds to wait before giving the first prompt to user to download the file
|
||||
*/
|
||||
downloadPromptDelay: number = 50;
|
||||
@Input()
|
||||
downloadPromptDelay = 50;
|
||||
|
||||
/**
|
||||
* Time in seconds to wait before giving the second and consequent reminders to the user to download the file.
|
||||
*/
|
||||
downloadPromptReminderDelay: number = 15;
|
||||
@Input()
|
||||
downloadPromptReminderDelay = 15;
|
||||
|
||||
/**
|
||||
* Emitted when user clicks on download button on download prompt dialog.
|
||||
@@ -390,12 +396,20 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private configureDownloadPromptProperties() {
|
||||
const nonResponsivePreviewConfig = this.appConfigService.get('viewer', DEFAULT_NON_PREVIEW_CONFIG);
|
||||
const config = this.appConfigService.get<ViewerComponentConfig>('viewer');
|
||||
|
||||
this.enableDownloadPrompt = nonResponsivePreviewConfig.enableDownloadPrompt;
|
||||
this.enableDownloadPromptReminder = nonResponsivePreviewConfig.enableDownloadPromptReminder;
|
||||
this.downloadPromptDelay = nonResponsivePreviewConfig.downloadPromptDelay;
|
||||
this.downloadPromptReminderDelay = nonResponsivePreviewConfig.downloadPromptReminderDelay;
|
||||
if (config) {
|
||||
this.enableDownloadPrompt = config.enableDownloadPrompt === true;
|
||||
this.enableDownloadPromptReminder = config.enableDownloadPromptReminder === true;
|
||||
|
||||
if (config.downloadPromptDelay !== undefined) {
|
||||
this.downloadPromptDelay = config.downloadPromptDelay;
|
||||
}
|
||||
|
||||
if (config.downloadPromptReminderDelay !== undefined) {
|
||||
this.downloadPromptReminderDelay = config.downloadPromptReminderDelay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private initDownloadPrompt() {
|
||||
|
Reference in New Issue
Block a user