mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-5600] AlfrescoViewerComponent shows the original mimetype (#9095)
* [ACS-5600]Changes for bug * [ACS-5600]Changes for bug fixes * [5600]fixed the space * [ACS-5600] modified the variable name * [ACS-5600]Implemented the review comments * [ACS-5600]modified the test cases * [ACS-5600] modified the test cases * [ACS-5600]modified the changes * [ci:force]
This commit is contained in:
@@ -70,6 +70,7 @@ See the [Custom layout](#custom-layout) section for full details of all availabl
|
|||||||
| canNavigateNext | `boolean` | true | Toggles the next (">") button. Requires `allowNavigate` to be enabled. |
|
| canNavigateNext | `boolean` | true | Toggles the next (">") button. Requires `allowNavigate` to be enabled. |
|
||||||
| fileName | `string` | | Override Content filename. |
|
| fileName | `string` | | Override Content filename. |
|
||||||
| mimeType | `string` | | Overload mimeType |
|
| mimeType | `string` | | Overload mimeType |
|
||||||
|
| originalMimeType | `string` | | Overload originalMimeType |
|
||||||
| overlayMode | `boolean` | false | If `true` then show the Viewer as a full page over the current content. Otherwise fit inside the parent div. |
|
| overlayMode | `boolean` | false | If `true` then show the Viewer as a full page over the current content. Otherwise fit inside the parent div. |
|
||||||
| readOnly | `boolean` | true | Enable when where is possible the editing functionalities |
|
| readOnly | `boolean` | true | Enable when where is possible the editing functionalities |
|
||||||
| showLeftSidebar | `boolean` | false | Toggles left sidebar visibility. Requires `allowLeftSidebar` to be set to `true`. |
|
| showLeftSidebar | `boolean` | false | Toggles left sidebar visibility. Requires `allowLeftSidebar` to be set to `true`. |
|
||||||
@@ -113,6 +114,7 @@ You can provide custom file parameters, for example a value for the `mimeType` o
|
|||||||
[fileName]="fileName"
|
[fileName]="fileName"
|
||||||
[allowGoBack]="false"
|
[allowGoBack]="false"
|
||||||
[mimeType]="mimeType"
|
[mimeType]="mimeType"
|
||||||
|
[originalMimeType]="originalMimeType"
|
||||||
[urlFile]="fileUrl">
|
[urlFile]="fileUrl">
|
||||||
</adf-viewer>
|
</adf-viewer>
|
||||||
```
|
```
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
[sidebarLeftTemplateContext]="sidebarLeftTemplateContext"
|
[sidebarLeftTemplateContext]="sidebarLeftTemplateContext"
|
||||||
[fileName]="fileName"
|
[fileName]="fileName"
|
||||||
[mimeType]="mimeType"
|
[mimeType]="mimeType"
|
||||||
|
[originalMimeType]="originalMimeType"
|
||||||
[urlFile]="urlFileContent"
|
[urlFile]="urlFileContent"
|
||||||
[tracks]="tracks"
|
[tracks]="tracks"
|
||||||
[readOnly]="readOnly"
|
[readOnly]="readOnly"
|
||||||
|
@@ -476,6 +476,42 @@ describe('AlfrescoViewerComponent', () => {
|
|||||||
//
|
//
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('originalMimeType', () => {
|
||||||
|
it('should set originalMimeType based on nodeData content', async () => {
|
||||||
|
const defaultNode: Node = {
|
||||||
|
id: 'mock-id',
|
||||||
|
name: 'Mock Node',
|
||||||
|
nodeType: 'cm:content',
|
||||||
|
isFolder: false,
|
||||||
|
isFile: true,
|
||||||
|
modifiedAt: new Date(),
|
||||||
|
modifiedByUser: { id: 'user123', displayName: 'John Doe' },
|
||||||
|
createdAt: new Date(),
|
||||||
|
createdByUser: { id: 'user456', displayName: 'Jane Doe' },
|
||||||
|
properties: { 'cm:versionLabel': 'mock-version-label' }
|
||||||
|
};
|
||||||
|
component.nodeEntry = { entry: defaultNode };
|
||||||
|
component.nodeId = '123';
|
||||||
|
spyOn(renditionService, 'getNodeRendition').and.returnValue(
|
||||||
|
Promise.resolve({
|
||||||
|
url: '',
|
||||||
|
mimeType: ''
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
nodesApiService.nodeUpdated.next({
|
||||||
|
id: '123',
|
||||||
|
name: 'file2',
|
||||||
|
content: {
|
||||||
|
mimeType: 'application/msWord'
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(component.originalMimeType).toEqual('application/msWord');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Toolbar', () => {
|
describe('Toolbar', () => {
|
||||||
it('should show only next file button', async () => {
|
it('should show only next file button', async () => {
|
||||||
component.allowNavigate = true;
|
component.allowNavigate = true;
|
||||||
|
@@ -192,6 +192,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
urlFileContent: string;
|
urlFileContent: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
|
originalMimeType: string;
|
||||||
nodeEntry: NodeEntry;
|
nodeEntry: NodeEntry;
|
||||||
tracks: Track[] = [];
|
tracks: Track[] = [];
|
||||||
readOnly: boolean = true;
|
readOnly: boolean = true;
|
||||||
@@ -328,6 +329,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
if (nodeRendition) {
|
if (nodeRendition) {
|
||||||
urlFileContent = nodeRendition.url;
|
urlFileContent = nodeRendition.url;
|
||||||
mimeType = nodeRendition.mimeType;
|
mimeType = nodeRendition.mimeType;
|
||||||
|
this.originalMimeType = nodeData?.content?.mimeType;
|
||||||
}
|
}
|
||||||
} else if (viewerType === 'media') {
|
} else if (viewerType === 'media') {
|
||||||
this.tracks = await this.renditionService.generateMediaTracksRendition(this.nodeId);
|
this.tracks = await this.renditionService.generateMediaTracksRendition(this.nodeId);
|
||||||
|
@@ -44,8 +44,8 @@
|
|||||||
<mat-icon>navigate_before</mat-icon>
|
<mat-icon>navigate_before</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<img class="adf-viewer__mimeicon"
|
<img class="adf-viewer__mimeicon"
|
||||||
[alt]="mimeType"
|
[alt]="originalMimeType || mimeType"
|
||||||
[src]="mimeType | adfMimeTypeIcon"
|
[src]="(originalMimeType || mimeType) | adfMimeTypeIcon"
|
||||||
data-automation-id="adf-file-thumbnail">
|
data-automation-id="adf-file-thumbnail">
|
||||||
<span class="adf-viewer__display-name"
|
<span class="adf-viewer__display-name"
|
||||||
id="adf-viewer-display-name">{{ fileName }}</span>
|
id="adf-viewer-display-name">{{ fileName }}</span>
|
||||||
|
@@ -115,6 +115,38 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('originalMimeType', () => {
|
||||||
|
const getMimeTypeIconElement = () => fixture.nativeElement.querySelector('.adf-viewer__mimeicon');
|
||||||
|
|
||||||
|
it('should set alt attribute to originalMimeType when originalMimeType is provided', () => {
|
||||||
|
component.originalMimeType = 'image/png';
|
||||||
|
fixture.detectChanges();
|
||||||
|
const altAttribute: string = getMimeTypeIconElement().getAttribute('alt');
|
||||||
|
expect(altAttribute).toBe('image/png');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set src attribute based on originalMimeType when originalMimeType is provided', () => {
|
||||||
|
component.originalMimeType = 'image';
|
||||||
|
fixture.detectChanges();
|
||||||
|
const srcAttribute: string = getMimeTypeIconElement().getAttribute('src');
|
||||||
|
expect(srcAttribute).toContain('image');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set alt attribute to mimeType when originalMimeType is not provided', () => {
|
||||||
|
component.mimeType = 'application/pdf';
|
||||||
|
fixture.detectChanges();
|
||||||
|
const altAttribute: string = getMimeTypeIconElement().getAttribute('alt');
|
||||||
|
expect(altAttribute).toBe('application/pdf');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set src attribute based on mimeType when originalMimeType is not provided', () => {
|
||||||
|
component.mimeType = 'image';
|
||||||
|
fixture.detectChanges();
|
||||||
|
const srcAttribute: string = getMimeTypeIconElement().getAttribute('src');
|
||||||
|
expect(srcAttribute).toContain('image');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('File Name Test', () => {
|
describe('File Name Test', () => {
|
||||||
|
|
||||||
it('should fileName be set by urlFile input if the fileName is not provided as Input', () => {
|
it('should fileName be set by urlFile input if the fileName is not provided as Input', () => {
|
||||||
|
@@ -160,6 +160,10 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
|
|
||||||
|
/** Overload originalMimeType*/
|
||||||
|
@Input()
|
||||||
|
originalMimeType: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context object available for binding by the local sidebarRightTemplate with let declarations.
|
* Context object available for binding by the local sidebarRightTemplate with let declarations.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user