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 background="Light"> |
<abp-card-header background="Secondary" class="text-white"> |
||||
<abp-card-header background="Secondary" class="text-white"> |
User Statistics |
||||
User Statistics |
</abp-card-header> |
||||
</abp-card-header> |
<abp-card-body> |
||||
<abp-card-body> |
<div> |
||||
<div> |
<div class="form-group frequency-filter"> |
||||
<div class="form-group frequency-filter"> |
<select class="form-control"> |
||||
<select class="form-control"> |
<option value="Daily">Daily</option> |
||||
<option value="Daily">Daily</option> |
<option value="Monthly">Monthly</option> |
||||
<option value="Monthly">Monthly</option> |
</select> |
||||
</select> |
|
||||
</div> |
|
||||
</div> |
</div> |
||||
<div class="row mt-5"> |
</div> |
||||
<canvas class="NewUserStatisticChart"></canvas> |
<div class="row mt-5"> |
||||
</div> |
<canvas class="NewUserStatisticChart"></canvas> |
||||
</abp-card-body> |
</div> |
||||
</abp-card> |
</abp-card-body> |
||||
</div> |
</abp-card> |
||||
@ -1,26 +1,73 @@ |
|||||
(function () { |
abp.widgets = abp.widgets || {}; //TODO: Remove later
|
||||
|
(function () { |
||||
function triggerWidgets(eventName) { |
|
||||
abp.event.trigger( |
abp.DashboardManager = function (opts) { |
||||
eventName, |
|
||||
{ |
if (typeof opts === 'string') { |
||||
container: $('#MyDashboardWidgetsArea'), |
opts = { |
||||
filters: { |
wrapper: opts |
||||
startDate: $('#StartDate').val(), |
}; |
||||
endDate: $('#EndDate').val() |
} |
||||
} |
|
||||
|
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) { |
var filterForm = $('#MyDashboardFilterForm'); |
||||
e.preventDefault(); |
|
||||
|
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