diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js
index b87f48a7..81168057 100644
--- a/Bootstrap.Admin/Content/js/common-scripts.js
+++ b/Bootstrap.Admin/Content/js/common-scripts.js
@@ -47,7 +47,7 @@
if (!$.browser.versions.ios) $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', scrollspeed: 60 });
// load widget data
- bd({
+ $.bc({
url: '../api/Notifications/',
swal: false,
method: 'GET',
diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js
index 59174481..27a8d4ed 100644
--- a/Bootstrap.Admin/Content/js/framework.js
+++ b/Bootstrap.Admin/Content/js/framework.js
@@ -1,9 +1,4 @@
(function ($) {
- var handlerCallback = function (callback, e, data) {
- if ($.isFunction(callback)) callback.call(e, data);
- if ($.isFunction(this.options.callback)) this.options.callback.call(e, data);
- }
-
BootstrapAdmin = function (options) {
var that = this;
options = options || {};
@@ -252,184 +247,118 @@
}
};
- var htmlTemplate = '
';
+ var handlerCallback = function (callback, e, data) {
+ if ($.isFunction(callback)) callback.call(e, data);
+ if ($.isFunction(this.options.callback)) this.options.callback.call(e, data);
+ }
- var processData = function (options) {
- var data = $.extend({ data: {}, remote: true, method: "POST", Id: "", url: this.url, title: this.title, html: this.html, swal: true }, options);
- if (data.remote) {
- $.ajax({
- url: data.url + data.Id,
- data: data.data,
- type: data.method,
- success: function (result) {
- success(result);
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- if ($.isFunction(data.callback)) data.callback(false);
- }
- });
- }
- else success()
+ $.extend({
+ bc: function (options, callback) {
+ var data = $.extend({
+ remote: true,
+ Id: "",
+ url: this.url,
+ data: {},
+ method: "POST",
+ htmlTemplate: '',
+ title: this.title,
+ swal: true,
+ modal: null,
+ callback: null
+ }, options);
- function success(result) {
- if ($.isFunction(data.callback)) {
- var formatData = result;
- if ($.isArray(result)) {
- if ($.isFunction(data.html)) formatData = data.html(result);
- }
- data.callback(formatData);
+ if (!data.url || data.url == "") {
+ swal('参数错误', '未设置请求地址Url', 'error');
+ return;
}
- else if ($.isPlainObject(data.callback) && data.callback.modal !== undefined) {
- $("#" + data.callback.modal).modal('hide');
+
+ if (data.remote && data.url) {
+ $.ajax({
+ url: data.url + data.Id,
+ data: data.data,
+ type: data.method,
+ success: function (result) {
+ success(result);
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ if ($.isFunction(data.callback)) data.callback(false);
+ }
+ });
}
- if (data.swal) {
- if (result) { swal("成功", data.title, "success"); }
- else { swal("失败", data.title, "error"); }
+ function success(result) {
+ if ($.isFunction(data.callback)) {
+ data.callback(result);
+ }
+ if (data.modal !== null) {
+ $("#" + data.modal).modal('hide');
+ }
+ if (data.swal) {
+ if (result) { swal("成功", data.title, "success"); }
+ else { swal("失败", data.title, "error"); }
+ }
}
}
- };
-
- window.bd = processData;
+ });
// Roles
Role = {
url: '../api/Roles/',
- title: "授权角色",
- html: function (result) {
- return $.map(result, function (element, index) {
- return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description);
- }).join('');
- }
- };
- Role.getRolesByUserId = function (userId, callback) {
- processData.call(this, { Id: userId, callback: callback, data: { type: "user" }, swal: false });
- };
- Role.getRolesByGroupId = function (groupId, callback) {
- processData.call(this, { Id: groupId, callback: callback, data: { type: "group" }, swal: false });
- };
- Role.getRolesByMenuId = function (menuId, callback) {
- processData.call(this, { Id: menuId, callback: callback, data: { type: "menu" }, swal: false });
- };
- Role.saveRolesByUserId = function (userId, roleIds, callback) {
- processData.call(this, { Id: userId, callback: callback, method: "PUT", data: { type: "user", roleIds: roleIds } });
- };
- Role.saveRolesByGroupId = function (groupId, roleIds, callback) {
- processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", roleIds: roleIds } });
- };
- Role.saveRolesByMenuId = function (menuId, roleIds, callback) {
- processData.call(this, { Id: menuId, callback: callback, method: "PUT", data: { type: "menu", roleIds: roleIds } });
+ title: "授权角色"
};
+
// Users
User = {
url: '../api/Users/',
- title: "授权用户",
- html: function (result) {
- return $.map(result, function (element, index) {
- return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName);
- }).join('');
- }
- };
- User.getUsersByRoleId = function (roleId, callback) {
- processData.call(this, { Id: roleId, callback: callback, data: { type: "role" }, swal: false });
- };
- User.saveUsersByRoleId = function (roleId, userIds, callback) {
- processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", userIds: userIds } });
- };
- User.getUsersByGroupeId = function (groupId, callback) {
- processData.call(this, { Id: groupId, callback: callback, data: { type: "group" }, swal: false });
- };
- User.saveUsersByGroupId = function (groupId, userIds, callback) {
- processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", userIds: userIds } });
- };
- User.saveUserDisplayName = function (user, callback) {
- processData.call(this, { Id: '', callback: callback, method: "PUT", data: user, title: "修改用户显示名称" });
- };
- User.changePassword = function (user) {
- processData.call(this, { Id: '', method: "PUT", data: user });
- };
- User.processUser = function (id, result, callback) {
- processData.call(this, { Id: id, callback: callback, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户" });
+ title: "授权用户"
};
+
// Groups
Group = {
url: '../api/Groups/',
- title: "授权部门",
- html: function (result) {
- return $.map(result, function (element, index) {
- return $.format(htmlTemplate, element.ID, element.GroupName, element.Checked, element.Description);
- }).join('');
- }
- };
- Group.getGroupsByUserId = function (userId, callback) {
- processData.call(this, { Id: userId, callback: callback, data: { type: "user" }, swal: false });
- };
- Group.saveGroupsByUserId = function (userId, groupIds, callback) {
- processData.call(this, { Id: userId, callback: callback, method: "PUT", data: { type: "user", groupIds: groupIds } });
- };
- Group.getGroupsByRoleId = function (roleId, callback) {
- processData.call(this, { Id: roleId, callback: callback, data: { type: "role" }, swal: false });
- };
- Group.saveGroupsByRoleId = function (roleId, groupIds, callback) {
- processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", groupIds: groupIds } });
+ title: "授权部门"
};
// Menus
Menu = {
url: '../api/Menus/',
- title: "授权菜单",
- html: function (result) {
- var htmlString = "";
- if ($.isArray(result)) {
- htmlString = Menu.cascadeMenu(result)
- }
- return htmlString;
- }
- };
- Menu.cascadeMenu = function (menus) {
- var html = "";
- $.each(menus, function (index, menu) {
- if (menu.Menus.length == 0) {
- html += $.format('', menu.ID, menu.Icon, menu.Name, menu.Category);
- }
- else {
- html = $.format('{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, Menu.cascadeMenu(menu.Menus));
- }
- });
- return html;
- };
- Menu.getMenus = function (callback) {
- processData.call(this, { Id: 0, callback: callback, data: { type: "user" }, swal: false });
- };
- Menu.getMenusByRoleId = function (roleId, callback) {
- processData.call(this, { Id: roleId, callback: callback, data: { type: "role" }, swal: false, html: null });
- };
- Menu.saveMenusByRoleId = function (roleId, menuIds, callback) {
- processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", menuIds: menuIds } });
+ title: "授权菜单"
};
// Exceptions
Exceptions = {
url: '../api/Exceptions/',
- title: "程序异常日志",
- html: function (result) {
- return result.map(function (ele) {
- return $.format('', ele);
- }).join('');
- }
- };
- Exceptions.getFiles = function (callback) {
- processData.call(this, { Id: "", callback: callback, swal: false });
- }
- Exceptions.getFileByName = function (fileName, callback) {
- processData.call(this, { Id: "", callback: callback, method: "PUT", swal: false, data: { "": fileName } });
+ title: "程序异常日志"
};
// Dicts
Dicts = {
url: '../api/Dicts/'
};
- Dicts.retrieveCategories = function (callback) {
- processData.call(this, { Id: 1, callback: callback, swal: false, data: { type: 'category' } });
- };
+
+ // Infos
+ Infos = {
+ url: '../api/Infos/'
+ }
+
+ // Profiles
+ Profiles = {
+ url: '../api/Profiles/',
+ title: '网站设置'
+ }
+
+ // Messages
+ Messages = {
+ url: '../api/Messages/'
+ }
+
+ // Tasks
+ Tasks = {
+ url: '../api/Tasks/'
+ }
+
+ // Notifications
+ Notifications = {
+ url: '../api/Notifications/'
+ }
})(jQuery);
\ No newline at end of file
diff --git a/Bootstrap.Admin/Controllers/TasksController.cs b/Bootstrap.Admin/Controllers/TasksController.cs
index eab28724..fafd8b05 100644
--- a/Bootstrap.Admin/Controllers/TasksController.cs
+++ b/Bootstrap.Admin/Controllers/TasksController.cs
@@ -1,27 +1,15 @@
using Bootstrap.DataAccess;
using System.Collections.Generic;
using System.Web.Http;
-using System.Linq;
namespace Bootstrap.Admin.Controllers
{
public class TasksController : ApiController
{
[HttpGet]
- public Tasks Get()
+ public IEnumerable Get()
{
- var tasks = new Tasks();
- TaskHelper.RetrieveTasks().AsParallel().ForAll(n => tasks.Users.Add(n));
- return tasks;
- }
-
- public class Tasks
- {
- public Tasks()
- {
- Users = new List();
- }
- public List Users { get; set; }
+ return TaskHelper.RetrieveTasks();
}
}
}
\ No newline at end of file
diff --git a/Bootstrap.Admin/Scripts/Dicts.js b/Bootstrap.Admin/Scripts/Dicts.js
index 56c17795..460c2e95 100644
--- a/Bootstrap.Admin/Scripts/Dicts.js
+++ b/Bootstrap.Admin/Scripts/Dicts.js
@@ -1,7 +1,7 @@
$(function () {
$('#panelResultHeader').html('查询结果(仅 Administrators 角色成员可删除数据)');
var bsa = new BootstrapAdmin({
- url: '../api/Dicts',
+ url: Dicts.url,
dataEntity: new DataEntity({
map: {
ID: "dictID",
@@ -14,7 +14,7 @@
});
$('table').smartTable({
- url: '../api/Dicts',
+ url: Dicts.url,
sortName: 'Category',
queryParams: function (params) { return $.extend(params, { category: $('#txt_dict_cate').val(), name: $("#txt_dict_name").val(), define: $("#txt_dict_define").val() }); },
columns: [{ checkbox: true },
@@ -49,10 +49,13 @@
$('select').selectpicker();
// autocomplete
- Dicts.retrieveCategories(function (result) {
- $('#txt_dict_cate').typeahead({
- source: result,
- autoSelect: true
- });
+ $.bc({
+ Id: 1, url: Dicts.url, data: { type: 'category' }, swal: false,
+ callback: function (result) {
+ $('#txt_dict_cate').typeahead({
+ source: result,
+ autoSelect: true
+ });
+ }
});
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Scripts/Exceptions.js b/Bootstrap.Admin/Scripts/Exceptions.js
index 2c8fcde6..8b2f7910 100644
--- a/Bootstrap.Admin/Scripts/Exceptions.js
+++ b/Bootstrap.Admin/Scripts/Exceptions.js
@@ -32,8 +32,14 @@
});
$('#btn_view').on('click', function (row) {
- Exceptions.getFiles(function (data) {
- $dataForm.children('div').html(data);
+ $.bc({
+ Id: "", url: Exceptions.url, swal: false,
+ callback: function (result) {
+ var html = result.map(function (ele) {
+ return $.format('', ele);
+ }).join('');
+ $dataForm.children('div').html(html);
+ }
});
$dialog.modal('show');
});
@@ -44,8 +50,11 @@
$errorList.hide();
$errorDetail.show();
$dataFormDetail.html('
');
- Exceptions.getFileByName(fileName, function (data) {
- $dataFormDetail.html(data);
+ $.bc({
+ Id: "", url: Exceptions.url, method: "PUT", swal: false, data: { "": fileName },
+ callback: function (result) {
+ $dataFormDetail.html(result);
+ }
});
});
diff --git a/Bootstrap.Admin/Scripts/Groups.js b/Bootstrap.Admin/Scripts/Groups.js
index bd8d7632..cc03c59f 100644
--- a/Bootstrap.Admin/Scripts/Groups.js
+++ b/Bootstrap.Admin/Scripts/Groups.js
@@ -1,6 +1,13 @@
$(function () {
+ var $dialogUser = $("#dialogUser");
+ var $dialogUserHeader = $('#myUserModalLabel');
+ var $dialogUserForm = $('#userForm');
+ var $dialogRole = $('#dialogRole');
+ var $dialogRoleHeader = $('#myRoleModalLabel');
+ var $dialogRoleForm = $('#roleForm');
+
var bsa = new BootstrapAdmin({
- url: '../api/Groups',
+ url: Group.url,
dataEntity: new DataEntity({
map: {
ID: "groupID",
@@ -12,45 +19,59 @@
assign: [{
id: 'btn_assignRole',
click: function (row) {
- Role.getRolesByGroupId(row.ID, function (data) {
- $("#dialogRole .modal-title").text($.format('{0}-角色授权窗口', row.GroupName));
- $('#dialogRole form').html(data);
- $('#dialogRole').modal('show');
+ $.bc({
+ Id: row.ID, url: Role.url, data: { type: "group" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description);
+ }).join('')
+ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName));
+ $dialogRoleForm.html(html);
+ $dialogRole.modal('show');
+ }
});
}
}, {
id: 'btn_assignUser',
click: function (row) {
- User.getUsersByGroupeId(row.ID, function (data) {
- $("#dialogUser .modal-title").text($.format('{0}-用户授权窗口', row.GroupName));
- $('#dialogUser form').html(data);
- $('#dialogUser').modal('show');
+ $.bc({
+ Id: row.ID, url: User.url, data: { type: "group" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName);
+ }).join('');
+ $dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName));
+ $dialogUserForm.html(html);
+ $dialogUser.modal('show');
+ }
});
}
}, {
id: 'btnSubmitRole',
click: function (row) {
var groupId = row.ID;
- var roleIds = $('#dialogRole :checked').map(function (index, element) {
+ var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- Role.saveRolesByGroupId(groupId, roleIds, { modal: 'dialogRole' });
+ $.bc({ Id: groupId, url: Role.url, method: "PUT", data: { type: "group", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
}
}, {
id: 'btnSubmitUser',
click: function (row) {
var groupId = row.ID;
- var userIds = $('#dialogUser :checked').map(function (index, element) {
+ var userIds = $dialogUser.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- User.saveUsersByGroupId(groupId, userIds, { modal: 'dialogUser' });
+ $.bc({ Id: groupId, url: User.url, method: "PUT", data: { type: "group", userIds: userIds }, title: User.title, modal: 'dialogUser' });
}
}]
}
});
$('table').smartTable({
- url: '../api/Groups', //请求后台的URL(*)
+ url: Group.url, //请求后台的URL(*)
sortName: 'GroupName',
queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(*)
columns: [{ checkbox: true },
diff --git a/Bootstrap.Admin/Scripts/Infos.js b/Bootstrap.Admin/Scripts/Infos.js
index f0e1f1fd..37890479 100644
--- a/Bootstrap.Admin/Scripts/Infos.js
+++ b/Bootstrap.Admin/Scripts/Infos.js
@@ -2,7 +2,7 @@
var $headerIcon = $('#headerIcon');
var preIcon = $headerIcon.attr('src');
$('#fileIcon').fileinput({
- uploadUrl: '../api/Infos',
+ uploadUrl: Infos.url,
language: 'zh',
allowedFileExtensions: ['jpg'],
initialPreview: [
@@ -62,7 +62,7 @@
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
data.UserStatus = 2;
- User.changePassword(data);
+ $.bc({ url: User.url, method: "PUT", data: data, title: "更改密码" });
}
}
}, {
@@ -70,9 +70,12 @@
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
data.UserStatus = 1;
- User.saveUserDisplayName(data, function (result) {
- if (result) {
- $('#userDisplayName').text(data.DisplayName);
+ $.bc({
+ url: User.url, method: "PUT", data: data, title: "修改用户显示名称",
+ callback: function (result) {
+ if (result) {
+ $('#userDisplayName').text(data.DisplayName);
+ }
}
});
}
diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js
index df744d2e..40ffa4dc 100644
--- a/Bootstrap.Admin/Scripts/Menus.js
+++ b/Bootstrap.Admin/Scripts/Menus.js
@@ -1,4 +1,22 @@
$(function () {
+ var $dialog = $('#dialogNew');
+ var $pickIcon = $('#pickIcon');
+ var $iconList = $('#iconTab').find('div.fontawesome-icon-list');
+ var $dialogNew = $dialog.find('div.modal-dialog');
+ var $dialogIcon = $('#dialogIcon');
+ var $dialogMenu = $('#dialogSubMenu').find('.modal-content');
+ var $dialogRole = $('#dialogRole');
+ var $dialogRoleHeader = $('#myRoleModalLabel');
+ var $dialogRoleForm = $('#roleForm');
+ var $btnSubmitMenu = $('#btnSubmitMenu');
+ var $btnPickIcon = $('#btnIcon');
+ var $inputIcon = $('#icon');
+ var $nestMenu = $('#nestable_menu');
+ var $nestMenuInput = $nestMenu.find('div.dd3-content');
+ var $parentMenuID = $('#parentId');
+ var $parentMenuName = $('#parentName');
+ $nestMenuInput.find('label:first').hide();
+
var bsa = new BootstrapAdmin({
url: '../api/Menus',
dataEntity: new DataEntity({
@@ -17,39 +35,62 @@
assign: [{
id: 'btn_assignRole',
click: function (row) {
- Role.getRolesByMenuId(row.ID, function (data) {
- var dialog = $('#dialogRole');
- dialog.find('.modal-title').text($.format('{0}-角色授权窗口', row.Name));
- dialog.find('form').html(data);
- dialog.modal('show');
+ $.bc({
+ Id: row.ID, url: Role.url, data: { type: "menu" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description);
+ }).join('')
+ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name));
+ $dialogRoleForm.html(html);
+ $dialogRole.modal('show');
+ }
});
}
}, {
id: 'btnSubmitRole',
click: function (row) {
var menuId = row.ID;
- var dialog = $('#dialogRole');
- var roleIds = dialog.find('input:checked').map(function (index, element) {
+ var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- Role.saveRolesByMenuId(menuId, roleIds, { modal: 'dialogRole' });
+ $.bc({ Id: menuId, url: Role.url, method: "PUT", data: { type: "menu", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
}
}]
},
callback: function (result) {
if (!result.success) return;
if ((result.oper == "save") || result.oper == "del") {
- Menu.getMenus(function (data) {
- $nestMenu.find('ol:first').html(data);
- $nestMenuInput = $nestMenu.find('div.dd3-content');
- $nestMenuInput.find('label:first').hide();
+ $.bc({
+ Id: 0, url: Menu.url, data: { type: "user" }, swal: false,
+ callback: function (result) {
+ var html = "";
+ if ($.isArray(result)) html = cascadeMenu(result);
+ $nestMenu.find('ol:first').html(html);
+ $nestMenuInput = $nestMenu.find('div.dd3-content');
+ $nestMenuInput.find('label:first').hide();
+ }
});
}
}
});
+ var cascadeMenu = function (menus) {
+ var html = "";
+ $.each(menus, function (index, menu) {
+ if (menu.Menus.length == 0) {
+ html += $.format('', menu.ID, menu.Icon, menu.Name, menu.Category);
+ }
+ else {
+ html = $.format('{4}
', menu.ID, menu.Icon, menu.Name, menu.Category, cascadeMenu(menu.Menus));
+ }
+ });
+ return html;
+ };
+
$('table').smartTable({
- url: '../api/Menus', //请求后台的URL(*)
+ url: Menu.url, //请求后台的URL(*)
sortName: 'Order',
queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').val() }); }, //传递参数(*)
columns: [{ checkbox: true },
@@ -82,21 +123,6 @@
}
});
- var $dialog = $('#dialogNew');
- var $pickIcon = $('#pickIcon');
- var $iconList = $('#iconTab').find('div.fontawesome-icon-list');
- var $dialogNew = $dialog.find('div.modal-dialog');
- var $dialogIcon = $('#dialogIcon');
- var $dialogMenu = $('#dialogSubMenu').find('.modal-content');
- var $btnSubmitMenu = $('#btnSubmitMenu');
- var $btnPickIcon = $('#btnIcon');
- var $inputIcon = $('#icon');
- var $nestMenu = $('#nestable_menu');
- var $nestMenuInput = $nestMenu.find('div.dd3-content');
- var $parentMenuID = $('#parentId');
- var $parentMenuName = $('#parentName');
- $nestMenuInput.find('label:first').hide();
-
$iconList.find('ul li').addClass('col-md-3 col-sm-4 col-sm-6');
$iconList.on('click', 'div.fa-hover a, ul li', function () {
$pickIcon.attr('class', $(this).find('i, span:first').attr('class'));
@@ -182,9 +208,7 @@
if (icon == "") icon = "fa fa-dashboard";
$btnPickIcon.find('i').attr('class', icon);
});
-
$nestMenu.nestable();
-
// select
$('select').selectpicker();
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Scripts/Profiles.js b/Bootstrap.Admin/Scripts/Profiles.js
index d0259561..2c6b23ee 100644
--- a/Bootstrap.Admin/Scripts/Profiles.js
+++ b/Bootstrap.Admin/Scripts/Profiles.js
@@ -17,10 +17,8 @@
button: ['footSave']
});
- var options = { url: '../api/Profiles', title: '网站设置' };
-
var bsa = new BootstrapAdmin({
- url: options.url,
+ url: Profiles.url,
bootstrapTable: null,
validateForm: null,
modal: null,
@@ -35,26 +33,24 @@
id: 'sysSave',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
- var op = $.extend({
- data: { name: '网站标题', code: data.Title, category: '网站设置' },
+ $.bc({
+ url: Profiles.url, data: { name: '网站标题', code: data.Title, category: Profiles.title }, title: Profiles.title,
callback: function (result) {
- $('#websiteTitle').text(data.Title);
+ if (result) $('#websiteTitle').text(data.Title);
}
- }, options)
- bd(op);
+ });
}
}
}, {
id: 'footSave',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
- var op = $.extend({
- data: { name: '网站页脚', code: data.Footer, category: '网站设置' },
+ $.bc({
+ url: Profiles.url, data: { name: '网站页脚', code: data.Footer, category: Profiles.title }, title: Profiles.title,
callback: function (result) {
- $('#websiteFooter').text(data.Footer);
+ if (result) $('#websiteFooter').text(data.Footer);
}
- }, options)
- bd(op);
+ });
}
}
}]
@@ -63,7 +59,7 @@
function listCache(options) {
options = $.extend({ url: '../../CacheList.axd' }, options);
- bd({
+ $.bc({
url: options.url,
swal: false,
callback: function (result) {
diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js
index ac24e987..989c23e3 100644
--- a/Bootstrap.Admin/Scripts/Roles.js
+++ b/Bootstrap.Admin/Scripts/Roles.js
@@ -1,7 +1,12 @@
$(function () {
var $dialogUser = $("#dialogUser");
+ var $dialogUserHeader = $('#myUserModalLabel');
+ var $dialogUserForm = $('#userForm');
var $dialogGroup = $("#dialogGroup");
+ var $dialogGroupHeader = $('#myGroupModalLabel');
+ var $dialogGroupForm = $('#groupForm');
var $dialogMenu = $('#dialogMenu');
+ var $dialogMenuHeader = $('#myMenuModalLabel');
var $dialogSubMenu = $('#dialogSubMenu').find('.modal-content');
var $btnSubmitMenu = $('#btnSubmitMenu');
var $nestMenu = $('#nestable_menu');
@@ -9,7 +14,7 @@
$nestMenuInput.find('label:last').hide();
var bsa = new BootstrapAdmin({
- url: '../api/Roles',
+ url: Role.url,
dataEntity: new DataEntity({
map: {
ID: "roleID",
@@ -21,20 +26,54 @@
assign: [{
id: 'btn_assignUser',
click: function (row) {
- User.getUsersByRoleId(row.ID, function (data) {
- $dialogUser.find("div.modal-header").find('h4').text($.format('{0}-用户授权窗口', row.RoleName));
- $dialogUser.find('form').html(data);
- $dialogUser.modal('show');
- })
+ $.bc({
+ Id: row.ID, url: User.url, data: { type: "role" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName);
+ }).join('');
+ $dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName));
+ $dialogUserForm.html(html);
+ $dialogUser.modal('show');
+ }
+ });
}
}, {
id: 'btn_assignGroup',
click: function (row) {
- Group.getGroupsByRoleId(row.ID, function (data) {
- $dialogGroup.find("div.modal-header").find("h4").text($.format('{0}-部门授权窗口', row.RoleName));
- $dialogGroup.find('form').html(data);
- $dialogGroup.modal('show');
- })
+ $.bc({
+ Id: row.ID, url: Group.url, data: { type: "role" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.GroupName, element.Checked, element.Description);
+ }).join('');
+ $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName));
+ $dialogGroupForm.html(html);
+ $dialogGroup.modal('show');
+ }
+ });
+ }
+ }, {
+ id: 'btn_assignMenu',
+ click: function (row) {
+ $.bc({
+ Id: row.ID, url: Menu.url, data: { type: "role" }, swal: false,
+ callback: function (result) {
+ $dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName));
+ $btnSubmitMenu.data('type', 'menu');
+ // set checkbox status
+ var menus = $nestMenu.find('input:checkbox');
+ menus.removeProp('checked');
+ $.each(result, function (index, item) {
+ var selector = $.format('[value={0}]', item.ID);
+ menus.filter(selector).prop('checked', 'checked');
+ });
+ $dialogSubMenu.show();
+ $dialogMenu.modal('show');
+ }
+ });
}
}, {
id: 'btnSubmitUser',
@@ -43,38 +82,18 @@
var userIds = $dialogUser.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- User.saveUsersByRoleId(roleId, userIds, { modal: 'dialogUser' });
+ $.bc({ Id: roleId, url: User.url, method: "PUT", data: { type: "role", userIds: userIds }, modal: 'dialogUser', title: User.title });
}
- },
- {
+ }, {
id: 'btnSubmitGroup',
click: function (row) {
var roleId = row.ID;
var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- Group.saveGroupsByRoleId(roleId, groupIds, { modal: 'dialogGroup' });
+ $.bc({ Id: roleId, url: Group.url, method: "PUT", data: { type: "role", groupIds: groupIds }, modal: 'dialogGroup', title: Group.title });
}
- },
- {
- id: 'btn_assignMenu',
- click: function (row) {
- Menu.getMenusByRoleId(row.ID, function (data) {
- $dialogSubMenu.find("div.modal-header").find('h4').text($.format('{0}-菜单授权窗口', row.RoleName));
- $btnSubmitMenu.data('type', 'menu');
- // set checkbox status
- var menus = $nestMenu.find('input:checkbox');
- menus.removeProp('checked');
- $.each(data, function (index, item) {
- var selector = $.format('[value={0}]', item.ID);
- menus.filter(selector).prop('checked', 'checked');
- });
- $dialogSubMenu.show();
- $dialogMenu.modal('show');
- })
- }
- },
- {
+ }, {
id: 'btnSubmitMenu',
click: function (row) {
var roleId = row.ID;
@@ -88,7 +107,7 @@
default:
break;
}
- Menu.saveMenusByRoleId(roleId, menuIds, { modal: 'dialogMenu' });
+ $.bc({ Id: roleId, url: Menu.url, method: "PUT", data: { type: "role", menuIds: menuIds }, modal: 'dialogMenu', title: Menu.title });
}
}]
}
@@ -97,7 +116,7 @@
$nestMenu.nestable();
$('table').smartTable({
- url: '../api/Roles', //请求后台的URL(*)
+ url: Role.url, //请求后台的URL(*)
sortName: 'RoleName',
queryParams: function (params) { return $.extend(params, { roleName: $("#txt_search_name").val(), description: $("#txt_role_desc").val() }); }, //传递参数(*)
columns: [{ checkbox: true },
diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js
index e3e83c72..297ad6b6 100644
--- a/Bootstrap.Admin/Scripts/Users.js
+++ b/Bootstrap.Admin/Scripts/Users.js
@@ -1,6 +1,13 @@
$(function () {
+ var $dialogRole = $('#dialogRole');
+ var $dialogRoleHeader = $('#myRoleModalLabel');
+ var $dialogRoleForm = $('#roleForm');
+ var $dialogGroup = $("#dialogGroup");
+ var $dialogGroupHeader = $('#myGroupModalLabel');
+ var $dialogGroupForm = $('#groupForm');
+
var bsa = new BootstrapAdmin({
- url: '../api/Users',
+ url: User.url,
dataEntity: new DataEntity({
map: {
ID: "userID",
@@ -14,38 +21,52 @@
assign: [{
id: 'btn_assignRole',
click: function (row) {
- Role.getRolesByUserId(row.ID, function (data) {
- $("#dialogRole .modal-title").text($.format('{0}-角色授权窗口', row.DisplayName));
- $('#dialogRole form').html(data);
- $('#dialogRole').modal('show');
+ $.bc({
+ Id: row.ID, url: Role.url, data: { type: "user" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description);
+ }).join('')
+ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName));
+ $dialogRoleForm.html(html);
+ $dialogRole.modal('show');
+ }
});
}
}, {
id: 'btn_assignGroup',
click: function (row) {
- Group.getGroupsByUserId(row.ID, function (data) {
- $("#dialogGroup .modal-title").text($.format('{0}-部门授权窗口', row.DisplayName));
- $('#dialogGroup form').html(data);
- $('#dialogGroup').modal('show');
+ $.bc({
+ Id: row.ID, url: Group.url, data: { type: "user" }, swal: false,
+ callback: function (result) {
+ var htmlTemplate = this.htmlTemplate;
+ var html = $.map(result, function (element, index) {
+ return $.format(htmlTemplate, element.ID, element.GroupName, element.Checked, element.Description);
+ }).join('');
+ $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName));
+ $dialogGroupForm.html(html);
+ $dialogGroup.modal('show');
+ }
});
}
}, {
id: 'btnSubmitRole',
click: function (row) {
var userId = row.ID;
- var roleIds = $('#dialogRole :checked').map(function (index, element) {
+ var roleIds = $dialogRole.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- Role.saveRolesByUserId(userId, roleIds, { modal: 'dialogRole' });
+ $.bc({ Id: userId, url: Role.url, method: 'PUT', data: { type: "user", roleIds: roleIds }, title: Role.title, modal: 'dialogRole' });
}
}, {
id: 'btnSubmitGroup',
click: function (row) {
var userId = row.ID;
- var groupIds = $('#dialogGroup :checked').map(function (index, element) {
+ var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
return $(element).val();
}).toArray().join(',');
- Group.saveGroupsByUserId(userId, groupIds, { modal: 'dialogGroup' });
+ $.bc({ Id: userId, url: Group.url, method: 'PUT', data: { type: "user", groupIds: groupIds }, title: Group.title, modal: 'dialogGroup' });
}
}]
},
@@ -57,13 +78,13 @@
});
$('table').smartTable({
- url: '../api/Users', //请求后台的URL(*)
- sortName: 'UserName',
+ url: User.url, //请求后台的URL(*)
+ sortName: 'DisplayName',
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(*)
columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "登陆名称", field: "UserName", sortable: true },
- { title: "显示名称", field: "DisplayName", sortable: false }
+ { title: "显示名称", field: "DisplayName", sortable: true }
]
});
diff --git a/Bootstrap.Admin/Scripts/message.js b/Bootstrap.Admin/Scripts/message.js
index beccbd0a..9c22f513 100644
--- a/Bootstrap.Admin/Scripts/message.js
+++ b/Bootstrap.Admin/Scripts/message.js
@@ -2,11 +2,8 @@
var html = ' | | {0} | {1} | {2} | {3} |
';
function listData() {
- bd({
- Id: 'inbox',
- url: '../api/Messages/',
- method: 'GET',
- swal: false,
+ $.bc({
+ Id: 'inbox', url: Messages.url, method: 'GET', swal: false,
callback: function (result) {
if (result) {
var content = result.map(function (mail) {
@@ -14,7 +11,6 @@
}).join('');
$('#tbMsg').html(content);
}
- console.log(result);
}
});
}
diff --git a/Bootstrap.Admin/Scripts/noti.js b/Bootstrap.Admin/Scripts/noti.js
index cb933b92..a0a46114 100644
--- a/Bootstrap.Admin/Scripts/noti.js
+++ b/Bootstrap.Admin/Scripts/noti.js
@@ -1,14 +1,11 @@
$(function () {
+ var $btnRefreshUser = $('#refreshUsers');
var htmlNewUsers = '';
- function listData(options) {
- options = $.extend({ animation: true, ctl: $('a.fa-refresh') }, options);
- if (options.animation) options.ctl.toggleClass('fa-spin');
- bd({
- Id: 'newusers',
- url: '../api/Notifications/',
- method: 'GET',
- swal: false,
+ function listData() {
+ $btnRefreshUser.toggleClass('fa-spin');
+ $.bc({
+ Id: 'newusers', url: Notifications.url, method: 'GET', swal: false,
callback: function (result) {
if (result) {
var content = result.Users.map(function (noti) {
@@ -16,21 +13,24 @@
}).join('');
$('#tasks-users').html(content);
}
- if (options.animation) options.ctl.toggleClass('fa-spin');
+ $btnRefreshUser.toggleClass('fa-spin');
}
});
}
listData();
- $('a.fa-refresh').on('click', function () {
- listData({ ctl: $(this) });
+ $btnRefreshUser.on('click', function () {
+ listData();
});
$('#tasks-users').on('click', 'button', function () {
var id = $(this).attr('data-id');
var result = $(this).attr('data-result');
- User.processUser(id, result, function (result) {
- listData({ ctl: $('#refreshUsers') });
+ $.bc({
+ Id: id, url: User.url, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户",
+ callback: function (result) {
+ listData({ ctl: $('#refreshUsers') });
+ }
});
});
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Scripts/tasks.js b/Bootstrap.Admin/Scripts/tasks.js
index 52bf6f5d..b1ffd509 100644
--- a/Bootstrap.Admin/Scripts/tasks.js
+++ b/Bootstrap.Admin/Scripts/tasks.js
@@ -1,33 +1,26 @@
-$(function () {
- var url = '../api/Tasks/';
-
- var htmlTask = '{0}{1}{2}';
- htmlTask += '
';
-
- function listData(options) {
- options = $.extend({ url: url, animation: true, ctl: $('a.fa-refresh') }, options);
- if (options.animation) options.ctl.toggleClass('fa-spin');
- $.ajax({
- url: options.url,
- type: 'GET',
- success: function (result) {
- if (result) {
- var content = result.Users.map(function (task) {
- var t = new Date(task.AssignTime).format('yyyy-MM-dd HH:mm:ss');
- return $.format(htmlTask, task.TaskName, task.UserName, t, task.ID);
- }).join('');
- $('#list-task').html(content);
- }
- if (options.animation) options.ctl.toggleClass('fa-spin');
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- if (options.animation) options.ctl.toggleClass('fa-spin');
- }
- });
- }
- listData();
-
- $('a.fa-refresh').on('click', function () {
- listData({ ctl: $(this) });
- });
+$(function () {
+ var $btnRefresh = $('#refreshTask');
+
+ var htmlTask = '';
+
+ function listData() {
+ $btnRefresh.toggleClass('fa-spin');
+ $.bc({
+ url: Tasks.url, method: 'GET', swal: false,
+ callback: function (result) {
+ if (result) {
+ var content = result.map(function (task) {
+ return $.format(htmlTask, task.TaskName, task.UserName, task.AssignTime, task.ID);
+ }).join('');
+ $('#list-task').html(content);
+ }
+ $btnRefresh.toggleClass('fa-spin');
+ }
+ });
+ }
+ listData();
+
+ $btnRefresh.on('click', function () {
+ listData();
+ });
})
\ No newline at end of file
diff --git a/Bootstrap.Admin/Views/Admin/Tasks.cshtml b/Bootstrap.Admin/Views/Admin/Tasks.cshtml
index acf93947..04ba4d3c 100644
--- a/Bootstrap.Admin/Views/Admin/Tasks.cshtml
+++ b/Bootstrap.Admin/Views/Admin/Tasks.cshtml
@@ -1,40 +1,33 @@
-@model NavigatorBarModel
-@{
- ViewBag.Title = "任务消息";
- Layout = "~/Views/Shared/_Admin.cshtml";
-}
-@section Javascript {
-
-
-}
-@section css {
-
-
-}
-@section header {
- @Html.Partial("Header", Model)
-}
-@section navigator {
- @Html.Partial("Navigator", Model)
-}
-
+@model NavigatorBarModel
+@{
+ ViewBag.Title = "任务消息";
+ Layout = "~/Views/Shared/_Admin.cshtml";
+}
+@section Javascript {
+
+
+}
+@section css {
+
+
+}
+@section header {
+ @Html.Partial("Header", Model)
+}
+@section navigator {
+ @Html.Partial("Navigator", Model)
+}
+
diff --git a/Bootstrap.Admin/Views/Shared/GroupConfig.cshtml b/Bootstrap.Admin/Views/Shared/GroupConfig.cshtml
index 0ea4ba47..27899c9b 100644
--- a/Bootstrap.Admin/Views/Shared/GroupConfig.cshtml
+++ b/Bootstrap.Admin/Views/Shared/GroupConfig.cshtml
@@ -1,17 +1,17 @@
-
+
diff --git a/Bootstrap.Admin/Views/Shared/RoleConfig.cshtml b/Bootstrap.Admin/Views/Shared/RoleConfig.cshtml
index a1ef8da8..76f35c69 100644
--- a/Bootstrap.Admin/Views/Shared/RoleConfig.cshtml
+++ b/Bootstrap.Admin/Views/Shared/RoleConfig.cshtml
@@ -6,7 +6,7 @@
角色授权窗口
-