diff --git a/WebInterface/Controllers/AccountsController.cs b/WebInterface/Controllers/AccountsController.cs new file mode 100644 index 0000000..09e26e6 --- /dev/null +++ b/WebInterface/Controllers/AccountsController.cs @@ -0,0 +1,35 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using vassago.Models; +using vassago.WebInterface.Models; + +namespace vassago.WebInterface.Controllers; + +public class AccountsController(ChattingContext db) : Controller +{ + private ChattingContext Database => db; + + public async Task Index() + { + return Database.Accounts != null ? + View(await Database.Accounts.ToListAsync()) : + Problem("Entity set '_db.Accounts' is null."); + } + public async Task Details(Guid id) + { + var account = await Database.Accounts + .Include(a => a.IsUser) + .Include(a => a.SeenInChannel) + .FirstAsync(a => a.Id == id); + return Database.Accounts != null ? + View(account) : + Problem("Entity set '_db.Accounts' is null."); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorPageViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } +} \ No newline at end of file diff --git a/WebInterface/Controllers/HomeController.cs b/WebInterface/Controllers/HomeController.cs index 769adcf..f0d9b00 100644 --- a/WebInterface/Controllers/HomeController.cs +++ b/WebInterface/Controllers/HomeController.cs @@ -163,7 +163,7 @@ public class HomeController : Controller } private void serializeAccount(ref StringBuilder sb, Account currentAccount) { - sb.Append($"{{\"text\": \"{currentAccount.DisplayName}\"}}"); + sb.Append($"{{\"text\": \"{currentAccount.DisplayName}\"}}"); } private void serializeUser(ref StringBuilder sb, ref List allAccounts, User currentUser) { diff --git a/WebInterface/Controllers/api/UsersController.cs b/WebInterface/Controllers/api/UsersController.cs new file mode 100644 index 0000000..c522461 --- /dev/null +++ b/WebInterface/Controllers/api/UsersController.cs @@ -0,0 +1,40 @@ +using System.Diagnostics; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using vassago.Models; +using vassago.ProtocolInterfaces.DiscordInterface; + +namespace vassago.Controllers.api; + +[Route("api/[controller]")] +[ApiController] +public class UsersController : ControllerBase +{ + private readonly ILogger _logger; + + public UsersController(ILogger logger) + { + _logger = logger; + } + + [HttpPatch] + [Produces("application/json")] + public IActionResult Patch([FromBody] User user) + { + var fromDb = Rememberer.SearchUser(u => u.Id == user.Id); + if (fromDb == null) + { + _logger.LogError($"attempt to update user {user.Id}, not found"); + return NotFound(); + } + else + { + _logger.LogDebug($"patching {user.DisplayName} (id: {user.Id})"); + } + + //TODO: settable values: display name + //fromDb.DisplayName = user.DisplayName; + Rememberer.RememberUser(fromDb); + return Ok(fromDb); + } +} \ No newline at end of file diff --git a/WebInterface/Views/Accounts/Details.cshtml b/WebInterface/Views/Accounts/Details.cshtml new file mode 100644 index 0000000..ea6a847 --- /dev/null +++ b/WebInterface/Views/Accounts/Details.cshtml @@ -0,0 +1,66 @@ +@model Account +@using Newtonsoft.Json +@using System.Text +@{ + ViewData["Title"] = "Account details"; +} + + + + + + + + + + + + + + + + +
belongs to user@Model.IsUser.DisplayName
Seen in channel
 
@Model.SeenInChannel.LineageSummary@Model.SeenInChannel.DisplayName
Permission Tags +
+
+ +@section Scripts{ + + +} diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index 8d9d549..b342938 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -1,5 +1,6 @@ @using System.ComponentModel @using Newtonsoft.Json +@using System.Text; @model Tuple @{ var ThisChannel = Model.Item1; @@ -91,7 +92,16 @@ Accounts - @(ThisChannel.Users?.Count ?? 0) + + @if((ThisChannel.Users?.Count ?? 0) > 0) + { + @Html.Raw("
"); + } + else + { + @Html.Raw("none") + } + @@ -105,9 +115,9 @@ } \ No newline at end of file diff --git a/WebInterface/Views/Users/Details.cshtml b/WebInterface/Views/Users/Details.cshtml index d127af4..ffa17f0 100644 --- a/WebInterface/Views/Users/Details.cshtml +++ b/WebInterface/Views/Users/Details.cshtml @@ -5,35 +5,37 @@ ViewData["Title"] = "User details"; } - - - - - - - - - - - + + + + + + + + + + + + + +
-
-
-
-
Display Name (here)
Accounts +
+
Permission Tags +
+
-placeholderlink - @section Scripts{ - + }