-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified retrival of backend url (#4)
- migrated url to use configuration file - started changing Dockerfile to make sure the config exists
- Loading branch information
1 parent
21e0b90
commit c20fa52
Showing
5 changed files
with
54 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"serverEndpoint": "http://localhost:5200" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'; | ||
import { TrackerComponent } from '../tracker/tracker.component'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { SocketService } from '../services/SocketService'; | ||
|
||
import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core"; | ||
import { TrackerComponent } from "../tracker/tracker.component"; | ||
import { ActivatedRoute } from "@angular/router"; | ||
import { SocketService } from "../services/SocketService"; | ||
import { Config } from "../shared/config"; | ||
|
||
@Component({ | ||
selector: 'app-overlay', | ||
templateUrl: './overlay.component.html', | ||
styleUrls: ['./overlay.component.scss'] | ||
selector: "app-overlay", | ||
templateUrl: "./overlay.component.html", | ||
styleUrls: ["./overlay.component.scss"], | ||
}) | ||
export class OverlayComponent implements OnInit, AfterViewInit { | ||
|
||
@ViewChild(TrackerComponent) trackerComponent!: TrackerComponent; | ||
groupCode: string = "UNKNOWN"; | ||
socketService!: SocketService; | ||
|
||
constructor(private route: ActivatedRoute) { | ||
this.route.queryParams.subscribe(params => { | ||
this.groupCode = params['groupCode']?.toUpperCase() || "UNKNOWN"; | ||
constructor( | ||
private route: ActivatedRoute, | ||
private config: Config, | ||
) { | ||
this.route.queryParams.subscribe((params) => { | ||
this.groupCode = params["groupCode"]?.toUpperCase() || "UNKNOWN"; | ||
console.log(`Requested group code is ${this.groupCode}`); | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
const siteUrl = window.location.hostname; | ||
this.socketService = new SocketService(`https://${siteUrl}:5200`, this.groupCode); | ||
this.socketService = new SocketService( | ||
this.config.serverEndpoint, | ||
this.groupCode, | ||
); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.socketService.subscribe((data: any) => {this.trackerComponent.updateMatch(data)}); | ||
this.socketService.subscribe((data: any) => { | ||
this.trackerComponent.updateMatch(data); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class Config { | ||
serverEndpoint!: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { enableProdMode } from "@angular/core"; | ||
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; | ||
|
||
import { AppModule } from './app/app.module'; | ||
import { environment } from './environments/environment'; | ||
import { AppModule } from "./app/app.module"; | ||
import { environment } from "./environments/environment"; | ||
import { Config } from "./app/shared/config"; | ||
|
||
if (environment.production) { | ||
enableProdMode(); | ||
} | ||
fetch("/assets/config/config.json").then(async (res) => { | ||
const configuration: Config = await res.json(); | ||
|
||
platformBrowserDynamic().bootstrapModule(AppModule) | ||
.catch(err => console.error(err)); | ||
if (environment.production) { | ||
enableProdMode(); | ||
} | ||
|
||
platformBrowserDynamic([{ provide: Config, useValue: configuration }]) | ||
.bootstrapModule(AppModule) | ||
.catch((err) => console.error(err)); | ||
}); |