Replace the usage of environment.ts with config.json (not too stable) (ref #251)

This commit is contained in:
George Kalampokis 2020-03-26 18:44:12 +02:00
parent 759016dd0b
commit 21fe5bb621
62 changed files with 524 additions and 147 deletions

View File

@ -13,6 +13,7 @@ import { Title } from '@angular/platform-browser';
import { NgcCookieConsentService, NgcStatusChangeEvent } from "ngx-cookieconsent";
import { CookieService } from "ngx-cookie-service";
import { LanguageService } from './core/services/language/language.service';
import { ConfigurationService } from './core/services/configuration/configuration.service';
declare const gapi: any;
@ -27,7 +28,7 @@ export class AppComponent implements OnInit {
hasBreadCrumb = observableOf(false);
sideNavOpen = false;
helpContentEnabled = environment.HelpService.Enabled;
helpContentEnabled : boolean;
private statusChangeSubscription: Subscription;
constructor(
@ -40,9 +41,11 @@ export class AppComponent implements OnInit {
private cultureService: CultureService,
private cookieService: CookieService,
private ccService: NgcCookieConsentService,
private language: LanguageService
private language: LanguageService,
private configurationService: ConfigurationService
) {
this.initializeServices();
this.helpContentEnabled = configurationService.helpService.enabled;
}
onActivate(event: any) {
@ -99,6 +102,8 @@ export class AppComponent implements OnInit {
}
});
this.ccService.getConfig().content.href = this.configurationService.app + "terms-of-service";
this.ccService.getConfig().cookie.domain = this.configurationService.app;
this.translate
.get(['COOKIE.MESSAGE', 'COOKIE.DISMISS', 'COOKIE.DENY', 'COOKIE.LINK', 'COOKIE.POLICY'])
.subscribe(data => {
@ -146,7 +151,7 @@ export class AppComponent implements OnInit {
initializeServices() {
this.translate.setDefaultLang('en');
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture);
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(this.configurationService.defaultCulture);
this.authentication.current() && this.authentication.current().language ? this.language.changeLanguage(this.authentication.current().language) : this.language.changeLanguage('en');
}
}

View File

@ -1,6 +1,6 @@
import { OverlayModule } from '@angular/cdk/overlay';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { LOCALE_ID, NgModule } from '@angular/core';
import { LOCALE_ID, NgModule, APP_INITIALIZER } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatMomentDateModule, MAT_MOMENT_DATE_FORMATS } from '@angular/material-moment-adapter';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
@ -29,10 +29,11 @@ import { CookieService } from 'ngx-cookie-service';
import { NgcCookieConsentConfig, NgcCookieConsentModule } from 'ngx-cookieconsent';
import { TranslateServerLoader } from './core/services/language/server.loader';
import { BaseHttpService } from './core/services/http/base-http.service';
import { ConfigurationService } from './core/services/configuration/configuration.service';
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateServerLoader(http);
export function HttpLoaderFactory(http: HttpClient, appConfig: ConfigurationService) {
return new TranslateServerLoader(http, appConfig);
//GK: In case we want the original translation provider uncomment the line below.
//return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
@ -40,7 +41,7 @@ export function HttpLoaderFactory(http: HttpClient) {
const cookieConfig: NgcCookieConsentConfig = {
enabled: true,
cookie: {
domain: environment.App // or 'your.domain.com' // it is mandatory to set a domain, for cookies to work properly (see https://goo.gl/S2Hy2A)
domain: ""//environment.App // or 'your.domain.com' // it is mandatory to set a domain, for cookies to work properly (see https://goo.gl/S2Hy2A)
},
palette: {
popup: {
@ -59,7 +60,7 @@ const cookieConfig: NgcCookieConsentConfig = {
dismiss: "Got it!",
deny: "Refuse cookies",
link: "Learn more",
href: environment.App + "terms-of-service",
href: "",//environment.App + "terms-of-service",
policy: "Cookie Policy"
},
position: "bottom-right",
@ -78,7 +79,7 @@ const cookieConfig: NgcCookieConsentConfig = {
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
deps: [HttpClient, ConfigurationService]
}
}),
HttpClientModule,

View File

@ -1,4 +1,4 @@
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { ModuleWithProviders, NgModule, Optional, SkipSelf, APP_INITIALIZER } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { AuthGuard } from './auth-guard.service';
import { AuthService } from './services/auth/auth.service';
@ -39,12 +39,18 @@ import { LanguageService } from './services/language/language.service';
import { AdminAuthGuard } from './admin-auth-guard.service';
import { LockService } from './services/lock/lock.service';
import { UserGuideService } from './services/user-guide/user-guide.service';
import { ConfigurationService } from './services/configuration/configuration.service';
import { HttpClient } from '@angular/common/http';
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
//
//
export function ConfigurationFactory(appConfig: ConfigurationService) {
return () => appConfig.loadConfiguration();
}
@NgModule({
})
export class CoreServiceModule {
@ -97,7 +103,14 @@ export class CoreServiceModule {
ContactSupportService,
LanguageService,
LockService,
UserGuideService
UserGuideService,
ConfigurationService,
{
provide: APP_INITIALIZER,
useFactory: ConfigurationFactory,
deps: [ConfigurationService, HttpClient],
multi: true
},
],
};
}

View File

@ -0,0 +1,20 @@
export class HelpService {
private _enabled: boolean;
get enabled(): boolean {
return this._enabled;
}
private _url: string;
get url(): string {
return this._url;
}
public static parseValue(value: any): HelpService {
const obj: HelpService = new HelpService();
obj._enabled = value.Enabled;
obj._url = value.Url;
return obj;
}
}

View File

@ -0,0 +1,19 @@
export class Logging {
private _enabled: boolean;
get enabled(): boolean {
return this._enabled;
}
private _loglevels: string[] = [];
get loglevels(): string[] {
return this._loglevels;
}
public static parseValue(value: any): Logging {
const obj: Logging = new Logging();
obj._enabled = value.enabled;
obj._loglevels = value.logLevels;
return obj;
}
}

View File

@ -0,0 +1,22 @@
export class LoginConfiguration {
private _clientId: string;
get clientId(): string {
return this._clientId;
}
private _oauthUrl: string;
get oauthUrl(): string {
return this._oauthUrl;
}
private _redirectUri: string;
get redirectUri(): string {
return this._redirectUri;
}
private _state: string;
get state(): string {
return this._state;
}
}

View File

@ -0,0 +1,57 @@
import { LoginConfiguration } from './login-configuration.model';
export class LoginProviders {
private _enabled: number[] = [];
get enabled(): number[] {
return this._enabled;
}
private _facebookConfiguration: LoginConfiguration;
get facebookConfiguration(): LoginConfiguration {
return this._facebookConfiguration;
}
private _googleConfiguration: LoginConfiguration;
get googleConfiguration(): LoginConfiguration {
return this._googleConfiguration;
}
private _linkedInConfiguration: LoginConfiguration;
get linkedInConfiguration(): LoginConfiguration {
return this._linkedInConfiguration;
}
private _twitterConfiguration: LoginConfiguration;
get twitterConfiguration(): LoginConfiguration {
return this._twitterConfiguration;
}
private _b2accessConfiguration: LoginConfiguration;
get b2accessConfiguration(): LoginConfiguration {
return this._b2accessConfiguration;
}
private _orcidConfiguration: LoginConfiguration;
get orcidConfiguration(): LoginConfiguration {
return this._orcidConfiguration;
}
private _openAireConfiguration: LoginConfiguration;
get openAireConfiguration(): LoginConfiguration {
return this._openAireConfiguration;
}
public static parseValue(value: any): LoginProviders {
const obj: LoginProviders = new LoginProviders();
obj._enabled = value.enabled;
obj._facebookConfiguration = value.facebookConfiguration;
obj._googleConfiguration = value.googleConfiguration;
obj._linkedInConfiguration = value.linkedInConfiguration;
obj._twitterConfiguration = value.twitterConfiguration;
obj._b2accessConfiguration = value.b2accessConfiguration;
obj._orcidConfiguration = value.orcidConfiguration;
obj._openAireConfiguration = value.openAireConfiguration;
return obj;
}
}

View File

@ -13,6 +13,7 @@ import { TranslateService } from '@ngx-translate/core';
import { environment } from 'environments/environment';
import { Observable, of as observableOf, throwError as observableThrowError } from 'rxjs';
import { catchError, map, takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class AuthService extends BaseService {
@ -24,10 +25,11 @@ export class AuthService extends BaseService {
private snackBar: MatSnackBar,
private language: TranslateService,
private router: Router,
private uiNotificationService: UiNotificationService
private uiNotificationService: UiNotificationService,
private configurationService: ConfigurationService
) {
super();
this.actionUrl = environment.Server + 'auth/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
@ -65,6 +67,7 @@ export class AuthService extends BaseService {
//}
public login(loginInfo: LoginInfo): Observable<Principal> {
this.actionUrl = this.configurationService.server + 'auth/';
const url = this.actionUrl + 'externallogin';
return this.http.post(url, loginInfo, { headers: this.headers }).pipe(
@ -80,6 +83,7 @@ export class AuthService extends BaseService {
}
public nativeLogin(credentials: Credential): Observable<Principal> {
this.actionUrl = this.configurationService.server + 'auth/';
const url = this.actionUrl + 'nativelogin';
return this.http.post(url, credentials, { headers: this.headers }).pipe(
@ -96,6 +100,7 @@ export class AuthService extends BaseService {
public logout(): void {
this.actionUrl = this.configurationService.server + 'auth/';
const url = this.actionUrl + 'logout';
const principal = this.current();
this.clear();

View File

@ -0,0 +1,97 @@
import { Injectable } from '@angular/core';
import { BaseHttpParams } from '@common/http/base-http-params';
import { InterceptorType } from '@common/http/interceptors/interceptor-type';
import { BaseHttpService } from '@common/base/base-http.service';
import { BaseComponent } from '@common/base/base.component';
import { catchError, takeUntil } from 'rxjs/operators';
import { Observable, throwError } from 'rxjs';
import { HelpService } from '@app/core/model/configuration-models/help-service.model';
import { LoginProviders } from '@app/core/model/configuration-models/login-providers.model';
import { Logging } from '@app/core/model/configuration-models/logging.model';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root',
})
export class ConfigurationService extends BaseComponent {
constructor(private http: HttpClient) { super(); }
private _server: string;
get server(): string {
return this._server;
}
private _app: string;
get app(): string {
return this._app;
}
private _helpService: HelpService;
get helpService(): HelpService {
return this._helpService;
}
private _defaultCulture: string;
get defaultCulture(): string {
return this._defaultCulture;
}
private _loginProviders: LoginProviders;
get loginProviders(): LoginProviders {
return this._loginProviders;
}
private _logging: Logging;
get logging(): Logging {
return this._logging;
}
private _lockInterval: number;
get lockInterval(): number {
return this._lockInterval;
}
private _guideAssets: string;
get guideAssets():string {
return this._guideAssets;
}
public loadConfiguration(): Promise<any> {
return new Promise((r, e) => {
// We need to exclude all interceptors here, for the initial configuration request.
const params = new BaseHttpParams();
params.interceptorContext = {
excludedInterceptors: [InterceptorType.AuthToken,
InterceptorType.JSONContentType,
InterceptorType.Locale,
InterceptorType.ProgressIndication,
InterceptorType.RequestTiming,
InterceptorType.UnauthorizedResponse]
};
this.http.get('./assets/config/config.json', { params: params }).pipe(catchError((err: any, caught: Observable<any>) => throwError(err)))
.pipe(takeUntil(this._destroyed))
.subscribe(
(content: ConfigurationService) => {
this.parseResponse(content);
r(this);
},
reason => e(reason));
});
}
private parseResponse(config: any) {
this._server = config.Server;
this._app = config.App;
this._helpService = HelpService.parseValue(config.HelpService);
this._defaultCulture = config.defaultCulture;
this._loginProviders = LoginProviders.parseValue(config.loginProviders);
this._logging = Logging.parseValue(config.logging);
this._lockInterval = config.lockInterval;
this._guideAssets = config.guideAssets;
}
}

View File

@ -4,14 +4,16 @@ import { environment } from "../../../../environments/environment";
import { Injectable } from "@angular/core";
import { ContactEmail } from "../../model/contact/contact-email-form-model";
import { Observable } from "rxjs";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class ContactSupportService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'contactEmail/';
constructor(private http: BaseHttpService,
private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'contactEmail/';
}
postEmail(contentEmail: ContactEmail): Observable<ContactEmail> {

View File

@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { DashboardStatisticsModel } from '../../model/dashboard/dashboard-statistics-model';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DashboardService {
@ -11,8 +12,9 @@ export class DashboardService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'dashboard/';
constructor(private http: BaseHttpService,
private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'dashboard/';
}
getStatistics(): Observable<DashboardStatisticsModel> {

View File

@ -14,6 +14,7 @@ import { InterceptorType } from '@common/http/interceptors/interceptor-type';
import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { takeUntil } from "rxjs/operators";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DatasetProfileService extends BaseService {
@ -24,9 +25,9 @@ export class DatasetProfileService extends BaseService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
super();
this.actionUrl = environment.Server + 'admin/';
this.actionUrl = configurationService.server + 'admin/';
}
createForm(data) {

View File

@ -10,6 +10,7 @@ import { DatasetWizardModel } from '../../model/dataset/dataset-wizard';
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
import { RequestItem } from '../../query/request-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DatasetWizardService {
@ -17,8 +18,8 @@ export class DatasetWizardService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
this.actionUrl = environment.Server + 'datasetwizard/';
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'datasetwizard/';
}
// public userDmps(criteria: RequestItem<DmpCriteria>): Observable<DmpModel[]> {

View File

@ -5,6 +5,7 @@ import { environment } from '../../../../environments/environment';
import { DatasetExternalAutocompleteCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria';
import { RequestItem } from '../../query/request-item';
import { DatasetProfileService } from '../dataset-profile/dataset-profile.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DatasetExternalAutocompleteService {
@ -13,8 +14,9 @@ export class DatasetExternalAutocompleteService {
constructor(
private httpClient: HttpClient,
private datasetProfileService: DatasetProfileService) {
this.actionUrl = environment.Server + 'datasetwizard/';
private datasetProfileService: DatasetProfileService,
private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'datasetwizard/';
}
getDatasetProfileById(datasetProfileID) {
@ -22,7 +24,7 @@ export class DatasetExternalAutocompleteService {
}
queryAutocomplete(lookUpItem: RequestItem<DatasetExternalAutocompleteCriteria>): Observable<any> {
return this.httpClient.post(environment.Server + 'search/autocomplete', lookUpItem);
return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem);
}
}

View File

@ -9,14 +9,17 @@ import { DatasetCriteria } from '../../query/dataset/dataset-criteria';
import { ExploreDatasetCriteriaModel } from '../../query/explore-dataset/explore-dataset-criteria';
import { BaseHttpService } from '../http/base-http.service';
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DatasetService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'datasets/';
constructor(
private http: BaseHttpService,
private configurationSevice: ConfigurationService) {
this.actionUrl = configurationSevice.server + 'datasets/';
}
getPaged(dataTableRequest: DataTableRequest<DatasetCriteria>): Observable<DataTableData<DatasetListingModel>> {
@ -32,7 +35,7 @@ export class DatasetService {
}
getDatasetProfiles(dataTableRequest: DataTableRequest<DatasetProfileCriteria>): Observable<DatasetProfileModel[]> {
return this.http.post<DatasetProfileModel[]>(environment.Server + 'datasetprofiles/getAll', dataTableRequest);
return this.http.post<DatasetProfileModel[]>(this.configurationSevice.server + 'datasetprofiles/getAll', dataTableRequest);
}
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {

View File

@ -7,6 +7,7 @@ import { DmpInvitation } from '../../model/dmp/invitation/dmp-invitation';
import { DmpInvitationUser } from '../../model/dmp/invitation/dmp-invitation-user';
import { DmpInvitationUserCriteria } from '../../query/dmp/dmp-invitation-user-criteria';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DmpInvitationService {
@ -14,8 +15,8 @@ export class DmpInvitationService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'invite/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'invite/';
}
public inviteDmpInvitationUsers(invitation: DmpInvitation): Observable<DmpInvitationUser[]> {

View File

@ -13,6 +13,7 @@ import { DatasetListingModel } from '../../model/dataset/dataset-listing';
import { BaseHttpParams } from '../../../../common/http/base-http-params';
import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type';
import { DmpProfileExternalAutocompleteCriteria } from '../../query/dmp/dmp-profile-external-autocomplete-criteria';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DmpProfileService {
@ -20,8 +21,8 @@ export class DmpProfileService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
this.actionUrl = environment.Server + 'dmpprofile/';
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'dmpprofile/';
}
getPaged(dataTableRequest: DataTableRequest<DmpProfileCriteria>): Observable<DataTableData<DmpProfileListing>> {

View File

@ -18,6 +18,7 @@ import { DmpCriteria } from '../../query/dmp/dmp-criteria';
import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria';
import { RequestItem } from '../../query/request-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class DmpService {
@ -25,8 +26,8 @@ export class DmpService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
this.actionUrl = environment.Server + 'dmps/';
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'dmps/';
}

View File

@ -2,14 +2,15 @@ import { HttpHeaders } from '@angular/common/http';
import { Injectable } from "@angular/core";
import { environment } from "../../../../environments/environment";
import { BaseHttpService } from "../http/base-http.service";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class EmailConfirmationService {
private actioUrl: string;
private headers: HttpHeaders
constructor(private http: BaseHttpService) {
this.actioUrl = environment.Server + 'emailConfirmation/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actioUrl = configurationService.server + 'emailConfirmation/';
}
public emailConfirmation(token: string) {

View File

@ -3,13 +3,14 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../../environments/environment';
import { DataRepositoryModel } from '../../../model/data-repository/data-repository';
import { BaseHttpService } from '../../http/base-http.service';
import { ConfigurationService } from '../../configuration/configuration.service';
@Injectable()
export class ExternalDataRepositoryService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'external/datarepos';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'external/datarepos';
}
create(dataRepoModel: DataRepositoryModel): Observable<DataRepositoryModel> {

View File

@ -7,13 +7,14 @@ import { DataTableRequest } from '../../../model/data-table/data-table-request';
import { ExternalDatasetModel } from '../../../model/external-dataset/external-dataset';
import { ExternalDatasetCriteria } from '../../../query/external-dataset/external-dataset-criteria';
import { BaseHttpService } from '../../http/base-http.service';
import { ConfigurationService } from '../../configuration/configuration.service';
@Injectable()
export class ExternalDatasetService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'externaldatasets/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'externaldatasets/';
}
create(externalDatasetModel: ExternalDatasetModel): Observable<ExternalDatasetModel> {

View File

@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { ExternalSourcesConfiguration } from '../../model/external-sources/external-sources-configuration';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class ExternalSourcesConfigurationService {
@ -11,8 +12,8 @@ export class ExternalSourcesConfigurationService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'common/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'common/';
}
public getExternalSourcesConfiguration(): Observable<ExternalSourcesConfiguration> {

View File

@ -11,6 +11,7 @@ import { ResearcherCriteria } from '../../query/researcher/researcher-criteria';
import { ServiceCriteria } from '../../query/service/service-criteria';
import { TagCriteria } from '../../query/tag/tag-criteria';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class ExternalSourcesService {
@ -18,9 +19,9 @@ export class ExternalSourcesService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = environment.Server + 'external/';
this.actionUrl = configurationService.server + 'external/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
@ -58,7 +59,7 @@ export class ExternalSourcesService {
}
public searchDMPResearchers(requestItem: RequestItem<ResearcherCriteria>): Observable<ExternalSourceItemModel[]> {
return this.http.post<ExternalSourceItemModel[]>(environment.Server + 'researchers/getWithExternal', requestItem, { headers: this.headers });
return this.http.post<ExternalSourceItemModel[]>(this.configurationService.server + 'researchers/getWithExternal', requestItem, { headers: this.headers });
}
public searchDMPOrganizations(like: string): Observable<ExternalSourceItemModel[]> {

View File

@ -3,13 +3,14 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../../environments/environment';
import { RegistryModel } from '../../../model/registry/registry';
import { BaseHttpService } from '../../http/base-http.service';
import { ConfigurationService } from '../../configuration/configuration.service';
@Injectable()
export class ExternalRegistryService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'registries/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'registries/';
}
create(registerModel: RegistryModel): Observable<RegistryModel> {

View File

@ -2,14 +2,15 @@ import { Injectable } from '@angular/core';
import { environment } from '../../../../../environments/environment';
import { ResearcherModel } from '../../../model/researcher/researcher';
import { BaseHttpService } from '../../http/base-http.service';
import { ConfigurationService } from '../../configuration/configuration.service';
@Injectable()
export class ExternalResearcherService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'researchers/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'researchers/';
}
public createResearcher(researcher: ResearcherModel) {

View File

@ -3,13 +3,14 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../../environments/environment';
import { ServiceModel } from '../../../model/service/service';
import { BaseHttpService } from '../../http/base-http.service';
import { ConfigurationService } from '../../configuration/configuration.service';
@Injectable()
export class ExternalServiceService {
private actionUrl: string;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'services/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'services/';
}
create(serviceModel: ServiceModel): Observable<ServiceModel> {

View File

@ -6,14 +6,15 @@ import { BaseHttpService } from "../http/base-http.service";
import { environment } from '../../../../environments/environment';
import { FunderCriteria } from "../../query/funder/funder-criteria";
import { FunderModel } from "../../model/funder/funder";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class FunderService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'funders/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'funders/';
}
getWithExternal(requestItem: RequestItem<FunderCriteria>): Observable<FunderModel[]> {

View File

@ -6,14 +6,15 @@ import { ContentFile } from '../../model/grant/grant-listing';
import { BaseHttpService } from '../http/base-http.service';
import { BaseHttpParams } from '../../../../common/http/base-http-params';
import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class GrantFileUploadService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'files/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'files/';
}
uploadFile(formData: FormData): Observable<ContentFile> {

View File

@ -8,6 +8,7 @@ import { GrantListingModel } from '../../model/grant/grant-listing';
import { GrantCriteria } from '../../query/grant/grant-criteria';
import { RequestItem } from '../../query/request-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
@ -16,8 +17,8 @@ export class GrantService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'grants/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'grants/';
}
getPaged(dataTableRequest: DataTableRequest<GrantCriteria>, fieldsGroup?: string): Observable<DataTableData<GrantListingModel>> {

View File

@ -8,14 +8,16 @@ import { catchError, map } from 'rxjs/operators';
import { environment } from '../../../../environments/environment';
import { PageHelpContent } from '../../model/help-content/page-help-content';
import { CachedContentItem } from './cached-content-item';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class HelpContentService {
private _helpServiceUrl = environment.HelpService.Url;
private _helpServiceUrl: string;
cache = new Map<String, CachedContentItem>();
constructor(private http: HttpClient) {
constructor(private http: HttpClient, private configurationService: ConfigurationService) {
this._helpServiceUrl = configurationService.helpService.url;
}
// getActivePageContent(route: string) {

View File

@ -5,19 +5,23 @@ import { Observable } from 'rxjs';
import { HttpResponse, HttpClient } from '@angular/common/http';
import { BaseHttpService } from '../http/base-http.service';
import { Language } from '@app/models/language/Language';
import { ConfigurationService } from '../configuration/configuration.service';
const availableLanguages: any[] = require('../../../../assets/resources/language.json');
@Injectable()
export class LanguageService {
private currentLanguage: string = 'en';
private languageUrl = `${environment.Server}language`;
private languageUrl : string;
constructor(
private translate: TranslateService,
private http: HttpClient,
private baseHttp: BaseHttpService
) {}
private baseHttp: BaseHttpService,
private configurationService: ConfigurationService
) {
this.languageUrl = `${configurationService.server}language`;
}
public changeLanguage(lang: string) {
this.currentLanguage = lang;

View File

@ -2,14 +2,19 @@ import { TranslateLoader } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { environment } from 'environments/environment';
import { HttpClient } from '@angular/common/http';
import { ConfigurationService } from '../configuration/configuration.service';
export class TranslateServerLoader implements TranslateLoader{
private languageUrl = `${environment.Server}language`;
private languageUrl: string;
constructor(
private http: HttpClient
) {}
private http: HttpClient,
private configurationService: ConfigurationService
) {
}
getTranslation(lang: string): Observable<any> {
this.languageUrl = `${this.configurationService.server}language`;
return this.http.get(`${this.languageUrl}/${lang}`);
}
}

View File

@ -4,6 +4,7 @@ import { BaseHttpService } from '../http/base-http.service';
import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { LockModel } from '@app/core/model/lock/lock.model';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class LockService {
@ -11,8 +12,8 @@ export class LockService {
private actionUrl: string;
private headers = new HttpHeaders();
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
this.actionUrl = environment.Server + 'lock/';
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'lock/';
}
checkLockStatus(id: string): Observable<boolean> {

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { environment } from '../../../../environments/environment';
import { ConfigurationService } from '../configuration/configuration.service';
export enum LogLevel {
Error = 'error',
@ -16,7 +17,7 @@ export class LoggingService {
private loggingLevels: LogLevel[];
private loggingOutputs: LogOutput[] = [];
constructor() {
constructor(private configurationService: ConfigurationService) {
}
@ -37,7 +38,7 @@ export class LoggingService {
}
init() {
this.loggingLevels = environment.logging.logLevels as LogLevel[];
this.loggingLevels = this.configurationService.logging.loglevels as LogLevel[];
this.loggingOutputs.push((level: LogLevel, ...objects: any[]) => {
switch (level) {
@ -62,7 +63,7 @@ export class LoggingService {
private log(level: LogLevel, logs: any[]) {
if (!this.loggingLevels) { this.init(); }
if (environment.logging.enabled && this.loggingLevels.includes(level)) {
if (this.configurationService.logging.enabled && this.loggingLevels.includes(level)) {
this.loggingOutputs.forEach((output) => output.apply(output, [level, logs]));
}
}

View File

@ -7,6 +7,7 @@ import { DataTableData } from "../../model/data-table/data-table-data";
import { OrganizationModel } from "../../model/organisation/organization";
import { OrganisationCriteria } from "../../query/organisation/organisation-criteria";
import { DataTableRequest } from "../../model/data-table/data-table-request";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class OrganisationService {
@ -14,9 +15,9 @@ export class OrganisationService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = environment.Server;
this.actionUrl = configurationService.server;
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');

View File

@ -7,14 +7,15 @@ import { BaseHttpService } from "../http/base-http.service";
import { environment } from '../../../../environments/environment';
import { ProjectCriteria } from "../../query/project/project-criteria";
import { ProjectModel } from "../../model/project/project";
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class ProjectService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'projects/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'projects/';
}
getWithExternal(requestItem: RequestItem<ProjectCriteria>): Observable<ProjectModel[]> {

View File

@ -5,14 +5,15 @@ import { environment } from '../../../../environments/environment';
import { QuickWizardEditorWizardModel } from '../../../ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.model';
import { BaseHttpService } from '../http/base-http.service';
import { DatasetCreateWizardModel } from '../../../ui/dataset-create-wizard/dataset-create-wizard.model';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class QuickWizardService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'quick-wizard/';
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'quick-wizard/';
}
createQuickWizard(quickWizard: QuickWizardEditorWizardModel): Observable<QuickWizardEditorWizardModel> {

View File

@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { SearchBarItem } from '../../model/dashboard/search-bar-item';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class SearchBarService {
@ -11,9 +12,9 @@ export class SearchBarService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = environment.Server + 'dashboard/';
this.actionUrl = configurationService.server + 'dashboard/';
}
search(like: string): Observable<SearchBarItem[]> {

View File

@ -4,21 +4,25 @@ import { environment } from 'environments/environment';
import { Observable } from 'rxjs';
import { HttpResponse, HttpClient } from '@angular/common/http';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class UserGuideService {
private userGuideUrl = `${environment.Server}userguide`;
private userGuideUrl : string;
constructor(
private translate: TranslateService,
private http: HttpClient,
private baseHttp: BaseHttpService
) {}
private baseHttp: BaseHttpService,
private configurationService: ConfigurationService
) {
this.userGuideUrl = `${configurationService.server}userguide`;
}
public getUserGuide(): Observable<HttpResponse<Blob>> {
return this.http.get(`${this.userGuideUrl}/current`, { responseType: 'blob', observe: 'response', headers: {'Content-type': 'text/html',
'Accept': 'text/html',
'Access-Control-Allow-Origin': environment.App,
'Access-Control-Allow-Origin': this.configurationService.app,
'Access-Control-Allow-Credentials': 'true'} });
}

View File

@ -7,6 +7,7 @@ import { DataTableRequest } from '../../model/data-table/data-table-request';
import { UserListingModel } from '../../model/user/user-listing';
import { UserCriteria } from '../../query/user/user-criteria';
import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class UserService {
@ -14,9 +15,9 @@ export class UserService {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = environment.Server + 'user/';
this.actionUrl = configurationService.server + 'user/';
}
getPaged(dataTableRequest: DataTableRequest<UserCriteria>): Observable<DataTableData<UserListingModel>> {

View File

@ -20,6 +20,7 @@ import { environment } from 'environments/environment';
import * as FileSaver from 'file-saver';
import { Observable, of as observableOf } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
@ -33,7 +34,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
viewOnly = false;
dmpProfileModel: DmpProfileEditorModel;
formGroup: FormGroup = null;
host = environment.Server;
host: string;
dmpProfileId: string;
breadCrumbs: Observable<BreadcrumbItem[]>;
@ -44,9 +45,11 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
private language: TranslateService,
private enumUtils: EnumUtils,
private uiNotificationService: UiNotificationService,
private formService: FormService
private formService: FormService,
private configurationService: ConfigurationService
) {
super();
this.host = configurationService.server;
}
ngAfterViewInit() {

View File

@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-b2access-login',
@ -20,7 +21,8 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit {
private route: ActivatedRoute,
private authService: AuthService,
private loginService: LoginService,
private httpClient: HttpClient
private httpClient: HttpClient,
private configurationService: ConfigurationService
) {
super();
}
@ -36,10 +38,10 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit {
}
public b2AccessGetAuthCode() {
window.location.href = environment.loginProviders.b2accessConfiguration.oauthUrl
+ '?response_type=code&client_id=' + environment.loginProviders.b2accessConfiguration.clientId
+ '&redirect_uri=' + environment.loginProviders.b2accessConfiguration.redirectUri
+ '&state=' + environment.loginProviders.b2accessConfiguration.state
window.location.href = this.configurationService.loginProviders.b2accessConfiguration.oauthUrl
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.b2accessConfiguration.clientId
+ '&redirect_uri=' + this.configurationService.loginProviders.b2accessConfiguration.redirectUri
+ '&state=' + this.configurationService.loginProviders.b2accessConfiguration.state
+ '&scope=USER_PROFILE';
}
@ -47,7 +49,7 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json');
headers = headers.set('Accept', 'application/json');
this.httpClient.post(environment.Server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers })
this.httpClient.post(this.configurationService.server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers })
.pipe(takeUntil(this._destroyed))
.subscribe((data: any) => {
this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.B2Access, data: null })

View File

@ -9,6 +9,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-configurable-login',
@ -33,7 +34,8 @@ export class ConfigurableLoginComponent extends BaseComponent implements OnInit
private authService: AuthService,
private router: Router,
private httpClient: HttpClient,
private providers: ConfigurableProvidersService
private providers: ConfigurableProvidersService,
private configurationService: ConfigurationService
) {
super();
}
@ -80,7 +82,7 @@ export class ConfigurableLoginComponent extends BaseComponent implements OnInit
if (state !== this.provider.state) {
this.router.navigate(['/login'])
}
this.httpClient.post(environment.Server + 'auth/configurableProviderRequestToken', { code: code, provider: AuthProvider.Configurable, configurableLoginId: this.providerId })
this.httpClient.post(this.configurationService.server + 'auth/configurableProviderRequestToken', { code: code, provider: AuthProvider.Configurable, configurableLoginId: this.providerId })
.pipe(takeUntil(this._destroyed))
.subscribe((data: any) => {
this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.Configurable, data: { configurableLoginId: this.provider.configurableLoginId } })

View File

@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-linkedin-login',
@ -21,7 +22,8 @@ export class LinkedInLoginComponent extends BaseComponent implements OnInit {
private loginService: LoginService,
private authService: AuthService,
private router: Router,
private httpClient: HttpClient
private httpClient: HttpClient,
private configurationService: ConfigurationService
) {
super();
}
@ -37,18 +39,18 @@ export class LinkedInLoginComponent extends BaseComponent implements OnInit {
}
public linkedinAuthorize() {
window.location.href = environment.loginProviders.linkedInConfiguration.oauthUrl
+ '?response_type=code&client_id=' + environment.loginProviders.linkedInConfiguration.clientId
+ '&redirect_uri=' + environment.loginProviders.linkedInConfiguration.redirectUri
+ '&state=' + environment.loginProviders.linkedInConfiguration.state
window.location.href = this.configurationService.loginProviders.linkedInConfiguration.oauthUrl
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.linkedInConfiguration.clientId
+ '&redirect_uri=' + this.configurationService.loginProviders.linkedInConfiguration.redirectUri
+ '&state=' + this.configurationService.loginProviders.linkedInConfiguration.state
+ '&scope=r_emailaddress';
}
public linkedInLoginUser(code: string, state: string) {
if (state !== environment.loginProviders.linkedInConfiguration.state) {
if (state !== this.configurationService.loginProviders.linkedInConfiguration.state) {
this.router.navigate(['/login']);
}
this.httpClient.post(environment.Server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn })
this.httpClient.post(this.configurationService.server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn })
.pipe(takeUntil(this._destroyed))
.subscribe((data: any) => {
this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.LinkedIn, data: null })

View File

@ -8,6 +8,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
/// <reference types="gapi" />
/// <reference types="facebook-js-sdk" />
@ -31,7 +32,8 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
private route: ActivatedRoute,
private loginService: LoginService,
private authService: AuthService,
public configurableProviderService: ConfigurableProvidersService
public configurableProviderService: ConfigurableProvidersService,
private configurationService: ConfigurationService
) { super(); }
ngOnInit(): void {
@ -110,21 +112,21 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
}
public hasProvider(provider: AuthProvider) {
for (let i = 0; i < environment.loginProviders.enabled.length; i++) {
if (provider === environment.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); }
for (let i = 0; i < this.configurationService.loginProviders.enabled.length; i++) {
if (provider === this.configurationService.loginProviders.enabled[i]) { return this.isProviderProperlyConfigured(provider); }
}
return false;
}
private isProviderProperlyConfigured(provider: AuthProvider) {
switch (provider) {
case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.facebookConfiguration);
case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.googleConfiguration);
case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.linkedInConfiguration);
case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.twitterConfiguration);
case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.b2accessConfiguration);
case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.orcidConfiguration);
case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(environment.loginProviders.openAireConfiguration);
case AuthProvider.Facebook: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.facebookConfiguration);
case AuthProvider.Google: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.googleConfiguration);
case AuthProvider.LinkedIn: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.linkedInConfiguration);
case AuthProvider.Twitter: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.twitterConfiguration);
case AuthProvider.B2Access: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.b2accessConfiguration);
case AuthProvider.ORCID: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.orcidConfiguration);
case AuthProvider.OpenAire: return this.hasAllRequiredFieldsConfigured(this.configurationService.loginProviders.openAireConfiguration);
default: throw new Error('Unsupported Provider Type');
}
}
@ -140,7 +142,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
private initializeGoogleOauth(): void {
gapi.load('auth2', () => {
this.auth2 = gapi.auth2.init({
client_id: environment.loginProviders.googleConfiguration.clientId,
client_id: this.configurationService.loginProviders.googleConfiguration.clientId,
scope: 'profile email'
});
this.attachGoogleSignΙn(document.getElementById('googleSignInButton'));
@ -169,7 +171,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
*/
private initializeFacebookOauth(): void {
FB.init({
appId: environment.loginProviders.facebookConfiguration.clientId,
appId: this.configurationService.loginProviders.facebookConfiguration.clientId,
cookie: false,
xfbml: true,
version: 'v2.8'

View File

@ -7,6 +7,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-openaire-login',
@ -20,7 +21,8 @@ export class OpenAireLoginComponent extends BaseComponent implements OnInit {
private loginService: LoginService,
private authService: AuthService,
private router: Router,
private httpClient: HttpClient
private httpClient: HttpClient,
private configurationService: ConfigurationService
) {
super();
}
@ -36,18 +38,18 @@ export class OpenAireLoginComponent extends BaseComponent implements OnInit {
}
public openaireAuthorize() {
window.location.href = environment.loginProviders.openAireConfiguration.oauthUrl
+ '?response_type=code&client_id=' + environment.loginProviders.openAireConfiguration.clientId
+ '&redirect_uri=' + environment.loginProviders.openAireConfiguration.redirectUri
+ '&state=' + environment.loginProviders.openAireConfiguration.state
window.location.href = this.configurationService.loginProviders.openAireConfiguration.oauthUrl
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.openAireConfiguration.clientId
+ '&redirect_uri=' + this.configurationService.loginProviders.openAireConfiguration.redirectUri
+ '&state=' + this.configurationService.loginProviders.openAireConfiguration.state
+ '&scope=openid profile email';
}
public openaireLoginUser(code: string, state: string) {
if (state !== environment.loginProviders.openAireConfiguration.state) {
if (state !== this.configurationService.loginProviders.openAireConfiguration.state) {
this.router.navigate(['/login'])
}
this.httpClient.post(environment.Server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire })
this.httpClient.post(this.configurationService.server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire })
.pipe(takeUntil(this._destroyed))
.subscribe((data: any) => {
this.authService.login({ ticket: data.payload.accessToken, provider: AuthProvider.OpenAire, data: null })

View File

@ -9,6 +9,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-orcid-login',
@ -26,7 +27,8 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit {
private route: ActivatedRoute,
private authService: AuthService,
private loginService: LoginService,
private httpClient: HttpClient
private httpClient: HttpClient,
private configurationService: ConfigurationService
) {
super();
this.orcidUser = new OrcidUser;
@ -43,18 +45,18 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit {
}
public orcidAccessGetAuthCode() {
window.location.href = environment.loginProviders.orcidConfiguration.oauthUrl
window.location.href = this.configurationService.loginProviders.orcidConfiguration.oauthUrl
+ '?client_id='
+ environment.loginProviders.orcidConfiguration.clientId
+ this.configurationService.loginProviders.orcidConfiguration.clientId
+ '&response_type=code&scope=/authenticate&redirect_uri='
+ environment.loginProviders.orcidConfiguration.redirectUri;
+ this.configurationService.loginProviders.orcidConfiguration.redirectUri;
}
public orcidLogin(code: string) {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json');
headers = headers.set('Accept', 'application/json');
this.httpClient.post(environment.Server + 'auth/orcidRequestToken', { code: code }, { headers: headers })
this.httpClient.post(this.configurationService.server + 'auth/orcidRequestToken', { code: code }, { headers: headers })
.pipe(takeUntil(this._destroyed))
.subscribe((responseData: any) => {
this.orcidUser.orcidId = responseData.payload.orcidId

View File

@ -8,6 +8,7 @@ import { LoginService } from '@app/ui/auth/login/utilities/login.service';
import { BaseComponent } from '@common/base/base.component';
import { environment } from 'environments/environment';
import { takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-twitter-login',
@ -21,7 +22,8 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit {
private route: ActivatedRoute,
private authService: AuthService,
private httpClient: BaseHttpService,
private loginService: LoginService
private loginService: LoginService,
private configurationService: ConfigurationService
) {
super();
}
@ -40,10 +42,10 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json');
headers = headers.set('Accept', 'application/json');
this.httpClient.get(environment.Server + 'auth/twitterRequestToken', { headers: headers })
this.httpClient.get(this.configurationService.server + 'auth/twitterRequestToken', { headers: headers })
.pipe(takeUntil(this._destroyed))
.subscribe((data: any) => {
window.location.href = environment.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.value;
window.location.href = this.configurationService.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.value;
});
}

View File

@ -40,6 +40,7 @@ import { Guid } from '@common/types/guid';
import { isNullOrUndefined } from 'util';
import { AuthService } from '@app/core/services/auth/auth.service';
import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-dataset-wizard-component',
@ -85,7 +86,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
private formService: FormService,
private lockService: LockService,
private location: Location,
private authService: AuthService
private authService: AuthService,
private configurationService: ConfigurationService
) {
super();
}
@ -152,7 +154,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
@ -259,7 +261,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.

View File

@ -42,6 +42,7 @@ import { LockModel } from '@app/core/model/lock/lock.model';
import { Guid } from '@common/types/guid';
import { isNullOrUndefined } from 'util';
import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-dmp-editor-component',
@ -82,7 +83,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
private authentication: AuthService,
private authService: AuthService,
private formService: FormService,
private lockService: LockService
private lockService: LockService,
private configurationService: ConfigurationService
) {
super();
}
@ -139,7 +141,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
// if (!this.isAuthenticated) {
@ -198,7 +200,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(environment.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
})

View File

@ -20,6 +20,7 @@ import { TranslateService } from '@ngx-translate/core';
import { environment } from 'environments/environment';
import { Observable, of as observableOf } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
@ -33,7 +34,7 @@ export class GrantEditorComponent extends BaseComponent implements OnInit, IBrea
isNew = true;
grant: GrantEditorModel;
formGroup: FormGroup = null;
host = environment.Server;
host: string;
editMode = false;
sizeError = false;
maxFileSize: number = 1048576;
@ -46,9 +47,11 @@ export class GrantEditorComponent extends BaseComponent implements OnInit, IBrea
private dialog: MatDialog,
private grantFileUploadService: GrantFileUploadService,
private uiNotificationService: UiNotificationService,
private formService: FormService
private formService: FormService,
private configurationService: ConfigurationService
) {
super();
this.host = this.configurationService.server;
}
ngOnInit() {

View File

@ -8,6 +8,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Router } from '@angular/router';
import { isNullOrUndefined } from 'util';
import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-user-guide-editor',
@ -22,6 +23,7 @@ export class UserGuideEditorComponent extends BaseComponent implements OnInit {
private uiNotificationService: UiNotificationService,
private translate: TranslateService,
private router: Router,
private configurationService: ConfigurationService
) { super(); }
ngOnInit() {
@ -40,7 +42,7 @@ export class UserGuideEditorComponent extends BaseComponent implements OnInit {
}
private parseText(source: string): string {
source = source.replace(/src="images/g, `src="${environment.guideAssets}`);
source = source.replace(/src="images/g, `src="${this.configurationService.guideAssets}`);
source = source.replace(/\r\n +>/g, '>\n');
const brokenElements = Array.from(new Set(source.match(/&lt;\/\w+\d* &gt;/g)));
if (!isNullOrUndefined(brokenElements)) {

View File

@ -0,0 +1,48 @@
{
"production": false,
"Server": "http://localhost:8080/api/",
"App": "http://localhost:4200/",
"HelpService": {
"Enabled": false,
"Url": "localhost:5000/"
},
"defaultCulture": "en-US",
"loginProviders": {
"enabled": [1, 2, 3, 4, 5, 6, 7, 8],
"facebookConfiguration": { "clientId": "" },
"googleConfiguration": { "clientId": "" },
"linkedInConfiguration": {
"clientId": "",
"oauthUrl": "https://www.linkedin.com/oauth/v2/authorization",
"redirectUri": "http://localhost:4200/login/linkedin",
"state": "987654321"
},
"twitterConfiguration": {
"clientId": "",
"oauthUrl": "https://api.twitter.com/oauth/authenticate"
},
"b2accessConfiguration": {
"clientId": "",
"oauthUrl": "https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz",
"redirectUri": "http://localhost:4200/api/oauth/authorized/b2access",
"state": ""
},
"orcidConfiguration": {
"clientId": "",
"oauthUrl": "https://orcid.org/oauth/authorize",
"redirectUri": "http://localhost:4200/login/external/orcid"
},
"openAireConfiguration": {
"clientId": "",
"oauthUrl": "",
"redirectUri": "",
"state": "987654321"
}
},
"logging": {
"enabled": true,
"logLevels": ["debug", "info", "warning", "error"]
},
"lockInterval": 60000,
"guideAssets": "assets/images/guide"
}

View File

@ -4,12 +4,14 @@ import { Observable } from 'rxjs';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { AuthService } from '../../../app/core/services/auth/auth.service';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class AuthTokenInterceptor extends BaseInterceptor {
constructor(
private authService: AuthService) { super(); }
private authService: AuthService,
configurationService: ConfigurationService) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.AuthToken; }

View File

@ -3,10 +3,11 @@ import { Observable } from 'rxjs';
import { BaseHttpParams } from '../base-http-params';
import { InterceptorType } from './interceptor-type';
import { environment } from '../../../environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
export abstract class BaseInterceptor implements HttpInterceptor {
constructor() { }
constructor(public configurationService: ConfigurationService) { }
abstract type: InterceptorType;
abstract interceptRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
@ -25,6 +26,6 @@ export abstract class BaseInterceptor implements HttpInterceptor {
}
return (req.params instanceof BaseHttpParams && req.params.interceptorContext && Array.isArray(req.params.interceptorContext.interceptAllRequests) && req.params.interceptorContext.interceptAllRequests.includes(this.type))
|| req.url.startsWith(environment.Server);
|| req.url.startsWith(this.configurationService.server);
}
}

View File

@ -3,12 +3,14 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class JsonInterceptor extends BaseInterceptor {
constructor(
) { super(); }
configurationService: ConfigurationService
) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.JSONContentType; }

View File

@ -4,12 +4,14 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class LocaleInterceptor extends BaseInterceptor {
constructor(
private language: TranslateService) { super(); }
private language: TranslateService,
configurationService: ConfigurationService) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.Locale; }

View File

@ -5,12 +5,14 @@ import { finalize } from 'rxjs/operators';
import { ProgressIndicationService } from '../../../app/core/services/progress-indication/progress-indication-service';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class ProgressIndicationInterceptor extends BaseInterceptor {
constructor(
private progressIndicationService: ProgressIndicationService) { super(); }
private progressIndicationService: ProgressIndicationService,
configurationService: ConfigurationService) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.ProgressIndication; }

View File

@ -5,12 +5,14 @@ import { tap } from 'rxjs/operators';
import { LoggingService } from '../../../app/core/services/logging/logging-service';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class RequestTimingInterceptor extends BaseInterceptor {
constructor(
private logger: LoggingService) { super(); }
private logger: LoggingService,
configurationService: ConfigurationService) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.RequestTiming; }

View File

@ -5,13 +5,15 @@ import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class ResponsePayloadInterceptor extends BaseInterceptor {
constructor(
private snackBar: MatSnackBar
) { super(); }
private snackBar: MatSnackBar,
configurationService: ConfigurationService
) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.ResponsePayload; }

View File

@ -6,6 +6,7 @@ import { InterceptorType } from "./interceptor-type";
import { HttpHandler, HttpRequest, HttpEvent } from "@angular/common/http";
import { Observable } from "rxjs";
import { Router } from "@angular/router";
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class StatusCodeInterceptor extends BaseInterceptor {
@ -21,5 +22,6 @@ export class StatusCodeInterceptor extends BaseInterceptor {
constructor(
private router: Router,
) { super(); }
configurationService: ConfigurationService
) { super(configurationService); }
}

View File

@ -6,6 +6,7 @@ import { catchError, mergeMap, tap } from 'rxjs/operators';
import { AuthService } from '../../../app/core/services/auth/auth.service';
import { BaseInterceptor } from './base.interceptor';
import { InterceptorType } from './interceptor-type';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Injectable()
export class UnauthorizedResponseInterceptor extends BaseInterceptor {
@ -13,7 +14,8 @@ export class UnauthorizedResponseInterceptor extends BaseInterceptor {
constructor(
public router: Router,
private authService: AuthService,
) { super(); }
configurationService: ConfigurationService
) { super(configurationService); }
get type(): InterceptorType { return InterceptorType.UnauthorizedResponse; }