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 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
|
||||||
|
@ -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.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
||||||
}
|
}
|
@ -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">
|
|
||||||
@{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTagsTree() {
|
</div>
|
||||||
@{
|
|
||||||
sb = new StringBuilder();
|
<div class="accounts">
|
||||||
sb.Append("[{text: \"permission tags\", \"expanded\":true, nodes: [");
|
@foreach (var acc in Model.Accounts)
|
||||||
first = true;
|
{
|
||||||
for(int i = 0; i < 1; i++)
|
<div class="account @acc.Protocol">
|
||||||
{
|
<div class="protocol-icon"> </div>
|
||||||
if(!first)
|
@Html.DisplayFor(acc => acc.DisplayName)
|
||||||
sb.Append(',');
|
<a asp-controller="Accounts" asp-action="Details" asp-route-id="@acc.Id">Details</a>
|
||||||
sb.Append($"{{text: \"<input type=\\\"checkbox\\\" > is goated (w/ sauce)</input>\"}}");
|
</div>
|
||||||
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.
|
// 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?
|
||||||
|
Loading…
Reference in New Issue
Block a user