reorganized Raid pages

This commit is contained in:
Sarah Faey 2022-11-16 22:23:53 +01:00
parent f40903851e
commit d0ff8251a2
16 changed files with 174 additions and 53 deletions

View file

@ -0,0 +1,140 @@
@using System.Security.Claims
@using Lieb.Data
@using Lieb.Models
@using Lieb.Models.GuildWars2.Raid
@inject UserService UserService
@inject RaidService RaidService
@inject TimeZoneService TimeZoneService
@inject RaidRandomizerService RaidRandomizerService
@inject NavigationManager NavigationManager
<body>
<div @onclick="() => _isCollapsed = !_isCollapsed">
<label class="errormessage">@_errorMessage</label>
<h5>@_raid.Title
@if (_user != null && _isRaidSignUpAllowed)
{
<div class="signUpStatusTooltip">
@if(_raid.SignUps.Where(s => s.LiebUserId == _user.Id && s.SignUpType != SignUpType.SignedOff && s.LiebUserId > 0).Any())
{
<span class="oi oi-badge" style="color:green"></span>
<span class="tooltiptext">You are signed up</span>
}
else if(_raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count() < _raid.Roles.Sum(r => r.Spots))
{
<span class="oi oi-aperture nametooltip"></span>
<span class="tooltiptext">You can sign up</span>
}
else
{
<span class="oi oi-ban nametooltip" style="color:red"></span>
<span class="tooltiptext">The raid is full</span>
}
</div>
}
</h5>
<label style="white-space: pre-line">@_raid.Description</label>
<span class="timesblock">
<span class="times">
<h5>Date</h5>
<p>@_startTime.DateTime.ToLongDateString()</p>
</span>
<span class="times">
<h5>Time</h5>
<p>from: @_startTime.DateTime.ToShortTimeString() to: @_endTime.DateTime.ToShortTimeString()</p>
</span>
</span>
</div>
@if (!_isCollapsed)
{
<span class="detailsblock">
<span class="details">
<h5>Organizer</h5>
<p>@_raid.Organizer</p>
</span>
<span class="details">
<h5>Guild</h5>
<p>@_raid.Guild</p>
</span>
<span class="details">
<h5>Voice chat</h5>
<p>@_raid.VoiceChat</p>
</span>
</span>
<RaidRoles _Parent=@this _raid=@_raid _user=@_user _isRaidSignUpAllowed=@_isRaidSignUpAllowed/>
<div>
<AuthorizeView>
<button class="controlButton raidButton" @onclick="() => SignOffClicked()">Sign Off</button>
@if (_raid.RaidOwnerId == _user.Id || _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel)
{
<button class="controlButton raidButton" @onclick="() => EditClicked()">Edit</button>
@if (_raid.RaidType != RaidType.Planned)
{
<button class="controlButton raidButton" type=button @onclick="() => RandomizeClicked()">Randomize</button>
}
}
</AuthorizeView>
</div>
}
</body>
@code {
[Parameter]
public Raid _raid { get; set; }
[Parameter]
public LiebUser? _user { get; set; }
bool _isRaidSignUpAllowed;
string _errorMessage;
private DateTimeOffset _startTime;
private DateTimeOffset _endTime;
private DateTimeOffset _freeForAllTime;
bool _isCollapsed = true;
protected override async Task OnParametersSetAsync()
{
_isRaidSignUpAllowed = _user != null && RaidService.IsRaidSignUpAllowed(_user.Id, _raid.RaidId, out _errorMessage);
_startTime = await TimeZoneService.GetLocalDateTime(_raid.StartTimeUTC);
_endTime = await TimeZoneService.GetLocalDateTime(_raid.EndTimeUTC);
_freeForAllTime = await TimeZoneService.GetLocalDateTime(_raid.FreeForAllTimeUTC);
}
async Task SignOffClicked()
{
await RaidService.SignOff(_raid.RaidId, _user.Id);
_raid = RaidService.GetRaid(_raid.RaidId);
}
async Task EditClicked()
{
NavigationManager.NavigateTo($"raidedit/{_raid.RaidId}");
}
async Task RandomizeClicked()
{
await RaidRandomizerService.RandomizeRaid(_raid.RaidId);
_raid = RaidService.GetRaid(_raid.RaidId);
}
public void HasChanged()
{
_raid = RaidService.GetRaid(_raid.RaidId);
this.StateHasChanged();
}
}

