mirror of https://github.com/abpframework/abp.git
4 changed files with 116 additions and 115 deletions
@ -1,20 +1,18 @@ |
|||
<div class="newUserStatistic-widget"> |
|||
<abp-card background="Light"> |
|||
<abp-card-header background="Secondary" class="text-white"> |
|||
User Statistics |
|||
</abp-card-header> |
|||
<abp-card-body> |
|||
<div> |
|||
<div class="form-group frequency-filter"> |
|||
<select class="form-control"> |
|||
<option value="Daily">Daily</option> |
|||
<option value="Monthly">Monthly</option> |
|||
</select> |
|||
</div> |
|||
<abp-card background="Light"> |
|||
<abp-card-header background="Secondary" class="text-white"> |
|||
User Statistics |
|||
</abp-card-header> |
|||
<abp-card-body> |
|||
<div> |
|||
<div class="form-group frequency-filter"> |
|||
<select class="form-control"> |
|||
<option value="Daily">Daily</option> |
|||
<option value="Monthly">Monthly</option> |
|||
</select> |
|||
</div> |
|||
<div class="row mt-5"> |
|||
<canvas class="NewUserStatisticChart"></canvas> |
|||
</div> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
</div> |
|||
</div> |
|||
<div class="row mt-5"> |
|||
<canvas class="NewUserStatisticChart"></canvas> |
|||
</div> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
@ -1,26 +1,73 @@ |
|||
(function () { |
|||
|
|||
function triggerWidgets(eventName) { |
|||
abp.event.trigger( |
|||
eventName, |
|||
{ |
|||
container: $('#MyDashboardWidgetsArea'), |
|||
filters: { |
|||
startDate: $('#StartDate').val(), |
|||
endDate: $('#EndDate').val() |
|||
} |
|||
abp.widgets = abp.widgets || {}; //TODO: Remove later
|
|||
(function () { |
|||
|
|||
abp.DashboardManager = function (opts) { |
|||
|
|||
if (typeof opts === 'string') { |
|||
opts = { |
|||
wrapper: opts |
|||
}; |
|||
} |
|||
|
|||
var $dashboardWrapper; |
|||
if (typeof opts.wrapper === 'string') { |
|||
$dashboardWrapper = $(opts.wrapper); |
|||
} else { |
|||
$dashboardWrapper = opts.wrapper; |
|||
} |
|||
|
|||
var getFilters = function() { |
|||
if (!opts.filterCallback) { |
|||
return {}; |
|||
} |
|||
); |
|||
} |
|||
|
|||
$(function () { |
|||
return opts.filterCallback(); |
|||
} |
|||
|
|||
var init = function () { |
|||
$dashboardWrapper.find('.abp-widget-wrapper').each(function () { |
|||
var $widgetWrapperDiv = $(this); |
|||
var widgetName = $widgetWrapperDiv.attr('data-widget-name'); |
|||
var widgetApiClass = abp.widgets[widgetName]; |
|||
if (widgetApiClass) { |
|||
var widgetApi = new widgetApiClass($widgetWrapperDiv); |
|||
if (widgetApi.init) { |
|||
widgetApi.init(getFilters()); |
|||
} |
|||
$widgetWrapperDiv.data('abp-widget-api', widgetApi); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
var refresh = function() { |
|||
$dashboardWrapper.find('.abp-widget-wrapper').each(function () { |
|||
var $widgetWrapperDiv = $(this); |
|||
var widgetApi = $widgetWrapperDiv.data('abp-widget-api'); |
|||
if (widgetApi && widgetApi.refresh) { |
|||
widgetApi.refresh(getFilters()); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
return { |
|||
init: init, |
|||
refresh: refresh |
|||
}; |
|||
}; |
|||
|
|||
$('#MyDashboardFilterForm').submit(function(e) { |
|||
e.preventDefault(); |
|||
var filterForm = $('#MyDashboardFilterForm'); |
|||
|
|||
var myDashboard = new abp.DashboardManager({ |
|||
wrapper: '#MyDashboardWidgetsArea', |
|||
filterCallback: function() { |
|||
return filterForm.serializeFormToObject(); |
|||
} |
|||
}); |
|||
|
|||
triggerWidgets('refresh-widgets'); |
|||
}); |
|||
myDashboard.init(); |
|||
|
|||
triggerWidgets('init-widgets'); |
|||
filterForm.submit(function(e) { |
|||
e.preventDefault(); |
|||
myDashboard.refresh(); |
|||
}); |
|||
})(); |
|||
Loading…
Reference in new issue