2016-10-21 16:35:26 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
2017-04-03 15:56:17 +08:00
|
|
|
|
using Bootstrap.Security;
|
2016-11-03 19:52:35 +08:00
|
|
|
|
using System;
|
2016-10-21 16:35:26 +08:00
|
|
|
|
using System.Collections.Generic;
|
2016-10-26 14:02:40 +08:00
|
|
|
|
using System.Linq;
|
2016-10-21 16:35:26 +08:00
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Models
|
|
|
|
|
{
|
|
|
|
|
public class NavigatorBarModel : HeaderBarModel
|
|
|
|
|
{
|
2016-11-03 19:52:35 +08:00
|
|
|
|
public NavigatorBarModel(string url)
|
2016-10-21 16:35:26 +08:00
|
|
|
|
{
|
2017-04-03 15:56:17 +08:00
|
|
|
|
Navigations = BootstrapMenu.RetrieveSystemMenus(UserName);
|
2017-03-03 13:34:53 +08:00
|
|
|
|
Applications = DictHelper.RetrieveApps();
|
2016-11-12 18:23:03 +08:00
|
|
|
|
ActiveMenu(null, Navigations.ToList(), url);
|
2016-11-03 19:52:35 +08:00
|
|
|
|
HomeUrl = "~/Admin/Index";
|
2016-10-21 16:35:26 +08:00
|
|
|
|
}
|
2016-11-12 18:23:03 +08:00
|
|
|
|
|
2017-04-03 15:56:17 +08:00
|
|
|
|
private void ActiveMenu(BootstrapMenu parent, List<BootstrapMenu> menus, string url)
|
2016-11-12 18:23:03 +08:00
|
|
|
|
{
|
|
|
|
|
menus.ForEach(m =>
|
|
|
|
|
{
|
|
|
|
|
m.Active = m.Url.Equals(url, StringComparison.OrdinalIgnoreCase) ? "active" : "";
|
|
|
|
|
ActiveMenu(m, m.Menus.ToList(), url);
|
|
|
|
|
if (parent != null && m.Active != "") parent.Active = m.Active;
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2017-04-03 15:56:17 +08:00
|
|
|
|
public IEnumerable<BootstrapMenu> Navigations { get; private set; }
|
2017-03-03 13:34:53 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2017-03-30 15:32:49 +08:00
|
|
|
|
public IEnumerable<KeyValuePair<string, string>> Applications { get; private set; }
|
2016-10-21 16:35:26 +08:00
|
|
|
|
}
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|