mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5426] Remove compatibility layer from Lib (#7110)
* remove compatibility step 1 * remove compatibility step 2 * remove compatibility step 3 * remove compatibility step 4 * remove compatibility step 5
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { SimpleChange, SimpleChanges } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { MediaPlayerComponent } from './media-player.component';
|
||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { NodeEntry, RenditionPaging } from '@alfresco/js-api';
|
||||
|
||||
describe('Test Media player component ', () => {
|
||||
|
||||
let component: MediaPlayerComponent;
|
||||
let fixture: ComponentFixture<MediaPlayerComponent>;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
let change: SimpleChanges;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
describe('Media tracks', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MediaPlayerComponent);
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
change = { nodeId: new SimpleChange(null, 'nodeId', true) };
|
||||
|
||||
component = fixture.componentInstance;
|
||||
component.urlFile = 'http://fake.url';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should generate tracks for media file when webvtt rendition exists', fakeAsync(() => {
|
||||
const fakeRenditionUrl = 'http://fake.rendition.url';
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
|
||||
);
|
||||
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
|
||||
Promise.resolve(new RenditionPaging({ list: { entries: [{ entry: { id: 'webvtt', status: 'CREATED' } }] } }))
|
||||
);
|
||||
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
|
||||
spyOn(alfrescoApiService.contentApi, 'getRenditionUrl').and.returnValue(fakeRenditionUrl);
|
||||
|
||||
component.ngOnChanges(change);
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
expect(component.tracks).toEqual([{ src: fakeRenditionUrl, kind: 'subtitles', label: 'ADF_VIEWER.SUBTITLES' }]);
|
||||
}));
|
||||
|
||||
it('should not generate tracks for media file when webvtt rendition is not created', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
|
||||
Promise.resolve(new RenditionPaging({ list: { entries: [{ entry: { id: 'webvtt', status: 'NOT_CREATED' } }] } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
|
||||
|
||||
component.ngOnChanges(change);
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
expect(component.tracks.length).toBe(0);
|
||||
}));
|
||||
|
||||
it('should not generate tracks for media file when webvtt rendition does not exist', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.renditionsApi, 'getRenditions').and.returnValue(
|
||||
Promise.resolve(new RenditionPaging({ list: { entries: [] } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValue('http://iam-fake.url');
|
||||
|
||||
component.ngOnChanges(change);
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
expect(component.tracks.length).toBe(0);
|
||||
}));
|
||||
});
|
||||
});
|
@@ -129,7 +129,6 @@ class ViewerWithCustomOpenWithComponent {
|
||||
})
|
||||
class ViewerWithCustomMoreActionsComponent {
|
||||
}
|
||||
|
||||
describe('ViewerComponent', () => {
|
||||
|
||||
let component: ViewerComponent;
|
||||
@@ -291,20 +290,17 @@ describe('ViewerComponent', () => {
|
||||
|
||||
it('should node without content show unkonwn', (done) => {
|
||||
const displayName = 'the-name';
|
||||
const nodeDetails = { name: displayName, id: '12' };
|
||||
const contentUrl = '/content/url/path';
|
||||
const alfrescoApiInstanceMock: any = {
|
||||
nodes: {
|
||||
getNodeInfo: () => Promise.resolve(nodeDetails),
|
||||
getNode: () => Promise.resolve({ id: 'fake-node', entry: { content: {} } })
|
||||
},
|
||||
content: { getContentUrl: () => contentUrl }
|
||||
};
|
||||
|
||||
component.nodeId = '12';
|
||||
component.urlFile = null;
|
||||
component.displayName = null;
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve({
|
||||
id: 'fake-node',
|
||||
entry: { content: { name: displayName, id: '12' } }
|
||||
}));
|
||||
|
||||
spyOn(component['contentApi'], 'getContentUrl').and.returnValue(contentUrl);
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
@@ -365,10 +361,10 @@ describe('ViewerComponent', () => {
|
||||
done();
|
||||
});
|
||||
}, 25000);
|
||||
});
|
||||
});
|
||||
|
||||
it('should change display name every time node changes', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } })),
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file2', content: {} } }))
|
||||
);
|
||||
@@ -392,10 +388,16 @@ describe('ViewerComponent', () => {
|
||||
}));
|
||||
|
||||
it('should append version of the file to the file content URL', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {}, properties: { 'cm:versionLabel' : '10'} } }))
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({
|
||||
entry: {
|
||||
name: 'file1',
|
||||
content: {},
|
||||
properties: { 'cm:versionLabel': '10' }
|
||||
}
|
||||
}))
|
||||
);
|
||||
spyOn(alfrescoApiService.versionsApi, 'getVersion').and.returnValue(Promise.resolve(undefined));
|
||||
spyOn(component['versionsApi'], 'getVersion').and.returnValue(Promise.resolve(undefined));
|
||||
|
||||
component.nodeId = 'id1';
|
||||
component.urlFile = null;
|
||||
@@ -412,11 +414,11 @@ describe('ViewerComponent', () => {
|
||||
}));
|
||||
|
||||
it('should change display name every time node\`s version changes', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'node1', content: {} } }))
|
||||
);
|
||||
|
||||
spyOn(alfrescoApiService.versionsApi, 'getVersion').and.returnValues(
|
||||
spyOn(component['versionsApi'], 'getVersion').and.returnValues(
|
||||
Promise.resolve(new VersionEntry({ entry: { name: 'file1', content: {} } })),
|
||||
Promise.resolve(new VersionEntry({ entry: { name: 'file2', content: {} } }))
|
||||
);
|
||||
@@ -441,10 +443,10 @@ describe('ViewerComponent', () => {
|
||||
}));
|
||||
|
||||
it('should update node only if node name changed', fakeAsync(() => {
|
||||
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValues(
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {} } }))
|
||||
);
|
||||
spyOn(alfrescoApiService.contentApi, 'getContentUrl').and.returnValues('http://iam-fake.url');
|
||||
spyOn(component['contentApi'], 'getContentUrl').and.returnValues('http://iam-fake.url');
|
||||
spyOn(component, 'getViewerTypeByExtension').and.returnValue('pdf');
|
||||
|
||||
component.urlFile = null;
|
||||
@@ -684,28 +686,25 @@ describe('ViewerComponent', () => {
|
||||
component.nodeId = '12';
|
||||
component.urlFile = '';
|
||||
const displayName = 'the-name';
|
||||
const node = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
|
||||
const nodeDetails = { name: displayName, id: '12', content: { mimeType: 'txt' } };
|
||||
const contentUrl = '/content/url/path';
|
||||
const alfrescoApiInstanceMock: any = {
|
||||
nodes: {
|
||||
getNodeInfo: () => Promise.resolve(nodeDetails),
|
||||
getNode: () => Promise.resolve(node)
|
||||
},
|
||||
content: { getContentUrl: () => contentUrl }
|
||||
const nodeDetails = {
|
||||
id: 'fake-node',
|
||||
entry: { name: displayName, id: '12', content: { mimeType: 'txt' } }
|
||||
};
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
|
||||
|
||||
const contentUrl = '/content/url/path';
|
||||
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve(nodeDetails));
|
||||
spyOn(component['contentApi'], 'getContentUrl').and.returnValue(contentUrl);
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.nodeEntry).toBe(node);
|
||||
expect(component.nodeEntry).toBe(nodeDetails);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should render close viewer button if it is not a shared link', (done) => {
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
@@ -716,7 +715,6 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit `showViewerChange` event on close', async () => {
|
||||
|
||||
spyOn(component.showViewerChange, 'emit');
|
||||
|
||||
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-back"]') as HTMLButtonElement;
|
||||
@@ -729,7 +727,7 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should not render close viewer button if it is a shared link', (done) => {
|
||||
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
|
||||
component.sharedLinkId = 'the-Shared-Link-id';
|
||||
@@ -803,7 +801,7 @@ describe('ViewerComponent', () => {
|
||||
const event = new KeyboardEvent('keydown', {
|
||||
bubbles: true,
|
||||
keyCode: 27
|
||||
} as KeyboardEventInit );
|
||||
} as KeyboardEventInit);
|
||||
const dialogRef = dialog.open(DummyDialogComponent);
|
||||
|
||||
dialogRef.afterClosed().subscribe(() => {
|
||||
@@ -886,7 +884,7 @@ describe('ViewerComponent', () => {
|
||||
describe('error handling', () => {
|
||||
|
||||
it('should show unknown view when node file not found', (done) => {
|
||||
spyOn(alfrescoApiService.getInstance().nodes, 'getNode')
|
||||
spyOn(component['nodesApi'], 'getNode')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
|
||||
component.nodeId = 'the-node-id-of-the-file-to-preview';
|
||||
@@ -902,7 +900,7 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should show unknown view when sharedLink file not found', (done) => {
|
||||
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
|
||||
component.sharedLinkId = 'the-Shared-Link-id';
|
||||
@@ -919,7 +917,7 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should raise an event when the shared link is invalid', (done) => {
|
||||
spyOn(alfrescoApiService.getInstance().core.sharedlinksApi, 'getSharedLink')
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
|
||||
component.invalidSharedLink.subscribe(() => {
|
||||
@@ -965,10 +963,17 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should update version when emitted by image-viewer and user has update permissions', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {
|
||||
});
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
component.readOnly = false;
|
||||
component.nodeEntry = new NodeEntry({ entry: { name: 'fakeImage.png', id: '12', content: { mimeType: 'img/png' } } });
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: {
|
||||
name: 'fakeImage.png',
|
||||
id: '12',
|
||||
content: { mimeType: 'img/png' }
|
||||
}
|
||||
});
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
||||
const newImageFile: File = new File([fakeBlob], component?.nodeEntry?.entry?.name, { type: component?.nodeEntry?.entry?.content?.mimeType });
|
||||
@@ -990,9 +995,16 @@ describe('ViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should not update version when emitted by image-viewer and user doesn`t have update permissions', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {
|
||||
});
|
||||
component.readOnly = true;
|
||||
component.nodeEntry = new NodeEntry({ entry: { name: 'fakeImage.png', id: '12', content: { mimeType: 'img/png' } } });
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: {
|
||||
name: 'fakeImage.png',
|
||||
id: '12',
|
||||
content: { mimeType: 'img/png' }
|
||||
}
|
||||
});
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
||||
component.onSubmitFile(fakeBlob);
|
||||
@@ -1062,31 +1074,26 @@ describe('ViewerComponent', () => {
|
||||
|
||||
describe('display name property override by nodeId', () => {
|
||||
|
||||
const displayName = 'the-name';
|
||||
const nodeDetails = new NodeEntry({ entry: { name: displayName, id: '12', content: { mimeType: 'txt' } } });
|
||||
const contentUrl = '/content/url/path';
|
||||
const alfrescoApiInstanceMock: any = {
|
||||
nodes: {
|
||||
getNode: () => Promise.resolve(nodeDetails)
|
||||
},
|
||||
content: { getContentUrl: () => contentUrl }
|
||||
};
|
||||
const nodeDetails = new NodeEntry({ entry: { name: 'node-id-name', id: '12', content: { mimeType: 'txt' } } });
|
||||
|
||||
it('should use the node name if displayName is NOT set and nodeId is set', (done) => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve(nodeDetails));
|
||||
spyOn(component['contentApi'], 'getContentUrl').and.returnValue(contentUrl);
|
||||
|
||||
component.nodeId = '12';
|
||||
component.urlFile = null;
|
||||
component.displayName = null;
|
||||
spyOn(alfrescoApiService, 'getInstance').and.returnValue(alfrescoApiInstanceMock);
|
||||
component.displayName = 'the-name';
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual(displayName);
|
||||
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('the-name');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Viewer component - Full Screen Mode - Mocking fixture element', () => {
|
||||
|
||||
|
@@ -20,7 +20,15 @@ import {
|
||||
Input, OnChanges, Output, TemplateRef,
|
||||
ViewEncapsulation, OnInit, OnDestroy
|
||||
} from '@angular/core';
|
||||
import { SharedLinkEntry, Node, Version, RenditionEntry, NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import {
|
||||
SharedLinkEntry,
|
||||
Node,
|
||||
Version,
|
||||
RenditionEntry,
|
||||
NodeEntry,
|
||||
VersionEntry,
|
||||
SharedlinksApi, VersionsApi, NodesApi, ContentApi
|
||||
} from '@alfresco/js-api';
|
||||
import { BaseEvent } from '../../events';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
@@ -249,6 +257,11 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private shouldCloseViewer = true;
|
||||
private keyDown$ = fromEvent<KeyboardEvent>(document, 'keydown');
|
||||
|
||||
private sharedLinksApi: SharedlinksApi;
|
||||
private versionsApi: VersionsApi;
|
||||
private nodesApi: NodesApi;
|
||||
private contentApi: ContentApi;
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private viewUtilService: ViewUtilService,
|
||||
private logService: LogService,
|
||||
@@ -257,6 +270,10 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
private uploadService: UploadService,
|
||||
private el: ElementRef,
|
||||
public dialog: MatDialog) {
|
||||
this.sharedLinksApi = new SharedlinksApi(this.apiService.getInstance());
|
||||
this.versionsApi = new VersionsApi(this.apiService.getInstance());
|
||||
this.nodesApi = new NodesApi(this.apiService.getInstance());
|
||||
this.contentApi = new ContentApi(this.apiService.getInstance());
|
||||
viewUtilService.maxRetries = this.maxRetries;
|
||||
}
|
||||
|
||||
@@ -329,44 +346,52 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.setUpUrlFile();
|
||||
this.isLoading = false;
|
||||
} else if (this.nodeId) {
|
||||
this.apiService.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] }).then(
|
||||
(node: NodeEntry) => {
|
||||
this.nodeEntry = node;
|
||||
if (this.versionId) {
|
||||
this.apiService.versionsApi.getVersion(this.nodeId, this.versionId).then(
|
||||
(version: VersionEntry) => {
|
||||
this.versionEntry = version;
|
||||
this.setUpNodeFile(node.entry, version.entry).then(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.setUpNodeFile(node.entry).then(() => {
|
||||
this.setupNode();
|
||||
} else if (this.sharedLinkId) {
|
||||
this.setupSharedLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setupSharedLink() {
|
||||
this.allowGoBack = false;
|
||||
|
||||
this.sharedLinksApi.getSharedLink(this.sharedLinkId).then(
|
||||
(sharedLinkEntry: SharedLinkEntry) => {
|
||||
this.setUpSharedLinkFile(sharedLinkEntry);
|
||||
this.isLoading = false;
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
this.logService.error('This sharedLink does not exist');
|
||||
this.invalidSharedLink.next();
|
||||
});
|
||||
}
|
||||
|
||||
private setupNode() {
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] }).then(
|
||||
(node: NodeEntry) => {
|
||||
this.nodeEntry = node;
|
||||
if (this.versionId) {
|
||||
this.versionsApi.getVersion(this.nodeId, this.versionId).then(
|
||||
(version: VersionEntry) => {
|
||||
this.versionEntry = version;
|
||||
this.setUpNodeFile(node.entry, version.entry).then(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
);
|
||||
} else {
|
||||
this.setUpNodeFile(node.entry).then(() => {
|
||||
this.isLoading = false;
|
||||
this.logService.error('This node does not exist');
|
||||
}
|
||||
);
|
||||
} else if (this.sharedLinkId) {
|
||||
this.allowGoBack = false;
|
||||
|
||||
this.apiService.sharedLinksApi.getSharedLink(this.sharedLinkId).then(
|
||||
(sharedLinkEntry: SharedLinkEntry) => {
|
||||
this.setUpSharedLinkFile(sharedLinkEntry);
|
||||
this.isLoading = false;
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
this.logService.error('This sharedLink does not exist');
|
||||
this.invalidSharedLink.next();
|
||||
});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
this.isLoading = false;
|
||||
this.logService.error('This node does not exist');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private setUpBlobData() {
|
||||
@@ -414,8 +439,8 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
const currentFileVersion = this.nodeEntry?.entry?.properties && this.nodeEntry.entry.properties['cm:versionLabel'] ?
|
||||
encodeURI(this.nodeEntry?.entry?.properties['cm:versionLabel']) : encodeURI('1.0');
|
||||
|
||||
this.urlFileContent = versionData ? this.apiService.contentApi.getVersionContentUrl(this.nodeId, versionData.id) :
|
||||
this.apiService.contentApi.getContentUrl(this.nodeId);
|
||||
this.urlFileContent = versionData ? this.contentApi.getVersionContentUrl(this.nodeId, versionData.id) :
|
||||
this.contentApi.getContentUrl(this.nodeId);
|
||||
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + currentFileVersion + '&' + this.cacheBusterNumber :
|
||||
this.urlFileContent + '&' + currentFileVersion;
|
||||
|
||||
@@ -450,7 +475,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this.extension = this.getFileExtension(details.entry.name);
|
||||
this.fileName = details.entry.name;
|
||||
|
||||
this.urlFileContent = this.apiService.contentApi.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
this.urlFileContent = this.contentApi.getSharedLinkContentUrl(this.sharedLinkId, false);
|
||||
|
||||
this.viewerType = this.getViewerTypeByMimeType(this.mimeType);
|
||||
if (this.viewerType === 'unknown') {
|
||||
@@ -467,7 +492,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
toggleSidebar() {
|
||||
this.showRightSidebar = !this.showRightSidebar;
|
||||
if (this.showRightSidebar && this.nodeId) {
|
||||
this.apiService.getInstance().nodes.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.then((nodeEntry: NodeEntry) => {
|
||||
this.sidebarRightTemplateContext.node = nodeEntry.entry;
|
||||
});
|
||||
@@ -477,7 +502,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
toggleLeftSidebar() {
|
||||
this.showLeftSidebar = !this.showLeftSidebar;
|
||||
if (this.showRightSidebar && this.nodeId) {
|
||||
this.apiService.getInstance().nodes.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
this.nodesApi.getNode(this.nodeId, { include: ['allowableOperations'] })
|
||||
.then((nodeEntry: NodeEntry) => {
|
||||
this.sidebarLeftTemplateContext.node = nodeEntry.entry;
|
||||
});
|
||||
@@ -662,18 +687,18 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
private async displaySharedLinkRendition(sharedId: string) {
|
||||
try {
|
||||
const rendition: RenditionEntry = await this.apiService.renditionsApi.getSharedLinkRendition(sharedId, 'pdf');
|
||||
const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'pdf');
|
||||
if (rendition.entry.status.toString() === 'CREATED') {
|
||||
this.viewerType = 'pdf';
|
||||
this.urlFileContent = this.apiService.contentApi.getSharedLinkRenditionUrl(sharedId, 'pdf');
|
||||
this.urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'pdf');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
try {
|
||||
const rendition: RenditionEntry = await this.apiService.renditionsApi.getSharedLinkRendition(sharedId, 'imgpreview');
|
||||
const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'imgpreview');
|
||||
if (rendition.entry.status.toString() === 'CREATED') {
|
||||
this.viewerType = 'image';
|
||||
this.urlFileContent = this.apiService.contentApi.getSharedLinkRenditionUrl(sharedId, 'imgpreview');
|
||||
this.urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'imgpreview');
|
||||
}
|
||||
} catch (error) {
|
||||
this.logService.error(error);
|
||||
|
Reference in New Issue
Block a user