added Raid Logs
This commit is contained in:
parent
796f27aff6
commit
6d4c39c49d
2 changed files with 74 additions and 0 deletions
65
Lieb/Pages/GuildWars2/RaidLogs.razor
Normal file
65
Lieb/Pages/GuildWars2/RaidLogs.razor
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
@page "/raidlogs"
|
||||||
|
@using Lieb.Data
|
||||||
|
@using Lieb.Models
|
||||||
|
@using Lieb.Models.GuildWars2
|
||||||
|
@using System.Security.Claims
|
||||||
|
@inject UserService UserService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||||
|
|
||||||
|
|
||||||
|
<h3>RaidLogs</h3>
|
||||||
|
|
||||||
|
<select value=@_selectedLogFolder @onchange="args => ChangeShownLogs(args)">
|
||||||
|
@if (_logGroups.Contains(TRAINING))
|
||||||
|
{
|
||||||
|
<option value="@TRAINING">@TRAINING</option>
|
||||||
|
}
|
||||||
|
@if (_logGroups.Contains(RANDOM))
|
||||||
|
{
|
||||||
|
<option value="@RANDOM">@RANDOM</option>
|
||||||
|
}
|
||||||
|
@foreach (string group in _logGroups)
|
||||||
|
{
|
||||||
|
if (_user.RoleAssignments.FirstOrDefault(r => r.LiebRole.RoleName == group) != null)
|
||||||
|
{
|
||||||
|
<option value=@group>@group</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
@foreach(string logFolder in _availabeLogs)
|
||||||
|
{
|
||||||
|
string path = $"{LOGS}/{_selectedLogFolder}/{logFolder}/index.html";
|
||||||
|
<NavLink class="nav-link" href="@path"> @logFolder </NavLink>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private const string TRAINING = "Training";
|
||||||
|
private const string RANDOM = "Random";
|
||||||
|
private const string LOGS = "logs";
|
||||||
|
private const string LOG_DIR = $"wwwroot/{LOGS}";
|
||||||
|
private LiebUser _user;
|
||||||
|
private List<string> _logGroups = new List<string>();
|
||||||
|
private List<string> _availabeLogs = new List<string>();
|
||||||
|
private string _selectedLogFolder = "Training";
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||||
|
ulong discordId = ulong.Parse(authState.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
|
||||||
|
_user = UserService.GetLiebUser(discordId);
|
||||||
|
_logGroups = Directory.EnumerateDirectories(LOG_DIR).Select(d => Path.GetFileName(d)).ToList();
|
||||||
|
_availabeLogs = Directory.EnumerateDirectories($"{LOG_DIR}/{_selectedLogFolder}").Select(d => Path.GetFileName(d)).OrderByDescending(s => s).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task ChangeShownLogs( ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
_selectedLogFolder = e.Value.ToString();
|
||||||
|
_availabeLogs = Directory.EnumerateDirectories($"{LOG_DIR}/{_selectedLogFolder}").Select(d => Path.GetFileName(d)).OrderByDescending(s => s).ToList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,15 @@
|
||||||
<span class="oi oi-plus" aria-hidden="true"></span> Raid Overview
|
<span class="oi oi-plus" aria-hidden="true"></span> Raid Overview
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
<AuthorizeView>
|
||||||
|
<Authorized>
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="raidlogs">
|
||||||
|
<span class="oi oi-list-rich" aria-hidden="true"></span> Logs
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
</Authorized>
|
||||||
|
</AuthorizeView>
|
||||||
<AuthorizeView Policy="@Constants.Roles.Admin">
|
<AuthorizeView Policy="@Constants.Roles.Admin">
|
||||||
<Authorized>
|
<Authorized>
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue