From 41591702441028980e016662f4aee52276a6850c Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Tue, 17 Oct 2023 09:00:59 +0200 Subject: [PATCH] Added ticket models. Did some ui --- Moonlight/App/Database/DataContext.cs | 3 + .../App/Database/Entities/Tickets/Ticket.cs | 18 ++ .../Entities/Tickets/TicketMessage.cs | 11 ++ .../App/Database/Enums/TicketPriority.cs | 9 + Moonlight/Moonlight.csproj | 1 - .../Shared/Components/Partials/LiveChat.razor | 133 -------------- .../Partials/LiveChat/LiveChatMain.razor | 163 ++++++++++++++++++ Moonlight/Shared/Layouts/DefaultLayout.razor | 6 +- 8 files changed, 208 insertions(+), 136 deletions(-) create mode 100644 Moonlight/App/Database/Entities/Tickets/Ticket.cs create mode 100644 Moonlight/App/Database/Entities/Tickets/TicketMessage.cs create mode 100644 Moonlight/App/Database/Enums/TicketPriority.cs delete mode 100644 Moonlight/Shared/Components/Partials/LiveChat.razor create mode 100644 Moonlight/Shared/Components/Partials/LiveChat/LiveChatMain.razor diff --git a/Moonlight/App/Database/DataContext.cs b/Moonlight/App/Database/DataContext.cs index d48f8e24..81c5117d 100644 --- a/Moonlight/App/Database/DataContext.cs +++ b/Moonlight/App/Database/DataContext.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Moonlight.App.Database.Entities; +using Moonlight.App.Database.Entities.Tickets; using Moonlight.App.Services; namespace Moonlight.App.Database; @@ -9,6 +10,8 @@ public class DataContext : DbContext private readonly ConfigService ConfigService; public DbSet Users { get; set; } + //public DbSet Tickets { get; set; } + //public DbSet TicketMessages { get; set; } public DataContext(ConfigService configService) { diff --git a/Moonlight/App/Database/Entities/Tickets/Ticket.cs b/Moonlight/App/Database/Entities/Tickets/Ticket.cs new file mode 100644 index 00000000..ef6d485f --- /dev/null +++ b/Moonlight/App/Database/Entities/Tickets/Ticket.cs @@ -0,0 +1,18 @@ +using Moonlight.App.Database.Enums; + +namespace Moonlight.App.Database.Entities.Tickets; + +public class Ticket +{ + public int Id { get; set; } + public User Creator { get; set; } + public string Name { get; set; } = ""; + public string Description { get; set; } = ""; + public string Tries { get; set; } = ""; + public TicketPriority Priority { get; set; } = TicketPriority.Low; + public bool Open { get; set; } = true; + + public List Messages = new(); + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; +} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Tickets/TicketMessage.cs b/Moonlight/App/Database/Entities/Tickets/TicketMessage.cs new file mode 100644 index 00000000..84caee33 --- /dev/null +++ b/Moonlight/App/Database/Entities/Tickets/TicketMessage.cs @@ -0,0 +1,11 @@ +namespace Moonlight.App.Database.Entities.Tickets; + +public class TicketMessage +{ + public int Id { get; set; } + public User? Sender { get; set; } + public bool IsSupport { get; set; } + public string Content { get; set; } = ""; + public string? Attachment { get; set; } + public DateTime CreatedAt { get; set; } +} \ No newline at end of file diff --git a/Moonlight/App/Database/Enums/TicketPriority.cs b/Moonlight/App/Database/Enums/TicketPriority.cs new file mode 100644 index 00000000..4936372e --- /dev/null +++ b/Moonlight/App/Database/Enums/TicketPriority.cs @@ -0,0 +1,9 @@ +namespace Moonlight.App.Database.Enums; + +public enum TicketPriority +{ + Low, + Medium, + High, + Critical +} \ No newline at end of file diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 400b3ec3..d7de8415 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -14,7 +14,6 @@ - diff --git a/Moonlight/Shared/Components/Partials/LiveChat.razor b/Moonlight/Shared/Components/Partials/LiveChat.razor deleted file mode 100644 index c95aaf5e..00000000 --- a/Moonlight/Shared/Components/Partials/LiveChat.razor +++ /dev/null @@ -1,133 +0,0 @@ -
- @if (ShowLiveChat) - { - if (ShowChatsView) - { -
-
- Chats -
- -
-
-
-
- -
-
- M -
-
- Melody Macy -
melody@altbox.com
-
-
-
- 2 weeks -
- -
-
-
-
- Pic -
-
- Max Smith -
max@kt.com
-
-
-
- 1 day -
-
-
-
-
- } - else - { -
-
- Some chat -
- -
-
-
-
- @for (int i = 0; i < 9; i++) - { -
-
-
-
- Pic -
-
- Brian Cox - 2 mins -
-
-
- How likely are you to recommend our company to your friends and family ? -
-
-
-
-
-
-
- 5 mins - You -
-
- Pic -
-
-
- Hey there, we’re just writing to let you know that you’ve been subscribed to a repository on GitHub. -
-
-
- } -
-
- -
- } - } - else - { - - } -
- -@code -{ - private bool ShowLiveChat = false; - private bool ShowChatsView = true; - - private async Task ToggleShow() - { - ShowLiveChat = !ShowLiveChat; - await InvokeAsync(StateHasChanged); - } - - private async Task SetShowChats(bool state) - { - ShowChatsView = state; - await InvokeAsync(StateHasChanged); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Partials/LiveChat/LiveChatMain.razor b/Moonlight/Shared/Components/Partials/LiveChat/LiveChatMain.razor new file mode 100644 index 00000000..8a1d08ba --- /dev/null +++ b/Moonlight/Shared/Components/Partials/LiveChat/LiveChatMain.razor @@ -0,0 +1,163 @@ +
+ @if (ViewIndex == 1) + { +
+
+ Chats +
+ +
+
+
+
+
+ +
+ + +
+
+ M +
+
+ Melody Macy +
melody@altbox.com
+
+
+
+ 2 weeks +
+ +
+
+
+
+ Pic +
+
+ Max Smith +
max@kt.com
+
+
+
+ 1 day +
+
+
+
+
+ } + else if (ViewIndex == 2) + { +
+
+ Some chat +
+ +
+
+
+
+ @for (int i = 0; i < 9; i++) + { +
+
+
+
+ Pic +
+
+ Brian Cox + 2 mins +
+
+
+ How likely are you to recommend our company to your friends and family ? +
+
+
+
+
+
+
+ 5 mins + You +
+
+ Pic +
+
+
+ Hey there, we’re just writing to let you know that you’ve been subscribed to a repository on GitHub. +
+
+
+ } +
+
+ +
+ } + else if (ViewIndex == 3) + { +
+
+ Create ticket +
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+
+
+ } + else + { + + } +
+ +@code +{ + private int ViewIndex = 0; + + private async Task SetViewIndex(int index) + { + ViewIndex = index; + await InvokeAsync(StateHasChanged); + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Layouts/DefaultLayout.razor b/Moonlight/Shared/Layouts/DefaultLayout.razor index 13e9f0c4..025226bd 100644 --- a/Moonlight/Shared/Layouts/DefaultLayout.razor +++ b/Moonlight/Shared/Layouts/DefaultLayout.razor @@ -1,4 +1,6 @@ -
+@using Moonlight.Shared.Components.Partials.LiveChat + +
@@ -9,7 +11,7 @@
@ChildContent - +