diff --git a/Bootstrap.Admin/Content/css/site.css b/Bootstrap.Admin/Content/css/site.css
index 25c01320..204930ab 100644
--- a/Bootstrap.Admin/Content/css/site.css
+++ b/Bootstrap.Admin/Content/css/site.css
@@ -441,7 +441,7 @@
padding-top: 2px;
}
- .notify-row .dropdown-menu.notification > li > a > div {
+ .notify-row .dropdown-menu.notification li a div {
position: absolute;
left: 36px;
right: 44px;
diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js
index 95649804..3992ff74 100644
--- a/Bootstrap.Admin/Content/js/common-scripts.js
+++ b/Bootstrap.Admin/Content/js/common-scripts.js
@@ -45,4 +45,19 @@
// custom scrollbar
if (!$.browser.versions.ios) $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', scrollspeed: 60 });
+
+ // load widget data
+ Notifications.retrieveAllNotifies(function (result) {
+ $('#logoutNoti').text(result.NewUsersCount);
+
+ // new users
+ $('#msgHeaderUser').text(result.NewUsersCount);
+ $('#msgHeaderUserBadge').text(result.NewUsersCount);
+ var htmlUserTemplate = '
{0}({1})
{2}';
+ var html = result.Users.map(function (u) {
+ return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Period);
+ }).join('');
+ $(html).insertAfter($('#msgHeaderUserContent'));
+ console.log(result);
+ });
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js
index 76c7bb29..3c4e43b7 100644
--- a/Bootstrap.Admin/Content/js/framework.js
+++ b/Bootstrap.Admin/Content/js/framework.js
@@ -255,7 +255,7 @@
var htmlTemplate = '';
var processData = function (options) {
- var data = $.extend({ data: { type: "" }, remote: true, method: "POST", Id: "", url: this.url, title: this.title, html: this.html, swal: true }, 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({
@@ -288,7 +288,7 @@
else { swal("失败", data.title, "error"); }
}
}
- }
+ };
// Roles
Role = {
url: '../api/Roles/',
@@ -310,10 +310,10 @@
};
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 } });
};
@@ -326,7 +326,7 @@
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" } });
};
@@ -340,12 +340,14 @@
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:"修改用户显示名称" });
+ processData.call(this, { Id: '', callback: callback, method: "PUT", data: user, title: "修改用户显示名称" });
};
User.changePassword = function (user) {
- processData.call(this, { Id: '', method: "PUT", data: user, title: "修改密码" });
- }
-
+ 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" ? "授权用户" : "拒绝用户" });
+ };
// Groups
Group = {
url: '../api/Groups/',
@@ -380,7 +382,7 @@
}
return htmlString;
}
- }
+ };
Menu.cascadeMenu = function (menus) {
var html = "";
$.each(menus, function (index, menu) {
@@ -392,7 +394,7 @@
}
});
return html;
- }
+ };
Menu.getMenus = function (callback) {
processData.call(this, { Id: 0, callback: callback, data: { type: "user" } });
};
@@ -407,10 +409,10 @@
Profiles = {
url: '../api/Profiles/',
title: "个性化维护"
- }
+ };
Profiles.saveWebSite = function (options) {
processData.call(this, { data: options });
- }
+ };
// Exceptions
Exceptions = {
@@ -421,19 +423,30 @@
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 } });
- }
+ };
// Dicts
Dicts = {
url: '../api/Dicts/'
- }
+ };
Dicts.retrieveCategories = function (callback) {
processData.call(this, { Id: 1, callback: callback, swal: false, data: { type: 'category' } });
+ };
+
+ // Notifi
+ Notifications = {
+ url: '../api/Notifications/'
+ };
+ Notifications.retrieveNotifies = function (category, callback) {
+ processData.call(this, { Id: category, callback: callback, method: "GET", swal: false });
+ };
+ Notifications.retrieveAllNotifies = function (callback) {
+ processData.call(this, { Id: "", callback: callback, method: "GET", swal: false });
}
})(jQuery);
\ No newline at end of file
diff --git a/Bootstrap.Admin/Controllers/NotificationsController.cs b/Bootstrap.Admin/Controllers/NotificationsController.cs
index 55ff7274..9984e8c5 100644
--- a/Bootstrap.Admin/Controllers/NotificationsController.cs
+++ b/Bootstrap.Admin/Controllers/NotificationsController.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Web.Http;
using System.Linq;
+using System;
namespace Bootstrap.Admin.Controllers
{
@@ -15,12 +16,20 @@ namespace Bootstrap.Admin.Controllers
public Notifications Get()
{
var ret = new Notifications();
- NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n =>
- {
- if (n.Category == "0") ret.Users.Add(n);
- else if (n.Category == "1") ret.Apps.Add(n);
- else if (n.Category == "2") ret.Dbs.Add(n);
- });
+ // New Users
+ var user = UserHelper.RetrieveNewUsers();
+ ret.Users = user.Take(6).OrderByDescending(u => u.RegisterTime).ToList();
+ ret.Users.AsParallel().ForAll(n =>
+ {
+ var ts = DateTime.Now - n.RegisterTime;
+ if (ts.TotalMinutes < 5) n.Period = "刚刚";
+ else if (ts.Days > 0) n.Period = string.Format("{0}天", ts.Days);
+ else if (ts.Hours > 0) n.Period = string.Format("{0}小时", ts.Hours);
+ else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes);
+ });
+ ret.NewUsersCount = user.Count();
+
+ // Tasks
return ret;
}
///
@@ -32,13 +41,9 @@ namespace Bootstrap.Admin.Controllers
public Notifications Get(string id)
{
var ret = new Notifications();
- NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n =>
- {
- if (id != n.Category) return;
- if (n.Category == "0") ret.Users.Add(n);
- else if (n.Category == "1") ret.Apps.Add(n);
- else if (n.Category == "2") ret.Dbs.Add(n);
- });
+ if (id == "newusers" || id == "all") ret.Users = UserHelper.RetrieveNewUsers().OrderByDescending(u => u.RegisterTime).ToList();
+ else if (id == "apps" || id == "all") ret.Apps = new List();
+ else if (id == "dbs" || id == "all") ret.Dbs = new List();
return ret;
}
@@ -46,15 +51,52 @@ namespace Bootstrap.Admin.Controllers
{
public Notifications()
{
- Users = new List();
- Apps = new List();
- Dbs = new List();
+ Users = new List();
+ Apps = new List();
+ Dbs = new List();
+ Tasks = new List();
+ Messages = new List();
}
- public List Users { get; set; }
-
- public List Apps { get; set; }
-
- public List Dbs { get; set; }
+ ///
+ ///
+ ///
+ public List Users { get; set; }
+ ///
+ ///
+ ///
+ public List Apps { get; set; }
+ ///
+ ///
+ ///
+ public List Dbs { get; set; }
+ ///
+ ///
+ ///
+ public List Tasks { get; set; }
+ ///
+ ///
+ ///
+ public List Messages { get; set; }
+ ///
+ /// 获得/设置 消息数量
+ ///
+ public int MessagesCount { get; set; }
+ ///
+ /// 获得/设置 新用户数量
+ ///
+ public int NewUsersCount { get; set; }
+ ///
+ /// 获取/设置 任务数量
+ ///
+ public int TasksCount { get; set; }
+ ///
+ /// 获取/设置 应用程序错误数量
+ ///
+ public int AppExceptionsCount { get; set; }
+ ///
+ /// 获取/设置 数据库错误数量
+ ///
+ public int DbExceptionsCount { get; set; }
}
}
}
\ No newline at end of file
diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs
index 2a2f8539..0ec0a38d 100644
--- a/Bootstrap.Admin/Controllers/UsersController.cs
+++ b/Bootstrap.Admin/Controllers/UsersController.cs
@@ -2,7 +2,6 @@
using Bootstrap.DataAccess;
using Longbow.Security.Principal;
using Newtonsoft.Json.Linq;
-using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
@@ -66,7 +65,6 @@ namespace Bootstrap.Admin.Controllers
}
return ret;
}
-
///
///
///
@@ -88,7 +86,12 @@ namespace Bootstrap.Admin.Controllers
value.ApprovedBy = User.Identity.Name;
return UserHelper.SaveUser(value);
}
-
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
[HttpPut]
public bool Put(int id, [FromBody]JObject value)
{
@@ -122,7 +125,6 @@ namespace Bootstrap.Admin.Controllers
}
return ret;
}
-
///
///
///
diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs
index 5815c799..520fc7f3 100644
--- a/Bootstrap.Admin/Models/HeaderBarModel.cs
+++ b/Bootstrap.Admin/Models/HeaderBarModel.cs
@@ -1,6 +1,5 @@
using Bootstrap.DataAccess;
using System.Collections.Generic;
-using System.Linq;
using System.Web;
namespace Bootstrap.Admin.Models
@@ -19,16 +18,6 @@ namespace Bootstrap.Admin.Models
UserID = user.ID;
HomeUrl = "~/";
Menus = MenuHelper.RetrieveLinksByUserName(UserName);
- var notis = NotificationHelper.RetrieveNotifications();
- NotifiCount = notis.Count();
- Notifications = notis.Take(6);
- var msgs = MessageHelper.RetrieveMessagesHeader(UserName);
- MessageCount = msgs.Count();
- Messages = msgs.Take(6);
- MessageList = MessageHelper.RetrieveMessages(UserName);
- var tasks = TaskHelper.RetrieveTasks();
- TaskCount = tasks.Count();
- Tasks = tasks.Take(6);
}
public string UserName { get; protected set; }
///
@@ -52,37 +41,12 @@ namespace Bootstrap.Admin.Models
///
public IEnumerable