diff --git a/src/app/pages/simulation-wizard/ml-module/ml-module.component.ts b/src/app/pages/simulation-wizard/ml-module/ml-module.component.ts index 6473f19cb9b4c69ff744f609dcefff09bd20ac13..9ab6875be478d6f3d897f419099c28ba4167f65d 100644 --- a/src/app/pages/simulation-wizard/ml-module/ml-module.component.ts +++ b/src/app/pages/simulation-wizard/ml-module/ml-module.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from "@angular/core"; import { environment } from "../../../../environments/environment"; +import { ConfigService } from '@ngx-config/core'; @Component({ selector: "ngx-ml-module", @@ -7,10 +8,15 @@ import { environment } from "../../../../environments/environment"; styleUrls: ["./ml-module.component.scss"], }) export class MlModuleComponent implements OnInit { - constructor() {} + constructor( + private configService: ConfigService + ) { + this.storage_url = `${configService.getSettings("traffic_simulation_storage_url")}`; + this.file_url = `${configService.getSettings("traffic_simulation_storage_url")}/ml-experiments`; + } - storage_url = `${environment.storageAPIUrl}`; - file_url = this.storage_url + "/ml-experiments"; + storage_url: any; + file_url: any; visualizationBtnDisabled: boolean = true; mlBtnDisabled: boolean = true; recommendationBtnDisabled: boolean = true; diff --git a/src/app/pages/simulation-wizard/simulation-wizard.module.ts b/src/app/pages/simulation-wizard/simulation-wizard.module.ts index 13099f141ee4ad454e3f9ce35a5fa421628a8f9b..bb0a2dac32617488aef9e0dfb920ab11a9574859 100644 --- a/src/app/pages/simulation-wizard/simulation-wizard.module.ts +++ b/src/app/pages/simulation-wizard/simulation-wizard.module.ts @@ -48,11 +48,20 @@ import { MlModuleComponent } from "./ml-module/ml-module.component"; import { VisualizationsGeojsonComponent } from "./visualizations/visualizations-geojson/visualizations-geojson.component"; import { RecommenderPageComponent } from "./recommender-page/recommender-page.component"; import { EditNetworkMapComponent } from "./edit-network-map/edit-network-map.component"; +import { ConfigService } from '@ngx-config/core'; -const rxStompConfig: InjectableRxStompConfig = { - brokerURL: environment.baseStompURL, - debug: (msg) => environment.showWebSocketDebug && console.debug(msg), -}; +export class MyRxStompConfig extends InjectableRxStompConfig { + constructor(private configService: ConfigService) { + super(); + this.brokerURL = `${configService.getSettings("traffic_simulation_stomp_url")}`; + this.heartbeatIncoming = 0; + this.heartbeatOutgoing = 10000; + this.reconnectDelay = 500; + this.debug = (msg: string): void => { + environment.showWebSocketDebug && console.debug(msg); + }; + } +} @NgModule({ imports: [ @@ -101,8 +110,9 @@ const rxStompConfig: InjectableRxStompConfig = { ], providers: [ { - provide: InjectableRxStompConfig, - useValue: rxStompConfig, + provide: InjectableRxStompConfig, + useClass: MyRxStompConfig, + deps: [ConfigService] }, { provide: RxStompService, diff --git a/src/app/pages/simulation-wizard/utils/services/city.service.ts b/src/app/pages/simulation-wizard/utils/services/city.service.ts index 27465485c08caeaa0889479a27cfe0db2e82b11b..0002b608a25d988d6a90f8a37f935db5ad34e04a 100644 --- a/src/app/pages/simulation-wizard/utils/services/city.service.ts +++ b/src/app/pages/simulation-wizard/utils/services/city.service.ts @@ -7,15 +7,19 @@ import { City } from "../data/city"; import { Network } from "../data/network"; import { Scenario } from "../data/scenario"; import { tapDebugApi } from "./tap-debug"; +import { ConfigService } from '@ngx-config/core'; @Injectable({ providedIn: "root" }) export class CityService { - private url = `${environment.baseAPIUrl}/traffic-simulation/city`; + private url: any; private selectedCityIndex: number; private selectedCity$ = new BehaviorSubject<City | null>(null); cities: City[]; - constructor(private httpClient: HttpClient) {} + constructor( + private httpClient: HttpClient, + private configService: ConfigService + ) { this.url = `${configService.getSettings("traffic_simulation_base_url")}/city`; } public setSelectedCity(cityId: string) { this.selectedCityIndex = this.cities.findIndex( diff --git a/src/app/pages/simulation-wizard/utils/services/com.service.ts b/src/app/pages/simulation-wizard/utils/services/com.service.ts index eb731979a73c9fe605bf3adda92ad59bd003f349..9113f9c8f85172bbefcc55d4bb0fb263c0f87c8a 100644 --- a/src/app/pages/simulation-wizard/utils/services/com.service.ts +++ b/src/app/pages/simulation-wizard/utils/services/com.service.ts @@ -4,14 +4,18 @@ import { Observable } from "rxjs"; import { tap } from "rxjs/operators"; import { Simulation } from "../data/simulation"; import { environment } from "../../../../../environments/environment"; +import { ConfigService } from '@ngx-config/core'; @Injectable({ providedIn: "root", }) export class ComService { - private traffic_sim_server = `${environment.baseAPIUrl}/traffic-simulation/network`; + private traffic_sim_server: any; - constructor(private http: HttpClient) {} + constructor( + private http: HttpClient, + private configService: ConfigService + ) { this.traffic_sim_server = `${configService.getSettings("traffic_simulation_base_url")}/network`; } sendGetResultsVis(simId: number): Observable<any> { const url: string = `${this.traffic_sim_server}/simulation/${simId}/results/vis-trips`; diff --git a/src/app/pages/simulation-wizard/utils/services/network.service.ts b/src/app/pages/simulation-wizard/utils/services/network.service.ts index 7111797283dbd344efe1a005091c8b14fb03ac07..b29f3ca745e55beabcb59b1d24b18c168b5de420 100644 --- a/src/app/pages/simulation-wizard/utils/services/network.service.ts +++ b/src/app/pages/simulation-wizard/utils/services/network.service.ts @@ -8,14 +8,18 @@ import { map, catchError } from "rxjs/operators"; import { environment } from "../../../../../environments/environment"; import { Network } from "../data/network"; import { tapDebugApi } from "./tap-debug"; +import { ConfigService } from '@ngx-config/core'; @Injectable({ providedIn: "root", }) export class NetworkService { - private baseAPIUrl = `${environment.baseAPIUrl}/traffic-simulation/network`; + private baseAPIUrl: any; - constructor(private httpClient: HttpClient) {} + constructor( + private httpClient: HttpClient, + private configService: ConfigService + ) { this.baseAPIUrl = `${configService.getSettings("traffic_simulation_base_url")}/network`; } handleError(error: HttpErrorResponse) { let errorMessage = "Some sort of error."; diff --git a/src/app/pages/simulation-wizard/utils/services/scenario.service.ts b/src/app/pages/simulation-wizard/utils/services/scenario.service.ts index fe5c0ec419a5f6cbfb70cc481c4bcec80a90a0ed..28fba85bdac792d841a48e2e0f82be0cc052ab73 100644 --- a/src/app/pages/simulation-wizard/utils/services/scenario.service.ts +++ b/src/app/pages/simulation-wizard/utils/services/scenario.service.ts @@ -6,14 +6,18 @@ import { environment } from "../../../../../environments/environment"; import { Scenario } from "../data/scenario"; import { Simulation } from "../data/simulation"; import { tapDebugApi } from "./tap-debug"; +import { ConfigService } from '@ngx-config/core'; @Injectable({ providedIn: 'root', }) export class ScenarioService { - private baseApiUrl = `${environment.baseAPIUrl}/traffic-simulation/scenario`; + private baseApiUrl: any; - constructor(private httpClient: HttpClient) { } + constructor( + private httpClient: HttpClient, + private configService: ConfigService + ) { this.baseApiUrl = `${configService.getSettings("traffic_simulation_base_url")}/scenario`; } createScenario(scenario: Scenario) { return this.httpClient.post(this.baseApiUrl, scenario).pipe( diff --git a/src/app/pages/simulation-wizard/utils/services/simulation.service.ts b/src/app/pages/simulation-wizard/utils/services/simulation.service.ts index 4026b77656462bed82053ec1dc554e59ea5a7c30..b566537cd4ec0516b009cfbfe4f5850d0946640c 100644 --- a/src/app/pages/simulation-wizard/utils/services/simulation.service.ts +++ b/src/app/pages/simulation-wizard/utils/services/simulation.service.ts @@ -5,17 +5,26 @@ import { map, tap, catchError } from "rxjs/operators"; import { environment } from "../../../../../environments/environment"; import { Simulation } from "../data/simulation"; import { tapDebugApi } from "./tap-debug"; +import { ConfigService } from '@ngx-config/core'; @Injectable({ providedIn: "root", }) export class SimulationService { - private ts_simulation_url = `${environment.baseAPIUrl}/traffic-simulation/simulation`; - private ts_url = `${environment.baseAPIUrl}/traffic-simulation`; - private storage_url = `${environment.storageAPIUrl}`; - private dssUrl = `${environment.dssUrl}`; + private ts_simulation_url: any; + private ts_url: any; + private storage_url: any; + private dssUrl: any; - constructor(private httpClient: HttpClient) {} + constructor( + private httpClient: HttpClient, + private configService: ConfigService + ) { + this.ts_simulation_url = `${configService.getSettings("traffic_simulation_base_url")}/simulation`; + this.ts_url = `${configService.getSettings("traffic_simulation_base_url")}`; + this.storage_url = `${configService.getSettings("traffic_simulation_storage_url")}`; + this.dssUrl = `${configService.getSettings("traffic_simulation_dss_url")}`; + } createSimulation(simulation: Simulation): Observable<Simulation> { return this.httpClient.post(this.ts_simulation_url, simulation).pipe( diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 44b42f23a113afe83a6a2e61b0d39c05fc1316fd..8a8c51e533401ca33fa227622692d14580061bb4 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -5,15 +5,6 @@ */ export const environment = { production: true, - baseAPIUrl: 'http://localhost:8082', - storageAPIUrl: 'http://localhost:8081', - baseStompURL: 'ws://localhost:8082/gs-guide-websocket', - dssUrl: 'http://localhost:8083', showAPIDebug: false, - showWebSocketDebug: true, - ftpHost: '127.0.0.1', - ftpPort: '2121', - ftpUser: 'urbanite', - ftpPassword: 'password', - ftpDirectory: 'data' + showWebSocketDebug: true }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index b17b0debd095c2476cac5a2bd85bec1b4ce02fbe..6046cfcb3650709e021e0aed260e1ecc6b231cea 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -10,15 +10,6 @@ export const environment = { production: false, - baseAPIUrl: 'http://localhost:8082', - storageAPIUrl: 'http://localhost:8081', - baseStompURL: 'ws://localhost:8082/gs-guide-websocket', - dssUrl: 'http://localhost:8083', showAPIDebug: false, - showWebSocketDebug: true, - ftpHost: '127.0.0.1', - ftpPort: '2121', - ftpUser: 'urbanite', - ftpPassword: 'password', - ftpDirectory: 'data' + showWebSocketDebug: true };