-
-
-
-
-
-
+
+
+ Format Types
+
+ ?
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+ Workout Title
+
+ ?
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+ Lap Types
+
+ ?
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+ Strength
+
+ ?
+
+
+
+
+
+
+
+
+
+
- Advanced
+
+ Advanced
+
+ ?
+
+
@@ -58,12 +136,18 @@
@code {
private static ICollection lapTypes = Enum.GetValues(typeof(PreferredLapType)).Cast().ToList();
- private Format formatSettings;
+ private Format formatSettings;
+
+ private string workoutTemplateExample;
+ private string configDocumentation;
public FormatSettingsForm()
{
var settings = new SettingsGetResponse();
formatSettings = settings.Format;
+
+ workoutTemplateExample = string.Empty;
+ configDocumentation = string.Empty;
}
protected override Task OnInitializedAsync()
@@ -75,9 +159,13 @@
private async Task LoadDataAsync()
{
using var tracing = Tracing.ClientTrace($"{nameof(FormatSettingsForm)}.{nameof(LoadDataAsync)}", kind: ActivityKind.Client);
- var settings = await _apiClient.SettingsGetAsync();
+ var settings = await _apiClient.SettingsGetAsync();
formatSettings = settings.Format;
+ ValueChanged(formatSettings!.WorkoutTitleTemplate);
+
+ var systemInfo = await _apiClient.SystemInfoGetAsync(new SystemInfoGetRequest() { CheckForUpdate = settings.App.CheckForUpdates });
+ configDocumentation = systemInfo.Documentation + "/configuration/json/#format-config";
}
protected async Task SaveFormatSettings()
@@ -101,4 +189,32 @@
Log.Error("UI - Failed to save Format settings.", e);
}
}
+
+ protected void ValueChanged(string newValue)
+ {
+ formatSettings.WorkoutTitleTemplate = newValue;
+
+ var template = formatSettings.WorkoutTitleTemplate;
+ var sampleData = new
+ {
+ PelotonWorkoutTitle = "15 minute HIIT Ride",
+ PelotonInstructorName = "Ally Love"
+ };
+
+ var compiledTemplate = Handlebars.Compile(template);
+ var titleExample = compiledTemplate(sampleData);
+
+ foreach (var c in Path.GetInvalidFileNameChars())
+ {
+ titleExample = titleExample.Replace(c, '-');
+ }
+
+ workoutTemplateExample = $"Example: {titleExample}";
+ }
+
+ private string FormatSettingsDocumentation => $"- FIT is the recommended format
- FIT and TCX are the only types that can be uploaded to Garmin
- If you enable JSON, you'll also need to enable saving a local copy in the Advanced settings below.
Documentation
(click the ? to pin this window)";
+ private string WorkoutTitleDocumentation => $"Allows you to customize how your workout title will appear in Garmin Connect using Handlebars templates. Some characters are not allowed, these characters will automatically be replaced with `-`. Below are the data fields you can use in the template:
- PelotonWorkoutTitle
- PelotonInstructorName
Documentation
(click the ? to pin this window)";
+ private string LapTypesDocumentation => $"Lap type defines how/when P2G will create a new Lap within a workout. This can be customized per Cardio type. To read more about each Lap Type please see the documentation.
Documentation
(click the ? to pin this window)";
+ private string StrengthDocumentation => $"Some Strength workouts have you do an exercise for time rather than for a specific number of reps. This setting allows you to customize how P2G should estimate the number of reps that were done in a time based exercise.
Documentation
(click the ? to pin this window)";
+ private string AdvancedDocumentation => $"Most users should not need to modify these settings. These settings should only be modified if you are trying to solve a specific problem. Please be sure you've read the documentation about these before modifying.
Documentation
(click the ? to pin this window)";
}
diff --git a/src/SharedUI/wwwroot/css/site.css b/src/SharedUI/wwwroot/css/site.css
index 2882e0899..90875d433 100644
--- a/src/SharedUI/wwwroot/css/site.css
+++ b/src/SharedUI/wwwroot/css/site.css
@@ -71,3 +71,7 @@ a.nav-link {
.blazor-error-boundary::after {
content: "An error has occurred."
}
+
+.popover {
+ --bs-popover-max-width: 500px;
+}
\ No newline at end of file
diff --git a/src/UnitTests/Common/Helpers/WorkoutHelperTests.cs b/src/UnitTests/Common/Helpers/WorkoutHelperTests.cs
index 7ac3a0103..9e97c9bf1 100644
--- a/src/UnitTests/Common/Helpers/WorkoutHelperTests.cs
+++ b/src/UnitTests/Common/Helpers/WorkoutHelperTests.cs
@@ -75,7 +75,7 @@ public void GetTitle_NullInstructorName_ShouldReturn_EmptyInstructorName()
}
[Test]
- public void GetTitle_NullPrefix_ShouldReturn_EmptyPrefix()
+ public void GetTitle_NullTemplate_ShouldReturn_DefaultTemplate()
{
var workout = new Workout()
{
@@ -91,11 +91,11 @@ public void GetTitle_NullPrefix_ShouldReturn_EmptyPrefix()
}
[Test]
- public void GetTitle_With_Prefix_ShouldReturn_Title_With_Prefix()
+ public void GetTitle_With_Template_ShouldReturn_TemplateAppliedToTitle()
{
var format = new Format()
{
- WorkoutTitlePrefix = "Peloton - "
+ WorkoutTitleTemplate = "{{PelotonInstructorName}} - {{PelotonWorkoutTitle}}"
};
var workout = new Workout()
@@ -108,6 +108,6 @@ public void GetTitle_With_Prefix_ShouldReturn_Title_With_Prefix()
};
var title = WorkoutHelper.GetTitle(workout, format);
- title.Should().Be("Peloton_-_My_Title_with_Instructor");
+ title.Should().Be("Instructor_-_My_Title");
}
}
diff --git a/vNextReleaseNotes.md b/vNextReleaseNotes.md
index 282583b11..82208caa6 100644
--- a/vNextReleaseNotes.md
+++ b/vNextReleaseNotes.md
@@ -3,7 +3,7 @@
## Features
-- [#564] Set a custom title prefix on Workouts
+- [#564] [#591] Set a custom title on Workouts using templating
- [#559] Ability to exclude Outdoor Cycling workouts from sycning
## Fixes