mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
renditions available methods
This commit is contained in:
parent
8c76aed11d
commit
0c60ff168d
@ -154,6 +154,12 @@ bootstrap(MyDemoApp, [
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Renditions Service
|
||||||
|
|
||||||
|
* getRenditionsListByNodeId(nodeId: string)
|
||||||
|
* createRendition(nodeId: string, encoding: string)
|
||||||
|
* getRendition(nodeId: string, encoding: string)
|
||||||
|
* isRenditionAvailable(nodeId: string, encoding: string)
|
||||||
|
|
||||||
## Build from sources
|
## Build from sources
|
||||||
|
|
||||||
|
@ -28,6 +28,14 @@ describe('RenditionsService', () => {
|
|||||||
let service: any;
|
let service: any;
|
||||||
|
|
||||||
let fakeRedition = {
|
let fakeRedition = {
|
||||||
|
'entry': {
|
||||||
|
'id': 'pdf',
|
||||||
|
'content': {'mimeType': 'application/pdf', 'mimeTypeName': 'Adobe PDF Document'},
|
||||||
|
'status': 'NOT_CREATED'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let fakeReditionsList = {
|
||||||
'list': {
|
'list': {
|
||||||
'pagination': {
|
'pagination': {
|
||||||
'count': 6,
|
'count': 6,
|
||||||
@ -95,12 +103,41 @@ describe('RenditionsService', () => {
|
|||||||
jasmine.Ajax.uninstall();
|
jasmine.Ajax.uninstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('Get redition list service should call the server with the ID passed', (done) => {
|
it('Get redition list service should call the server with the ID passed', (done) => {
|
||||||
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
service.getRenditionsListByNodeId('fake-node-id').subscribe((res) => {
|
||||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeReditionsList)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Get redition service should call the server with the ID passed', (done) => {
|
||||||
|
service.getRendition('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions/pdf');
|
||||||
|
expect(res.entry.status).toBe('NOT_CREATED');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
'status': 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify(fakeRedition)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isRenditionsAvailable service should call the server with the ID passed and return false if is not created', (done) => {
|
||||||
|
service.isRenditionAvailable('fake-node-id', 'pdf').subscribe((res) => {
|
||||||
|
expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions/pdf');
|
||||||
|
expect(res).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 200,
|
'status': 200,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@ -131,7 +168,7 @@ describe('RenditionsService', () => {
|
|||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
'status': 403,
|
'status': 403,
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
responseText: JSON.stringify(fakeRedition)
|
responseText: 'error'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -31,19 +31,31 @@ export class RenditionsService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isReditionsAvailable(nodeId: string, encoding: string) {
|
isRenditionAvailable(nodeId: string, encoding: string) {
|
||||||
this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId).then((res) => {
|
return Observable.create((observer) => {
|
||||||
console.log('res' + res);
|
this.getRendition(nodeId, encoding).subscribe((res) => {
|
||||||
|
let isAvailable = true;
|
||||||
|
if (res.entry.status === 'NOT_CREATED') {
|
||||||
|
isAvailable = false;
|
||||||
|
}
|
||||||
|
observer.next(isAvailable);
|
||||||
|
observer.complete();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRendition(nodeId: string, encoding: string) {
|
||||||
|
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.getRendition(nodeId, encoding))
|
||||||
|
.catch(this.handleError);
|
||||||
|
}
|
||||||
|
|
||||||
getRenditionsListByNodeId(nodeId: string) {
|
getRenditionsListByNodeId(nodeId: string) {
|
||||||
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId))
|
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.getRenditions(nodeId))
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
createRendition(nodeId: string, encoding: string) {
|
createRendition(nodeId: string, encoding: string) {
|
||||||
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.createRendition(nodeId, encoding))
|
return Observable.fromPromise(this.apiService.getInstance().core.renditionsApi.createRendition(nodeId, {id: 'pdf'}))
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user