mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
take ip from settings
This commit is contained in:
@@ -15,18 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {AlfrescoSettingsService} from './src/services/AlfrescoSettingsService.service';
|
||||
import {AlfrescoTranslationLoader} from './src/services/AlfrescoTranslationLoader.service';
|
||||
import {AlfrescoTranslationService} from './src/services/AlfrescoTranslationService.service';
|
||||
import {AlfrescoPipeTranslate} from './src/services/AlfrescoPipeTranslate.service';
|
||||
import { AlfrescoAuthenticationService } from './src/services/alfresco-authentication.service';
|
||||
import { AlfrescoSettingsService } from './src/services/AlfrescoSettingsService.service';
|
||||
import { AlfrescoTranslationLoader } from './src/services/AlfrescoTranslationLoader.service';
|
||||
import { AlfrescoTranslationService } from './src/services/AlfrescoTranslationService.service';
|
||||
import { AlfrescoPipeTranslate } from './src/services/AlfrescoPipeTranslate.service';
|
||||
import { AlfrescoAuthenticationService } from './src/services/AlfrescoAuthenticationService.service';
|
||||
|
||||
export * from './src/services/AlfrescoSettingsService.service';
|
||||
export * from './src/services/AlfrescoTranslationLoader.service';
|
||||
export * from './src/services/AlfrescoTranslationService.service';
|
||||
export * from './src/services/AlfrescoPipeTranslate.service';
|
||||
export * from './src/material/MaterialDesignLiteUpgradeElement';
|
||||
export * from './src/services/alfresco-authentication.service';
|
||||
export * from './src/services/AlfrescoAuthenticationService.service';
|
||||
|
||||
export const ALFRESCO_CORE_PROVIDERS: [any] = [
|
||||
AlfrescoAuthenticationService,
|
||||
|
@@ -19,7 +19,7 @@ import { it, describe, beforeEach } from 'angular2/testing';
|
||||
import { provide, Injector } from 'angular2/core';
|
||||
import { Http, HTTP_PROVIDERS, XHRBackend, Response, ResponseOptions } from 'angular2/http';
|
||||
import { MockBackend } from 'angular2/http/testing';
|
||||
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
|
||||
import { AlfrescoAuthenticationService } from './AlfrescoAuthenticationService.service';
|
||||
|
||||
|
||||
describe('AlfrescoAuthentication', () => {
|
||||
@@ -115,4 +115,3 @@ describe('AlfrescoAuthentication', () => {
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -18,6 +18,7 @@
|
||||
import { Injectable } from 'angular2/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { Http, Headers, Response } from 'angular2/http';
|
||||
import { AlfrescoSettingsService } from './AlfrescoSettingsService.service';
|
||||
|
||||
/**
|
||||
* The AlfrescoAuthenticationService provide the login service and store the token in the localStorage
|
||||
@@ -26,22 +27,25 @@ import { Http, Headers, Response } from 'angular2/http';
|
||||
export class AlfrescoAuthenticationService {
|
||||
token: string;
|
||||
|
||||
private _host: string = 'http://192.168.99.100:8080';
|
||||
private _baseUrl: string = this._host + '/alfresco/api/-default-/public/authentication/versions/1';
|
||||
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param http
|
||||
*/
|
||||
constructor(public http: Http) {
|
||||
constructor(public http: Http, private alfrescoSettingsService: AlfrescoSettingsService) {
|
||||
this.token = localStorage.getItem('token');
|
||||
}
|
||||
|
||||
getBaseUrl(): string {
|
||||
return this.alfrescoSettingsService.host + this._authUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isLoggedIn() {
|
||||
isLoggedIn(): boolean {
|
||||
return !!localStorage.getItem('token');
|
||||
}
|
||||
|
||||
@@ -68,7 +72,7 @@ export class AlfrescoAuthenticationService {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
headers.append('Accept', 'application/json');
|
||||
|
||||
return this.http.post(this._baseUrl + '/tickets', credentials, {
|
||||
return this.http.post(this.getBaseUrl() + '/tickets', credentials, {
|
||||
headers: headers
|
||||
})
|
||||
.map((res: any) => {
|
||||
@@ -90,7 +94,7 @@ export class AlfrescoAuthenticationService {
|
||||
headers.append('Content-Type', 'application/json');
|
||||
headers.append('Authorization', 'Basic ' + btoa(this.token));
|
||||
|
||||
return this.http.delete(this._baseUrl + '/tickets/-me-', {
|
||||
return this.http.delete(this.getBaseUrl() + '/tickets/-me-', {
|
||||
headers: headers
|
||||
})
|
||||
.map((res: any) => {
|
@@ -15,17 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Injectable} from 'angular2/core';
|
||||
import { Injectable } from 'angular2/core';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoSettingsService {
|
||||
private _host: string = 'http://127.0.0.1:8080';
|
||||
|
||||
public get host():string {
|
||||
public get host(): string {
|
||||
return this._host;
|
||||
}
|
||||
|
||||
public set host(value:string) {
|
||||
public set host(value: string) {
|
||||
this._host = value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user