diff --git a/src/app/content/live/components/livetiming/livetiming.component.ts b/src/app/content/live/components/livetiming/livetiming.component.ts index b631680..8471523 100644 --- a/src/app/content/live/components/livetiming/livetiming.component.ts +++ b/src/app/content/live/components/livetiming/livetiming.component.ts @@ -222,8 +222,8 @@ export class LivetimingComponent implements OnInit, OnDestroy { } if (this.liveSettingsData.isLive) { // in live mode, set to finished when finished_at is set - console.log(st[0].heat.getFinishedAt()) - this.heatFinished = (st.length > 0 && st[0].heat.getFinishedAtTime() != "0:00"); + console.log(st[0].heat.getFinishedAt().getMilliseconds()) + this.heatFinished = (st.length > 0 && st[0].heat.getFinishedAt().getMilliseconds() > 0); } if (this.liveSettingsData.isLive) { diff --git a/src/app/core/model/start/current-next-heat.model.ts b/src/app/core/model/start/current-next-heat.model.ts new file mode 100644 index 0000000..a3e6db8 --- /dev/null +++ b/src/app/core/model/start/current-next-heat.model.ts @@ -0,0 +1,6 @@ +import {Heat} from "./heat.model"; + +export interface CurrentNextHeat { + current?: Heat; + next?: Heat; +} diff --git a/src/app/core/service/api/start/heat.service.ts b/src/app/core/service/api/start/heat.service.ts index 33384b0..df9ab5a 100644 --- a/src/app/core/service/api/start/heat.service.ts +++ b/src/app/core/service/api/start/heat.service.ts @@ -6,6 +6,7 @@ import {Heat} from "../../../model/start/heat.model"; import {ApiService} from "../api.service"; import {EventHeatInfo} from "../../../model/start/event-heat-info.model"; import {EventListHeats} from "../../../model/start/event-list-heats.model"; +import {CurrentNextHeat} from "../../../model/start/current-next-heat.model"; @Injectable({ providedIn: 'root' @@ -34,6 +35,10 @@ export class HeatService extends BaseService{ return this.apiService.get(this.API_URL, "heat/meet/" + meeting + "/current"); } + getCurrentAndNextHeat(meeting: string): Observable { + return this.apiService.get(this.API_URL, "heat/meet/" + meeting + "/current_next"); + } + getHeatsByMeetingForEventList(meeting: string): Observable { return this.apiService.get(this.API_URL, "heat/meet/" + meeting + "/event_list"); } diff --git a/src/app/shared/layout/live-bar/live-bar.component.html b/src/app/shared/layout/live-bar/live-bar.component.html index 4dfd474..4d7e08d 100644 --- a/src/app/shared/layout/live-bar/live-bar.component.html +++ b/src/app/shared/layout/live-bar/live-bar.component.html @@ -1,5 +1,4 @@ -
- +
- + +
+ {{statusText}} +
+
- + -
- {{'COMMON.EVENT.SINGULAR' | translate}} {{event.number}} - {{event.relay_distance ? event.relay_distance : event.distance}}m {{'COMMON.STYLE.' + event.style.name + '.NAME' | translate}} {{event.name_extension}} {{'COMMON.GENDER.' + event.gender + '.NAME' | translate}} - {{'COMMON.HEAT.SINGULAR' | translate}} {{currentHeat.number}} / {{maxHeat}} -
+ + + +
+ {{'COMMON.EVENT.SINGULAR' | translate}} {{event.number}} - {{event.relay_distance ? event.relay_distance : event.distance}}m {{'COMMON.STYLE.' + event.style.name + '.NAME' | translate}} {{event.name_extension}} {{'COMMON.GENDER.' + event.gender + '.NAME' | translate}} + {{'COMMON.HEAT.SINGULAR' | translate}} {{currentHeat.number}} / {{maxHeat}} +
+
diff --git a/src/app/shared/layout/live-bar/live-bar.component.scss b/src/app/shared/layout/live-bar/live-bar.component.scss index 3e508d4..ff65a4e 100644 --- a/src/app/shared/layout/live-bar/live-bar.component.scss +++ b/src/app/shared/layout/live-bar/live-bar.component.scss @@ -10,6 +10,12 @@ .bar-content { width: calc(100% - 116px); + + .bar-status-text { + font-weight: bold; + display: block; + text-align: center; + } } .bar-content, diff --git a/src/app/shared/layout/live-bar/live-bar.component.ts b/src/app/shared/layout/live-bar/live-bar.component.ts index 383896c..36825c2 100644 --- a/src/app/shared/layout/live-bar/live-bar.component.ts +++ b/src/app/shared/layout/live-bar/live-bar.component.ts @@ -14,9 +14,12 @@ export class LiveBarComponent implements OnInit, OnDestroy { liveUpdateInterval: number = 15000; currentHeat?: HeatImpl + nextHeat?: HeatImpl maxHeat: number = 1; event?: MeetingEventImpl; + statusText?: string; + private interval: any; constructor( @@ -36,10 +39,13 @@ export class LiveBarComponent implements OnInit, OnDestroy { fetchCurrentHeat() { if (!this.meetingId) return; - this.heatService.getCurrentHeat(this.meetingId).subscribe(data => { - this.currentHeat = new HeatImpl(data); + this.heatService.getCurrentAndNextHeat(this.meetingId).subscribe(data => { + if (data.current) this.currentHeat = new HeatImpl(data.current); else this.currentHeat = undefined; + if (data.next) this.nextHeat = new HeatImpl(data.next); else this.nextHeat = undefined; + + this.updateStatusText(); - if (this.meetingId) { + if (this.meetingId && this.currentHeat) { this.heatService.getEventHeatInfo(this.meetingId, this.currentHeat.event).subscribe(data => { if (data && data.amount) this.maxHeat = data.amount @@ -51,10 +57,73 @@ export class LiveBarComponent implements OnInit, OnDestroy { }); } + updateStatusText() { + console.log("[LIVE BAR STATUS] refresh live bar status"); + + if (this.currentHeat) { + let now = new Date(); // to check, how long current heat is over + let finish = this.currentHeat.getFinishedAt(); // to check how long it is over and how much time until next + let current = this.currentHeat.getStartDelayEstimation(); // to compare dates of current and next + + + if (finish.getTime() > 1000) { // current heat is over + let d = now.getTime() - finish.getTime(); + + if (d > 1 * 60 * 1000) { // current heat is over for more than 1 minute + + if (!this.nextHeat) { // no next heat + this.statusText = "Ende der Veranstaltung. Kommt gut nach Hause!"; + } else { + + let currentPlan = this.currentHeat.getEstimatedStart(); + let nextPlan = this.nextHeat.getEstimatedStart(); + + let next = this.nextHeat.getStartDelayEstimation(); // to check, if next is today, and if it is a break + // TODO: do not check planned time, but finish and start time (has problems with testing the day before) + + let d2 = next.getTime() - finish.getTime(); + + console.log("current heat is over for a while and next heat exists") + + console.log(current); + console.log(finish); + console.log(next); + console.log("----"); + console.log(currentPlan); + console.log(nextPlan); + + // need to compare start dates, since estimations can be different when testing on another day + if (currentPlan.getDate() === nextPlan.getDate()) { + if (d2 > 60 * 60 * 1000) { + this.statusText = "Pause. Es geht weiter um " + this.nextHeat.getStartDelayEstimationTime() + " Uhr"; + } else { + this.statusText = undefined; + } + } else { + this.statusText = "Bis Morgen. Erster Start um " + this.nextHeat.getStartDelayEstimationTime() + " Uhr"; + } + } + } else { + this.statusText = undefined; + } + + } else { + this.statusText = undefined; + } + } else { + if (this.nextHeat !== undefined) { + console.log("before meeting"); + this.statusText = "Der Wettkampf beginnt um " + this.nextHeat.getStartDelayEstimationTime(); + } else { + this.statusText = undefined; + } + } + } + startLiveCycle() { this.interval = setInterval(() => { console.log("LIVE CYCLE RUNNING: interval: " + this.liveUpdateInterval + " rnd: " + Math.random()); - this.fetchCurrentHeat() + this.fetchCurrentHeat(); }, this.liveUpdateInterval); } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 33d4e78..3d05d33 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -81,6 +81,21 @@ }, "UNDEFINED": { "NAME": "Schwimmen" + }, + "FINSWIMMING": { + "NAME": "FS" + }, + "DISTANCE_DIVING": { + "NAME": "ST" + }, + "BIFIN": { + "NAME": "BF" + }, + "APNOE": { + "NAME": "AP" + }, + "SB": { + "NAME": "SB" } }, "GENDER": {