Skip to content

Commit

Permalink
treegrid
Browse files Browse the repository at this point in the history
  • Loading branch information
magicdict committed Sep 19, 2016
1 parent 54fa699 commit 4739a41
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 63 deletions.
169 changes: 107 additions & 62 deletions MongoColaWebAdmin/Views/Home/MainPanel.cshtml
Original file line number Diff line number Diff line change
@@ -1,62 +1,107 @@
@using MongoUtility.Core;
@using System.Linq;
@using System.Linq.Expressions;
@using MongoDB.Bson;
@{
ViewData["Title"] = "Home Page";

var ConnectionName = ViewData["ConnectionName"];
var config = MongoConnectionConfig.MongoConfig.ConnectionList[ConnectionName.ToString()];
var mongoClient = RuntimeMongoDbContext.CreateMongoClient(ref config);
var DataBaseList = GetConnectionInfo.GetDatabaseList(mongoClient);
DataBaseList.Sort((x, y) =>
{
return x.GetElement("name").Value.ToString().CompareTo(y.GetElement("name").Value.ToString());
}
);
}



<br />
<br />
<p class="alert alert-info">
@ViewData["ConnectionName"]
</p>
<br />
<div>
<div id="jstree_demo_div">
<ul>
@foreach (var db in DataBaseList)
{
<li>
@db.GetElement("name").Value.ToString()
<ul>
@{
var ColList = GetConnectionInfo.GetCollectionList(mongoClient, db.GetElement("name").Value.ToString());
ColList.Sort((x, y) =>
{
return x.GetElement("name").Value.ToString().CompareTo(y.GetElement("name").Value.ToString());
}
);
}
@foreach (var col in ColList)
{
var ColInfo = GetConnectionInfo.GetCollectionInfo(mongoClient, db.GetElement("name").Value.ToString(), col.GetElement("name").Value.ToString());
Expression<Func<BsonDocument, bool>> countfun = x => true;
<li>
@col.GetElement("name").Value.ToString()
(@ColInfo.Count(countfun).ToString())
</li>
}
</ul>
</li>
}
</ul>
</div>
</div>
@section scripts{
<script type="text/javascript">
$(function () { $('#jstree_demo_div').jstree(); });
</script>
}
@using MongoUtility.Core;
@using System.Linq.Expressions;
@using MongoDB.Bson;
@using System.Linq;
@{
ViewData["Title"] = "Home Page";

var ConnectionName = ViewData["ConnectionName"];
var config = MongoConnectionConfig.MongoConfig.ConnectionList[ConnectionName.ToString()];
var mongoClient = RuntimeMongoDbContext.CreateMongoClient(ref config);
var DataBaseList = GetConnectionInfo.GetDatabaseList(mongoClient);
DataBaseList.Sort((x, y) =>
{
return x.GetElement("name").Value.ToString().CompareTo(y.GetElement("name").Value.ToString());
});
}
<br />
<br />
<p class="alert alert-info">
@ViewData["ConnectionName"]
</p>
<br />
<div>
<div id="jstree" class="col-md-4">
<ul>
@foreach (var db in DataBaseList)
{
<li>
@db.GetElement("name").Value.ToString()
<ul>
@{
var ColList = GetConnectionInfo.GetCollectionList(mongoClient, db.GetElement("name").Value.ToString());
ColList.Sort((x, y) =>
{
return x.GetElement("name").Value.ToString().CompareTo(y.GetElement("name").Value.ToString());
}
);
}
@foreach (var col in ColList)
{
var ColInfo = GetConnectionInfo.GetCollectionInfo(mongoClient, db.GetElement("name").Value.ToString(), col.GetElement("name").Value.ToString());
Expression<Func<BsonDocument, bool>> countfun = x => true;
<li>
@col.GetElement("name").Value.ToString()
(@ColInfo.Count(countfun).ToString())
<ul>
@{
var Indexes = GetConnectionInfo.GetColIndexInfo(mongoClient, db.GetElement("name").Value.ToString(), col.GetElement("name").Value.ToString());
foreach (var Index in Indexes)
{
<li>
@Index.GetElement("name").Value.ToString()
<ul>
@foreach (var item in Index.Elements)
{
<li>@item.Name : @item.Value</li>
}
</ul>
</li>
}
}
</ul>
</li>
}
</ul>
</li>
}
</ul>
</div>
<div id="treegrid" class="col-md-8">

</div>
</div>
@section scripts{
<script src="~/lib/treegrid/TreeGrid.js" type="text/javascript"></script>
<link href="~/lib/treegrid/TreeGrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () { $('#jstree').jstree(); });
</script>
<script type="text/javascript">
var config = {
id: "tg1",
//width: "800",
renderTo: "treegrid",
headerAlign: "left",
headerHeight: "30",
dataAlign: "left",
indentation: "20",
folderOpenIcon: "/lib/treegrid/images/folderOpen.gif",
folderCloseIcon: "/lib/treegrid/images/folderClose.gif",
defaultLeafIcon: "/lib/treegrid/images/defaultLeaf.gif",
hoverRowBackground: "false",
folderColumnIndex: "0",
itemClick: "itemClickEvent",
columns: [
{ headerText: "", headerAlign: "center", dataAlign: "center", width: "20" },
{ headerText: "名称", dataField: "name", headerAlign: "center"},
{ headerText: "", dataField: "value", headerAlign: "center", dataAlign: "center", width: "100" },
{ headerText: "类型", dataField: "type", headerAlign: "center", dataAlign: "center", width: "100" }
],
data:[]
};
//创建一个组件对象
var treeGrid = new TreeGrid(config);
treeGrid.show();
</script>
}
Expand Down
4 changes: 3 additions & 1 deletion MongoColaWebAdmin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"runtimes": { "win7-x64": {} },
"runtimes": {
"win7-x64": {}
},

"frameworks": {
"netcoreapp1.0": {
Expand Down
47 changes: 47 additions & 0 deletions MongoColaWebAdmin/wwwroot/lib/treegrid/TreeGrid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
body{
font-size:11px;
}
.TreeGrid{
border-collapse: collapse;
font-size: 11px;
border: 1px solid #778899;
}

.TreeGrid .header{
background-color: #87CEEB;
font-size: 11px;
font-weight: 600;
}

.TreeGrid td{
border: 1px solid #E6E6FA;
padding: 4px 3px 2px 3px;
}

.TreeGrid a{
text-decoration: underline;
color: black;
}

.TreeGrid a:hover{
color: blue;
}

.TreeGrid .image_hand{
border: 0;
cursor:hand;
align:absmiddle;
}

.TreeGrid .image_nohand{
border: 0;
align:absmiddle;
}

.TreeGrid .row_hover{
background-color: #E6E6FA;
}

.TreeGrid .row_active{
background-color: #E0FFFF;
}
Loading

0 comments on commit 4739a41

Please sign in to comment.