Browse Source

Remove DashboardManager

pull/1545/head
Halil İbrahim Kalkan 7 years ago
parent
commit
6c85ee4777
  1. 1
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs
  2. 54
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/dashboard-manager.js
  3. 103
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js
  4. 1
      samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs
  5. 2
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.js

1
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs

@ -36,7 +36,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/jquery-extensions.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/jquery-extensions.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery-form/jquery-form-extensions.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery-form/jquery-form-extensions.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/dashboard-manager.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js",
"/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js", "/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js",

54
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/dashboard-manager.js

@ -1,54 +0,0 @@
(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 init = function () {
$dashboardWrapper.find('.abp-widget-wrapper').each(function () {
var widgetManager = new abp.WidgetManager({
wrapper: $(this),
filterCallback: opts.filterCallback || function () {
if (opts.filterForm) {
return opts.filterForm.serializeFormToObject();
}
return {};
}
});
widgetManager.init();
});
};
var refresh = function () {
$dashboardWrapper.find('.abp-widget-wrapper').each(function () {
var widgetManager = $(this).data('abp-widget-manager');
widgetManager && widgetManager.refresh();
});
};
if (opts.filterForm) {
opts.filterForm.submit(function (e) {
e.preventDefault();
refresh();
});
}
return {
init: init,
refresh: refresh
};
};
})(jQuery);

103
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js

@ -2,28 +2,29 @@
abp.widgets = abp.widgets || {}; abp.widgets = abp.widgets || {};
abp.WidgetManager = function (opts) { abp.WidgetManager = function (opts) {
if (typeof opts === 'string') { if (!opts) {
opts = {};
} else if (typeof opts === 'string') {
opts = { opts = {
wrapper: opts wrapper: opts
}; };
} }
var $widgetWrapperDiv; if (!opts.wrapper) {
if (typeof opts.wrapper === 'string') { opts.wrapper = $('body');
$widgetWrapperDiv = $(opts.wrapper); } else if (typeof opts.wrapper === 'string') {
} else { opts.wrapper = $(opts.wrapper);
$widgetWrapperDiv = opts.wrapper;
} }
if (!$widgetWrapperDiv.hasClass('abp-widget-wrapper')) { var getFilters = function ($widgetWrapperDiv) {
$widgetWrapperDiv = $widgetWrapperDiv.closest('.abp-widget-wrapper');
}
var getFilters = function () {
var filters = {}; var filters = {};
if (opts.filterForm) {
filters = opts.filterForm.serializeFormToObject();
}
if (opts.filterCallback) { if (opts.filterCallback) {
filters = opts.filterCallback(); filters = $.extend(filters, opts.filterCallback());
} }
var widgetApi = $widgetWrapperDiv.data('abp-widget-api'); var widgetApi = $widgetWrapperDiv.data('abp-widget-api');
@ -35,52 +36,54 @@
}; };
var init = function () { var init = function () {
var widgetName = $widgetWrapperDiv.attr('data-widget-name'); opts.wrapper.find('.abp-widget-wrapper').each(function () {
var widgetApiClass = abp.widgets[widgetName]; var $widgetWrapperDiv = $(this);
if (widgetApiClass) { var widgetName = $widgetWrapperDiv.attr('data-widget-name');
var widgetApi = new widgetApiClass($widgetWrapperDiv); var widgetApiClass = abp.widgets[widgetName];
$widgetWrapperDiv.data('abp-widget-api', widgetApi); if (widgetApiClass) {
if (widgetApi.init) { var widgetApi = new widgetApiClass($widgetWrapperDiv);
widgetApi.init(getFilters($widgetWrapperDiv)); $widgetWrapperDiv.data('abp-widget-api', widgetApi);
if (widgetApi.init) {
widgetApi.init(getFilters($widgetWrapperDiv));
}
} }
} });
}; };
var callRefreshWidgetApi = function () {
var widgetApi = $widgetWrapperDiv.data('abp-widget-api');
if (widgetApi && widgetApi.refresh) {
widgetApi.refresh(getFilters($widgetWrapperDiv));
}
}
var refresh = function () { var refresh = function () {
var refreshUrl = $widgetWrapperDiv.attr('data-refresh-url'); opts.wrapper.find('.abp-widget-wrapper').each(function () {
if (refreshUrl) { var $widgetWrapperDiv = $(this);
abp.ajax({
url: refreshUrl, var refreshUrl = $widgetWrapperDiv.attr('data-refresh-url');
type: 'GET', if (refreshUrl) {
dataType: 'html', abp.ajax({
contentType: 'application/x-www-form-urlencoded; charset=UTF-8', url: refreshUrl,
data: getFilters() type: 'GET',
}).then(function (result) { dataType: 'html',
var $newWidgetWrapperDiv = $(result); contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
$widgetWrapperDiv.replaceWith($newWidgetWrapperDiv); data: getFilters($widgetWrapperDiv)
$widgetWrapperDiv = $newWidgetWrapperDiv; }).then(function (result) {
$widgetWrapperDiv.data('abp-widget-manager', publicApi); $widgetWrapperDiv.replaceWith($(result));
init(); });
}); } else {
} else { var widgetApi = $widgetWrapperDiv.data('abp-widget-api');
callRefreshWidgetApi(); if (widgetApi && widgetApi.refresh) {
} widgetApi.refresh(getFilters($widgetWrapperDiv));
}
}
});
}; };
var publicApi = { if (opts.filterForm) {
opts.filterForm.submit(function (e) {
e.preventDefault();
refresh();
});
}
return {
init: init, init: init,
refresh: refresh refresh: refresh
}; };
$widgetWrapperDiv.data('abp-widget-manager', publicApi);
return publicApi;
}; };
})(jQuery); })(jQuery);

1
samples/DashboardDemo/src/DashboardDemo.Web/DashboardDemoWebModule.cs

@ -115,6 +115,7 @@ namespace DashboardDemo.Web
{ {
Configure<VirtualFileSystemOptions>(options => Configure<VirtualFileSystemOptions>(options =>
{ {
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Domain.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Domain.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Domain", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Domain", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Application.Contracts", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical<DashboardDemoApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}DashboardDemo.Application.Contracts", Path.DirectorySeparatorChar)));

2
samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyDashboard.js

@ -1,6 +1,6 @@
(function () { (function () {
var myDashboard = new abp.DashboardManager({ var myDashboard = new abp.WidgetManager({
wrapper: '#MyDashboardWidgetsArea', wrapper: '#MyDashboardWidgetsArea',
filterForm: $('#MyDashboardFilterForm') filterForm: $('#MyDashboardFilterForm')
}); });

Loading…
Cancel
Save