mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import {Injectable} from 'angular2/core';
|
|
import {Http, Response, RequestOptions, Headers} from 'angular2/http';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {FolderEntity} from "./core/entities/folder.entity";
|
|
|
|
@Injectable()
|
|
export class AlfrescoService {
|
|
constructor(private http: Http) {}
|
|
|
|
private _host: string = 'http://192.168.99.100:8080';
|
|
private _baseUrl: string = this._host + '/alfresco/service/slingshot/doclib/doclist/all/site/';
|
|
|
|
getFolder(folder: string) {
|
|
let headers = new Headers({
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Basic ' + btoa('admin:admin')
|
|
});
|
|
let options = new RequestOptions({ headers: headers });
|
|
return this.http
|
|
.get(this._baseUrl + folder, options)
|
|
.map(res => <FolderEntity> res.json())
|
|
.do(data => console.log(data)) // eyeball results in the console
|
|
.catch(this.handleError);
|
|
}
|
|
|
|
private handleError (error: Response) {
|
|
// in a real world app, we may send the error to some remote logging infrastructure
|
|
// instead of just logging it to the console
|
|
console.error(error);
|
|
return Observable.throw(error.json().error || 'Server error');
|
|
}
|
|
}
|