users in treeview
This commit is contained in:
parent
b4b5544ec4
commit
43eaa5ad0d
@ -27,7 +27,8 @@ public class HomeController : Controller
|
|||||||
sb.Append("{text: \"channels\", nodes: [");
|
sb.Append("{text: \"channels\", nodes: [");
|
||||||
|
|
||||||
var first = true;
|
var first = true;
|
||||||
foreach (var topLevelChannel in _db.Channels.Where(x => x.ParentChannel == null))
|
var topLevelChannels = _db.Channels.Where(x => x.ParentChannel == null);
|
||||||
|
foreach (var topLevelChannel in topLevelChannels)
|
||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
@ -66,7 +67,7 @@ public class HomeController : Controller
|
|||||||
}
|
}
|
||||||
if (allAccounts.Any())
|
if (allAccounts.Any())
|
||||||
{
|
{
|
||||||
sb.Append("{text: \"orphaned accounts\", nodes: [");
|
sb.Append("{text: \"channelless accounts\", nodes: [");
|
||||||
first = true;
|
first = true;
|
||||||
foreach (var acc in allAccounts)
|
foreach (var acc in allAccounts)
|
||||||
{
|
{
|
||||||
@ -82,6 +83,31 @@ public class HomeController : Controller
|
|||||||
}
|
}
|
||||||
sb.Append("]}");
|
sb.Append("]}");
|
||||||
}
|
}
|
||||||
|
var users = _db.Users.ToList();
|
||||||
|
if(topLevelChannels.Any() && users.Any())
|
||||||
|
{
|
||||||
|
sb.Append(',');
|
||||||
|
}
|
||||||
|
if(users.Any())
|
||||||
|
{
|
||||||
|
sb.Append("{text: \"users\", nodes: [");
|
||||||
|
first=true;
|
||||||
|
//refresh list; we'll be knocking them out again in serializeUser
|
||||||
|
allAccounts = _db.Accounts.ToList();
|
||||||
|
foreach(var user in users)
|
||||||
|
{
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(',');
|
||||||
|
}
|
||||||
|
serializeUser(ref sb, ref allAccounts, user);
|
||||||
|
}
|
||||||
|
sb.Append("]}");
|
||||||
|
}
|
||||||
sb.Append("]");
|
sb.Append("]");
|
||||||
ViewData.Add("treeString", sb.ToString());
|
ViewData.Add("treeString", sb.ToString());
|
||||||
return View("Index");
|
return View("Index");
|
||||||
@ -146,7 +172,7 @@ public class HomeController : Controller
|
|||||||
sb.Append($"{{\"text\": \"{currentUser.DisplayName}\", ");
|
sb.Append($"{{\"text\": \"{currentUser.DisplayName}\", ");
|
||||||
var ownedAccounts = allAccounts.Where(a => a.IsUser == currentUser);
|
var ownedAccounts = allAccounts.Where(a => a.IsUser == currentUser);
|
||||||
sb.Append("nodes: [");
|
sb.Append("nodes: [");
|
||||||
sb.Append($"{{\"text\": \"owned accounts:\", \"nodes\": [");
|
sb.Append($"{{\"text\": \"owned accounts:\", \"expanded\":true, \"nodes\": [");
|
||||||
if (ownedAccounts != null)
|
if (ownedAccounts != null)
|
||||||
{
|
{
|
||||||
foreach (var acc in ownedAccounts)
|
foreach (var acc in ownedAccounts)
|
||||||
|
@ -7,51 +7,7 @@ tree above.
|
|||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function getTree() {
|
function getTree() {
|
||||||
// Some logic to retrieve, or generate tree structure
|
|
||||||
var tree = @Html.Raw(ViewData["treeString"]);
|
var tree = @Html.Raw(ViewData["treeString"]);
|
||||||
console.log(tree);
|
|
||||||
@* var channels = {text: "channels", nodes: []};
|
|
||||||
@{
|
|
||||||
var doThing = (currentChannel) => {};
|
|
||||||
foreach(Channel c in ViewData["Channels"])
|
|
||||||
{
|
|
||||||
channels.push(currentChannel);
|
|
||||||
}
|
|
||||||
} *@
|
|
||||||
var throwaway =
|
|
||||||
[
|
|
||||||
{
|
|
||||||
text: "Parent 1",
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
text: "Child 1",
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
text: "Grandchild 1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Grandchild 2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Child 2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Parent 2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Parent 3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Parent 4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Parent 5"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user