diff --git a/components/control_center/src/app/component/landing/landing.component.html b/components/control_center/src/app/component/landing/landing.component.html index 1569c95..f5a10eb 100644 --- a/components/control_center/src/app/component/landing/landing.component.html +++ b/components/control_center/src/app/component/landing/landing.component.html @@ -1,6 +1,8 @@ - - + + + diff --git a/components/control_center/src/app/component/landing/landing.component.ts b/components/control_center/src/app/component/landing/landing.component.ts index 0fc0ca4..481018e 100644 --- a/components/control_center/src/app/component/landing/landing.component.ts +++ b/components/control_center/src/app/component/landing/landing.component.ts @@ -1,6 +1,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AgmMap, AgmMarker} from '@agm/core'; -import {RestService} from "../../services/rest.service"; +import {RestService} from '../../services/rest.service'; +import {NGXLogger} from 'ngx-logger'; @Component({ selector: 'app-landing', @@ -10,7 +11,8 @@ import {RestService} from "../../services/rest.service"; export class LandingComponent implements OnInit { constructor( - private restService: RestService + private restService: RestService, + private logger: NGXLogger ) { } @@ -40,9 +42,31 @@ export class LandingComponent implements OnInit { }, ]; + traffic_light_markers = []; + ngOnInit() { + let traffic_lights = []; + + this.restService.getTrafficLights().subscribe( + (data: any) => { + traffic_lights = data; + console.log(data['cursor']); + for (const traffic_light of data['cursor']) { + traffic_light['iconUrl'] = 'assets/pictures/traffic_light_red.png'; + traffic_light['lat'] = traffic_light['location'][1]; + traffic_light['lng'] = traffic_light['location'][0]; + console.log(traffic_light); + this.traffic_light_markers.push(traffic_light); + } + }, + err => this.logger.error(err), + () => { + this.logger.debug('loaded traffic lights'); + } + ); } + getDelta(source, destination, steps) { return { lat: (destination.lat - source.lat) / steps, diff --git a/components/control_center/src/app/services/rest.service.ts b/components/control_center/src/app/services/rest.service.ts index a0f659e..0a60896 100644 --- a/components/control_center/src/app/services/rest.service.ts +++ b/components/control_center/src/app/services/rest.service.ts @@ -6,7 +6,7 @@ import {Observable} from 'rxjs'; @Injectable() export class RestService { - private currentLocation = 'http://' + environment.location + ':' + environment.port + '/'; + private currentLocation = 'http://' + environment.location + ':' + environment.port + '/api/v1/resources/'; constructor( private logger: NGXLogger, @@ -14,9 +14,7 @@ export class RestService { ) { } - testCall(i: number): Observable { - const url = this.currentLocation + 'api1'; - this.logger.debug('Performing ' + i + '. test rest call on', url); - return this.http.get(url); + getTrafficLights() { + return this.http.get(this.currentLocation + 'traffic_lights'); } } diff --git a/components/control_center/src/assets/pictures/traffic_light.png b/components/control_center/src/assets/pictures/traffic_light.png new file mode 100644 index 0000000..147ed69 Binary files /dev/null and b/components/control_center/src/assets/pictures/traffic_light.png differ diff --git a/components/control_center/src/assets/pictures/traffic_light_green.png b/components/control_center/src/assets/pictures/traffic_light_green.png new file mode 100644 index 0000000..ea0d07c Binary files /dev/null and b/components/control_center/src/assets/pictures/traffic_light_green.png differ diff --git a/components/control_center/src/assets/pictures/traffic_light_red.png b/components/control_center/src/assets/pictures/traffic_light_red.png new file mode 100644 index 0000000..44cd8d2 Binary files /dev/null and b/components/control_center/src/assets/pictures/traffic_light_red.png differ diff --git a/components/control_center/src/environments/environment.ts b/components/control_center/src/environments/environment.ts index da64f42..152fea1 100644 --- a/components/control_center/src/environments/environment.ts +++ b/components/control_center/src/environments/environment.ts @@ -6,7 +6,7 @@ import {NgxLoggerLevel} from 'ngx-logger'; export const environment = { production: false, - location: 'localhost', + location: 'xwayserver', port: 5004, ws_location: 'ws://127.0.0.1', ws_port: 8000, diff --git a/components/entitiy_ident/mongo/traffic_lights.json b/components/entitiy_ident/mongo/traffic_lights.json index ec5282a..8dc949c 100644 --- a/components/entitiy_ident/mongo/traffic_lights.json +++ b/components/entitiy_ident/mongo/traffic_lights.json @@ -1,21 +1,21 @@ [ { "id": "1", - "location": [16.20703, 47.90853], + "location": [16.20719, 47.89584], "range": 2000, "switchingTime": 500, "initialColor": "RED" }, { "id": "2", - "location": [16.20703, 47.91572], + "location": [16.20814, 47.90937], "range": 800, "switchingTime": 240, "initialColor": "GREEN" }, { "id": "3", - "location": [16.20703, 47.92471], + "location": [16.20917, 47.92703], "range": 1000, "switchingTime": 360, "initialColor": "RED"