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:
@@ -17,14 +17,12 @@
|
|||||||
|
|
||||||
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
|
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { NodeEntry, Node, SitePaging, Site } from '@alfresco/js-api';
|
import { NodeEntry, Node, SitePaging, Site } from '@alfresco/js-api';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { DocumentListService, NodeAction } from '../document-list';
|
||||||
import { DocumentListService } from '../document-list/services/document-list.service';
|
|
||||||
import { ContentNodeDialogService } from './content-node-dialog.service';
|
import { ContentNodeDialogService } from './content-node-dialog.service';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { Subject, of } from 'rxjs';
|
import { Subject, of } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
import { NodeAction } from '../document-list/models/node-action.enum';
|
import { SitesService } from '../common';
|
||||||
import { SitesService } from '../common/services/sites.service';
|
|
||||||
|
|
||||||
const fakeNodeEntry = {
|
const fakeNodeEntry = {
|
||||||
entry: {
|
entry: {
|
||||||
@@ -71,9 +69,6 @@ describe('ContentNodeDialogService', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ContentTestingModule]
|
imports: [ContentTestingModule]
|
||||||
});
|
});
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
|
||||||
|
|
||||||
service = TestBed.inject(ContentNodeDialogService);
|
service = TestBed.inject(ContentNodeDialogService);
|
||||||
documentListService = TestBed.inject(DocumentListService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
materialDialog = TestBed.inject(MatDialog);
|
materialDialog = TestBed.inject(MatDialog);
|
||||||
|
@@ -19,12 +19,8 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|||||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { Node, NodeEntry, NodePaging, ResultSetPaging, Site, SiteEntry, SitePaging, SitePagingList, UserInfo } from '@alfresco/js-api';
|
import { Node, NodeEntry, NodePaging, ResultSetPaging, Site, SiteEntry, SitePaging, SitePagingList, UserInfo } from '@alfresco/js-api';
|
||||||
import { AppConfigService, DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
|
import { DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
|
||||||
import { ContentService } from '../common/services/content.service';
|
import { ContentService, UploadService, NodesApiService, SitesService, FileModel, FileUploadStatus, FileUploadCompleteEvent } from '../common';
|
||||||
import { UploadService } from '../common/services/upload.service';
|
|
||||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
|
||||||
import { FileModel, FileUploadStatus } from '../common/models/file.model';
|
|
||||||
import { FileUploadCompleteEvent } from '../common/events/file.event';
|
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { DropdownBreadcrumbComponent } from '../breadcrumb';
|
import { DropdownBreadcrumbComponent } from '../breadcrumb';
|
||||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||||
@@ -35,7 +31,6 @@ import { NodeEntryEvent, ShareDataRow, ShareDataTableAdapter } from '../document
|
|||||||
import { SearchQueryBuilderService } from '../search';
|
import { SearchQueryBuilderService } from '../search';
|
||||||
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
||||||
import { mockContentModelTextProperty } from '../mock/content-model.mock';
|
import { mockContentModelTextProperty } from '../mock/content-model.mock';
|
||||||
import { SitesService } from '../common/services/sites.service';
|
|
||||||
|
|
||||||
const fakeResultSetPaging: ResultSetPaging = {
|
const fakeResultSetPaging: ResultSetPaging = {
|
||||||
list: {
|
list: {
|
||||||
@@ -732,32 +727,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Sorting', () => {
|
|
||||||
let appConfigService: AppConfigService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
appConfigService = TestBed.inject(AppConfigService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should read the sorting value from appConfig json in case it is present', async () => {
|
|
||||||
const fakeSortingConfig = ['fakeKey', 'fakeAsc'];
|
|
||||||
|
|
||||||
appConfigService.config = Object.assign(appConfigService.config, {
|
|
||||||
'adf-content-node-selector': { sorting: fakeSortingConfig }
|
|
||||||
});
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(component.sorting).toEqual(fakeSortingConfig);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should take default sorting when there is no content node selector sorting config in appConfig json', async () => {
|
|
||||||
appConfigService.config = null;
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(component.sorting).toEqual(['createdAt', 'desc']);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Selected nodes counter', () => {
|
describe('Selected nodes counter', () => {
|
||||||
it('should getSelectedCount return 0 by default', () => {
|
it('should getSelectedCount return 0 by default', () => {
|
||||||
expect(component.getSelectedCount()).toBe(0);
|
expect(component.getSelectedCount()).toBe(0);
|
||||||
|
@@ -22,26 +22,22 @@ import {
|
|||||||
UserPreferenceValues,
|
UserPreferenceValues,
|
||||||
InfinitePaginationComponent,
|
InfinitePaginationComponent,
|
||||||
PaginatedComponent,
|
PaginatedComponent,
|
||||||
AppConfigService,
|
|
||||||
DataSorting,
|
DataSorting,
|
||||||
ShowHeaderMode
|
ShowHeaderMode
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
import { NodesApiService, UploadService, FileUploadCompleteEvent, FileUploadDeleteEvent, SitesService } from '../common';
|
||||||
import { UploadService } from '../common/services/upload.service';
|
|
||||||
import { FileUploadCompleteEvent, FileUploadDeleteEvent } from '../common/events/file.event';
|
|
||||||
import { UntypedFormControl } from '@angular/forms';
|
import { UntypedFormControl } from '@angular/forms';
|
||||||
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, SearchRequest, RequestScope } from '@alfresco/js-api';
|
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, SearchRequest, RequestScope } from '@alfresco/js-api';
|
||||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||||
import { RowFilter } from '../document-list/data/row-filter.model';
|
import { RowFilter } from '../document-list/data/row-filter.model';
|
||||||
import { ImageResolver } from '../document-list/data/image-resolver.model';
|
import { ImageResolver } from '../document-list/data/image-resolver.model';
|
||||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
|
||||||
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
|
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
|
||||||
import { ShareDataRow } from '../document-list/data/share-data-row.model';
|
import { ShareDataRow } from '../document-list/data/share-data-row.model';
|
||||||
import { Subject } from 'rxjs';
|
|
||||||
import { SearchQueryBuilderService } from '../search/services/search-query-builder.service';
|
|
||||||
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
|
||||||
import { NodeEntryEvent } from '../document-list/components/node.event';
|
import { NodeEntryEvent } from '../document-list/components/node.event';
|
||||||
import { SitesService } from '../common/services/sites.service';
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
import { SearchQueryBuilderService } from '../search';
|
||||||
|
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
|
||||||
|
|
||||||
export type ValidationFunction = (entry: Node) => boolean;
|
export type ValidationFunction = (entry: Node) => boolean;
|
||||||
|
|
||||||
@@ -262,7 +258,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
preselectedNodes: NodeEntry[] = [];
|
preselectedNodes: NodeEntry[] = [];
|
||||||
currentUploadBatch: NodeEntry[] = [];
|
currentUploadBatch: NodeEntry[] = [];
|
||||||
|
|
||||||
sorting: string[] | DataSorting;
|
sorting: string[] | DataSorting = ['createdAt', 'desc'];
|
||||||
|
|
||||||
searchPanelExpanded: boolean = false;
|
searchPanelExpanded: boolean = false;
|
||||||
|
|
||||||
@@ -275,7 +271,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private sitesService: SitesService,
|
private sitesService: SitesService,
|
||||||
private appConfigService: AppConfigService,
|
|
||||||
private contentNodeSelectorPanelService: ContentNodeSelectorPanelService
|
private contentNodeSelectorPanelService: ContentNodeSelectorPanelService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -347,8 +342,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
|||||||
this.documentList.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((currentNode: Node) => {
|
this.documentList.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((currentNode: Node) => {
|
||||||
this.currentFolder.emit(currentNode);
|
this.currentFolder.emit(currentNode);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sorting = this.appConfigService.get('adf-content-node-selector.sorting', ['createdAt', 'desc']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@@ -18,9 +18,8 @@
|
|||||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { NotificationService, AppConfigService } from '@alfresco/adf-core';
|
import { NotificationService } from '@alfresco/adf-core';
|
||||||
import { NodesApiService } from '../common/services/nodes-api.service';
|
import { NodesApiService, RenditionService } from '../common';
|
||||||
import { RenditionService } from '../common/services/rendition.service';
|
|
||||||
import { SharedLinksApiService } from './services/shared-links-api.service';
|
import { SharedLinksApiService } from './services/shared-links-api.service';
|
||||||
import { ShareDialogComponent } from './content-node-share.dialog';
|
import { ShareDialogComponent } from './content-node-share.dialog';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
@@ -43,7 +42,6 @@ describe('ShareDialogComponent', () => {
|
|||||||
let nodesApiService: NodesApiService;
|
let nodesApiService: NodesApiService;
|
||||||
let fixture: ComponentFixture<ShareDialogComponent>;
|
let fixture: ComponentFixture<ShareDialogComponent>;
|
||||||
let component: ShareDialogComponent;
|
let component: ShareDialogComponent;
|
||||||
let appConfigService: AppConfigService;
|
|
||||||
|
|
||||||
const shareToggleId = '[data-automation-id="adf-share-toggle"]';
|
const shareToggleId = '[data-automation-id="adf-share-toggle"]';
|
||||||
const expireToggle = '[data-automation-id="adf-expire-toggle"]';
|
const expireToggle = '[data-automation-id="adf-expire-toggle"]';
|
||||||
@@ -77,7 +75,6 @@ describe('ShareDialogComponent', () => {
|
|||||||
sharedLinksApiService = TestBed.inject(SharedLinksApiService);
|
sharedLinksApiService = TestBed.inject(SharedLinksApiService);
|
||||||
renditionService = TestBed.inject(RenditionService);
|
renditionService = TestBed.inject(RenditionService);
|
||||||
nodesApiService = TestBed.inject(NodesApiService);
|
nodesApiService = TestBed.inject(NodesApiService);
|
||||||
appConfigService = TestBed.inject(AppConfigService);
|
|
||||||
|
|
||||||
node = {
|
node = {
|
||||||
entry: {
|
entry: {
|
||||||
@@ -330,10 +327,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update node with input date and end of day time when type is `date`', async () => {
|
it('should update node with input date and end of day time when type is `date`', async () => {
|
||||||
const dateTimePickerType = 'date';
|
|
||||||
const date = new Date('2525-01-01');
|
const date = new Date('2525-01-01');
|
||||||
spyOn(appConfigService, 'get').and.callFake(() => dateTimePickerType as any);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const toggle = await loader.getHarness(MatSlideToggleHarness.with({ selector: expireToggle }));
|
const toggle = await loader.getHarness(MatSlideToggleHarness.with({ selector: expireToggle }));
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NgModule, ModuleWithProviders } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { MaterialModule } from '../material.module';
|
import { MaterialModule } from '../material.module';
|
||||||
@@ -23,30 +23,8 @@ import { ShareDialogComponent } from './content-node-share.dialog';
|
|||||||
import { NodeSharedDirective } from './content-node-share.directive';
|
import { NodeSharedDirective } from './content-node-share.directive';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [CoreModule, CommonModule, MaterialModule],
|
||||||
CoreModule,
|
declarations: [ShareDialogComponent, NodeSharedDirective],
|
||||||
CommonModule,
|
exports: [ShareDialogComponent, NodeSharedDirective]
|
||||||
MaterialModule
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
ShareDialogComponent,
|
|
||||||
NodeSharedDirective
|
|
||||||
],
|
|
||||||
exports: [
|
|
||||||
ShareDialogComponent,
|
|
||||||
NodeSharedDirective
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class ContentNodeShareModule {
|
export class ContentNodeShareModule {}
|
||||||
static forRoot(): ModuleWithProviders<ContentNodeShareModule> {
|
|
||||||
return {
|
|
||||||
ngModule: ContentNodeShareModule
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static forChild(): ModuleWithProviders<ContentNodeShareModule> {
|
|
||||||
return {
|
|
||||||
ngModule: ContentNodeShareModule
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -57,7 +57,8 @@ import {
|
|||||||
DataRow,
|
DataRow,
|
||||||
DataTableService,
|
DataTableService,
|
||||||
DataTableSchema,
|
DataTableSchema,
|
||||||
DataColumn
|
DataColumn,
|
||||||
|
ViewerComponentConfig
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||||
import { Node, NodeEntry, NodePaging, NodesApi, Pagination } from '@alfresco/js-api';
|
import { Node, NodeEntry, NodePaging, NodesApi, Pagination } from '@alfresco/js-api';
|
||||||
@@ -789,9 +790,10 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
|
|||||||
onPreviewFile(node: NodeEntry) {
|
onPreviewFile(node: NodeEntry) {
|
||||||
if (node) {
|
if (node) {
|
||||||
const sizeInMB = node.entry?.content?.sizeInBytes / BYTES_TO_MB_CONVERSION_VALUE;
|
const sizeInMB = node.entry?.content?.sizeInBytes / BYTES_TO_MB_CONVERSION_VALUE;
|
||||||
|
const config = this.appConfig.get<ViewerComponentConfig>('viewer');
|
||||||
|
|
||||||
const fileAutoDownloadFlag: boolean = this.appConfig.get('viewer.enableFileAutoDownload', true);
|
const fileAutoDownloadFlag = config?.enableFileAutoDownload ?? true;
|
||||||
const sizeThreshold: number = this.appConfig.get('viewer.fileAutoDownloadSizeThresholdInMB', 15);
|
const sizeThreshold = config?.fileAutoDownloadSizeThresholdInMB ?? 15;
|
||||||
|
|
||||||
if (fileAutoDownloadFlag && sizeInMB && sizeInMB > sizeThreshold) {
|
if (fileAutoDownloadFlag && sizeInMB && sizeInMB > sizeThreshold) {
|
||||||
this.dialog.open(FileAutoDownloadComponent, { disableClose: true, data: node });
|
this.dialog.open(FileAutoDownloadComponent, { disableClose: true, data: node });
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { FileNode, FolderNode } from '../../mock';
|
import { FileNode, FolderNode } from '../../mock';
|
||||||
import { ContentActionHandler } from '../models/content-action.model';
|
import { ContentActionHandler } from '../models/content-action.model';
|
||||||
@@ -33,9 +32,6 @@ describe('FolderActionsService', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ContentTestingModule]
|
imports: [ContentTestingModule]
|
||||||
});
|
});
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
|
||||||
|
|
||||||
documentListService = TestBed.inject(DocumentListService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
service = TestBed.inject(FolderActionsService);
|
service = TestBed.inject(FolderActionsService);
|
||||||
});
|
});
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
|
||||||
import { DocumentListService } from './document-list.service';
|
import { DocumentListService } from './document-list.service';
|
||||||
import { NodeActionsService } from './node-actions.service';
|
import { NodeActionsService } from './node-actions.service';
|
||||||
import { ContentNodeDialogService } from '../../content-node-selector/content-node-dialog.service';
|
import { ContentNodeDialogService } from '../../content-node-selector/content-node-dialog.service';
|
||||||
@@ -43,9 +42,6 @@ describe('NodeActionsService', () => {
|
|||||||
imports: [ContentTestingModule],
|
imports: [ContentTestingModule],
|
||||||
providers: [{ provide: MatDialogRef, useValue: dialogRef }]
|
providers: [{ provide: MatDialogRef, useValue: dialogRef }]
|
||||||
});
|
});
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
|
||||||
|
|
||||||
service = TestBed.inject(NodeActionsService);
|
service = TestBed.inject(NodeActionsService);
|
||||||
documentListService = TestBed.inject(DocumentListService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
contentDialogService = TestBed.inject(ContentNodeDialogService);
|
contentDialogService = TestBed.inject(ContentNodeDialogService);
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
|
||||||
import { NodePermissionDialogService } from './node-permission-dialog.service';
|
import { NodePermissionDialogService } from './node-permission-dialog.service';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { of, Subject, throwError } from 'rxjs';
|
import { of, Subject, throwError } from 'rxjs';
|
||||||
@@ -35,8 +34,6 @@ describe('NodePermissionDialogService', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ContentTestingModule]
|
imports: [ContentTestingModule]
|
||||||
});
|
});
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
|
||||||
service = TestBed.inject(NodePermissionDialogService);
|
service = TestBed.inject(NodePermissionDialogService);
|
||||||
materialDialog = TestBed.inject(MatDialog);
|
materialDialog = TestBed.inject(MatDialog);
|
||||||
afterOpenObservable = new Subject<any>();
|
afterOpenObservable = new Subject<any>();
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
|
||||||
import { TagService } from './services/tag.service';
|
import { TagService } from './services/tag.service';
|
||||||
import { TagListComponent } from '././tag-list.component';
|
import { TagListComponent } from '././tag-list.component';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -53,8 +52,6 @@ describe('TagList', () => {
|
|||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ContentTestingModule]
|
imports: [ContentTestingModule]
|
||||||
});
|
});
|
||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
|
||||||
|
|
||||||
tagService = TestBed.inject(TagService);
|
tagService = TestBed.inject(TagService);
|
||||||
spyOn(tagService, 'getAllTheTags').and.returnValue(of(dataTag));
|
spyOn(tagService, 'getAllTheTags').and.returnValue(of(dataTag));
|
||||||
|
@@ -24,7 +24,6 @@ import { CoreTestingModule } from '../../../testing/core.testing.module';
|
|||||||
import { ClipboardService } from '../../../clipboard/clipboard.service';
|
import { ClipboardService } from '../../../clipboard/clipboard.service';
|
||||||
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
|
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
|
||||||
import { MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
|
import { MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
|
||||||
import { HarnessLoader } from '@angular/cdk/testing';
|
import { HarnessLoader } from '@angular/cdk/testing';
|
||||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||||
@@ -34,18 +33,11 @@ describe('CardViewDateItemComponent', () => {
|
|||||||
let loader: HarnessLoader;
|
let loader: HarnessLoader;
|
||||||
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
let fixture: ComponentFixture<CardViewDateItemComponent>;
|
||||||
let component: CardViewDateItemComponent;
|
let component: CardViewDateItemComponent;
|
||||||
let appConfigService: AppConfigService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), CoreTestingModule]
|
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);
|
fixture = TestBed.createComponent(CardViewDateItemComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -43,12 +43,14 @@ import { DownloadPromptDialogComponent } from './download-prompt-dialog/download
|
|||||||
import { AppConfigService } from '../../app-config';
|
import { AppConfigService } from '../../app-config';
|
||||||
import { DownloadPromptActions } from '../models/download-prompt.actions';
|
import { DownloadPromptActions } from '../models/download-prompt.actions';
|
||||||
|
|
||||||
const DEFAULT_NON_PREVIEW_CONFIG = {
|
export interface ViewerComponentConfig {
|
||||||
enableDownloadPrompt: false,
|
enableDownloadPrompt?: boolean;
|
||||||
enableDownloadPromptReminder: false,
|
enableDownloadPromptReminder?: boolean;
|
||||||
downloadPromptDelay: 50,
|
downloadPromptDelay?: number;
|
||||||
downloadPromptReminderDelay: 30
|
downloadPromptReminderDelay?: number;
|
||||||
};
|
enableFileAutoDownload?: boolean;
|
||||||
|
fileAutoDownloadSizeThresholdInMB?: number;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-viewer',
|
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.
|
* 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.
|
* 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
|
* 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.
|
* 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.
|
* 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() {
|
private configureDownloadPromptProperties() {
|
||||||
const nonResponsivePreviewConfig = this.appConfigService.get('viewer', DEFAULT_NON_PREVIEW_CONFIG);
|
const config = this.appConfigService.get<ViewerComponentConfig>('viewer');
|
||||||
|
|
||||||
this.enableDownloadPrompt = nonResponsivePreviewConfig.enableDownloadPrompt;
|
if (config) {
|
||||||
this.enableDownloadPromptReminder = nonResponsivePreviewConfig.enableDownloadPromptReminder;
|
this.enableDownloadPrompt = config.enableDownloadPrompt === true;
|
||||||
this.downloadPromptDelay = nonResponsivePreviewConfig.downloadPromptDelay;
|
this.enableDownloadPromptReminder = config.enableDownloadPromptReminder === true;
|
||||||
this.downloadPromptReminderDelay = nonResponsivePreviewConfig.downloadPromptReminderDelay;
|
|
||||||
|
if (config.downloadPromptDelay !== undefined) {
|
||||||
|
this.downloadPromptDelay = config.downloadPromptDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.downloadPromptReminderDelay !== undefined) {
|
||||||
|
this.downloadPromptReminderDelay = config.downloadPromptReminderDelay;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private initDownloadPrompt() {
|
private initDownloadPrompt() {
|
||||||
|
Reference in New Issue
Block a user