From 69cfeace82243d810c653f6573f0eda2c85556cc Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Tue, 21 Mar 2023 18:25:01 +0100 Subject: [PATCH] Added user edit form. Fixed edit link --- Moonlight/Shared/Views/Admin/Users/Edit.razor | 187 ++++++++++++++++++ .../Shared/Views/Admin/Users/Index.razor | 2 +- Moonlight/resources/lang/de_de.lang | 9 + 3 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 Moonlight/Shared/Views/Admin/Users/Edit.razor diff --git a/Moonlight/Shared/Views/Admin/Users/Edit.razor b/Moonlight/Shared/Views/Admin/Users/Edit.razor new file mode 100644 index 0000000..581400f --- /dev/null +++ b/Moonlight/Shared/Views/Admin/Users/Edit.razor @@ -0,0 +1,187 @@ +@page "/admin/users/edit/{Id:int}" +@using Moonlight.App.Repositories +@using Moonlight.App.Database.Entities +@using Moonlight.App.Models.Misc +@using Moonlight.App.Services +@using Moonlight.App.Services.Interop +@using Moonlight.App.Services.Sessions + +@inject UserRepository UserRepository +@inject SessionService SessionService +@inject ToastService ToastService +@inject SmartTranslateService SmartTranslateService + + + + @if (User == null) + { +
+ No user with this id found +
+ } + else + { +
+
+

+ + Manage user @(User.Email) + +

+
+
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + +
+
+
+
+ + Cancel + + + +
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ } +
+
+ +@code +{ + [Parameter] + public int Id { get; set; } + + private User? User; + + private Task Load(LazyLoader arg) + { + User = UserRepository.Get().FirstOrDefault(x => x.Id == Id); + + return Task.CompletedTask; + } + + private async Task UpdateStatus() + { + var user = UserRepository.Get().FirstOrDefault(x => x.Id == User!.Id)!; + user.Status = User!.Status; + UserRepository.Update(user); + + SessionService.ReloadUserSessions(User); + + await ToastService.Success(SmartTranslateService.Translate("Successfully updated user")); + } + + private async Task Update() + { + UserRepository.Update(User!); + + await ToastService.Success(SmartTranslateService.Translate("Successfully updated user")); + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Users/Index.razor b/Moonlight/Shared/Views/Admin/Users/Index.razor index b034f6a..b4d9324 100644 --- a/Moonlight/Shared/Views/Admin/Users/Index.razor +++ b/Moonlight/Shared/Views/Admin/Users/Index.razor @@ -41,7 +41,7 @@ diff --git a/Moonlight/resources/lang/de_de.lang b/Moonlight/resources/lang/de_de.lang index fe06631..485272e 100644 --- a/Moonlight/resources/lang/de_de.lang +++ b/Moonlight/resources/lang/de_de.lang @@ -384,3 +384,12 @@ Change power state for;Change power state for to;to Stop all servers;Stop all servers Do you really want to stop all running servers?;Do you really want to stop all running servers? +Manage ;Manage +Manage user ;Manage user +Reloading;Reloading +Update;Update +Updating;Updating +Successfully updated user;Successfully updated user +Discord id;Discord id +Discord username;Discord username +Discord discriminator;Discord discriminator