View file

@ -0,0 +1,93 @@
body {
background-color: rgb(38 38 38);
border-radius: 25px;
padding: 25px;
/*width: 900px;*/
width: stretch;
color: lightgrey;
}
h5 {
color: lightgrey;
}
.timesblock {
display: block;
}
.times {
display: inline-block;
width: 250px;
padding-top: 15px;
}
.detailsblock {
display: block;
}
.details {
display: inline-block;
width: 250px;
padding-top: 15px;
}
.controlButton {
margin-right: 10px;
}
::deep .raidButton {
color: lightgray;
background-color: #444444;
width: 100px;
border: none;
padding: 8px;
text-align: center;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
}
table {
column-width: auto;
color: lightgray;
}
.errormessage{
color:red;
}
.signUpStatusTooltip {
position: relative;
display: inline-block;
margin-left: 150px;
}
.signUpStatusTooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
right: 110%;
}
.signUpStatusTooltip .tooltiptext::after {
content: "";
position: absolute;
top: 50%;
left: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent transparent black;
}
.signUpStatusTooltip:hover .tooltiptext {
visibility: visible;
}

View file

@ -0,0 +1,117 @@
@page "/raidoverview"
@using Lieb.Data
@using System.Security.Claims
@using Lieb.Models
@using Lieb.Models.GuildWars2.Raid
@inject RaidService RaidService
@inject UserService UserService
@inject AuthenticationStateProvider AuthenticationStateProvider
<h3>Raid Overview</h3>
<AuthorizeView Policy="@Constants.Roles.RaidLead.Name">
<div class="nav-item px-3">
<NavLink class="nav-link" href="raidedit">
<span class="oi oi-plus" aria-hidden="true"></span> Add Raid
</NavLink>
</div>
</AuthorizeView>
<br />
<label>
From:
<input type="date" value="@_startDate.ToString("yyyy-MM-dd")" @onchange="args => StartFilterChanged(args)" />
To:
<input type="date" value="@_endDate.ToString("yyyy-MM-dd")" @onchange="args => EndFilterChanged(args)" />
Raid Group:
<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>
<br />
@foreach (var raid in _raidsToShow.OrderBy(r => r.StartTimeUTC))
{
<br />
<RaidDetails _raid=@raid _user=@_user/>
}
@code
{
private List<Raid> _raids;
private LiebUser? _user;
private DateTime _startDate = DateTime.Now.Date;
private DateTime _endDate = DateTime.Now.Date.AddDays(15).AddSeconds(-1);
private string _filterRole = string.Empty;
private List<Raid> _raidsToShow;
protected override async Task OnInitializedAsync()
{
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);
}
_raids = RaidService.GetRaids();
ApplyFilter();
}
private void StartFilterChanged(ChangeEventArgs e)
{
if(!DateTime.TryParse(e.Value.ToString(), out _startDate))
{
_startDate = DateTime.UnixEpoch;
}
ApplyFilter();
}
private void EndFilterChanged(ChangeEventArgs e)
{
if(DateTime.TryParse(e.Value.ToString(), out _endDate))
{
_endDate.AddDays(1).AddSeconds(-1);
}
else
{
_endDate = DateTime.MaxValue.Date;
}
ApplyFilter();
}
private void GroupFilterChanged(ChangeEventArgs e)
{
_filterRole = e.Value?.ToString();
ApplyFilter();
}
private void ApplyFilter()
{
if(String.IsNullOrEmpty(_filterRole))
{
_raidsToShow = _raids.Where(r => r.StartTimeUTC > _startDate && r.StartTimeUTC < _endDate).ToList();
}
else if(_filterRole == "No Group")
{
_raidsToShow = _raids.Where(r => r.StartTimeUTC > _startDate && r.StartTimeUTC < _endDate && string.IsNullOrEmpty(r.RequiredRole)).ToList();
}
else
{
_raidsToShow = _raids.Where(r => r.StartTimeUTC > _startDate && r.StartTimeUTC < _endDate && r.RequiredRole == _filterRole).ToList();
}
}
}

