104 lines
3 KiB
Text
104 lines
3 KiB
Text
@page "/raidtemplateoverview"
|
|
@using Lieb.Data
|
|
@using System.Security.Claims
|
|
@using Lieb.Models
|
|
@using Lieb.Models.GuildWars2.Raid
|
|
@inject RaidTemplateService RaidTemplateService
|
|
@inject UserService UserService
|
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
|
|
|
|
|
<h3>Event Templates</h3>
|
|
|
|
|
|
<AuthorizeView Policy="@Constants.Roles.RaidLead.Name">
|
|
<div class="nav-item px-3">
|
|
<NavLink class="nav-link" href="raidtemplateedit">
|
|
<span class="oi oi-plus" aria-hidden="true"></span> Add Template
|
|
</NavLink>
|
|
</div>
|
|
</AuthorizeView>
|
|
|
|
<br />
|
|
<label>Raid Group:</label>
|
|
<select @onchange="args => GroupFilterChanged(args)" >
|
|
<option value="">All</option>
|
|
<option value="No Group">No Group</option>
|
|
@foreach(LiebRole role in UserService.GetLiebRoles())
|
|
{
|
|
if (role.Type != RoleType.SystemRole)
|
|
{
|
|
<option value="@role.RoleName">@role.RoleName</option>
|
|
}
|
|
}
|
|
</select>
|
|
<label>Event Type:</label>
|
|
<select @onchange="args => EventTypeFilterChanged(args)" >
|
|
<option value="">All</option>
|
|
@foreach(EventType eventType in (EventType[]) Enum.GetValues(typeof(EventType)))
|
|
{
|
|
<option value="@eventType">@eventType.ToString()</option>
|
|
}
|
|
</select>
|
|
|
|
<br />
|
|
|
|
@foreach (var raid in _templatesToShow.OrderBy(r => r.StartTime))
|
|
{
|
|
<br />
|
|
<RaidTemplateDetails _template=@raid _user=@_user/>
|
|
}
|
|
|
|
@code
|
|
{
|
|
private List<RaidTemplate> _templates;
|
|
private LiebUser? _user;
|
|
private string _filterRole = string.Empty;
|
|
private string _filterEventType = string.Empty;
|
|
private List<RaidTemplate> _templatesToShow;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_templates = RaidTemplateService.GetTemplates();
|
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
|
|
if (authState.User.Identity.IsAuthenticated)
|
|
{
|
|
ulong discordId = ulong.Parse(authState.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
|
|
_user = UserService.GetLiebUser(discordId);
|
|
}
|
|
ApplyFilter();
|
|
}
|
|
|
|
private void GroupFilterChanged(ChangeEventArgs e)
|
|
{
|
|
_filterRole = e.Value?.ToString();
|
|
ApplyFilter();
|
|
}
|
|
|
|
private void EventTypeFilterChanged(ChangeEventArgs e)
|
|
{
|
|
_filterEventType = e.Value?.ToString();
|
|
ApplyFilter();
|
|
}
|
|
|
|
private void ApplyFilter()
|
|
{
|
|
if(String.IsNullOrEmpty(_filterRole))
|
|
{
|
|
_templatesToShow = _templates;
|
|
}
|
|
else if(_filterRole == "No Group")
|
|
{
|
|
_templatesToShow = _templates.Where(r => string.IsNullOrEmpty(r.RequiredRole)).ToList();
|
|
}
|
|
else
|
|
{
|
|
_templatesToShow = _templates.Where(r => r.RequiredRole == _filterRole).ToList();
|
|
}
|
|
if(!String.IsNullOrEmpty(_filterEventType))
|
|
{
|
|
_templatesToShow = _templatesToShow.Where(r => r.EventType.ToString() == _filterEventType).ToList();
|
|
}
|
|
}
|
|
}
|