Compare commits

..

No commits in common. "e0c7bdb35f84387ce933e4452b8766ff72953548" and "5eeec240691f95a306ce0ac2170508d18a6a73d2" have entirely different histories.

5 changed files with 19 additions and 102 deletions

View File

@ -11,9 +11,6 @@ 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,16 +24,8 @@ 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(user) : View(await _db.Users.Include(u => u.Accounts).FirstAsync(u => u.Id == id)) :
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">Accounts</th> <th scope="row">Users</th>
<td>@(ThisChannel.Users?.Count ?? 0)</td> <td>@(ThisChannel.Users?.Count ?? 0)</td>
</tr> </tr>
</tbody> </tbody>
@ -109,12 +109,5 @@
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,86 +1,21 @@
@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 />
@section Scripts{ <div class="permissions">
<script type="text/javascript"> </div>
@{
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;
}
function getTagsTree() { <div class="accounts">
@{ @foreach (var acc in Model.Accounts)
sb = new StringBuilder(); {
sb.Append("[{text: \"permission tags\", \"expanded\":true, nodes: ["); <div class="account @acc.Protocol">
first = true; <div class="protocol-icon">&nbsp;</div>
for(int i = 0; i < 1; i++) @Html.DisplayFor(acc => acc.DisplayName)
{ <a asp-controller="Accounts" asp-action="Details" asp-route-id="@acc.Id">Details</a>
if(!first) </div>
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){
this.displayName = displayName; function testfunct(caller){
this.accountId = accountId; console.log("[gibberish]");
this.protocol = protocol; console.log(caller);
} }
//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?