Merge pull request #353 from Moonlight-Panel/v2_ImproveTicketing

Improved ticketing
This commit is contained in:
Marcel Baumgartner 2024-01-08 08:34:39 +01:00 committed by GitHub
commit 8d1cb47a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 16 deletions

View file

@ -18,14 +18,24 @@
</div>
<div class="card-body pt-5">
<div class="scroll-y me-n5 pe-5" style="height: 50vh; width: 40vh; display: flex; flex-direction: column;">
<div class="d-flex flex-stack py-2 justify-content-center">
<h3 class="align-middle text-center">Need help? Create a <a @onclick="() => TicketPopupMain.SetViewIndex(3)" @onclick:preventDefault href="#" class="text-primary">ticket</a></h3>
<div class="d-flex flex-stack py-2">
<div class="btn-group w-100">
<button class="btn btn-primary" type="button" @onclick="() => TicketPopupMain.SetViewIndex(3)">Create ticket</button>
@if (ViewClosed)
{
<button class="btn btn-success" type="button" @onclick="ToggleViewClosed">Open tickets</button>
}
else
{
<button class="btn btn-danger" type="button" @onclick="ToggleViewClosed">Closed tickets</button>
}
</div>
</div>
<div class="d-flex flex-stack py-4">
</div>
<LazyLoader Load="LoadTickets">
<LazyLoader @ref="LazyLoader" Load="LoadTickets">
@if (Tickets.Any())
{
foreach (var ticket in Tickets)
@ -45,7 +55,7 @@
}
else
{
<div class="text-center text-muted fs-5">No open tickets found</div>
<div class="text-center text-muted fs-5">No @(ViewClosed ? "closed" : "open") tickets found</div>
}
</LazyLoader>
</div>
@ -56,16 +66,27 @@
[CascadingParameter]
public TicketPopupMain TicketPopupMain { get; set; }
private LazyLoader LazyLoader;
private Ticket[] Tickets;
private bool ViewClosed = false;
private Task LoadTickets(LazyLoader _)
{
Tickets = TicketRepository
.Get()
.Where(x => x.Creator.Id == IdentityService.CurrentUser.Id)
.Where(x => x.Open)
.Where(x => x.Open == !ViewClosed)
.ToArray();
return Task.CompletedTask;
}
private async Task ToggleViewClosed()
{
ViewClosed = !ViewClosed;
await InvokeAsync(StateHasChanged);
await LazyLoader.Reload();
}
}

View file

@ -66,22 +66,34 @@
<div class="card-footer">
<div class="row">
<div class="input-group">
<textarea @bind="MessageContent" class="form-control form-control-solid-bg rounded-end me-3" placeholder="Type a message" style="height: 1vh"></textarea>
<ChatFileSelect @ref="FileSelect"/>
<WButton OnClick="SendMessage" CssClasses="ms-2 btn btn-icon btn-bg-light btn-color-white">
<i class="bx bx-sm bx-send"></i>
</WButton>
@if (HasStarted && TicketService.Chat.Ticket.Open)
{
<textarea @bind="MessageContent" class="form-control form-control-solid-bg rounded-end me-3" placeholder="Type a message" style="height: 1vh"></textarea>
<ChatFileSelect @ref="FileSelect"/>
<WButton OnClick="SendMessage" CssClasses="ms-2 btn btn-icon btn-bg-light btn-color-white">
<i class="bx bx-sm bx-send"></i>
</WButton>
}
else
{
<textarea @bind="MessageContent" class="form-control form-control-solid-bg rounded-end me-3 disabled" disabled="disabled" placeholder="Type a message" style="height: 1vh"></textarea>
<label class="btn btn-icon btn-bg-light btn-color-primary rounded-start rounded-end disabled" disabled="">
<i class="bx bx-sm bx-upload"></i>
</label>
<button class="ms-2 btn btn-icon btn-bg-light btn-color-white disabled" disabled="disabled">
<i class="bx bx-sm bx-send"></i>
</button>
}
</div>
</div>
</div>
@code
{
[CascadingParameter]
public TicketPopupMain TicketPopupMain { get; set; }
[CascadingParameter] public TicketPopupMain TicketPopupMain { get; set; }
private bool HasStarted = false;
private ChatFileSelect FileSelect;
private string MessageContent = "";
@ -89,11 +101,11 @@
{
await lazyLoader.SetText("Starting chat client");
// Initialize chat service and start it
// Initialize chat service and start it
TicketService.Chat.OnUpdate = OnUpdate;
await TicketService.Chat.Start(TicketPopupMain.CurrentTicket);
// Let the ui know that we are ready
// Let the ui know that we are ready
HasStarted = true;
await InvokeAsync(StateHasChanged);
}
@ -119,7 +131,7 @@
string.IsNullOrEmpty(MessageContent) ? $"Upload of {FileSelect.SelectedFile.Name}" : MessageContent,
FileSelect.SelectedFile.OpenReadStream(1024 * 1024 * 5),
FileSelect.SelectedFile.Name
);
);
await FileSelect.RemoveSelection();
}