View file

@ -0,0 +1,7 @@
body {
}
input {
margin-right: 20px;
width: fit-content;
}

View file

@ -0,0 +1,175 @@
@using Lieb.Data
@using Lieb.Models
@using Lieb.Models.GuildWars2
@using Lieb.Models.GuildWars2.Raid
@inject RaidService RaidService
<table class="table">
@{
bool flexExists = _raid.SignUps.Where(s => s.SignUpType == SignUpType.Flex).Any();
}
<thead>
<tr @onclick="() => ToggleAll()">
<th>
@if(_allExpanded)
{
<span class="oi oi-collapse-up" style="margin-right:7px"> </span>
}
else
{
<span class="oi oi-expand-down" style="margin-right:7px"> </span>
}
Role
</th>
<th>Users</th>
@if (flexExists)
{
<th>Flex</th>
}
<th>(@_raid.SignUps.Where(s => s.SignUpType == SignUpType.SignedUp).Count()/@_raid.Roles.Sum(r => r.Spots))</th>
</tr>
</thead>
<tbody>
@{
bool isSignedUp = _raid.SignUps.Where(s => s.LiebUserId == _liebUserId && s.SignUpType != SignUpType.SignedOff && s.LiebUserId > 0).Any();
}
@foreach (ExpandableRole role in _expandableRoles.OrderBy(r => r.Role.RaidRoleId))
{
<tr>
@{
<td class="tdRole" @onclick="() => ToggleRow(role)">
@if(@role.IsRowExpanded)
{
<span class="oi oi-chevron-top" style="margin-right:7px"> </span>
}
else
{
<span class="oi oi-chevron-bottom" style="margin-right:7px"> </span>
}
<b>@role.Role.Name</b> (@_raid.SignUps.Where(s => s.RaidRoleId == role.Role.RaidRoleId && s.SignUpType == SignUpType.SignedUp).Count() / @role.Role.Spots)
@if (@role.IsRowExpanded)
{
<br> @role.Role.Description
}
</td>
}
<td class="tdSignUp">
@{List<SignUpType> signUpTypes =new List<SignUpType>(){SignUpType.SignedUp, SignUpType.Maybe, SignUpType.Backup};}
<CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.RaidRoleId _signUpTypes=@signUpTypes _showToolTip=@true _showUserColor=@true></SignedUpUsers>
</CascadingValue>
</td>
@if (flexExists)
{
List<SignUpType> flexSignUpTypes =new List<SignUpType>(){SignUpType.Flex};
<td class="tdSignUp">
<CascadingValue Value="this">
<SignedUpUsers _raid=@_raid _usableAccounts=@_usableAccounts _liebUserId=@_liebUserId _currentRoleId=@role.Role.RaidRoleId _signUpTypes=@flexSignUpTypes></SignedUpUsers>
</CascadingValue>
</td>
}
@if(_liebUserId > 0 && _isRaidSignUpAllowed)
{
bool notIsRoleSignUpAllowed = !RaidService.IsRoleSignUpAllowed(_raid.RaidId, _liebUserId, role.Role.RaidRoleId, SignUpType.SignedUp, false);
bool notIsBackupAllowed = _raid.RaidType != RaidType.Planned && notIsRoleSignUpAllowed;
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.SignedUp)" disabled="@notIsRoleSignUpAllowed">Sign Up</button></td>
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Maybe)" disabled="@notIsRoleSignUpAllowed">Maybe</button></td>
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Backup)" disabled="@notIsBackupAllowed">Backup</button></td>
@if (isSignedUp && _raid.RaidType == RaidType.Planned)
{
<td><button class="raidButton" @onclick="() => SignUpClicked(role.Role, SignUpType.Flex)">Flex</button></td>
}
}
</tr>
}
</tbody>
</table>
@code {
[Parameter]
public RaidDetails _Parent { get; set; }
[Parameter]
public Raid _raid { get; set; }
[Parameter]
public LiebUser? _user { get; set; }
[Parameter]
public bool _isRaidSignUpAllowed { get; set; }
private ulong _liebUserId { get; set; } = 0;
private List<GuildWars2Account> _usableAccounts;
private List<ExpandableRole> _expandableRoles;
private bool _allExpanded = false;
private class ExpandableRole
{
public RaidRole Role;
public bool IsRowExpanded = false;
}
protected override async Task OnParametersSetAsync()
{
if (_user != null)
{
if (_raid.RaidType == RaidType.Planned)
{
_usableAccounts = _user.GuildWars2Accounts.ToList();
}
else
{
_usableAccounts = _user.GuildWars2Accounts.Where(a => a.EquippedBuilds.Count > 0).ToList();
}
_liebUserId = _user.Id;
}
_expandableRoles = new List<ExpandableRole>();
foreach(RaidRole role in _raid.Roles)
{
_expandableRoles.Add(new ExpandableRole()
{
Role = role
});
}
}
async Task SignUpClicked(RaidRole role, SignUpType signUpType)
{
if(_raid.SignUps.Where(s => s.LiebUserId == _liebUserId).Any() && signUpType != SignUpType.Flex)
{
await RaidService.ChangeSignUpType(_raid.RaidId, _liebUserId, role.RaidRoleId, signUpType);
}
else
{
await RaidService.SignUp(_raid.RaidId, _liebUserId, _usableAccounts.FirstOrDefault().GuildWars2AccountId, role.RaidRoleId, signUpType);
}
_Parent.HasChanged();
}
public async Task ChangeAccount(ChangeEventArgs e)
{
int accountId = int.Parse(e.Value.ToString());
await RaidService.ChangeAccount(_raid.RaidId, _liebUserId, accountId);
_raid = RaidService.GetRaid(_raid.RaidId);
this.StateHasChanged();
}
private async Task ToggleRow(ExpandableRole role)
{
role.IsRowExpanded = !role.IsRowExpanded;
_allExpanded = !_expandableRoles.Where(r => !r.IsRowExpanded).Any();
}
private async Task ToggleAll()
{
foreach(ExpandableRole role in _expandableRoles)
{
role.IsRowExpanded = !_allExpanded;
}
_allExpanded = !_allExpanded;
}
}

