Skip to content

Commit

Permalink
Version 1.50 (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
NomisNostab authored Feb 17, 2024
2 parents cd18bc9 + c8d3f97 commit 57f6abb
Show file tree
Hide file tree
Showing 19 changed files with 864 additions and 395 deletions.
24 changes: 4 additions & 20 deletions Model/Milestone/GetMilestoneResultModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,12 @@ public class MilestoneResult

public class Event_Count
{
public Participant participant { get; set; } = new Participant();
public Assistant assistant { get; set; } = new Assistant();
public Leader leader { get; set; } = new Leader();
public PALEventCount participant { get; set; } = new PALEventCount();
public PALEventCount assistant { get; set; } = new PALEventCount();
public PALEventCount leader { get; set; } = new PALEventCount();
}

public class Participant
{
public float community { get; set; }
public float outdoors { get; set; }
public float creative { get; set; }
public float personal_growth { get; set; }
}

public class Assistant
{
public float community { get; set; }
public float outdoors { get; set; }
public float creative { get; set; }
public float personal_growth { get; set; }
}

public class Leader
public class PALEventCount
{
public float community { get; set; }
public float outdoors { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Model/Wallchart/WallchartItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class WallchartItemModel
{
public string MemberName { get; set; } = string.Empty;
public string MemberPatrol { get; set; } = string.Empty;
public DateTime? IntroToScouting { get; set; }
public DateTime? IntroToSection { get; set; }
public int Milestone1Community { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Model/Wallchart/WallchartPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public class WallchartPageViewModel
public string UnitId { get; set; } = string.Empty;
public string UnitName { get; set; } = string.Empty;
public string GroupName { get; set; } = string.Empty;
public string ErrorMessage { get; set; } = string.Empty;
public bool BreakByPatrol { get; set; }
}
}
463 changes: 236 additions & 227 deletions Services/ReportService.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Topo/Controller/LogoutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LogoutController : ComponentBase

[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
_storageService.Logout();
NavigationManager.NavigateTo("index");
Expand Down
1 change: 1 addition & 0 deletions Topo/Controller/MilestoneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected override void OnInitialized()
model.GroupName = _storageService.GroupNameDisplay;
model.Units = _storageService.Units;
model.UnitId = _storageService.UnitId;
model.UnitName = _storageService.UnitName;
}

internal async Task UnitChange(ChangeEventArgs e)
Expand Down
11 changes: 10 additions & 1 deletion Topo/Controller/OasController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ protected override async Task OnInitializedAsync()
model.GroupName = _storageService.GroupNameDisplay;
model.Units = _storageService.Units;
model.Stages = await _oasService.GetOASStagesList();
model.UnitId = _storageService.UnitId;
if (!string.IsNullOrEmpty(_storageService.UnitId))
{
await UnitChange(_storageService.UnitId);
}

}

internal async Task UnitChange(ChangeEventArgs e)
{
var unitId = e.Value?.ToString() ?? "";
await UnitChange(unitId);
}

internal async Task UnitChange(string unitId)
{
model.UnitId = unitId;
_storageService.UnitId = model.UnitId;
if (_storageService.Units != null)
Expand Down
19 changes: 18 additions & 1 deletion Topo/Controller/WallchartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Topo.Model.Wallchart;
using Topo.Model.ReportGeneration;
using Topo.Services;
using System.Reflection;

namespace Topo.Controller
{
Expand Down Expand Up @@ -37,6 +38,7 @@ protected override void OnInitialized()
model.GroupName = _storageService.GroupNameDisplay;
model.Units = _storageService.Units;
model.UnitId = _storageService.UnitId;
model.UnitName = _storageService.UnitName;
}

internal async Task UnitChange(ChangeEventArgs e)

Check warning on line 44 in Topo/Controller/WallchartController.cs

View workflow job for this annotation

GitHub Actions / deploy-to-github-pages

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
Expand All @@ -55,6 +57,11 @@ internal async Task WallchartReportPdfClick()
return;

byte[] report = await WallchartReport(OutputType.PDF);
if (report.Length == 0)
{
model.ErrorMessage = "Group life request took too long. Please try Group Life for unit in Terrain first.";
return;
}
var fileName = $"Wallchart_{model.UnitName.Replace(' ', '_')}.pdf";

// Send the data to JS to actually download the file
Expand All @@ -67,6 +74,11 @@ internal async Task WallchartReportXlsxClick()
return;

byte[] report = await WallchartReport(OutputType.Excel);
if (report.Length == 0)
{
model.ErrorMessage = "Group life request took too long. Please try Group Life for unit in Terrain first.";
return;
}
var fileName = $"Wallchart_{model.UnitName.Replace(' ', '_')}.xlsx";

// Send the data to JS to actually download the file
Expand All @@ -75,15 +87,20 @@ internal async Task WallchartReportXlsxClick()

private async Task<byte[]> WallchartReport(OutputType outputType = OutputType.PDF)
{
model.ErrorMessage = "";
var wallchartItems = await _wallchartService.GetWallchartItems(model.UnitId);
if (wallchartItems.Count == 0)
{
return new byte[0];
}

var groupName = _storageService.GroupName ?? "";
var unitName = _storageService.UnitName ?? "";
var section = _storageService.Section;

var serialisedWallchartItems = JsonConvert.SerializeObject(wallchartItems);

var report = await _reportService.GetWallchartReport(groupName, section, unitName, outputType, serialisedWallchartItems);
var report = await _reportService.GetWallchartReport(groupName, section, unitName, outputType, serialisedWallchartItems, model.BreakByPatrol);
return report;
}

Expand Down
18 changes: 13 additions & 5 deletions Topo/DisplaySpinnerAutomaticallyHttpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ public DisplaySpinnerAutomaticallyHttpMessageHandler(SpinnerService spinnerServi
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
_spinnerService.Show();
// await Task.Delay(1000);
var response = await base.SendAsync(request, cancellationToken);
_spinnerService.Hide();
return response;
try
{
_spinnerService.Show();
// await Task.Delay(1000);
var response = await base.SendAsync(request, cancellationToken);
_spinnerService.Hide();
return response;
}
catch (Exception ex)

Check warning on line 22 in Topo/DisplaySpinnerAutomaticallyHttpMessageHandler.cs

View workflow job for this annotation

GitHub Actions / deploy-to-github-pages

The variable 'ex' is declared but never used
{
_spinnerService.Hide();
throw;
}
}
}
}
16 changes: 16 additions & 0 deletions Topo/Pages/Wallchart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,27 @@
</div>
</div>

<div class="mt-3 mb-3 row">
<div class="col-sm-3">
<InputCheckbox id="breakByPatrol" class="form-check-input"
@bind-Value="model.BreakByPatrol" />
<label class="form-check-label" for="breakByPatrol">
Break by Patrol
</label>
</div>
<div class="col-sm-9">
</div>
</div>

<div class="mt-3 mb-3 row">
<div class="col-sm">
<button type="submit" name="button" @onclick="WallchartReportPdfClick" class="btn btn-primary">Wallchart (pdf)</button>
<button type="submit" name="button" @onclick="WallchartReportXlsxClick" class="btn btn-success">Wallchart (xlsx)</button>
</div>
</div>

<div class="mt-3 mb-3 row">
<label class="col-form-label validation-message">@model.ErrorMessage</label>
</div>

</EditForm>
8 changes: 8 additions & 0 deletions Topo/Services/MembersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface IMembersService
{
public Task<List<MemberListModel>> GetMembersAsync(string unitId);
public void ClearMemberCache(string unitId);
public Task<MemberListModel> GetMember(string unitId, string memberId);
}

public class MembersService : IMembersService
Expand Down Expand Up @@ -80,6 +81,13 @@ public async Task<List<MemberListModel>> GetMembersAsync(string unitId)
return memberList;
}

public async Task<MemberListModel> GetMember(string unitId, string memberId)
{
var members = await GetMembersAsync(unitId);
var member = members.Where(m => m.id == memberId).FirstOrDefault();
return member ?? new MemberListModel();
}

private string GetAgeFromBirthdate(string dateOfBirth)
{
var birthday = DateTime.ParseExact(dateOfBirth, "yyyy-MM-dd", CultureInfo.InvariantCulture); // Date in AU format
Expand Down
Loading

0 comments on commit 57f6abb

Please sign in to comment.