Compare commits

...

3 Commits

Author SHA1 Message Date
e0c7bdb35f user management UI
Some checks failed
gitea/vassago/pipeline/head There was a failure building this commit
2024-07-07 15:27:48 -04:00
9648ea563b compiles, needs db update 2024-07-07 14:22:10 -04:00
1d73fe0be8 they're accounts. Maybe I should rename it in the DB. 2024-07-07 13:08:41 -04:00
5 changed files with 102 additions and 19 deletions

View File

@ -11,6 +11,9 @@ public class User
public Guid Id { get; set; } public Guid Id { get; set; }
public List<Account> Accounts { get; set; } public List<Account> Accounts { get; set; }
//if I ever get lots and lots of tags, or some automatic way to register a feature's arbitrary tags, then I can move this off.
//public bool Tag_CanTwitchSummon { get; set; }
public string DisplayName public string DisplayName
{ {
get get

View File

@ -24,8 +24,16 @@ public class UsersController : Controller
} }
public async Task<IActionResult> Details(Guid id) public async Task<IActionResult> Details(Guid id)
{ {
var user = await _db.Users
.Include(u => u.Accounts)
.FirstAsync(u => u.Id == id);
var allTheChannels = await _db.Channels.ToListAsync();
foreach(var acc in user.Accounts)
{
acc.SeenInChannel = allTheChannels.FirstOrDefault(c => c.Id == acc.SeenInChannel.Id);
}
return _db.Users != null ? return _db.Users != null ?
View(await _db.Users.Include(u => u.Accounts).FirstAsync(u => u.Id == id)) : View(user) :
Problem("Entity set '_db.Users' is null."); Problem("Entity set '_db.Users' is null.");
} }

View File

@ -81,7 +81,7 @@
<td>@(ThisChannel.SubChannels?.Count ?? 0)</td> <td>@(ThisChannel.SubChannels?.Count ?? 0)</td>
</tr> </tr>
<tr> <tr>
<th scope="row">Users</th> <th scope="row">Accounts</th>
<td>@(ThisChannel.Users?.Count ?? 0)</td> <td>@(ThisChannel.Users?.Count ?? 0)</td>
</tr> </tr>
</tbody> </tbody>
@ -109,5 +109,12 @@
console.log(channelNow); console.log(channelNow);
return channelNow; return channelNow;
} }
function getTree() {
var tree = @Html.Raw(ViewData["treeString"]);
console.log(tree);
return tree;
}
$('#tree').bstreeview({ data: getTree() });
</script> </script>
} }

View File

@ -1,21 +1,86 @@
@model User @model User
@using Newtonsoft.Json
@using System.Text
@{ @{
ViewData["Title"] = "User details"; ViewData["Title"] = "User details";
} }
<table class="table">
<tbody>
<tr>
<td><input type="text" id="displayName" value="@Model.DisplayName"></input> <button onclick="patchModel(jsonifyUser(), @Html.Raw("'/api/Users/'"))">update</button></td>
</tr>
<tr>
<td>
<div id="accountsTree"></div>
</td>
</tr>
<tr>
<td>
<div id="tagsTree"></div>
</td>
</tr>
</tbody>
</table>
<a asp-controller="Accounts" asp-action="Details" asp-route-id="1">placeholderlink</a>
User @Model.DisplayName<br />
<div class="permissions"> @section Scripts{
</div> <script type="text/javascript">
@{
var userAsString = JsonConvert.SerializeObject(Model, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
}
const userOnLoad = @Html.Raw(userAsString);
function jsonifyUser() {
var userNow = structuredClone(userOnLoad);
userNow.Accounts = null;
userNow.DisplayName = document.querySelector("#displayName").value;
//userNow.Tag_CanTwitchSummon = document.querySelector("#tagCanTwitchSummon").checked;
console.log(userNow);
return userNow;
}
function getAccountsTree() {
@{
var sb = new StringBuilder();
sb.Append("[{text: \"accounts\", \"expanded\":true, nodes: [");
var first = true;
foreach (var acc in Model.Accounts)
{
if(!first)
sb.Append(',');
sb.Append($"{{text: \"<div class=\\\"account {acc.Protocol}\\\"><div class=\\\"protocol-icon\\\">&nbsp;</div>{acc.SeenInChannel.LineageSummary}/<a href=\\\"/Accounts/Details/{acc.Id}\\\">{acc.DisplayName}</a>\"}}");
first=false;
}
sb.Append("]}]");
}
console.log(@Html.Raw(sb.ToString()));
var tree = @Html.Raw(sb.ToString());
return tree;
}
<div class="accounts"> function getTagsTree() {
@foreach (var acc in Model.Accounts) @{
{ sb = new StringBuilder();
<div class="account @acc.Protocol"> sb.Append("[{text: \"permission tags\", \"expanded\":true, nodes: [");
<div class="protocol-icon">&nbsp;</div> first = true;
@Html.DisplayFor(acc => acc.DisplayName) for(int i = 0; i < 1; i++)
<a asp-controller="Accounts" asp-action="Details" asp-route-id="@acc.Id">Details</a> {
</div> if(!first)
sb.Append(',');
sb.Append($"{{text: \"<input type=\\\"checkbox\\\" > is goated (w/ sauce)</input>\"}}");
first=false;
}
sb.Append("]}]");
}
console.log(@Html.Raw(sb.ToString()));
var tree = @Html.Raw(sb.ToString());
return tree;
}
$('#accountsTree').bstreeview({ data: getAccountsTree() });
$('#tagsTree').bstreeview({ data: getTagsTree() });
document.querySelectorAll("input[type=checkbox]").forEach(node => {node.onchange = () => {patchModel(jsonifyUser(), '/api/Users/')}});
</script>
} }
</div>

View File

@ -2,10 +2,10 @@
// for details on configuring this project to bundle and minify static web assets. // for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code. // Write your JavaScript code.
function Account(displayName, accountId, protocol){
function testfunct(caller){ this.displayName = displayName;
console.log("[gibberish]"); this.accountId = accountId;
console.log(caller); this.protocol = protocol;
} }
//todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself. //todo: figure out what the URL actually needs to be, rather than assuming you get a whole-ass server to yourself.
//you selfish fuck... What are you, fox? //you selfish fuck... What are you, fox?