View file

@ -0,0 +1,22 @@

table {
column-width: auto;
color: lightgrey;
width: fit-content;
}
button {
/*width: max-content;*/
width: 80px;
}
.tdSignUp {
max-width: 400px;
width: fit-content;
}
.tdRole {
max-width: 500px;
width: fit-content;
}

View file

@ -0,0 +1,85 @@
@using System.Security.Claims
@using Lieb.Data
@using Lieb.Models
@using Lieb.Models.GuildWars2.Raid
@inject UserService UserService
@inject RaidService RaidService
@inject TimeZoneService TimeZoneService
@inject NavigationManager NavigationManager
@inject RaidRandomizerService RaidRandomizerService
<body>
<h5>@_template.Title</h5>
<label style="white-space: pre-line">@_template.Description</label>
<div >
<div class="times">
<h5>Date</h5>
<p>@_template.StartTime.ToLongDateString()</p>
</div>
<div class="times">
<h5>Time</h5>
<p>from: @_template.StartTime.ToShortTimeString() to: @_template.EndTime.ToShortTimeString()</p>
</div>
<div class="times">
<h5>TimeZone</h5>
<p>@_template.TimeZone</p>
</div>
</div>
<div>
<div class="details">
<h5>Organizer</h5>
<p>@_template.Organizer</p>
</div>
<div class="details">
<h5>Guild</h5>
<p>@_template.Guild</p>
</div>
<div class="details">
<h5>Voice chat</h5>
<p>@_template.VoiceChat</p>
</div>
</div>
<div>
<table class="table">
<tbody>
@foreach (var role in _template.Roles.OrderBy(r => r.RaidRoleId))
{
<tr>
<td><Label> <b>@role.Name</b> (@role.Spots) <br> @role.Description </Label></td>
</tr>
}
</tbody>
</table>
</div>
<AuthorizeView>
@if (_template.RaidOwnerId == _user.Id || _user.RoleAssignments.Max(a => a.LiebRole.Level) >= Constants.RaidEditPowerLevel)
{
<button class="controlButton raidButton" @onclick="() => EditClicked()">Edit</button>
}
</AuthorizeView>
</body>
@code {
[Parameter]
public RaidTemplate _template { get; set; }
[Parameter]
public LiebUser? _user { get; set; }
protected override async Task OnParametersSetAsync()
{
}
async Task EditClicked()
{
NavigationManager.NavigateTo($"raidtemplateedit/{_template.RaidTemplateId}");
}
}

