diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/IWidgetRenderer.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/IWidgetRenderer.cs index 7d40aacf3d..ab3c4ee09f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/IWidgetRenderer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/IWidgetRenderer.cs @@ -7,6 +7,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets { public interface IWidgetRenderer : ITransientDependency { - Task RenderAsync(IViewComponentHelper component, string mywidget); + Task RenderAsync(IViewComponentHelper componentHelper, string widgetName, object args = null); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetRenderer.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetRenderer.cs index b39194e2f2..2bb8c58fe9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetRenderer.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetRenderer.cs @@ -15,12 +15,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets _widgetOptions = widgetOptions.Value; } - public async Task RenderAsync(IViewComponentHelper component, string mywidget) + public async Task RenderAsync(IViewComponentHelper componentHelper, string widgetName, object args = null) { - var componentType = _widgetOptions.Widgets.Single(w=>w.Name.Equals(mywidget)).ViewComponentType; - var args = new object(); + var componentType = _widgetOptions.Widgets.Single(w=>w.Name.Equals(widgetName)).ViewComponentType; - return await component.InvokeAsync(componentType, args); + return await componentHelper.InvokeAsync(componentType, args ?? new object()); } } } \ No newline at end of file diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs b/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs index 2854db7807..58821c536c 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs +++ b/samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs @@ -18,6 +18,7 @@ using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Dashboards; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; @@ -97,6 +98,14 @@ namespace DashboardDemo { options.Dashboards.AddRange(DashboardDefinitionProvider.GetDefinitions()); }); + + Configure(options => + { + options.ScriptBundles.Add("MyDashboard", configuration => + { + configuration.AddContributors(typeof(MyDashboardScriptBundleContributor)); + }); + }); } private void ConfigureDatabaseServices() diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/AbpBasicDashboardScriptContributor.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/AbpBasicDashboardScriptContributor.cs new file mode 100644 index 0000000000..94e913eac1 --- /dev/null +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/AbpBasicDashboardScriptContributor.cs @@ -0,0 +1,8 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace DashboardDemo.Dashboards +{ + public class AbpBasicDashboardScriptContributor : BundleContributor + { + } +} \ No newline at end of file diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/DashboardDefinitionProvider.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/DashboardDefinitionProvider.cs index 8f6d21a720..4d4d8564f2 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/DashboardDefinitionProvider.cs +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/DashboardDefinitionProvider.cs @@ -1,9 +1,12 @@ using System.Collections.Generic; using DashboardDemo.Localization.DashboardDemo; +using DashboardDemo.Pages.widgets; using DashboardDemo.Widgets; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Dashboards; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; using Volo.Abp.Localization; +using Volo.Abp.Modularity; namespace DashboardDemo.Dashboards { @@ -13,7 +16,7 @@ namespace DashboardDemo.Dashboards { var myDashboard = new DashboardDefinition( DashboardNames.MyDashboard, - new LocalizableString(typeof(DashboardDemoResource), "MyDashboard") + LocalizableString.Create("MyDashboard") ); myDashboard.AvailableWidgets.Add( @@ -32,4 +35,17 @@ namespace DashboardDemo.Dashboards return dashboards; } } + + [DependsOn( + typeof(AbpBasicDashboardScriptContributor), + typeof(MyDashboardScriptBundleContributor), + typeof(DemoStatisticsScriptContributor) + )] + public class MyDashboardScriptBundleContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + + } + } } diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml index 51d0ff62df..5055883e1d 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml @@ -6,6 +6,9 @@ @model DashboardDemo.Pages.MyDashboardModel @{ } +@section scripts { + +}

@Model.Dashboard.DisplayName.Localize(localizer)

@foreach (var widgetConfiguration in Model.Dashboard.AvailableWidgets) diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/DemoStatisticsScriptContributor.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/DemoStatisticsScriptContributor.cs new file mode 100644 index 0000000000..3c720dc4d1 --- /dev/null +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/DemoStatisticsScriptContributor.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace DashboardDemo.Pages.widgets +{ + public class DemoStatisticsScriptContributor : BundleContributor + { + } +} diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/MyWidgetScriptContributor.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/MyWidgetScriptContributor.cs new file mode 100644 index 0000000000..9bf8c6d2e6 --- /dev/null +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/MyWidgetScriptContributor.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace DashboardDemo.Pages.widgets +{ + public class MyWidgetScriptContributor : BundleContributor + { + } +} diff --git a/samples/DashboardDemo/src/DashboardDemo.Web/Widgets/WidgetDefinitionProvider.cs b/samples/DashboardDemo/src/DashboardDemo.Web/Widgets/WidgetDefinitionProvider.cs index 57a583e732..9ba02f0bed 100644 --- a/samples/DashboardDemo/src/DashboardDemo.Web/Widgets/WidgetDefinitionProvider.cs +++ b/samples/DashboardDemo/src/DashboardDemo.Web/Widgets/WidgetDefinitionProvider.cs @@ -15,12 +15,12 @@ namespace DashboardDemo.Widgets new WidgetDefinition( WidgetNames.MyWidget, typeof(MyWidgetViewComponentModel), - new LocalizableString(typeof(DashboardDemoResource), "MyWidgett") + LocalizableString.Create("MyWidgett") ), new WidgetDefinition( WidgetNames.DemoStatistics, typeof(DemoStatisticsViewComponentModel), - new LocalizableString(typeof(DashboardDemoResource), "DemoStatistics") + LocalizableString.Create("DemoStatistics") ) }; }