mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding a Dashboard module to support a (initially) simple Admin Dashboard
- Added Dashboard module to Orchard.Core - Updated "Admin" link in User partials to point to the Admin Dashboard (and consolidated partials) - Changed the admin menu to not hardcode the Dashboard item in the template. Instead all items come from admin menu item registration (hence the weird "Manage Orchard" sub-item) --HG-- branch : dev
This commit is contained in:
13
src/Orchard.Web/Core/Dashboard/AdminMenu.cs
Normal file
13
src/Orchard.Web/Core/Dashboard/AdminMenu.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.Core.Dashboard {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add("Dashboard", "0",
|
||||
menu => menu.Add("Manage Orchard", "0", item => item.Action("Index", "Admin", new { area = "Dashboard" }).Permission(StandardPermissions.AccessAdminPanel)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Core.Dashboard.Controllers {
|
||||
public class AdminController : Controller {
|
||||
public ActionResult Index() {
|
||||
return View(new AdminViewModel());
|
||||
}
|
||||
}
|
||||
}
|
1
src/Orchard.Web/Core/Dashboard/Module.txt
Normal file
1
src/Orchard.Web/Core/Dashboard/Module.txt
Normal file
@@ -0,0 +1 @@
|
||||
name: Dashboard
|
33
src/Orchard.Web/Core/Dashboard/Routes.cs
Normal file
33
src/Orchard.Web/Core/Dashboard/Routes.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.Mvc.Routes;
|
||||
|
||||
namespace Orchard.Core.Dashboard {
|
||||
public class Routes : IRouteProvider {
|
||||
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
||||
foreach (var routeDescriptor in GetRoutes())
|
||||
routes.Add(routeDescriptor);
|
||||
}
|
||||
|
||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||
return new[] {
|
||||
new RouteDescriptor {
|
||||
Priority = -5,
|
||||
Route = new Route(
|
||||
"Admin",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Dashboard"},
|
||||
{"controller", "admin"},
|
||||
{"action", "index"}
|
||||
},
|
||||
new RouteValueDictionary(),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Dashboard"}
|
||||
},
|
||||
new MvcRouteHandler())
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
4
src/Orchard.Web/Core/Dashboard/Views/Admin/Index.ascx
Normal file
4
src/Orchard.Web/Core/Dashboard/Views/Admin/Index.ascx
Normal file
@@ -0,0 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<AdminViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<h1><%=Html.TitleForPage(T("Orchard Admin").ToString())%></h1>
|
||||
<p><%=T("Insert admin text here -> ·") %></p>
|
34
src/Orchard.Web/Core/Dashboard/Views/Web.config
Normal file
34
src/Orchard.Web/Core/Dashboard/Views/Web.config
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<add path="*" verb="*"
|
||||
type="System.Web.HttpNotFoundHandler"/>
|
||||
</httpHandlers>
|
||||
|
||||
<!--
|
||||
Enabling request validation in view pages would cause validation to occur
|
||||
after the input has already been processed by the controller. By default
|
||||
MVC performs request validation before a controller processes the input.
|
||||
To change this behavior apply the ValidateInputAttribute to a
|
||||
controller or action.
|
||||
-->
|
||||
<pages
|
||||
validateRequest="false"
|
||||
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
|
||||
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<controls>
|
||||
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
|
||||
</controls>
|
||||
</pages>
|
||||
</system.web>
|
||||
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false"/>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
@@ -84,6 +84,9 @@
|
||||
<Compile Include="Common\ViewModels\BodyEditorViewModel.cs" />
|
||||
<Compile Include="Common\ViewModels\RoutableEditorViewModel.cs" />
|
||||
<Compile Include="Common\ViewModels\OwnerEditorViewModel.cs" />
|
||||
<Compile Include="Dashboard\AdminMenu.cs" />
|
||||
<Compile Include="Dashboard\Controllers\AdminController.cs" />
|
||||
<Compile Include="Dashboard\Routes.cs" />
|
||||
<Compile Include="Feeds\Controllers\FeedController.cs" />
|
||||
<Compile Include="Feeds\IFeedManager.cs" />
|
||||
<Compile Include="Feeds\Rss\Routes.cs" />
|
||||
@@ -212,6 +215,8 @@
|
||||
<Content Include="Themes\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Dashboard\Module.txt" />
|
||||
<Content Include="Dashboard\Views\Admin\Index.ascx" />
|
||||
<Content Include="HomePage\Module.txt" />
|
||||
<Content Include="Navigation\Views\Admin\Index.ascx" />
|
||||
<Content Include="Navigation\Views\EditorTemplates\Parts\Navigation.EditMenuPart.ascx" />
|
||||
@@ -221,6 +226,9 @@
|
||||
<Content Include="Themes\Views\EditorTemplates\Items\ContentItem.ascx" />
|
||||
<Content Include="Themes\Views\DisplayTemplates\Items\ContentItem.ascx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Dashboard\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Scheduling\Controllers\" />
|
||||
</ItemGroup>
|
||||
|
@@ -3,8 +3,8 @@
|
||||
<div id="logindisplay">
|
||||
<% if (Request.IsAuthenticated) { %>
|
||||
<%=T("Welcome, <strong>{0}</strong>!", Html.Encode(Page.User.Identity.Name)) %>
|
||||
<%=Html.Link(T("Admin").ToString(), "/admin/blogs") %> /
|
||||
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" }) %>
|
||||
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" })%>
|
||||
| <%= Html.ActionLink("Admin", "Index", new {Area = "Dashboard", Controller = "Admin"})%>
|
||||
<% } else { %>
|
||||
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
|
||||
<% } %>
|
||||
|
@@ -199,7 +199,6 @@
|
||||
<Content Include="Themes\Green\Views\Footer.ascx" />
|
||||
<Content Include="Themes\Green\Views\Layout.ascx" />
|
||||
<Content Include="Themes\Green\Views\ListOfComments.ascx" />
|
||||
<Content Include="Themes\Green\Views\User.ascx" />
|
||||
<Content Include="Themes\SafeMode\Styles\images\backgroundHeader.gif" />
|
||||
<Content Include="Themes\SafeMode\Styles\images\backgroundVines.gif" />
|
||||
<Content Include="Themes\SafeMode\Styles\images\orchardLogo.gif" />
|
||||
|
@@ -1,10 +0,0 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<object>" %>
|
||||
<div id="logindisplay">
|
||||
<% if (Request.IsAuthenticated) { %>
|
||||
<%=_Encoded("Welcome")%> <strong><%=Html.Encode(Page.User.Identity.Name) %></strong>!
|
||||
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" })%>
|
||||
| <%= Html.ActionLink("Admin", "List", new {Area = "Orchard.Blogs", Controller = "BlogAdmin"})%>
|
||||
<% } else { %>
|
||||
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl })%>
|
||||
<% } %>
|
||||
</div>
|
@@ -1,7 +1,6 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<AdminViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<ul id="navigation" role="navigation">
|
||||
<li class="first"><h3><span><%=_Encoded("Dashboard")%></span></h3></li>
|
||||
<%if (Model.AdminMenu != null) {
|
||||
foreach (var menuSection in Model.AdminMenu) {
|
||||
// todo: (heskew) need some help(er)
|
||||
@@ -9,8 +8,14 @@
|
||||
var sectionHeaderMarkup = firstSectionItem != null
|
||||
? Html.ActionLink(menuSection.Text, (string)firstSectionItem.RouteValues["action"], firstSectionItem.RouteValues).ToHtmlString()
|
||||
: string.Format("<span>{0}</span>", Html.Encode(menuSection.Text));
|
||||
var classification = "";
|
||||
if (menuSection == Model.AdminMenu.First())
|
||||
classification = "first ";
|
||||
if (menuSection == Model.AdminMenu.Last())
|
||||
classification += "last ";
|
||||
|
||||
%>
|
||||
<li><h3><%=sectionHeaderMarkup %></h3><ul><%foreach (var menuItem in menuSection.Items) { %>
|
||||
<li<%=!string.IsNullOrEmpty(classification) ? string.Format(" class=\"{0}\"", classification.TrimEnd()) : "" %>><h3><%=sectionHeaderMarkup %></h3><ul><%foreach (var menuItem in menuSection.Items) { %>
|
||||
<li><%=Html.ActionLink(menuItem.Text, (string)menuItem.RouteValues["action"], menuItem.RouteValues)%></li>
|
||||
<%} %></ul></li>
|
||||
<%
|
||||
|
Reference in New Issue
Block a user