Browse Source

dashboard script contributors

pull/1142/head
Yunus Emre Kalkan 7 years ago
parent
commit
bac5eb7d48
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/IWidgetRenderer.cs
  2. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetRenderer.cs
  3. 9
      samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs
  4. 8
      samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/AbpBasicDashboardScriptContributor.cs
  5. 18
      samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/DashboardDefinitionProvider.cs
  6. 3
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml
  7. 12
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/DemoStatisticsScriptContributor.cs
  8. 12
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/widgets/MyWidgetScriptContributor.cs
  9. 4
      samples/DashboardDemo/src/DashboardDemo.Web/Widgets/WidgetDefinitionProvider.cs

2
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<IHtmlContent> RenderAsync(IViewComponentHelper component, string mywidget);
Task<IHtmlContent> RenderAsync(IViewComponentHelper componentHelper, string widgetName, object args = null);
}
}

7
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<IHtmlContent> RenderAsync(IViewComponentHelper component, string mywidget)
public async Task<IHtmlContent> 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());
}
}
}

9
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<BundlingOptions>(options =>
{
options.ScriptBundles.Add("MyDashboard", configuration =>
{
configuration.AddContributors(typeof(MyDashboardScriptBundleContributor));
});
});
}
private void ConfigureDatabaseServices()

8
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
{
}
}

18
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<DashboardDemoResource>("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)
{
}
}
}

3
samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml

@ -6,6 +6,9 @@
@model DashboardDemo.Pages.MyDashboardModel
@{
}
@section scripts {
<abp-script-bundle name="MyDashboard" />
}
<h2>@Model.Dashboard.DisplayName.Localize(localizer)</h2>
<abp-row>
@foreach (var widgetConfiguration in Model.Dashboard.AvailableWidgets)

12
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
{
}
}

12
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
{
}
}

4
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<DashboardDemoResource>("MyWidgett")
),
new WidgetDefinition(
WidgetNames.DemoStatistics,
typeof(DemoStatisticsViewComponentModel),
new LocalizableString(typeof(DashboardDemoResource), "DemoStatistics")
LocalizableString.Create<DashboardDemoResource>("DemoStatistics")
)
};
}

Loading…
Cancel
Save