Browse Source

refactor

pull/1149/head
Yunus Emre Kalkan 7 years ago
parent
commit
9e1254e323
  1. 1
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo.Abp.AspNetCore.Mvc.UI.Dashboards.csproj
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/AbpBasicDashboardScriptContributor.cs
  3. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/DashboardViewComponent.cshtml.cs
  4. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/DashboardViewModel.cs
  5. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/Default.cshtml
  6. 20
      samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/MyDashboardScriptBundleContributor.cs
  7. 4
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.cshtml

1
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo.Abp.AspNetCore.Mvc.UI.Dashboards.csproj

@ -30,5 +30,6 @@
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Widgets\Volo.Abp.AspNetCore.Mvc.UI.Widgets.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj" />
</ItemGroup>
</Project>

4
samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/AbpBasicDashboardScriptContributor.cs → framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/AbpBasicDashboardScriptContributor.cs

@ -1,8 +1,8 @@
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
namespace DashboardDemo.Dashboards
namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards
{
public class AbpBasicDashboardScriptContributor : BundleContributor
{
}
}
}

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/DashboardViewComponent.cshtml.cs

@ -8,9 +8,21 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards.Components.Dashboard
{
public class DashboardViewComponent : AbpViewComponent
{
public async Task<IViewComponentResult> InvokeAsync(string dashboardName, DashboardOptions dashboardOptions, WidgetOptions widgetOptions)
private readonly DashboardOptions _dashboardOptions;
private readonly WidgetOptions _widgetOptions;
public DashboardViewComponent(IOptions<DashboardOptions> dashboardOptions, IOptions<WidgetOptions> widgetOptions)
{
_dashboardOptions = dashboardOptions.Value;
_widgetOptions = widgetOptions.Value;
}
public IViewComponentResult Invoke(string dashboardName)
{
var model = new DashboardViewModel(dashboardName, dashboardOptions, widgetOptions);
var dashboard = _dashboardOptions.Dashboards.Single(d => d.Name.Equals(dashboardName));
var model = new DashboardViewModel(dashboard, _widgetOptions);
return View("~/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/Default.cshtml", model);
}
}

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/DashboardViewModel.cs

@ -9,13 +9,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards.Components.Dashboard
public class DashboardViewModel
{
public DashboardDefinition Dashboard { get; set; }
public DashboardOptions DashboardOptions { get; set; }
public WidgetOptions WidgetOptions { get; set; }
public DashboardViewModel(string dashboardName, DashboardOptions dashboardOptions, WidgetOptions widgetOptions)
public DashboardViewModel(DashboardDefinition dashboard, WidgetOptions widgetOptions)
{
Dashboard = dashboardOptions.Dashboards.Single(d => d.Name.Equals(dashboardName));
DashboardOptions = dashboardOptions;
Dashboard = dashboard;
WidgetOptions = widgetOptions;
}

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/Components/Dashboard/Default.cshtml

@ -11,7 +11,7 @@
var widgetDefinition = Model.GetWidget(widgetConfiguration.WidgetName);
widgetDefinition.DefaultDimensions = widgetConfiguration.Dimensions ?? widgetDefinition.DefaultDimensions ?? new WidgetDimensions(5, 5);
<abp-column class="col-@widgetDefinition.DefaultDimensions.Width"
<abp-column class="col-@(widgetDefinition.DefaultDimensions.Width) m-2"
style="height: @(widgetDefinition.DefaultDimensions.Height * 100)px"
abp-border="Danger">

20
samples/DashboardDemo/src/DashboardDemo.Web/Dashboards/MyDashboardScriptBundleContributor.cs

@ -0,0 +1,20 @@
using DashboardDemo.Pages.widgets;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Dashboards;
using Volo.Abp.Modularity;
namespace DashboardDemo.Dashboards
{
[DependsOn(
typeof(AbpBasicDashboardScriptContributor),
typeof(MyWidgetViewComponentScriptBundleContributor),
typeof(DemoStatisticsScriptContributor)
)]
public class MyDashboardScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
}
}
}

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

@ -10,7 +10,7 @@
@{
}
@section scripts {
<abp-script-bundle name="MyDashboard" />
<abp-script-bundle name="@DashboardNames.MyDashboard" />
}
@await DashboardRenderer.RenderAsync(Component, new { dashboardName = DashboardNames.MyDashboard, dashboardOptions = Model._dashboardOptions, widgetOptions = Model._widgetOptions })
@await DashboardRenderer.RenderAsync(Component, new { dashboardName = DashboardNames.MyDashboard})
Loading…
Cancel
Save