Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TP premium detection #94

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class ConfigurationService(
return errors
}

fun platformInfo() =
platformInfoRepositoryMap.entries.associate { it.key to it.value.platformInfo() }

fun platformInfo(platform: Platform): PlatformInfo {
return platformInfoRepositoryMap[platform]!!.platformInfo()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package org.freekode.tp2intervals.rest.configuration

import org.freekode.tp2intervals.app.confguration.ConfigurationService
import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.TrainingType
import org.freekode.tp2intervals.domain.config.PlatformInfo
import org.freekode.tp2intervals.domain.config.UpdateConfigurationRequest
import org.freekode.tp2intervals.domain.workout.structure.StepModifier
import org.freekode.tp2intervals.rest.ErrorResponseDTO
Expand Down Expand Up @@ -43,9 +41,11 @@ class ConfigurationController(
return StepModifier.entries
}

@GetMapping("/api/configuration/platform")
fun getAllPlatformInfo() =
configurationService.platformInfo()

@GetMapping("/api/configuration/{platform}")
fun getConfigurations(@PathVariable platform: Platform): PlatformInfo {
log.debug("Received request for getting configurations for platform: {}", platform)
return configurationService.platformInfo(platform)
}
fun getConfigurations(@PathVariable platform: Platform) =
configurationService.platformInfo(platform)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<mat-form-field class="form-field">
<mat-label>Date Range</mat-label>
<mat-date-range-input
[max]="(platformInfo?.isPremium || direction.value.targetPlatform === Platform.INTERVALS.key) ? null : tomorrowDate"
[max]="(platformsInfo?.TRAINING_PEAKS.isPremium || direction.value.targetPlatform === Platform.INTERVALS.key) ? null : tomorrowDate"
[rangePicker]="copyPlanDatePicker">
<input matStartDate placeholder="Start Date" formControlName="startDate">
<input matEndDate placeholder="End Date" formControlName="endDate">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {finalize, switchMap, tap} from "rxjs";
import {WorkoutClient} from "infrastructure/client/workout.client";
import {NotificationService} from "infrastructure/notification.service";
import {MatTooltipModule} from "@angular/material/tooltip";
import {TrainingTypes} from "app/training-types";
import {TrainingTypes} from "infrastructure/training-types";

@Component({
selector: 'copy-calendar-to-calendar',
Expand Down Expand Up @@ -49,14 +49,13 @@ export class CopyCalendarToCalendarComponent implements OnInit {
readonly todayDate = new Date()
readonly tomorrowDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)

@Input() platform: any
@Input() trainingTypes: any[] = []
@Input() selectedTrainingTypes = ['BIKE', 'VIRTUAL_BIKE']
@Input() directions: any[] = []
@Input() inProgress = false

formGroup: FormGroup
platformInfo: any
platformsInfo: any
scheduledJobs: any[] = []

constructor(
Expand All @@ -68,8 +67,8 @@ export class CopyCalendarToCalendarComponent implements OnInit {
}

ngOnInit(): void {
this.configurationClient.platformInfo(this.platform.key).subscribe(value => {
this.platformInfo = value
this.configurationClient.getAllPlatformInfo().subscribe(value => {
this.platformsInfo = value
})
this.formGroup = this.getFormGroup();
this.loadScheduledJobs().subscribe()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<copy-calendar-to-calendar
[platform]="Platform.TRAINER_ROAD"
[directions]="directions"
[trainingTypes]="trainingTypes">
</copy-calendar-to-calendar>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<copy-calendar-to-calendar
[platform]="Platform.TRAINER_ROAD"
[directions]="directions"
[trainingTypes]="trainingTypes"
[selectedTrainingTypes]="selectedTrainingTypes">
Expand Down
9 changes: 9 additions & 0 deletions ui/src/infrastructure/client/configuration.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export class ConfigurationClient {
.put(`/api/configuration`, configData)
}

getAllPlatformInfo(): Observable<any> {
return this.httpClient.get(`/api/configuration/platform`).pipe(
map(response => {
Object.keys(response).forEach(key => response[key] = response[key].infoMap)
return response
})
)
}

platformInfo(platform): Observable<any> {
return this.httpClient.get(`/api/configuration/${platform}`).pipe(
map(response => (<any>response).infoMap)
Expand Down
File renamed without changes.
Loading