Skip to content

Commit

Permalink
Clean up stats page
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamMorrow committed Sep 22, 2024
1 parent 66531f6 commit 9d2d0cd
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion LiftLog.Ui/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ else
<div class="m-2">
<Tips/>
</div>
<CardList Items="upcoming.IndexedTuples()" OnClick="x => SelectSession(x.Item)">
<CardList CardType=Card.CardType.Outlined Items="upcoming.IndexedTuples()" OnClick="x => SelectSession(x.Item)">
<SplitCardControl>
<TitleContent>
<SessionSummaryTitle IsFilled="context.Item.IsStarted" Session="context.Item" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<LabelledForm>
<LabelledFormRow Label="Endpoint" Icon="public">
<TextField
TextFieldType="TextFieldType.Outline"
TextFieldType="TextFieldType.Outlined"
placeholder="https://example.com/backup"
Value="@EndpointValue"
error-text="@EndpointValueError"
Expand All @@ -28,7 +28,7 @@
</LabelledFormRow>
<LabelledFormRow Label="API Key" Icon="vpn_key">
<TextField
TextFieldType="TextFieldType.Outline"
TextFieldType="TextFieldType.Outlined"
Value="@ApiKeyValue"
SelectAllOnFocus=false
OnChange="UpdateApiKey">
Expand Down
22 changes: 9 additions & 13 deletions LiftLog.Ui/Pages/StatsPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Select T="string" Options="SessionSelectOptions" Value="StatsState.Value.OverallViewSessionName" ValueChanged="v => { Dispatcher.Dispatch(new SetOverallViewSessionAction(v)); Dispatcher.Dispatch(new SetStatsIsDirtyAction(true)); Dispatcher.Dispatch(new FetchOverallStatsAction());}"></Select>
<Select data-cy="stats-time-selector" T="TimeSpan" Options="SelectTimeOptions" Value="StatsState.Value.OverallViewTime" ValueChanged="v => { Dispatcher.Dispatch(new SetOverallViewTimeAction(v)); Dispatcher.Dispatch(new SetStatsIsDirtyAction(true)); Dispatcher.Dispatch(new FetchOverallStatsAction()); }"></Select>
</div>
<div class="flex flex-col justify-between m-2">
<div class="flex flex-col justify-between m-2 mb-5">
<SearchInput SearchTerm=@SearchTerm OnSearch="@((st)=>{SearchTerm = st; StateHasChanged();})" />
</div>
@if (StatsState.Value.IsLoading)
Expand All @@ -34,23 +34,23 @@ else if (!StatsState.Value.IsLoading && StatsState.Value.OverallView is not null
{
var overallStats = StatsState.Value.OverallView;
<div class="grid grid-rows-2 grid-cols-2 gap-2 mb-2 px-2 @HiddenOnSearch">
<SingleValueStatisticsCard>
<SingleValueStatisticsCard Class="scale-0 animate-zoom-in">
<Title>Average time between sets</Title>
<Body>
<TimeSpanFormat TimeSpan="@overallStats.AverageTimeBetweenSets"/>
</Body>
</SingleValueStatisticsCard>
<SingleValueStatisticsCard>
<SingleValueStatisticsCard Class="scale-0 animate-zoom-in" Style="animation-delay: 50ms;">
<Title>Average session length</Title>
<Body>
<TimeSpanFormat TimeSpan="@overallStats.AverageSessionLength" TruncateToMins="true"/>
</Body>
</SingleValueStatisticsCard>
<SingleValueStatisticsCard>
<SingleValueStatisticsCard Class="scale-0 animate-zoom-in" Style="animation-delay: 100ms;">
<Title>Most time spent</Title>
<Body>@overallStats.ExerciseMostTimeSpent?.ExerciseName</Body>
</SingleValueStatisticsCard>
<SingleValueStatisticsCard>
<SingleValueStatisticsCard Class="scale-0 animate-zoom-in" Style="animation-delay: 150ms;">
<Title>Heaviest lift</Title>
<Body>
<div class="flex flex-col justify-center items-center">
Expand All @@ -77,16 +77,10 @@ else if (!StatsState.Value.IsLoading && StatsState.Value.OverallView is not null
<Card class=@CardClass>
<StatGraphCardContent Title="Sessions" Statistics="overallStats.SessionStats" RenderDelay="TimeSpan.FromMilliseconds(200)"/>
</Card>
@{
var anyExercisesRendered = false;
}
<CardList Items="@(overallStats.ExerciseStats.Where(x=>!StatsState.Value.IsExercisePinned(x)).Where(SearchTermMatches).IndexedTuples())">
@{
anyExercisesRendered = true;
}
<CardList Items="@(UnpinnedExercisesToShow.IndexedTuples())">
<StatGraphCardContent Title="@context.Item.ExerciseName" Statistics="[context.Item.Statistics, context.Item.OneRepMaxStatistics]" RenderDelay="TimeSpan.FromMilliseconds(200 + context.Index * 200)"/>
</CardList>
@if(SearchTerm != "" && !anyExercisesRendered)
@if(SearchTerm != "" && !UnpinnedExercisesToShow.Any())
{
<EmptyInfo>
<p>No exercises found.<br> Try changing your filters at the top.</p>
Expand All @@ -99,6 +93,8 @@ else if (!StatsState.Value.IsLoading && StatsState.Value.OverallView is not null
private string SearchTerm = "";
private IEnumerable<ExerciseStatistics> UnpinnedExercisesToShow => StatsState.Value.OverallView?.ExerciseStats.Where(x=>!StatsState.Value.IsExercisePinned(x)).Where(SearchTermMatches) ?? [];

private List<Select<TimeSpan>.SelectOption> SelectTimeOptions =
[
new("7 days", TimeSpan.FromDays(7)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<LabelledFormRow Label="Any additional information?" Icon="info">
<TextField label="Goals, injuries, available equipment, etc." TextFieldType=TextFieldType.Outline type="textarea" inputmode="text" Value="@Value" maxlength=200 OnChange="@(value => OnUpdateAdditionalInfo(value))"/>
<TextField label="Goals, injuries, available equipment, etc." TextFieldType=TextFieldType.Outlined type="textarea" inputmode="text" Value="@Value" maxlength=200 OnChange="@(value => OnUpdateAdditionalInfo(value))"/>
</LabelledFormRow>

@code {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@inject IJSRuntime Js

<LabelledFormRow Label="How old are you?" Icon="cake">
<TextField TextFieldType=TextFieldType.Outline type="text" inputmode="numeric" Value="@(Value.ToString())" required OnChange="@(value => OnChanged(value))"/>
<TextField TextFieldType=TextFieldType.Outlined type="text" inputmode="numeric" Value="@(Value.ToString())" required OnChange="@(value => OnChanged(value))"/>
</LabelledFormRow>

@code {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@inject IJSRuntime Js

<LabelledFormRow Label="How much do you weigh?" Icon="monitor_weight">
<TextField suffix-text="@WeightUnit" TextFieldType=TextFieldType.Outline type="text" inputmode="decimal" Value="@(Value.ToString())" required OnChange="@(value => OnChanged(value))"/>
<TextField suffix-text="@WeightUnit" TextFieldType=TextFieldType.Outlined type="text" inputmode="decimal" Value="@(Value.ToString())" required OnChange="@(value => OnChanged(value))"/>
</LabelledFormRow>
@code {

Expand Down
1 change: 1 addition & 0 deletions LiftLog.Ui/Shared/Presentation/Card.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@inject IHapticFeedbackService HapticFeedback

<div
@attributes="AdditionalAttributes"
class="@(AdditionalAttributes?.GetValueOrDefault("class")) @(HasPadding ?"p-5":"") relative @Style rounded-card text-on-surface card"
@onpointercancel=OnPointerLeave
@onpointerdown="OnPointerDown"
Expand Down
5 changes: 4 additions & 1 deletion LiftLog.Ui/Shared/Presentation/SearchInput.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
@oninput="e=>OnSearch.InvokeAsync(e.Value as string)" >
</input>
<md-icon class="absolute top-4 left-4">search</md-icon>
<IconButton OnClick=@(e=>OnSearch.InvokeAsync("")) Type="IconButtonType.Standard" Icon="close" class="absolute top-2 right-2"/>
@if(!string.IsNullOrWhiteSpace(SearchTerm))
{
<IconButton OnClick=@(e=>OnSearch.InvokeAsync("")) Type="IconButtonType.Standard" Icon="close" class="absolute top-2 right-2"/>
}
<md-ripple></md-ripple>
<md-focus-ring for="@ControlId"></md-focus-ring>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Card Type="Card.CardType.Filled">
<div class="flex flex-col gap-1 items-center justify-center h-full">
<Card Type="Card.CardType.Filled" class="@Class" style="@Style">
<div class="flex flex-col gap-1 items-center justify-center h-full ">
<span class="text-tertiary font-bold text-xl">
@Body
</span>
Expand All @@ -13,4 +13,8 @@

[Parameter] [EditorRequired] public RenderFragment Body { get; set; } = null!;

[Parameter] public string? Class { get; set; }

[Parameter] public string? Style { get; set; }

}
4 changes: 2 additions & 2 deletions LiftLog.Ui/Shared/Presentation/TextField.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@switch (TextFieldType)
{
case TextFieldType.Outline:
case TextFieldType.Outlined:
<md-outlined-text-field @ref="_textField"
@attributes="AdditionalAttributes"
value=@Value
Expand Down Expand Up @@ -47,7 +47,7 @@

[Parameter] public EventCallback OnBlur { get; set; }

[Parameter] public TextFieldType TextFieldType { get; set; } = TextFieldType.Outline;
[Parameter] public TextFieldType TextFieldType { get; set; } = TextFieldType.Outlined;

[Parameter] public bool SelectAllOnFocus { get; set; } = true;

Expand Down
2 changes: 1 addition & 1 deletion LiftLog.Ui/Shared/Presentation/TextField.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace LiftLog.Ui.Shared.Presentation;

public enum TextFieldType
{
Outline,
Outlined,
Filled,
}
2 changes: 1 addition & 1 deletion LiftLog.Ui/Shared/Presentation/WeightDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span slot="headline">@Label</span>
<div slot="content">
<div class="flex flex-col gap-2">
<TextField data-cy="weight-input" label="@Label" required="@(!AllowNull)" suffix-text="@WeightSuffix" TextFieldType="TextFieldType.Outline" Value="@(EditorWeight.ToString())" OnChange="HandleInputChange" type="text" inputmode="decimal" step="@NonZeroIncrement"/>
<TextField data-cy="weight-input" label="@Label" required="@(!AllowNull)" suffix-text="@WeightSuffix" TextFieldType="TextFieldType.Outlined" Value="@(EditorWeight.ToString())" OnChange="HandleInputChange" type="text" inputmode="decimal" step="@NonZeroIncrement"/>
<div class="flex justify-between">
<AppButton data-cy="decrement-weight" Type="AppButtonType.OutlineSecondary" OnClick="OnWeightDecrementClick">
<md-icon slot="icon">remove</md-icon><WeightFormat Weight="NonZeroIncrement"/>
Expand Down
2 changes: 1 addition & 1 deletion LiftLog.Ui/Shared/Presentation/WeightedExercise.razor
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<Dialog @ref="notesDialog">
<span slot="headline">Session Notes for @(RecordedExercise.Blueprint.Name)</span>
<div slot="content" class="flex flex-col">
<TextField label="Notes" TextFieldType="TextFieldType.Outline" Value="@EditorNotes" OnChange="HandleNotesChange" type="textarea"/>
<TextField label="Notes" TextFieldType="TextFieldType.Outlined" Value="@EditorNotes" OnChange="HandleNotesChange" type="textarea"/>
</div>
<div slot="actions" data-cy="notes-dialog-actions">
<AppButton Type="AppButtonType.Text" OnClick="@(() => notesDialog?.Close())">Cancel</AppButton>
Expand Down

0 comments on commit 9d2d0cd

Please sign in to comment.