mirror of https://github.com/abpframework/abp.git
22 changed files with 194 additions and 36 deletions
@ -0,0 +1,7 @@ |
|||
namespace DashboardDemo |
|||
{ |
|||
public class MonthlyProfitStatisticDto |
|||
{ |
|||
public int[] Data { get; set; } |
|||
} |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
(function ($) { |
|||
var $container = $('#DateRangeGlobalFilterContainer'); |
|||
if ($container.length > 0) { |
|||
console.log("GlobalRefreshButton loaded"); |
|||
} |
|||
})(jQuery); |
|||
@ -1,17 +0,0 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace DashboardDemo.Pages.widgets.Filters |
|||
{ |
|||
[ViewComponent] |
|||
public class DateRangeGlobalFilterViewComponent : ViewComponent |
|||
{ |
|||
public const string GlobalFilterName = "DateRangeGlobalFilter"; |
|||
|
|||
public const string DisplayName = "Date Range Filter"; |
|||
|
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View("/Pages/widgets/Filters/DateRangeGlobalFilterViewComponent.cshtml", new DateRangeGlobalFilterViewComponent()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
(function ($) { |
|||
var $container = $('#RefreshGlobalFilterContainer'); |
|||
if ($container.length > 0) { |
|||
|
|||
} |
|||
})(jQuery); |
|||
@ -1,10 +1,10 @@ |
|||
@inject IHtmlLocalizer<DashboardDemoResource> L |
|||
@using DashboardDemo.Localization.DashboardDemo |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@model DashboardDemo.Pages.widgets.Filters.DateRangeGlobalFilterViewComponent |
|||
@model DashboardDemo.Pages.widgets.Filters.RefreshGlobalFilterViewComponent |
|||
@{ |
|||
} |
|||
<div id="DateRangeGlobalFilterContainer"> |
|||
<div id="RefreshGlobalFilterContainer"> |
|||
<abp-button button-type="Success" text="@L["Refresh"].Value" id="GlobalRefreshButton"/> |
|||
</div> |
|||
|
|||
@ -0,0 +1,17 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace DashboardDemo.Pages.widgets.Filters |
|||
{ |
|||
[ViewComponent] |
|||
public class RefreshGlobalFilterViewComponent : ViewComponent |
|||
{ |
|||
public const string GlobalFilterName = "RefreshGlobalFilter"; |
|||
|
|||
public const string DisplayName = "Refresh Filter"; |
|||
|
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View("/Pages/widgets/Filters/RefreshGlobalFilterViewComponent.cshtml", new RefreshGlobalFilterViewComponent()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
body { |
|||
margin: 0; |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
(function ($) { |
|||
var $container = $('#MonthlyProfitWidgetContainer'); |
|||
if ($container.length > 0) { |
|||
var chart = {}; |
|||
var $RefreshGlobalFilterContainer = $("#RefreshGlobalFilterContainer"); |
|||
|
|||
var createChart = function () { |
|||
dashboardDemo.demoStatistic.getMonthlyProfitStatistic().then(function (result) { |
|||
|
|||
chart = new Chart($container.find('#MonthlyProfitStatistics'), { |
|||
type: 'line', |
|||
data: { |
|||
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], |
|||
datasets: [{ |
|||
label: 'Monthly Profit', |
|||
data: result.data, |
|||
backgroundColor: 'rgba(255, 255, 132, 0.2)' |
|||
}] |
|||
}, |
|||
options: { |
|||
scales: { |
|||
yAxes: [{ |
|||
ticks: { |
|||
beginAtZero: true |
|||
} |
|||
}] |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
if ($RefreshGlobalFilterContainer.length > 0) { |
|||
$RefreshGlobalFilterContainer.find('#GlobalRefreshButton').on('click', |
|||
function () { |
|||
dashboardDemo.demoStatistic.getMonthlyProfitStatistic().then(function (result) { |
|||
chart.data.datasets[0].data = result.data; |
|||
chart.update(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
createChart(); |
|||
} |
|||
})(jQuery); |
|||
@ -0,0 +1,21 @@ |
|||
using DashboardDemo.Pages.widgets.Chartjs; |
|||
using DashboardDemo.Pages.widgets.Filters; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.Clipboard; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace DashboardDemo.Pages.widgets |
|||
{ |
|||
[DependsOn(typeof(JQueryScriptContributor))] |
|||
[DependsOn(typeof(ClipboardScriptBundleContributor))] |
|||
[DependsOn(typeof(ChartjsScriptContributor))] |
|||
[DependsOn(typeof(RefreshGlobalFilterScriptContributor))] |
|||
public class MonthlyProfitWidgetScriptBundleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.Add("/Pages/widgets/MonthlyProfitWidget/MonthlyProfitWidget.js"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using DashboardDemo.Pages.widgets.Chartjs; |
|||
using DashboardDemo.Pages.widgets.Filters; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.Bootstrap; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Packages.HighlightJs; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace DashboardDemo.Pages.widgets |
|||
{ |
|||
[DependsOn(typeof(BootstrapStyleContributor))] |
|||
[DependsOn(typeof(HighlightJsStyleContributor))] |
|||
[DependsOn(typeof(ChartjsStyleContributor))] |
|||
public class MonthlyProfitWidgetStyleBundleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.Add("/Pages/widgets/MonthlyProfitWidget/MonthlyProfitWidget.css"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
@inject IHtmlLocalizer<DashboardDemoResource> L |
|||
@using DashboardDemo.Localization.DashboardDemo |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@model DashboardDemo.Pages.widgets.MonthlyProfitWidgetViewComponent |
|||
@{ |
|||
} |
|||
<div id="MonthlyProfitWidgetContainer"> |
|||
<abp-card background="Light"> |
|||
<abp-card-header background="Info">@L["Monthly Profit"]</abp-card-header> |
|||
<abp-card-body> |
|||
<div class="row margin-bottom-5"> |
|||
<canvas id="MonthlyProfitStatistics"></canvas> |
|||
</div> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
</div> |
|||
@ -0,0 +1,17 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace DashboardDemo.Pages.widgets |
|||
{ |
|||
public class MonthlyProfitWidgetViewComponent : AbpViewComponent |
|||
{ |
|||
public const string WidgetName = "MonthlyProfitWidget"; |
|||
|
|||
public const string DisplayName = "Monthly Profit Widget"; |
|||
|
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View("/Pages/widgets/MonthlyProfitWidget/MonthlyProfitWidgetViewComponent.cshtml", new MonthlyProfitWidgetViewComponent()); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue