Configurable host address for document list

- allow application define host address for AlfrescoService
This commit is contained in:
Denys Vuika 2016-04-18 21:20:51 +01:00
parent f39653bf6f
commit fb208c6007
5 changed files with 26 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import {AuthRouterOutlet} from "./components/AuthRouterOutlet";
import {HomeView} from "./components/home.view";
import {Page1View} from "./components/page1.view";
import {Page2View} from "./components/page2.view";
import {AlfrescoService} from 'ng2-alfresco/components';
@Component({
selector: 'my-app',
@ -22,8 +23,11 @@ export class AppComponent {
constructor(
public auth: Authentication,
public router: Router
){}
public router: Router,
alfrescoService: AlfrescoService
){
alfrescoService.host = 'http://192.168.99.100:8080';
}
isActive(instruction: any[]): boolean {
return this.router.isRouteActive(this.router.generate(instruction));

View File

@ -3,6 +3,7 @@ import { DocumentList } from "./src/document-list.component";
import { AlfrescoService } from "./src/alfresco.service";
export * from './src/HelloWorld';
export * from './src/document-list.component';
export * from './src/alfresco.service';
declare var _default: {
directives: (typeof HelloWorld | typeof DocumentList)[];
providers: typeof AlfrescoService[];

View File

@ -4,6 +4,7 @@ import { AlfrescoService } from "./src/alfresco.service";
export * from './src/HelloWorld';
export * from './src/document-list.component';
export * from './src/alfresco.service';
export default {
directives: [HelloWorld, DocumentList],

View File

@ -6,7 +6,9 @@ export declare class AlfrescoService {
private http;
constructor(http: Http);
private _host;
private _baseUrl;
private _baseUrlPath;
host: string;
private getBaseUrl();
getFolder(folder: string): Observable<FolderEntity>;
getDocumentThumbnailUrl(document: DocumentEntity): string;
getContentUrl(document: DocumentEntity): string;

View File

@ -8,8 +8,20 @@ import {DocumentEntity} from "./core/entities/document.entity";
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/';
private _host: string = 'http://127.0.0.1:8080';
private _baseUrlPath: string = '/alfresco/service/slingshot/doclib/doclist/all/site/';
public get host():string {
return this._host;
}
public set host(value:string) {
this._host = value;
}
private getBaseUrl():string {
return this.host + this._baseUrlPath;
}
getFolder(folder: string) {
let headers = new Headers({
@ -18,7 +30,7 @@ export class AlfrescoService {
});
let options = new RequestOptions({ headers: headers });
return this.http
.get(this._baseUrl + folder, options)
.get(this.getBaseUrl() + folder, options)
.map(res => <FolderEntity> res.json())
.do(data => console.log(data)) // eyeball results in the console
.catch(this.handleError);