1
|
import {Inject, Injectable, Optional} from '@angular/core';
|
2
|
import {HttpClient} from "@angular/common/http";
|
3
|
import {Request} from 'express';
|
4
|
import {properties} from "../../../../environments/environment";
|
5
|
import {ConnectHelper} from "../../connect/connectHelper";
|
6
|
import {REQUEST} from '../tokens';
|
7
|
|
8
|
@Injectable({
|
9
|
providedIn: 'root'
|
10
|
})
|
11
|
export class EnvironmentSpecificService {
|
12
|
|
13
|
constructor(private http: HttpClient, @Optional() @Inject(REQUEST) private request: Request) {
|
14
|
if(properties.adminToolsCommunity == "connect") {
|
15
|
if(properties.environment == "development"){
|
16
|
properties.domain = "https://beta."+(ConnectHelper.getCommunityFromDomain(properties.domain)?ConnectHelper.getCommunityFromDomain(properties.domain):"connect")+".openaire.eu";
|
17
|
} else{
|
18
|
properties.domain = "https://" + this.getDomain();
|
19
|
}
|
20
|
} else if(properties.adminToolsPortalType === 'aggregator') {
|
21
|
if(properties.environment == "development"){
|
22
|
properties.domain = "https://beta.canada.openaire.eu";
|
23
|
} else {
|
24
|
properties.domain = "https://" + this.getDomain();
|
25
|
}
|
26
|
}
|
27
|
}
|
28
|
|
29
|
private getDomain() {
|
30
|
var domain = "";
|
31
|
if (this.request) {
|
32
|
domain = this.request.get('host').split(":")[0];
|
33
|
} else {
|
34
|
domain = document.location.hostname;
|
35
|
}
|
36
|
return domain;
|
37
|
}
|
38
|
}
|