View file

@ -0,0 +1,32 @@
body {
background-color: rgb(38 38 38);
border-radius: 25px;
padding: 25px;
width: 700px;
/*width: fit-content;*/
color: lightgray;
}
h5 {
color: lightgrey;
}
.times {
float: left;
display: inline;
width: 33%;
padding-top: 15px;
}
.details {
float: left;
display: inline;
width: 33%;
padding-top: 15px;
}
table {
column-width: auto;
color: lightgray;
}

View file

@ -0,0 +1,44 @@
@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>RaidTemplateOverview</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 Raid
</NavLink>
</div>
</AuthorizeView>
@foreach (var raid in _templates.OrderBy(r => r.StartTime))
{
<br />
<RaidTemplateDetails _template=@raid _user=@_user/>
}
@code
{
private List<RaidTemplate> _templates;
private LiebUser? _user;
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);
}
}
}

View file

@ -0,0 +1,90 @@
@using Lieb.Data
@using Lieb.Models
@using Lieb.Models.GuildWars2
@using Lieb.Models.GuildWars2.Raid
@inject RaidService RaidService
<table>
@{RaidSignUp[] signUps = _raid.SignUps.Where(s => s.RaidRoleId == _currentRoleId).ToArray();}
@foreach (var signUp in signUps.OrderBy(s => s.SignUpType))
{
@if(_signUpTypes.Contains(signUp.SignUpType))
{
<tr>
@{
bool isLoggedInUser = signUp.LiebUserId == _liebUserId;
string signUpStatus = string.Empty;
@if (signUp.SignUpType != SignUpType.SignedUp && _signUpTypes.Count > 1) signUpStatus = $" - {signUp.SignUpType}";
}
@if (isLoggedInUser && _usableAccounts.Count > 1 && signUp.SignUpType != SignUpType.Flex)
{
<td>
<select class="accountselect" value=@signUp.GuildWars2AccountId @onchange="args => _Parent.ChangeAccount(args)">
@foreach (var account in _usableAccounts)
{
<option value=@account.GuildWars2AccountId>@account.AccountName</option>
}
</select> @signUpStatus
</td>
}
else if(isLoggedInUser && _showUserColor)
{
<td class="nametooltip username">
@signUp.GuildWars2Account.AccountName @signUpStatus
@if(_showToolTip)
{
<span class="tooltiptext">@signUp.LiebUser.Name</span>
}
</td>
}
else if(!signUp.IsExternalUser)
{
<td class="nametooltip">
@signUp.GuildWars2Account.AccountName @signUpStatus
@if(_showToolTip)
{
<span class="tooltiptext">@signUp.LiebUser.Name</span>
}
</td>
}
else
{
<td class="nametooltip">
@signUp.ExternalUserName @signUpStatus
@if(_showToolTip)
{
<span class="tooltiptext">external user</span>
}
</td>
}
</tr>
}
}
</table>
@code {
[CascadingParameter]
public RaidRoles _Parent { get; set; }
[Parameter]
public Raid _raid { get; set; }
[Parameter]
public ulong _liebUserId { get; set; } = 0;
[Parameter]
public List<GuildWars2Account> _usableAccounts { get; set; }
[Parameter]
public int _currentRoleId { get; set; }
[Parameter]
public List<SignUpType> _signUpTypes { get; set; }
[Parameter]
public bool _showToolTip { get; set; } = false;
[Parameter]
public bool _showUserColor { get; set; } = false;
}

View file

@ -0,0 +1,42 @@
.username {
color: lightgreen;
}
.nametooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.nametooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
right: 110%;
}
.nametooltip .tooltiptext::after {
content: "";
position: absolute;
top: 50%;
left: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent transparent black;
}
.nametooltip:hover .tooltiptext {
visibility: visible;
}
.accountselect {
background-color: #555555;
}