Skip to content

Commit

Permalink
Weight details, Overdue indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
spech66 committed Dec 31, 2023
1 parent 8ebf92c commit af4c2c5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
4 changes: 2 additions & 2 deletions LifelogBb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public async Task<IActionResult> Dashboard()
{
var model = new IndexDashboardViewModel();

var weight = await _context.Weights.OrderByDescending(o => o.CreatedAt).Take(1).FirstOrDefaultAsync();
model.LastWeight = weight;
var weights = await _context.Weights.OrderByDescending(o => o.CreatedAt).Take(10).ToListAsync();
model.WeightList = weights.OrderBy(o => o.CreatedAt).ToList();

var enduranceTraining = await _context.EnduranceTrainings.OrderByDescending(o => o.CreatedAt).Take(1).FirstOrDefaultAsync();
model.LastEnduranceTraining = enduranceTraining;
Expand Down
2 changes: 1 addition & 1 deletion LifelogBb/Models/Home/IndexDashboardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class IndexDashboardViewModelActivity

public class IndexDashboardViewModel
{
public Weight? LastWeight { get; set; }
public List<Weight>? WeightList { get; set; }

public StrengthTraining? LastStrengthTraining { get; set; }

Expand Down
43 changes: 37 additions & 6 deletions LifelogBb/Views/Home/Dashboard.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="container-xl">
<div class="row row-deck row-cards">
@if (Model.LastWeight != null)
@if (Model.WeightList != null && Model.WeightList.Count > 0)
{
<div class="col-sm-6 col-lg-3">
<div class="card card-sm">
Expand All @@ -15,7 +15,40 @@
<div class="col-auto"><span class="bg-primary text-white avatar"><i class="fa-solid fa-weight-scale icon icon-tabler icon-tabler-weight"></i></span></div>
<div class="col">
<div class="font-weight-medium">Last Weight</div>
<div class="text-muted">@Model.LastWeight.BodyWeight</div>
<div class="text-muted">
@if(Model.WeightList.Count > 1)
{
@if (Model.WeightList.Last().BodyWeight > Model.WeightList.First().BodyWeight)
{
<i class="fa-solid fa-arrow-up text-red"></i>
}
else if (Model.WeightList.Last().BodyWeight < Model.WeightList.First().BodyWeight)
{
<i class="fa-solid fa-arrow-down text-green"></i>
}
else
{
<i class="fa-solid fa-minus"></i>
}
}
@Model.WeightList.Last().BodyWeight
</div>
</div>
</div>
</div>
</div>
</div>
}
@if (Model.WeightList != null && Model.WeightList.Count > 1)
{
<div class="col-sm-6 col-lg-3">
<div class="card card-sm">
<div class="card-body">
<div class="row align-items-center">
<div class="col-auto"><span class="bg-primary text-white avatar"><i class="fa-solid fa-weight-scale icon icon-tabler icon-tabler-weight"></i></span></div>
<div class="col">
<div class="font-weight-medium">Weight</div>
<div class="text-muted">MINI CHART</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -74,9 +107,6 @@
</div>
<div class="text-muted">@item.Date.ToString()</div>
</div>
<div class="col-auto align-self-center">
<div class="badge bg-primary"></div>
</div>
</div>
</div>
}
Expand All @@ -102,7 +132,8 @@
@if (item.DueDate != null)
{
<div class="col-auto">
<span class="text-muted">@item.DueDate.Value.ToString()</span>
<span class="text-muted">@item.DueDate.Value.ToShortDateString() @item.DueDate.Value.ToShortTimeString()</span>
<div class="badge bg-red"><span class="fas fa-clock"></span></div>
</div>
}
@if (item.IsImportant)
Expand Down

0 comments on commit af4c2c5

Please sign in to comment.