mirror of https://github.com/abpframework/abp.git
5 changed files with 50 additions and 3 deletions
@ -0,0 +1,9 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets |
||||
|
{ |
||||
|
public interface IWidgetDefinitionProvider |
||||
|
{ |
||||
|
List<WidgetDefinition> GetDefinitions(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets |
||||
|
{ |
||||
|
public static class WidgetOptionsExtensions |
||||
|
{ |
||||
|
public static void AddWidgets<T>(this WidgetOptions options) |
||||
|
where T : IWidgetDefinitionProvider, new() |
||||
|
{ |
||||
|
var provider = new T(); |
||||
|
var widgets = provider.GetDefinitions(); |
||||
|
options.Widgets.AddRange(widgets); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using DashboardDemo.Localization.DashboardDemo; |
||||
|
using DashboardDemo.Pages.widgets; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
||||
|
using Volo.Abp.Localization; |
||||
|
|
||||
|
namespace DashboardDemo |
||||
|
{ |
||||
|
public class WidgetDefinitionProvider : IWidgetDefinitionProvider |
||||
|
{ |
||||
|
public List<WidgetDefinition> GetDefinitions() |
||||
|
{ |
||||
|
var widgets = new List<WidgetDefinition>(); |
||||
|
|
||||
|
var myWidget = new WidgetDefinition("MyWidget", typeof(MyWidgetViewComponentModel), |
||||
|
new LocalizableString(typeof(DashboardDemoResource), "MyWidgett")); |
||||
|
|
||||
|
widgets.Add(myWidget); |
||||
|
|
||||
|
return widgets; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue