diff --git a/.gitignore b/.gitignore index 18b7304..9f2f01c 100644 --- a/.gitignore +++ b/.gitignore @@ -362,4 +362,7 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -**/uploaded/**/* \ No newline at end of file +**/uploaded/**/* + +# Idea +.idea/ \ No newline at end of file diff --git a/Ticky.Base/Entities/Card.cs b/Ticky.Base/Entities/Card.cs index f565081..80e69c6 100644 --- a/Ticky.Base/Entities/Card.cs +++ b/Ticky.Base/Entities/Card.cs @@ -31,6 +31,9 @@ public class Card : AbstractDbEntity, IOrderable, IDeletable, IAssignable public DateTime? SnoozedUntil { get; set; } + public TimeSpan GetTotalTime() => + TimeRecords.Select(x => x.GetTotalTime()).Sum(); + public DateTime CalculateNextRepeat(DateTime from) { if (RepeatInfo is null) diff --git a/Ticky.Base/Entities/TimeRecord.cs b/Ticky.Base/Entities/TimeRecord.cs index 28a1419..004780b 100644 --- a/Ticky.Base/Entities/TimeRecord.cs +++ b/Ticky.Base/Entities/TimeRecord.cs @@ -13,4 +13,7 @@ public class TimeRecord : AbstractDbEntity public required DateTime StartedAt { get; set; } public DateTime? EndedAt { get; set; } + + public TimeSpan GetTotalTime() => + (EndedAt ?? DateTime.Now) - StartedAt; } diff --git a/Ticky.Base/GlobalUsings.cs b/Ticky.Base/GlobalUsings.cs index 64ef504..978d1c8 100644 --- a/Ticky.Base/GlobalUsings.cs +++ b/Ticky.Base/GlobalUsings.cs @@ -1,3 +1,4 @@ +global using Devity.Extensions; global using System.ComponentModel.DataAnnotations; global using System.ComponentModel.DataAnnotations.Schema; global using System.Drawing; diff --git a/Ticky.Base/Ticky.Base.csproj b/Ticky.Base/Ticky.Base.csproj index d3dc56b..3a066e1 100644 --- a/Ticky.Base/Ticky.Base.csproj +++ b/Ticky.Base/Ticky.Base.csproj @@ -7,7 +7,7 @@ - + diff --git a/Ticky.Internal/Ticky.Internal.csproj b/Ticky.Internal/Ticky.Internal.csproj index 069ed2c..fb25093 100644 --- a/Ticky.Internal/Ticky.Internal.csproj +++ b/Ticky.Internal/Ticky.Internal.csproj @@ -7,7 +7,7 @@ - + diff --git a/Ticky.Web/Components/Elements/CardView.razor b/Ticky.Web/Components/Elements/CardView.razor index 07bb035..3847a7c 100644 --- a/Ticky.Web/Components/Elements/CardView.razor +++ b/Ticky.Web/Components/Elements/CardView.razor @@ -34,10 +34,10 @@ } @if (Card.Subtasks.Any()) { - + } @{ - var trackedTime = new TimeSpan(Card.TimeRecords.Select(x => ((x.EndedAt ?? DateTime.Now) - x.StartedAt).Ticks).Sum()).ToElapsedString(true); + var trackedTime = Card.GetTotalTime().ToElapsedString(true); } @if (!string.IsNullOrWhiteSpace(trackedTime)) { diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index bf8cf40..6f1b216 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -97,7 +97,7 @@ @if (_board is not null) { - var completedCards = _cards.Where(x => x.Column.Finished).Count(); + var completedCards = _cards.Count(x => x.Column.Finished); var totalCards = _cards.Count();
@@ -111,6 +111,51 @@
+ + +
+

Column time totals

+ @foreach(var col in _board.Columns.OrderBy(c => c.Index)) + { + var colCards = _cards.Where(c => c.ColumnId == col.Id).ToList(); + var colTotal = colCards.Select(x => x.GetTotalTime()).Sum(); + var perUser = colCards.SelectMany(x => x.TimeRecords).GroupBy(x => x.UserId).Select(x => new KeyValuePair(x.Key, x.Select(y => y.GetTotalTime()).Sum())).ToDictionary(x => x.Key, x => x.Value); + var expandId = $"columnTime_{col.Id}"; + +
+
+
+ + +
+
+ +
+
+ + @if (IsExpanded(expandId)) + { +
+ @if (perUser.Any()) + { + @foreach(var kv in perUser.OrderByDescending(k => k.Value)) + { + var user = _members.FirstOrDefault(m => m.Id == kv.Key); +
+
@(user != null ? user.Name : "Unknown")
+
@kv.Value.ToElapsedString()
+
+ } + } + else + { +
No time tracked
+ } +
+ } +
+ } +
} else @@ -162,6 +207,7 @@ private int? _initialCardId; private HubConnection? _hubConnection; + private HashSet _expandedSections = new(); protected override void OnParametersSet() { @@ -531,5 +577,17 @@ { _adding = columnId; } + + private void ToggleExpand(string id) + { + if (_expandedSections.Contains(id)) + _expandedSections.Remove(id); + else + _expandedSections.Add(id); + + StateHasChanged(); + } + + private bool IsExpanded(string id) => _expandedSections.Contains(id); } diff --git a/Ticky.Web/Ticky.Web.csproj b/Ticky.Web/Ticky.Web.csproj index ba7325d..41c30d7 100644 --- a/Ticky.Web/Ticky.Web.csproj +++ b/Ticky.Web/Ticky.Web.csproj @@ -9,7 +9,7 @@ - +