| | | 1 | | using Microsoft.AspNetCore.Components; |
| | | 2 | | using Pomodoro.Web.Models; |
| | | 3 | | using Pomodoro.Web.Services.Formatters; |
| | | 4 | | |
| | | 5 | | namespace Pomodoro.Web.Components.History; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Code-behind for ActivityTimeline component |
| | | 9 | | /// Displays a list of activity records |
| | | 10 | | /// </summary> |
| | | 11 | | public class ActivityTimelineBase : ComponentBase |
| | | 12 | | { |
| | | 13 | | [Inject] |
| | 225 | 14 | | private ActivityTimelineFormatter Formatter { get; set; } = null!; |
| | | 15 | | |
| | | 16 | | #region Parameters |
| | | 17 | | |
| | | 18 | | [Parameter] |
| | 413 | 19 | | public List<ActivityRecord> Activities { get; set; } = new(); |
| | | 20 | | |
| | | 21 | | #endregion |
| | | 22 | | |
| | | 23 | | #region Methods for Testing |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets count of activities |
| | | 27 | | /// </summary> |
| | | 28 | | public int GetActivityCount() |
| | 2 | 29 | | { |
| | 2 | 30 | | return Formatter.GetActivityCount(Activities); |
| | 2 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Checks if there are any activities |
| | | 35 | | /// </summary> |
| | | 36 | | public bool HasActivities() |
| | 2 | 37 | | { |
| | 2 | 38 | | return Formatter.HasActivities(Activities); |
| | 2 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets total duration of all activities in minutes |
| | | 43 | | /// </summary> |
| | | 44 | | public int GetTotalDuration() |
| | 1 | 45 | | { |
| | 1 | 46 | | return Formatter.GetTotalDuration(Activities); |
| | 1 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets count of pomodoro sessions |
| | | 51 | | /// </summary> |
| | | 52 | | public int GetPomodoroCount() |
| | 1 | 53 | | { |
| | 1 | 54 | | return Formatter.GetPomodoroCount(Activities); |
| | 1 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Gets count of completed sessions |
| | | 59 | | /// </summary> |
| | | 60 | | public int GetCompletedCount() |
| | 1 | 61 | | { |
| | 1 | 62 | | return Formatter.GetCompletedCount(Activities); |
| | 1 | 63 | | } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Checks if timeline is empty |
| | | 67 | | /// </summary> |
| | | 68 | | public bool IsEmpty() |
| | 2 | 69 | | { |
| | 2 | 70 | | return Formatter.IsEmpty(Activities); |
| | 2 | 71 | | } |
| | | 72 | | |
| | | 73 | | #endregion |
| | | 74 | | } |