forked from adam/discord-bot-shtik
Compare commits
3 Commits
5eeec24069
...
e0c7bdb35f
Author | SHA1 | Date | |
---|---|---|---|
e0c7bdb35f | |||
9648ea563b | |||
1d73fe0be8 |
@ -11,6 +11,9 @@ public class User
|
||||
public Guid Id { 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
|
||||
{
|
||||
get
|
||||
|
@ -24,8 +24,16 @@ public class UsersController : Controller
|
||||
}
|
||||
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 ?
|
||||
View(await _db.Users.Include(u => u.Accounts).FirstAsync(u => u.Id == id)) :
|
||||
View(user) :
|
||||
Problem("Entity set '_db.Users' is null.");
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
<td>@(ThisChannel.SubChannels?.Count ?? 0)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Users</th>
|
||||
<th scope="row">Accounts</th>
|
||||
<td>@(ThisChannel.Users?.Count ?? 0)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -109,5 +109,12 @@
|
||||
console.log(channelNow);
|
||||
return channelNow;
|
||||
}
|
||||
function getTree() {
|
||||
var tree = @Html.Raw(ViewData["treeString"]);
|
||||
console.log(tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
$('#tree').bstreeview({ data: getTree() });
|
||||
</script>
|
||||
}
|
@ -1,21 +1,86 @@
|
||||
@model User
|
||||
@using Newtonsoft.Json
|
||||
@using System.Text
|
||||
@{
|
||||
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>
|
||||
|
||||
<div class="accounts">
|
||||
@foreach (var acc in Model.Accounts)
|
||||
<script type="text/javascript">
|
||||
@{
|
||||
var userAsString = JsonConvert.SerializeObject(Model, new JsonSerializerSettings
|
||||
{
|
||||
<div class="account @acc.Protocol">
|
||||
<div class="protocol-icon"> </div>
|
||||
@Html.DisplayFor(acc => acc.DisplayName)
|
||||
<a asp-controller="Accounts" asp-action="Details" asp-route-id="@acc.Id">Details</a>
|
||||
</div>
|
||||
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\\\"> </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() {
|
||||
@{
|
||||
sb = new StringBuilder();
|
||||
sb.Append("[{text: \"permission tags\", \"expanded\":true, nodes: [");
|
||||
first = true;
|
||||
for(int i = 0; i < 1; i++)
|
||||
{
|
||||
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>
|
||||
|
@ -2,10 +2,10 @@
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
|
||||
function testfunct(caller){
|
||||
console.log("[gibberish]");
|
||||
console.log(caller);
|
||||
function Account(displayName, accountId, protocol){
|
||||
this.displayName = displayName;
|
||||
this.accountId = accountId;
|
||||
this.protocol = protocol;
|
||||
}
|
||||
//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?
|
||||
|
Loading…
Reference in New Issue
Block a user