forked from adam/discord-bot-shtik
Adam R Grey
e0c7bdb35f
Some checks failed
gitea/vassago/pipeline/head There was a failure building this commit
87 lines
3.0 KiB
Plaintext
87 lines
3.0 KiB
Plaintext
@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>
|
|
|
|
|
|
@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;
|
|
}
|
|
|
|
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>
|
|
}
|