From e7821b8bff1d1c2fb8acf42ea97a47f7d88ea5c3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 28 Dec 2024 11:52:55 +0100 Subject: [PATCH 1/3] add logging, upd readme --- README.md | 126 +++++++++--------- .../configuration/ConfigurationController.kt | 5 + .../rest/library/LibraryController.kt | 4 + .../rest/workout/WorkoutController.kt | 7 + .../configuration.component.html | 4 +- 5 files changed, 80 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 2d136af8..5014c6a7 100644 --- a/README.md +++ b/README.md @@ -11,47 +11,82 @@ Runs on MacOS (DMG), Windows (EXE installer), Linux (AppImage). Alternatively th All files are available for download on [Release page](https://github.com/freekode/tp2intervals/releases/latest). -### TrainerRoad Updates ⚠️ + +* [List of features](#list-of-features) + + [TrainingPeaks features](#trainingpeaks-features) + + [TrainerRoad features](#trainerroad-features) + + [Strava features](#strava-features) +* [Configuration](#configuration) + + [Intervals.icu](#intervalsicu) + + [TrainingPeaks](#trainingpeaks) + + [TrainerRoad](#trainerroad) +* [Other ways to run the app](#other-ways-to-run-the-app) + + [Executable JAR](#executable-jar) + + [Docker](#docker) +* [FAQ](#faq) + + [General](#general) + + [Sync automatically planned workouts to TrainingPeaks](#sync-automatically-planned-workouts-to-trainingpeaks) + + [Info regarding scheduling for the next day with TrainingPeaks free account](#info-regarding-scheduling-for-the-next-day-with-trainingpeaks-free-account) + + [How to export HAR file](#how-to-export-har-file) + + [How to get logs for your issue](#how-to-get-logs-for-your-issue) + + + +**TrainerRoad Updates ⚠️** I don't have access to TrainerRoad anymore. Account, which I used, cancelled subscription. I don't use the platform and it's too expensive to have it for occasional fixes. To fix issues I can only relay on logs and HAR files from you. -### TrainingPeaks features - -#### For athlete account +## List of features +### TrainingPeaks features +**Athlete account** * Sync planned workouts from Intervals to TrainingPeaks for today and tomorrow (free TP account) * Copy whole training plan from TrainingPeaks * Create training plan or workout folder on Intervals from planned workouts on TrainingPeaks -#### For coach account - +**Coach account** * Copy whole training plan and workout library from TrainingPeaks ### TrainerRoad features - * Copy workouts from TrainerRoad library to Intervals * Create training plan or workout folder on Intervals from planned workouts on TrainerRoad ### Strava features +* Sync activities. App exports original file from Strava and uploads it to Intervals.icu. Only recorded activities are supported. -* Sync activities. App exports original file from Strava and uploads it to Intervals.icu. Only recorded activities are supported. + -### Beta features +**Only for educational purposes** -Beta features can be enabled in Configuration +## Configuration -* Step Modifier (TrainingPeaks). Based on selecton `power=1s`, `power=3s` will be added for each step on Intervals. -* Remove HTML tags from description (TrainerRoad). Cleans up workouts descriptions from HTML tags. +Before using the application you need to configure access to platforms. +Access to Intervals.icu is required, access to other platforms is optional. - +After you gathered all required configuration, you can click Confirm button. +If everything is fine, you will be redirected to the home page. + +If your configuration is wrong. You will see an error that there is no access to particular platform. +Check all your values and save configuration again. + +### Intervals.icu +Copy API key and Athlete Id from [Settings page](https://intervals.icu/settings) in Developer Settings section on Intervals.icu web page. + +### TrainingPeaks +To use TrainingPeaks Copy cookie `Production_tpAuth` (key and value, smth like `Production_tpAuth=very_long_string`) from the browser on TrainingPeaks page. +Another guide is available here https://forum.intervals.icu/t/implemented-push-workout-to-wahoo/783/87 + + + +### TrainerRoad +Configuration is very similar to TrainingPeaks. Copy cookie `SharedTrainerRoadAuth` (key +and value, smth like `SharedTrainerRoadAuth=very_long_string`) from the browser on TrainerRoad page. -**Only for educational purposes** ## Other ways to run the app ### Executable JAR - The project has executable jar with web UI. It requires JDK 21. To run jar: ```shell java -jar tp2intervals.jar @@ -63,7 +98,6 @@ java -Dserver.port=9090 -jar tp2intervals.jar ``` ### Docker - Docker image also built for every release To run docker execute: @@ -83,42 +117,19 @@ services: - '8080:8080' ``` -## How to configure - -After you successfully started the application and were able to open the web UI page. -You need to configure it to gain access to Intervals.icu and to your other platform. -Nice post how to do it is written here https://forum.intervals.icu/t/implemented-push-workout-to-wahoo/783/87 - -### Intervals API Key and Athlete Id - -These values available on [Settings page](https://intervals.icu/settings) in Developer Settings section. - -### TrainingPeaks Auth Cookie - -If you want ot use TrainingPeaks you need to configure it. Copy cookie `Production_tpAuth` (key and value, smth -like `Production_tpAuth=very_long_string`) from the browser on TrainingPeaks page. - - - -### TrainerRoad Auth Cookie - -If you want to use TrainerRoad you need to configure it. Very similar to TrainingPeaks. Copy cookie `SharedTrainerRoadAuth` (key -and value, smth like `SharedTrainerRoadAuth=very_long_string`) from the browser on TrainerRoad page. - -After you gathered all required configuration, you can click Confirm button. -If everything is fine, you will be redirected to the home page. - -If your configuration is wrong. You will see an error that there is no access to particular platform. -Check all your values and save configuration again. - -### Strava Cookie - -For using Strava just copy all your cookies from browser for Strava. It should be enough. +## FAQ - +### General +* Only duration based steps in workouts are supported, the app can't work with distance based steps +* Ramp steps in TrainerRoad are not supported +* **MacOS** app is not signed. Usually you need to open it twice. After opening it, be patient, it takes some time to + start +* **Windows** The app will ask to access local network and Internet, you need to allow it. After all it makes HTTP requests +* In case of any problems. You can create an issue on [GitHub](https://github.com/freekode/tp2intervals/issues) + or write directly to me iam@freekode.org. Add logs from your app, it can help a lot to resolve the issue. Or in case of TrainerRoad create HAR file +* More info you can find on the forum https://forum.intervals.icu/t/tp2intervals-copy-trainingpeaks-and-trainerroad-workouts-plans-to-intervals/63375 ### Sync automatically planned workouts to TrainingPeaks - If you are using app in docker container, you can set up automatic sync of planned workouts for TrainingPeaks. Run command on your machine: @@ -128,17 +139,6 @@ docker exec -it ln -s /scripts/sync-planned-to-tp.sh /etc/perio Script `sync-planned-to-tp.sh` will be executed at 02:00 everyday. You can also edit crontab configuration manually and set your own schedule. -## FAQ - -* Only duration based steps in workouts are supported, the app can't work with distance based steps -* Ramp steps in TrainerRoad are not supported -* **MacOS** app is not signed. Usually you need to open it twice. After opening it, be patient, it takes some time to - start -* **Windows** The app will ask to access local network and Internet, you need to allow it. After all it makes HTTP requests -* In case of any problems. You can create an issue on [GitHub](https://github.com/freekode/tp2intervals/issues) - or write directly to me iam@freekode.org. Add logs from your app, it can help a lot to resolve the issue. Or in case of TrainerRoad create HAR file -* More info you can find on the forum https://forum.intervals.icu/t/tp2intervals-copy-trainingpeaks-and-trainerroad-workouts-plans-to-intervals/63375 - ### Info regarding scheduling for the next day with TrainingPeaks free account Officially you can't plan workouts for future dates, but practically you can plan workout for tomorrow with free TP account. You can plan workout for the next day relative to TP server local time. The server is in UTC-6 time zone. @@ -150,7 +150,6 @@ E.g your TZ is UTC+12, current local datetime 20.05.2024 18:00. TP server local Example with [worldtimebuddy](https://www.worldtimebuddy.com/?pl=1&lid=206,100,756135,2193733&h=206&hf=0) ### How to export HAR file - 1. Open new tab in your browser 2. Open dev tools, check Preserve log (Firefox Cog -> Persist Logs) @@ -163,9 +162,8 @@ Example with [worldtimebuddy](https://www.worldtimebuddy.com/?pl=1&lid=206,100,7 ### How to get logs for your issue - -1. Go to Configuration, check Show advanced configuration -2. Set Log Level to DEBUG, click Confirm +1. Go to Configuration +2. In General section set Log Level to DEBUG, click Confirm 3. Reproduce your issue 4. Find log file according to your system diff --git a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/configuration/ConfigurationController.kt b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/configuration/ConfigurationController.kt index ff5f7f5e..298dcb59 100644 --- a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/configuration/ConfigurationController.kt +++ b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/configuration/ConfigurationController.kt @@ -7,6 +7,7 @@ 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 +import org.slf4j.LoggerFactory import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable @@ -18,15 +19,18 @@ import org.springframework.web.bind.annotation.RestController class ConfigurationController( private val configurationService: ConfigurationService, ) { + private val log = LoggerFactory.getLogger(this.javaClass) @GetMapping("/api/configuration") fun getConfigurations(): AppConfigurationDTO { + log.info("Received request for getting all configurations") val configurations = configurationService.getConfigurations() return AppConfigurationDTO(configurations.configMap) } @PutMapping("/api/configuration") fun updateConfiguration(@RequestBody requestDTO: UpdateConfigurationRequestDTO): ResponseEntity { + log.info("Received request for updating configuration: $requestDTO") val errors = configurationService.updateConfiguration(UpdateConfigurationRequest(requestDTO.config)) if (errors.isNotEmpty()) { return ResponseEntity.badRequest().body(ErrorResponseDTO(errors.joinToString())) @@ -47,6 +51,7 @@ class ConfigurationController( @GetMapping("/api/configuration/{platform}") fun getConfigurations(@PathVariable platform: Platform): PlatformInfo { + log.info("Received request for getting configurations for platform: $platform") return configurationService.platformInfo(platform) } } diff --git a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/library/LibraryController.kt b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/library/LibraryController.kt index 758d4564..b8f6a8e9 100644 --- a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/library/LibraryController.kt +++ b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/library/LibraryController.kt @@ -5,6 +5,7 @@ import org.freekode.tp2intervals.app.plan.CopyPlanResponse import org.freekode.tp2intervals.app.plan.LibraryService import org.freekode.tp2intervals.domain.Platform import org.freekode.tp2intervals.domain.librarycontainer.LibraryContainer +import org.slf4j.LoggerFactory import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -15,14 +16,17 @@ import org.springframework.web.bind.annotation.RestController class LibraryController( private val libraryService: LibraryService ) { + private val log = LoggerFactory.getLogger(this.javaClass) @GetMapping("/api/library-container") fun getLibraryContainers(@RequestParam platform: Platform): List { + log.info("Received request for getting library containers: $platform") return libraryService.findByPlatform(platform) } @PostMapping("/api/library-container/copy") fun copyLibraryContainer(@RequestBody request: CopyLibraryRequest): CopyPlanResponse { + log.info("Received request to copy the library container: $request") return libraryService.copyLibrary(request) } } diff --git a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/workout/WorkoutController.kt b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/workout/WorkoutController.kt index ec1a0126..b73f3e3e 100644 --- a/boot/src/main/kotlin/org/freekode/tp2intervals/rest/workout/WorkoutController.kt +++ b/boot/src/main/kotlin/org/freekode/tp2intervals/rest/workout/WorkoutController.kt @@ -6,6 +6,7 @@ import org.freekode.tp2intervals.app.workout.CopyFromLibraryToLibraryRequest import org.freekode.tp2intervals.app.workout.CopyWorkoutsResponse import org.freekode.tp2intervals.app.workout.WorkoutService import org.freekode.tp2intervals.domain.Platform +import org.slf4j.LoggerFactory import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping @@ -17,24 +18,29 @@ import org.springframework.web.bind.annotation.RestController class WorkoutController( private val workoutService: WorkoutService ) { + private val log = LoggerFactory.getLogger(this.javaClass) @PostMapping("/api/workout/copy-calendar-to-calendar") fun copyWorkoutsFromCalendarToCalendar(@RequestBody request: CopyFromCalendarToCalendarRequest): CopyWorkoutsResponse { + log.info("Received request for copy calendar to calendar: $request") return workoutService.copyWorkoutsFromCalendarToCalendar(request) } @PostMapping("/api/workout/copy-calendar-to-library") fun copyWorkoutsFromCalendarToLibrary(@RequestBody request: CopyFromCalendarToLibraryRequest): CopyWorkoutsResponse { + log.info("Received request for copy calendar to library: $request") return workoutService.copyWorkoutsFromCalendarToLibrary(request) } @PostMapping("/api/workout/copy-library-to-library") fun copyWorkoutFromLibraryToLibrary(@RequestBody request: CopyFromLibraryToLibraryRequest): CopyWorkoutsResponse { + log.info("Received request for copy library to library: $request") return workoutService.copyWorkoutFromLibraryToLibrary(request) } @GetMapping("/api/workout/find") fun findWorkoutsByName(@RequestParam platform: Platform, @RequestParam name: String): List { + log.info("Received request for find workouts by name, platform: $platform, name: $name") return workoutService.findWorkoutsByName(platform, name) .map { workoutDetails -> WorkoutDetailsDTO( @@ -48,6 +54,7 @@ class WorkoutController( @DeleteMapping("/api/workout") fun deleteWorkoutsFromCalendar(@RequestBody request: DeleteWorkoutRequestDTO) { + log.info("Received request to delete workouts from calendar: $request") workoutService.deleteWorkoutsFromCalendar(request) } } diff --git a/ui/src/app/configuration/configuration.component.html b/ui/src/app/configuration/configuration.component.html index d914242d..5476809e 100644 --- a/ui/src/app/configuration/configuration.component.html +++ b/ui/src/app/configuration/configuration.component.html @@ -53,7 +53,7 @@

TrainingPeaks

-

TrainerRoad

+

TrainerRoad

TrainerRoad Auth Cookie @@ -81,7 +81,7 @@

Strava

-

Generic

+

General

Log Level (saved only for current session) From b975391fbe2b00afb3cf60dcb72034bc250f067d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 28 Dec 2024 11:55:12 +0100 Subject: [PATCH 2/3] upd readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5014c6a7..1dfcaf72 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ All files are available for download on [Release page](https://github.com/freeko + [TrainerRoad features](#trainerroad-features) + [Strava features](#strava-features) * [Configuration](#configuration) - + [Intervals.icu](#intervalsicu) + + [Intervals.icu](#config-intervalsicu) + [TrainingPeaks](#trainingpeaks) + [TrainerRoad](#trainerroad) * [Other ways to run the app](#other-ways-to-run-the-app) @@ -70,16 +70,16 @@ If everything is fine, you will be redirected to the home page. If your configuration is wrong. You will see an error that there is no access to particular platform. Check all your values and save configuration again. -### Intervals.icu +

Intervals.icu

Copy API key and Athlete Id from [Settings page](https://intervals.icu/settings) in Developer Settings section on Intervals.icu web page. -### TrainingPeaks +

TrainingPeaks

To use TrainingPeaks Copy cookie `Production_tpAuth` (key and value, smth like `Production_tpAuth=very_long_string`) from the browser on TrainingPeaks page. Another guide is available here https://forum.intervals.icu/t/implemented-push-workout-to-wahoo/783/87 -### TrainerRoad +

TrainerRoad

Configuration is very similar to TrainingPeaks. Copy cookie `SharedTrainerRoadAuth` (key and value, smth like `SharedTrainerRoadAuth=very_long_string`) from the browser on TrainerRoad page. From 8a40bac86400f160b85c9fa683586b17a907db1e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 28 Dec 2024 12:00:09 +0100 Subject: [PATCH 3/3] add links to readme --- ui/src/app/configuration/configuration.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/app/configuration/configuration.component.html b/ui/src/app/configuration/configuration.component.html index 5476809e..477b7bd9 100644 --- a/ui/src/app/configuration/configuration.component.html +++ b/ui/src/app/configuration/configuration.component.html @@ -2,7 +2,7 @@
-

Intervals.icu

+

Intervals.icu

Intervals API Key @@ -41,7 +41,7 @@

Intervals.icu

-

TrainingPeaks

+

TrainingPeaks

TrainingPeaks Auth Cookie @@ -53,7 +53,7 @@

TrainingPeaks

-

TrainerRoad

+

TrainerRoad

TrainerRoad Auth Cookie