Change environment-specific.service.ts to be able to read properties in server side. Had to add a property serverUrl - change it in every deployment
add check for server side before use document in isRouteEnabled.guard.ts & environment-specific.service.ts git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52449 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
8ce7227a49
commit
668304da29
|
@ -18,7 +18,7 @@ export class IsRouteEnabled implements CanActivate {
|
||||||
if(!community && route.data['community']){ // for openaire
|
if(!community && route.data['community']){ // for openaire
|
||||||
let community = route.data['community']
|
let community = route.data['community']
|
||||||
}
|
}
|
||||||
if(!community){
|
if(!community && typeof document != 'undefined'){
|
||||||
community = ConnectHelper.getCommunityFromDomain(document.location.hostname);
|
community = ConnectHelper.getCommunityFromDomain(document.location.hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Injectable, OnInit, PLATFORM_ID, Inject,InjectionToken } from '@angular/core';
|
import { Injectable, OnInit, PLATFORM_ID, Inject,InjectionToken , Optional } from '@angular/core';
|
||||||
import { isPlatformBrowser} from '@angular/common';
|
import { isPlatformBrowser} from '@angular/common';
|
||||||
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
import { Http, Response, Headers, RequestOptions } from '@angular/http';
|
||||||
import { Observable, Subscription, BehaviorSubject } from 'rxjs/Rx';
|
import { Observable, Subscription, BehaviorSubject } from 'rxjs/Rx';
|
||||||
|
@ -10,8 +10,7 @@ import { DOCUMENT } from '@angular/platform-browser';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EnvironmentSpecificService {
|
export class EnvironmentSpecificService {
|
||||||
// export function createTranslateLoader(http: Http, @Inject('ORIGIN_URL') originUrl: string) {
|
|
||||||
// return new TranslateHttpLoader(http, originUrl + './assets/i18n/', '.json');
|
|
||||||
public envSpecific: EnvProperties;
|
public envSpecific: EnvProperties;
|
||||||
public envSpecificNull: EnvProperties = null;
|
public envSpecificNull: EnvProperties = null;
|
||||||
testBrowser: boolean;
|
testBrowser: boolean;
|
||||||
|
@ -19,20 +18,27 @@ export class EnvironmentSpecificService {
|
||||||
private propertiesUrl = "/assets/env-properties.json";
|
private propertiesUrl = "/assets/env-properties.json";
|
||||||
|
|
||||||
|
|
||||||
// private propertiesUrl = "https://beta.connect.openaire.eu/assets/env-properties.json";
|
private serverUrl = "http://scoobydoo.di.uoa.gr:4000";
|
||||||
constructor(private http: Http,@Inject(PLATFORM_ID) platformId: string,@Inject(DOCUMENT) private document: any) {
|
// private serverUrl = "https://beta.explore.openaire.eu";
|
||||||
|
// private serverUrl = "https://beta.connect.openaire.eu";
|
||||||
|
constructor(private http: Http, @Inject(PLATFORM_ID) private platformId: string) {
|
||||||
this.testBrowser = isPlatformBrowser(platformId);
|
this.testBrowser = isPlatformBrowser(platformId);
|
||||||
if (this.testBrowser) {
|
if (this.testBrowser) {
|
||||||
//this is only executed on the browser
|
//this is only executed on the browser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadEnvironment() {
|
public loadEnvironment() {
|
||||||
// Only want to do this once - if root page is revisited, it calls this again.
|
// Only want to do this once - if root page is revisited, it calls this again.
|
||||||
if (this.envSpecific === null || this.envSpecific === undefined) {
|
if (this.envSpecific === null || this.envSpecific === undefined) {
|
||||||
console.log('Loading '+ document.location.protocol +"//" + document.location.host+this.propertiesUrl);
|
var location = this.propertiesUrl;
|
||||||
|
if(typeof document == 'undefined'){
|
||||||
|
location = this.serverUrl + this.propertiesUrl;
|
||||||
|
|
||||||
return this.http.get(document.location.protocol +"//" + document.location.host+this.propertiesUrl)
|
}else{
|
||||||
|
location = document.location.protocol +"//" + document.location.host+this.propertiesUrl;
|
||||||
|
}
|
||||||
|
console.log('Loading '+ location);
|
||||||
|
return this.http.get(location)
|
||||||
.map((data) => data.json())
|
.map((data) => data.json())
|
||||||
.toPromise<EnvProperties>();
|
.toPromise<EnvProperties>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue