1
|
import {HttpParams} from '@angular/common/http';
|
2
|
import {properties} from "../../../environments/environment";
|
3
|
|
4
|
export class ConnectHelper {
|
5
|
|
6
|
public static getCommunityFromDomain(domain: string): string{
|
7
|
//domain = "beta.covid-19.openaire.eu"; //for testing
|
8
|
if (domain.indexOf('openaire.eu') === -1) {
|
9
|
return null;
|
10
|
}
|
11
|
if ( domain.indexOf('beta') !== -1) {
|
12
|
domain = domain.substr(domain.indexOf('.') + 1, domain.length);
|
13
|
domain = domain.substr(0, domain.indexOf('.'));
|
14
|
} else if (domain.indexOf('test.') !== -1) {
|
15
|
return null;
|
16
|
} else {
|
17
|
domain = domain.substr(0, domain.indexOf('.'));
|
18
|
}
|
19
|
if (domain === 'connect' || domain === 'explore' || domain === 'monitor' || domain === 'admin'){
|
20
|
return null;
|
21
|
}
|
22
|
return domain;
|
23
|
}
|
24
|
|
25
|
public static getCommunityFromPath(path: string): string {
|
26
|
if (path.includes('?')) {
|
27
|
const httpParams = new HttpParams({ fromString: path.split('?')[1] });
|
28
|
return httpParams.get('communityId');
|
29
|
} else {
|
30
|
return null;
|
31
|
}
|
32
|
}
|
33
|
|
34
|
public static setPortalTypeFromPid(pid: string): void {
|
35
|
if(pid == "openaire") {
|
36
|
properties.adminToolsPortalType = "explore";
|
37
|
} else if(pid == "connect") {
|
38
|
properties.adminToolsPortalType = "connect";
|
39
|
} else if(pid == "monitor") {
|
40
|
properties.adminToolsPortalType = "monitor";
|
41
|
}
|
42
|
}
|
43
|
}
|