Challenges
Most Web applications have management interface is used to change the system or set of individuals, such as setting system parameters, user role management, category management, Forum moderation, profile,
and so on. Management interface development randomness is large, because there is no unified standard, design high - availability, high security and scalability of Manager brings a lot of code time.
Features
- Using Action base authorization (ABA) to control ControlPanel permission.
- DNA could load ControlPanel items in assemblies automatic at runtime.
- Supporting Site management and Personal management.
- Extending Action method to ControlPanel just by specified an attribute class.
What is ControlPanel
DNA has two kinds of Control Panel:
- SiteControlPanel - The control panel of the top website.It use to managet global settings of the DNA website,such as website settings,smtp settings,user roles, user accounts and as so on.
- MyControlPanel - The control panel of the users.It use to manage the personal settings such as profile, personal web folder, blog, threads etc.
The following screenshots are site control panel and personal control panel:
On the left of the screen is the control panel menu area and the right is the view area.When user access control panel DNA will load available control panel items which could be used for current user and
show in management item menu.The administrator would use the Role management tools to control the menu item accessiblity for roles
How to develop ControlPanel
The core idea of DNA is "Simple is the best", all the DNA of the extensive development will be very easy to learn.You only just specified an attribute class on the action method that the Action will become a
control panel.
The following tutorial will show you how to write a control panel in minutes.
Tutorial:"Customer profile management"
1.Open VS.NET 2010 and create a DNA Mvc application
2.Add CustomerController class to your project and add a CustomerManager Action method in controller.Specified the SiteControlPanel attribute on the CustomerManager method.
namespace DNA.Example
{
public class CustomerController:Controller
{
[SiteControlPanel(Text="Customers",Group="NorthWind")]
public ActionResult CustomerManager()
{
var db = new NorthWindEntities();
return View(db.Customers);
}
}
}
In the code above we add "Customers" control panel item to "NorthWind" item group.
3.Add CustomerManager View
@model IEnumerable<Customer>
@{
Layout = "~/Views/Shared/_Dashboard.cshtml";
}
@UIHelper.ImageTitle("Customers","Manage customer list.", "~/content/images/icon_customer_48.png")
@{ Ajax.Dna().Grid(Model).Render(); }
In CustomerManager.cshtml we use the DJME2 Grid helper to display the customer list.
Notes: The management veiw must be specified the Layout to "_Dashboard.cshtml" or "_MyDashboar.cshtml" master layout.
@{
Layout = "~/Views/Shared/_Dashboard.cshtml";
}
4.Pree F5 to run:
Globalization
SiteControlPanel , MyControlPanel offers globalization properties:(Available for DNA2.0.2 or later)
- ResBaseName - Specified the resource base name,if your resource file named northWind.zh-CN.resx that the base name is northWind
- ResKey - Specified resource key of the control panel text.
- GroupResKey - Specified the resource key of the group text.
Accessibility and visibility
By default all user could access the control panel Action, you could use the SecurityActionAttribute to extend the Action security.
We modify the CustomerController.cs file like this:
namespace DNA.Example
{
public class CustomerController:Controller
{
[SecurityAction("Customers","NorthWind","Allows user to use the Customer manager.")]
[SiteControlPanel(Title="Customers",Group="NorthWind")]
public ActionResult CustomerManager()
{
var db = new NorthWindEntities();
return View(db.Customers);
}
}
}
Conclusion
DNA promotes developer combination model in widget+service+management. Control panel (management) is a very important development concept in this model. Widgets, services and management can be combined by business designer, developers only need to develop fixed functions, this could save developers to consider how to provide extended functionality but focus on how to response to business changes.
-
-
Lee(2774)
-
Enlace permanente