[ACS-9406] Add getContentRenditionTypePreview to process-content service (#10743)

* [ACS-9406] Add getContentRenditionTypePreview to process-content service

* [ACS-9406] remove extra space

* [ACS-9406] fix unit tests

* [ACS-9406] fix unit tests

* [ACS-9406] cr fixes
This commit is contained in:
Mykyta Maliarchuk
2025-04-02 14:07:20 +02:00
committed by GitHub
parent c85245b241
commit 8e0ea373f0
14 changed files with 119 additions and 10 deletions

View File

@@ -33,6 +33,7 @@ export class ContentLinkModel {
contentRawUrl: string;
contentBlob: Blob;
thumbnailStatus: string;
sourceId: string;
constructor(obj?: any) {
this.contentAvailable = obj?.contentAvailable;

View File

@@ -1,6 +1,6 @@
<div class="adf-viewer__unknown-format-view">
<div>
<mat-icon class="icon">error</mat-icon>
<div class="adf-viewer__unknown-label">{{ 'ADF_VIEWER.UNKNOWN_FORMAT' | translate }}</div>
<div class="adf-viewer__unknown-label">{{ customError || 'ADF_VIEWER.UNKNOWN_FORMAT' | translate }}</div>
</div>
</div>

View File

@@ -0,0 +1,46 @@
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { UnknownFormatComponent } from './unknown-format.component';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CoreTestingModule } from '@alfresco/adf-core';
describe('Unknown Format Component', () => {
let fixture: ComponentFixture<UnknownFormatComponent>;
const getErrorMessageElement = (): string => fixture.debugElement.nativeElement.querySelector('.adf-viewer__unknown-label').innerText;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule]
});
fixture = TestBed.createComponent(UnknownFormatComponent);
fixture.detectChanges();
});
it('should render default error message', () => {
expect(getErrorMessageElement()).toBe('ADF_VIEWER.UNKNOWN_FORMAT');
});
it('should render custom error message if such provided', () => {
const errorMessage = 'Custom error message';
fixture.componentInstance.customError = errorMessage;
fixture.detectChanges();
expect(getErrorMessageElement()).toBe(errorMessage);
});
});

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, ViewEncapsulation } from '@angular/core';
import { Component, Input, ViewEncapsulation } from '@angular/core';
import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
@@ -27,4 +27,8 @@ import { TranslateModule } from '@ngx-translate/core';
imports: [MatIconModule, TranslateModule],
encapsulation: ViewEncapsulation.None
})
export class UnknownFormatComponent {}
export class UnknownFormatComponent {
/** Custom error message to be displayed . */
@Input()
customError: string;
}

View File

@@ -85,7 +85,7 @@
</ng-container>
<ng-container *ngSwitchDefault>
<adf-viewer-unknown-format />
<adf-viewer-unknown-format [customError]="customError"/>
</ng-container>
</div>
</div>

View File

@@ -117,6 +117,10 @@ export class ViewerRenderComponent implements OnChanges, OnInit {
@Input()
viewerTemplateExtensions: TemplateRef<any>;
/** Custom error message to be displayed in the viewer. */
@Input()
customError: string = undefined;
/** Emitted when the filename extension changes. */
@Output()
extensionChange = new EventEmitter<string>();

View File

@@ -174,7 +174,8 @@
(isSaving)="allowNavigate = !$event"
[tracks]="tracks"
[viewerTemplateExtensions]="viewerExtensions ?? viewerTemplateExtensions"
[nodeId]="nodeId" />
[nodeId]="nodeId"
[customError]="customError" />
</div>
</div>

View File

@@ -244,6 +244,10 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
@Input()
nodeMimeType: string = undefined;
/** Custom error message to be displayed in the viewer. */
@Input()
customError: string = undefined;
/**
* Enable dialog box to allow user to download the previewed file, in case the preview is not responding for a set period of time.
*/