mirror of https://github.com/abpframework/abp.git
15 changed files with 208 additions and 33 deletions
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace DashboardDemo |
|||
{ |
|||
public class LicenseStatistiWidgetResultDto |
|||
{ |
|||
public Dictionary<string, int> Data { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace DashboardDemo |
|||
{ |
|||
public class LicenseStatisticWidgetInputDto : WidgetFilter |
|||
{ |
|||
} |
|||
} |
|||
@ -1,9 +1,9 @@ |
|||
namespace DashboardDemo |
|||
using System.Collections.Generic; |
|||
|
|||
namespace DashboardDemo |
|||
{ |
|||
public class NewUserStatistiWidgetResultDto |
|||
{ |
|||
public string[] Labels { get; set; } |
|||
|
|||
public int[] Data { get; set; } |
|||
public Dictionary<string, int> Data { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
namespace DashboardDemo |
|||
{ |
|||
public class WidgetFilter |
|||
{ |
|||
public DateTime StartDate { get; set; } |
|||
|
|||
public DateTime EndDate { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<div class="license-statistic-widget"> |
|||
<abp-card background="Light"> |
|||
<abp-card-header background="Secondary" class="text-white"> |
|||
License Statistics |
|||
</abp-card-header> |
|||
<abp-card-body> |
|||
<div class="row"> |
|||
<canvas class="LicenseStatisticChart"></canvas> |
|||
</div> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
</div> |
|||
@ -0,0 +1,92 @@ |
|||
(function () { |
|||
var serviceMethod = dashboardDemo.dashboard.getLicenseStatisticWidget; |
|||
|
|||
function ChartManager($wrapper) { |
|||
|
|||
var _chart; |
|||
|
|||
var createChart = function (statistic) { |
|||
_chart = new Chart($wrapper.find('.LicenseStatisticChart'), |
|||
{ |
|||
type: 'pie', |
|||
data: { |
|||
labels: Object.keys(statistic.data), |
|||
datasets: [ |
|||
{ |
|||
label: 'License ratios', |
|||
data: Object.values(statistic.data), |
|||
backgroundColor: [ |
|||
'rgba(50, 150, 255, 1)', |
|||
'rgba(150, 255, 100, 1)', |
|||
'rgba(255, 100, 150, 1)' |
|||
] |
|||
} |
|||
] |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
var refreshChart = function (statistic) { |
|||
_chart.data = { |
|||
labels: Object.keys(statistic.data), |
|||
datasets: [ |
|||
{ |
|||
label: 'License ratios', |
|||
data: Object.values(statistic.data), |
|||
backgroundColor: [ |
|||
'rgba(50, 150, 255, 1)', |
|||
'rgba(150, 255, 100, 1)', |
|||
'rgba(255, 100, 150, 1)' |
|||
] |
|||
} |
|||
] |
|||
}; |
|||
_chart.update(); |
|||
}; |
|||
|
|||
var render = function (filters, callback) { |
|||
serviceMethod({ |
|||
startDate: filters.startDate, |
|||
endDate: filters.endDate |
|||
}) |
|||
.then(function (result) { |
|||
callback(result); |
|||
}); |
|||
}; |
|||
|
|||
var init = function (filters) { |
|||
render(filters, createChart); |
|||
}; |
|||
|
|||
var refresh = function (filters) { |
|||
render(filters, refreshChart); |
|||
}; |
|||
|
|||
return { |
|||
init: init, |
|||
refresh: refresh |
|||
}; |
|||
} |
|||
|
|||
abp.event.on('init-widgets', function (args) { |
|||
args.container |
|||
.find('.license-statistic-widget') |
|||
.each(function () { |
|||
var $this = $(this); |
|||
var chartManager = new ChartManager($this); |
|||
chartManager.init(args.filters); |
|||
$this.data('chart-manager', chartManager); |
|||
}); |
|||
|
|||
}); |
|||
|
|||
abp.event.on('refresh-widgets', function (args) { |
|||
args.container |
|||
.find('.license-statistic-widget') |
|||
.each(function () { |
|||
var $this = $(this); |
|||
var chartManager = $this.data('chart-manager'); |
|||
chartManager.refresh(args.filters); |
|||
}); |
|||
}); |
|||
})(); |
|||
@ -0,0 +1,15 @@ |
|||
using DashboardDemo.Web.Bundles; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace DashboardDemo.Web.Pages.Components.LicenseStatisticWidget |
|||
{ |
|||
[DependsOn(typeof(ChartjsScriptContributor))] |
|||
public class LicenseStatisticWidgetScriptContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.Add("/Pages/Components/LicenseStatisticWidget/Default.js"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using DashboardDemo.Web.Bundles; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
|||
|
|||
namespace DashboardDemo.Web.Pages.Components.LicenseStatisticWidget |
|||
{ |
|||
[Widget( |
|||
StyleTypes = new[] { typeof(ChartjsStyleContributor) }, |
|||
ScriptTypes = new[] { typeof(LicenseStatisticWidgetScriptContributor) } |
|||
)] |
|||
public class LicenseStatisticWidgetViewComponent : AbpViewComponent |
|||
{ |
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue