forked from adam/discord-bot-shtik
Compare commits
No commits in common. "e0c7bdb35f84387ce933e4452b8766ff72953548" and "5eeec240691f95a306ce0ac2170508d18a6a73d2" have entirely different histories.
e0c7bdb35f
...
5eeec24069
@ -11,9 +11,6 @@ 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,16 +24,8 @@ 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(user) :
|
||||
View(await _db.Users.Include(u => u.Accounts).FirstAsync(u => u.Id == id)) :
|
||||
Problem("Entity set '_db.Users' is null.");
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
<td>@(ThisChannel.SubChannels?.Count ?? 0)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Accounts</th>
|
||||
<th scope="row">Users</th>
|
||||
<td>@(ThisChannel.Users?.Count ?? 0)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -109,12 +109,5 @@
|
||||
console.log(channelNow);
|
||||
return channelNow;
|
||||
}
|
||||
function getTree() {
|
||||
var tree = @Html.Raw(ViewData["treeString"]);
|
||||
console.log(tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
$('#tree').bstreeview({ data: getTree() });
|
||||
</script>
|
||||
}
|
@ -1,86 +1,21 @@
|
||||
@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 />
|
||||
|
||||
@section Scripts{
|
||||
|
||||
<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\\\"> </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="permissions">
|
||||
|
||||
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>
|
||||
|
||||
<div class="accounts">
|
||||
@foreach (var acc in Model.Accounts)
|
||||
{
|
||||
<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>
|
||||
}
|
||||
</div>
|
||||
|
@ -2,10 +2,10 @@
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
function Account(displayName, accountId, protocol){
|
||||
this.displayName = displayName;
|
||||
this.accountId = accountId;
|
||||
this.protocol = protocol;
|
||||
|
||||
function testfunct(caller){
|
||||
console.log("[gibberish]");
|
||||
console.log(caller);
|
||||
}
|
||||
//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