This repository has been archived on 2023-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
discord-bot-shtik/WebInterface/Views/Users/Details.cshtml

87 lines
3.0 KiB
Plaintext
Raw Normal View History

2023-12-01 09:49:21 -05:00
@model User
2024-07-07 15:27:48 -04:00
@using Newtonsoft.Json
2024-07-07 14:22:10 -04:00
@using System.Text
2023-12-01 09:49:21 -05:00
@{
ViewData["Title"] = "User details";
}
2024-07-07 14:22:10 -04:00
<table class="table">
<tbody>
<tr>
2024-07-07 15:27:48 -04:00
<td><input type="text" id="displayName" value="@Model.DisplayName"></input> <button onclick="patchModel(jsonifyUser(), @Html.Raw("'/api/Users/'"))">update</button></td>
2024-07-07 14:22:10 -04:00
</tr>
<tr>
<td>
<div id="accountsTree"></div>
</td>
</tr>
<tr>
<td>
<div id="tagsTree"></div>
</td>
</tr>
</tbody>
</table>
2024-07-07 15:27:48 -04:00
<a asp-controller="Accounts" asp-action="Details" asp-route-id="1">placeholderlink</a>
2023-12-01 09:49:21 -05:00
2024-07-07 14:22:10 -04:00
@section Scripts{
<script type="text/javascript">
2024-07-07 15:27:48 -04:00
@{
var userAsString = JsonConvert.SerializeObject(Model, new JsonSerializerSettings
2024-07-07 14:22:10 -04:00
{
2024-07-07 15:27:48 -04:00
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;
2024-07-07 14:22:10 -04:00
}
2024-07-07 15:27:48 -04:00
function getAccountsTree() {
2024-07-07 14:22:10 -04:00
@{
var sb = new StringBuilder();
sb.Append("[{text: \"accounts\", \"expanded\":true, nodes: [");
var first = true;
foreach (var acc in Model.Accounts)
{
if(!first)
sb.Append(',');
2024-07-07 15:27:48 -04:00
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>\"}}");
2024-07-07 14:22:10 -04:00
first=false;
}
2024-07-07 15:27:48 -04:00
sb.Append("]}]");
2024-07-07 14:22:10 -04:00
}
2024-07-07 15:27:48 -04:00
console.log(@Html.Raw(sb.ToString()));
2024-07-07 14:22:10 -04:00
var tree = @Html.Raw(sb.ToString());
return tree;
}
2023-12-01 09:49:21 -05:00
2024-07-07 15:27:48 -04:00
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/')}});
2024-07-07 14:22:10 -04:00
</script>
2023-12-01 09:49:21 -05:00
}