migrate document list to new api

This commit is contained in:
Eugenio Romano 2016-06-29 15:56:32 +01:00
parent aa848e271e
commit 7396a57e5c
9 changed files with 27 additions and 20 deletions

View File

@ -24,7 +24,7 @@
<script src="node_modules/systemjs/dist/system.src.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="/app/js/xml2json.js"></script> <script src="/app/js/xml2json.js"></script>
<script src="node_modules/alfresco-js-api/bundle.js"></script> <script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
<script src="node_modules/pdfjs-dist/build/pdf.js"></script> <script src="node_modules/pdfjs-dist/build/pdf.js"></script>
<script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script> <script src="node_modules/pdfjs-dist/build/pdf.worker.js"></script>

View File

@ -41,6 +41,10 @@
{ {
"name": "Mario Romano", "name": "Mario Romano",
"email": "mario.romano83@gmail.com" "email": "mario.romano83@gmail.com"
},
{
"name": "Eugenio Romano",
"email": "eugenio.romano@alfresco.com"
} }
], ],
"keywords": [ "keywords": [

View File

@ -90,6 +90,10 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
}); });
} }
getAlfrescoApi(): any {
return this.alfrescoApi;
}
/** /**
* The method return tru if the user is logged in * The method return tru if the user is logged in
* @returns {boolean} * @returns {boolean}

View File

@ -30,8 +30,8 @@ export class AlfrescoContentService {
* @param document Node to get URL for. * @param document Node to get URL for.
* @returns {string} URL address. * @returns {string} URL address.
*/ */
getDocumentThumbnailUrl(document: any) { getDocumentThumbnailUrl(document: any): string {
this.authService.alfrescoApi.getDocumentThumbnailUrl(document.entry.id); return this.authService.alfrescoApi.getDocumentThumbnailUrl(document.entry.id);
} }
/** /**
@ -39,7 +39,7 @@ export class AlfrescoContentService {
* @param document Node to get URL for. * @param document Node to get URL for.
* @returns {string} URL address. * @returns {string} URL address.
*/ */
getContentUrl(document: any) { getContentUrl(document: any): string {
this.authService.alfrescoApi.getContentUrl(document.entry.id); return this.authService.alfrescoApi.getContentUrl(document.entry.id);
} }
} }

View File

@ -20,7 +20,7 @@
<script src="node_modules/systemjs/dist/system.src.js"></script> <script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- Additional Alfresco libraries --> <!-- Additional Alfresco libraries -->
<script src="node_modules/alfresco-js-api/bundle.js"></script> <script src="node_modules/alfresco-js-api/dist/alfresco-js-api.js"></script>
<script src="systemjs.config.js"></script> <script src="systemjs.config.js"></script>
<script> <script>

View File

@ -39,10 +39,10 @@
"material-design-lite": "1.1.3", "material-design-lite": "1.1.3",
"ng2-translate": "2.2.2", "ng2-translate": "2.2.2",
"alfresco-js-api": "^0.1.0", "alfresco-js-api": "0.1.0",
"ng2-alfresco-core": "^0.1.36", "ng2-alfresco-core": "0.1.36",
"ng2-alfresco-documentlist": "^0.1.34", "ng2-alfresco-documentlist": "0.1.34",
"ng2-alfresco-datatable": "^0.1.17" "ng2-alfresco-datatable": "0.1.17"
}, },
"devDependencies": { "devDependencies": {
"concurrently": "2.0.0", "concurrently": "2.0.0",

View File

@ -48,6 +48,10 @@
{ {
"name": "Mario Romano", "name": "Mario Romano",
"email": "mario.romano83@gmail.com" "email": "mario.romano83@gmail.com"
},
{
"name": "Eugenio Romano",
"email": "eugenio.romano@alfresco.com"
} }
], ],
"keywords": [ "keywords": [

View File

@ -68,26 +68,21 @@ export class DocumentListService {
) { ) {
} }
private getAlfrescoClient() { private getAlfrescoApi() {
return AlfrescoApi.getClientWithTicket(this.settings.getApiBaseUrl(), this.authService.getToken()); return this.authService.getAlfrescoApi();
} }
private getNodesPromise(folder: string) { private getNodesPromise(folder: string) {
let alfrescoClient = this.getAlfrescoClient();
let apiInstance = new AlfrescoApi.Core.NodesApi(alfrescoClient);
let nodeId = '-root-'; let nodeId = '-root-';
let opts = { let opts = {
relativePath: folder, relativePath: folder,
include: ['path'] include: ['path']
}; };
return apiInstance.getNodeChildren(nodeId, opts); return this.getAlfrescoApi().getNodeChildren(nodeId, opts);
} }
deleteNode(nodeId: string) { deleteNode(nodeId: string) {
let client = this.getAlfrescoClient(); return Observable.fromPromise(this.getAlfrescoApi().deleteNode(nodeId));
let nodesApi = new AlfrescoApi.Core.NodesApi(client);
let opts = {};
return Observable.fromPromise(nodesApi.deleteNode(nodeId, opts));
} }
/** /**

View File

@ -45,7 +45,7 @@ import { EventMock } from './assets/event.mock';
let element = fixture.nativeElement; let element = fixture.nativeElement;
let component = fixture.componentInstance; let component = fixture.componentInstance;
component.urlFile = 'http://localhost:9876/fake-url-file.pdf'; component.urlFile = 'http://localhost:9876/fake-url-file.pdf';
component.ngOnChanges().then(() => { component.ngOnChanges().then(() => {
fixture.detectChanges(); fixture.detectChanges();
expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf'); expect(element.querySelector('#viewer-name-file').innerHTML).toEqual('fake-url-file.pdf');