get to channel details

This commit is contained in:
Adam R Grey 2024-06-02 17:13:15 -04:00
parent 43eaa5ad0d
commit 2f7bc2c0ea
3 changed files with 74 additions and 5 deletions

View File

@ -24,9 +24,17 @@ public class ChannelsController : Controller
} }
public async Task<IActionResult> Details(Guid id) public async Task<IActionResult> Details(Guid id)
{ {
return _db.Channels != null ? if(_db.Channels == null)
View(await _db.Channels.Include(u => u.ParentChannel).FirstAsync(u => u.Id == id)) : return Problem("Entity set '_db.Channels' is null.");
Problem("Entity set '_db.Channels' is null."); var channel = await _db.Channels.Include(u => u.ParentChannel).FirstAsync(u => u.Id == id);
var walker = channel;
while(walker != null)
{
ViewData["breadcrumbs"] = $"<a href=\"{Url.ActionLink(action: "Details", controller: "Channels", values: new {id = walker.Id})}\">{walker.DisplayName}</a>/" +
ViewData["breadcrumbs"];
walker = walker.ParentChannel;
}
return View(channel);
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

View File

@ -115,7 +115,8 @@ public class HomeController : Controller
private void serializeChannel(ref StringBuilder sb, ref List<Channel> allChannels, ref List<Account> allAccounts, Channel currentChannel) private void serializeChannel(ref StringBuilder sb, ref List<Channel> allChannels, ref List<Account> allAccounts, Channel currentChannel)
{ {
allChannels.Remove(currentChannel); allChannels.Remove(currentChannel);
sb.Append($"{{\"text\": \"{currentChannel.DisplayName}\""); //"but adam", you say, "there's an href attribute, why make a link?" because that makes the entire bar a link, and trying to expand the node will probably click the link
sb.Append($"{{\"text\": \"<a href=\\\"{Url.ActionLink(action: "Details", controller: "Channels", values: new {id = currentChannel.Id})}\\\">{currentChannel.DisplayName}</a>\"");
var theseAccounts = allAccounts.Where(a => a.SeenInChannel?.Id == currentChannel.Id); var theseAccounts = allAccounts.Where(a => a.SeenInChannel?.Id == currentChannel.Id);
allAccounts.RemoveAll(a => a.SeenInChannel?.Id == currentChannel.Id); allAccounts.RemoveAll(a => a.SeenInChannel?.Id == currentChannel.Id);
var first = true; var first = true;

View File

@ -0,0 +1,60 @@
@model Channel
@Html.Raw(ViewData["breadcrumbs"])
<table class="table">
<tbody>
<tr>
<th scope="row">Display Name</th>
<td>@Model.DisplayName</td>
</tr>
<tr>
<th scope="row">Channel type</th>
<td>@Model.ChannelType</td>
</tr>
<tr>
<th scope="row">Lewdness Filter Level</th>
<td>@Model.LewdnessFilterLevel</td>
</tr>
<tr>
<th scope="row">Links Allowed</th>
<td>@Model.LinksAllowed</td>
</tr>
<tr>
<th scope="row">Lineage summary</th>
<td>@Model.LineageSummary</td>
</tr>
<tr>
<th scope="row">max attachment bytes</th>
<td>@Model.MaxAttachmentBytes (i hear there's "ByteSize")</td>
</tr>
<tr>
<th scope="row">max message length</th>
<td>@Model.MaxTextChars</td>
</tr>
<tr>
<th scope="row">Meanness Filter Level</th>
<td>@Model.MeannessFilterLevel</td>
</tr>
<tr>
<th scope="row">Messages (count)</th>
<td>@(Model.Messages?.Count ?? 0)</td>
</tr>
<tr>
<th scope="row">Protocol</th>
<td>@Model.Protocol</td>
</tr>
<tr>
<th scope="row">Reactions Possible</th>
<td>@Model.ReactionsPossible</td>
</tr>
<tr>
<th scope="row">Sub Channels</th>
<td>@Model.SubChannels</td>
</tr>
<tr>
<th scope="row">Users</th>
<td>@Model.Users</td>
</tr>
</tbody>
</table>