修改BUG:完善前台5个通知栏
This commit is contained in:
parent
8b04f10c27
commit
82d967f776
|
@ -149,6 +149,7 @@ a, a:hover, a:focus {
|
|||
background: none;
|
||||
margin-right: 0;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.top-menu > li > a:hover .caret {
|
||||
|
@ -273,10 +274,18 @@ a, a:hover, a:focus {
|
|||
background: #ff6c60;
|
||||
}
|
||||
|
||||
.notify-row .bg-user, .notify-row .dropdown-menu.users li p {
|
||||
background: #5cb85c;
|
||||
}
|
||||
|
||||
.notify-row .bg-warning, .notify-row .dropdown-menu.notification li p {
|
||||
background: #FCB322;
|
||||
}
|
||||
|
||||
.notify-row .bg-db, .notify-row .dropdown-menu.dbs li p {
|
||||
background: #d03633;
|
||||
}
|
||||
|
||||
.notify-row > li {
|
||||
float: left;
|
||||
position: relative;
|
||||
|
@ -345,6 +354,18 @@ a, a:hover, a:focus {
|
|||
border-top-color: #ff6c60;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu .notify-arrow.notify-arrow-db {
|
||||
border-color: transparent transparent #d03633;
|
||||
border-bottom-color: #d03633;
|
||||
border-top-color: #d03633;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu .notify-arrow.notify-arrow-user {
|
||||
border-color: transparent transparent #5cb85c;
|
||||
border-bottom-color: #5cb85c;
|
||||
border-top-color: #5cb85c;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu li:last-child, .notify-row .dropdown-menu li:last-child a:hover {
|
||||
border-radius: 0 0 4px 4px;
|
||||
}
|
||||
|
@ -367,14 +388,6 @@ a, a:hover, a:focus {
|
|||
color: #2E2E2E;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu .label {
|
||||
padding: 0.5em 0.8em;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu .label.label-danger {
|
||||
background-color: #FF6C60;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu p {
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
|
@ -424,17 +437,22 @@ a, a:hover, a:focus {
|
|||
font-size: 11px;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu.inbox .message {
|
||||
display: block !important;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
left: 56px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
|
||||
.notify-row .dropdown-menu.notification .label {
|
||||
.notify-row .dropdown-menu .label {
|
||||
display: inline-block;
|
||||
height: 18px;
|
||||
width: 20px;
|
||||
|
@ -442,7 +460,7 @@ a, a:hover, a:focus {
|
|||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu.notification .small {
|
||||
.notify-row .dropdown-menu .small {
|
||||
font-size: 10px;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
|
@ -450,7 +468,7 @@ a, a:hover, a:focus {
|
|||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.notify-row .dropdown-menu.notification li a div {
|
||||
.notify-row .dropdown-menu li a div {
|
||||
position: absolute;
|
||||
left: 36px;
|
||||
right: 44px;
|
||||
|
|
|
@ -47,17 +47,49 @@
|
|||
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);
|
||||
bd({
|
||||
url: '../api/Notifications/',
|
||||
swal: false,
|
||||
method: 'GET',
|
||||
callback: function (result) {
|
||||
$('#logoutNoti').text(result.NewUsersCount);
|
||||
|
||||
// new users
|
||||
$('#msgHeaderUser').text(result.NewUsersCount);
|
||||
$('#msgHeaderUserBadge').text(result.NewUsersCount);
|
||||
var htmlUserTemplate = '<li><a href="../Admin/Notifications"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{1}">{0}({1})</div><span class="small italic">{2}</span></a></li>';
|
||||
var html = result.Users.map(function (u) {
|
||||
return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Period);
|
||||
}).join('');
|
||||
$(html).insertAfter($('#msgHeaderUserContent'));
|
||||
console.log(result);
|
||||
// new users
|
||||
$('#msgHeaderUser').text(result.NewUsersCount);
|
||||
$('#msgHeaderUserBadge').text(result.NewUsersCount);
|
||||
var htmlUserTemplate = '<li><a href="../Admin/Notifications"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{2}">{1}({0})</div><span class="small italic">{3}</span></a></li>';
|
||||
var html = result.Users.map(function (u) {
|
||||
return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Description, u.Period);
|
||||
}).join('');
|
||||
$(html).insertAfter($('#msgHeaderUserContent'));
|
||||
|
||||
// apps
|
||||
$('#msgHeaderApp').text(result.AppExceptionsCount);
|
||||
$('#msgHeaderAppBadge').text(result.AppExceptionsCount);
|
||||
htmlUserTemplate = '<li><a href="../Admin/Exceptions"><span class="label label-warning"><i class="fa fa-bug"></i></span><div title="{1}">{0}</div><span class="small italic">{2}</span></a></li>';
|
||||
html = result.Apps.map(function (u) {
|
||||
return $.format(htmlUserTemplate, u.ExceptionType, u.Message, u.Period);
|
||||
}).join('');
|
||||
$(html).insertAfter($('#msgHeaderAppContent'));
|
||||
|
||||
// dbs
|
||||
$('#msgHeaderDb').text(result.DbExceptionsCount);
|
||||
$('#msgHeaderDbBadge').text(result.DbExceptionsCount);
|
||||
htmlUserTemplate = '<li><a href="../Admin/Exceptions"><span class="label label-danger"><i class="fa fa-bolt"></i></span><div title="{1}">{0}</div><span class="small italic">{2}</span></a></li>';
|
||||
html = result.Dbs.map(function (u) {
|
||||
return $.format(htmlUserTemplate, u.ErrorPage, u.Message, u.Period);
|
||||
}).join('');
|
||||
$(html).insertAfter($('#msgHeaderDbContent'));
|
||||
|
||||
// messages
|
||||
$('#msgHeaderMsg').text(result.MessagesCount);
|
||||
$('#msgHeaderMsgBadge').text(result.MessagesCount);
|
||||
htmlUserTemplate = '<li><a href="../Admin/Messages?id={0}"><span class="photo"><img alt="avatar" src="{1}"></span><span class="subject"><span class="from">{2}</span><span class="time">{4}</span></span><span class="message" title="{5}">{3}</span></a></li>';
|
||||
html = result.Messages.map(function (u) {
|
||||
return $.format(htmlUserTemplate, u.ID, u.FromIcon, u.FromDisplayName, u.Title, u.Period, u.Content);
|
||||
}).join('');
|
||||
$(html).insertAfter($('#msgHeaderMsgContent'));
|
||||
console.log(result);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -432,15 +432,4 @@
|
|||
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);
|
|
@ -37,6 +37,7 @@ namespace Bootstrap.Admin.Controllers
|
|||
//Message
|
||||
var message = MessageHelper.RetrieveMessagesHeader(User.Identity.Name);
|
||||
ret.Messages = message.Take(6).ToList();
|
||||
ret.Messages.AsParallel().ForAll(m => m.FromIcon = Url.Content(m.FromIcon));
|
||||
ret.MessagesCount = message.Count();
|
||||
|
||||
//Apps
|
||||
|
@ -44,6 +45,7 @@ namespace Bootstrap.Admin.Controllers
|
|||
ret.Apps = apps.Take(6).OrderByDescending(a => a.LogTime).ToList();
|
||||
ret.Apps.AsParallel().ForAll(n =>
|
||||
{
|
||||
n.ExceptionType = n.ExceptionType.Split('.').Last();
|
||||
var ts = DateTime.Now - n.LogTime;
|
||||
if (ts.TotalMinutes < 5) n.Period = "刚刚";
|
||||
else if (ts.Days > 0) n.Period = string.Format("{0}天", ts.Days);
|
||||
|
@ -77,8 +79,6 @@ namespace Bootstrap.Admin.Controllers
|
|||
{
|
||||
var ret = new Notifications();
|
||||
if (id == "newusers" || id == "all") ret.Users = UserHelper.RetrieveNewUsers().OrderByDescending(u => u.RegisterTime).ToList();
|
||||
else if (id == "apps" || id == "all") ret.Apps = ExceptionHelper.RetrieveExceptions().Where(n => n.ExceptionType != "Longbow.Data.DBAccessException").OrderByDescending(a => a.LogTime).ToList();
|
||||
else if (id == "dbs" || id == "all") ret.Dbs = ExceptionHelper.RetrieveExceptions().Where(n => n.ExceptionType == "Longbow.Data.DBAccessException").OrderByDescending(d => d.LogTime).ToList();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +1,23 @@
|
|||
$(function () {
|
||||
var htmlNewUsers = '<li class="list-primary"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><button class="btn btn-success btn-xs fa fa-check" data-id="{3}" data-result="1"></button><button class="btn btn-danger btn-xs fa fa-remove" data-id="{3}" data-result="0" data-placement="left" data-original-title="拒绝授权"></button></div></div></li>';
|
||||
var htmlApp = '<li class="list-warning"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-warning btn-xs fa fa-bug"></a></div></div></li>';
|
||||
var htmlDb = '<li class="list-danger"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-danger btn-xs fa fa-database"></a></div></div></li>';
|
||||
|
||||
function listData(options) {
|
||||
options = $.extend({ animation: true, ctl: $('a.fa-refresh') }, options);
|
||||
var category = options.ctl.length == 1 ? options.ctl.attr('data-category') : "all";
|
||||
if (options.animation) options.ctl.toggleClass('fa-spin');
|
||||
Notifications.retrieveNotifies(category, function (result) {
|
||||
if (result) {
|
||||
if (category == 'newusers' || category == 'all') {
|
||||
bd({
|
||||
Id: 'newusers',
|
||||
url: '../api/Notifications/',
|
||||
method: 'GET',
|
||||
swal: false,
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
var content = result.Users.map(function (noti) {
|
||||
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID);
|
||||
}).join('');
|
||||
$('#tasks-users').html(content);
|
||||
}
|
||||
if (category == 'apps' || category == 'all') {
|
||||
var content = result.Apps.map(function (noti) {
|
||||
return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
||||
}).join('');
|
||||
$('#tasks-app').html(content);
|
||||
}
|
||||
if (category == 'dbs' || category == 'all') {
|
||||
var content = result.Dbs.map(function (noti) {
|
||||
return $.format(htmlDb, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
||||
}).join('');
|
||||
$('#tasks-db').html(content);
|
||||
}
|
||||
if (options.animation) options.ctl.toggleClass('fa-spin');
|
||||
}
|
||||
if (options.animation) options.ctl.toggleClass('fa-spin');
|
||||
});
|
||||
}
|
||||
listData();
|
||||
|
@ -41,8 +30,7 @@
|
|||
var id = $(this).attr('data-id');
|
||||
var result = $(this).attr('data-result');
|
||||
User.processUser(id, result, function (result) {
|
||||
var refresh = $('#tasks-users').parentsUntil('div.panel').last().prev().find('a.fa-refresh');
|
||||
listData(refresh);
|
||||
listData({ ctl: $('#refreshUsers') });
|
||||
});
|
||||
});
|
||||
});
|
|
@ -18,7 +18,7 @@
|
|||
@Html.Partial("Navigator", Model)
|
||||
}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">用户注册<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="newusers"></a></span></div>
|
||||
<div class="panel-heading">用户注册<span class="pull-right"><a id="refreshUsers" href="javascript:;" class="fa fa-refresh"></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="tasks-users" class="task-list ui-sortable">
|
||||
|
@ -26,22 +26,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">程序错误<a href="javascript:;" class="pull-right fa fa-refresh" data-category="apps"></a></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="tasks-app" class="task-list ui-sortable">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">数据库错误<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="dbs"></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="tasks-db" class="task-list ui-sortable">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@
|
|||
<ul class="dropdown-menu tasks-bar">
|
||||
<div class="notify-arrow notify-arrow-green"></div>
|
||||
<li>
|
||||
<p>您有 0 个未读的消息</p>
|
||||
<p>您有 0 个未完成的任务</p>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Tasks">查看所有消息</a>
|
||||
<a href="~/Admin/Tasks">查看所有任务</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -46,12 +46,12 @@
|
|||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<i class="fa fa-envelope"></i>
|
||||
<span class="badge bg-important"></span>
|
||||
<span id="msgHeaderMsgBadge" class="badge bg-important"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu inbox">
|
||||
<div class="notify-arrow notify-arrow-red"></div>
|
||||
<li>
|
||||
<p>您有 0 个未读的消息</p>
|
||||
<li id="msgHeaderMsgContent">
|
||||
<p>您有 <span id="msgHeaderMsg">0</span> 个未读的消息</p>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Messages">查看所有消息</a>
|
||||
|
@ -63,14 +63,14 @@
|
|||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<i class="fa fa-user-plus"></i>
|
||||
<span id="msgHeaderUserBadge" class="badge bg-warning"></span>
|
||||
<span id="msgHeaderUserBadge" class="badge bg-user"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu notification">
|
||||
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||
<ul class="dropdown-menu users">
|
||||
<div class="notify-arrow notify-arrow-user"></div>
|
||||
<li id="msgHeaderUserContent">
|
||||
<p>您有 <span id="msgHeaderUser">0</span> 条新通知</p>
|
||||
<p>您有 <span id="msgHeaderUser">0</span> 条新用户通知</p>
|
||||
</li>
|
||||
<li id="msgHeaderUserFooter">
|
||||
<li>
|
||||
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -80,15 +80,15 @@
|
|||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<i class="fa fa-bug"></i>
|
||||
<span class="badge bg-warning"></span>
|
||||
<span id="msgHeaderAppBadge" class="badge bg-warning"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu notification">
|
||||
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||
<li>
|
||||
<p>您有 0 条新通知</p>
|
||||
<li id="msgHeaderAppContent">
|
||||
<p>您有 <span id="msgHeaderApp">0</span> 条程序异常通知</p>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||
<a href="~/Admin/Exceptions">查看所有异常</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -97,15 +97,15 @@
|
|||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<i class="fa fa-database"></i>
|
||||
<span class="badge bg-warning"></span>
|
||||
<span id="msgHeaderDbBadge" class="badge bg-db"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu notification">
|
||||
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||
<li>
|
||||
<p>您有 0 条新通知</p>
|
||||
<ul class="dropdown-menu dbs">
|
||||
<div class="notify-arrow notify-arrow-db"></div>
|
||||
<li id="msgHeaderDbContent">
|
||||
<p>您有 <span id="msgHeaderDb">0</span> 条数据库异常通知</p>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||
<a href="~/Admin/Exceptions">查看所有异常</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -115,9 +115,6 @@
|
|||
}
|
||||
<!--search & user info start-->
|
||||
<ul class="pull-right top-menu">
|
||||
<li>
|
||||
<input type="text" class="form-control search" placeholder="搜索">
|
||||
</li>
|
||||
<!-- user login dropdown start-->
|
||||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
|
|
|
@ -63,9 +63,10 @@ namespace Bootstrap.DataAccess
|
|||
ErrorPage = (string)reader[2],
|
||||
UserID = (string)reader[3],
|
||||
UserIp = (string)reader[4],
|
||||
Message = (string)reader[5],
|
||||
StackTrace = (string)reader[6],
|
||||
LogTime = (DateTime)reader[7],
|
||||
ExceptionType = (string)reader[5],
|
||||
Message = (string)reader[6],
|
||||
StackTrace = (string)reader[7],
|
||||
LogTime = (DateTime)reader[8],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,5 +60,13 @@ namespace Bootstrap.DataAccess
|
|||
/// 获得/设置 时间描述 2分钟内为刚刚
|
||||
/// </summary>
|
||||
public string Period { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 发件人头像
|
||||
/// </summary>
|
||||
public string FromIcon { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 发件人昵称
|
||||
/// </summary>
|
||||
public string FromDisplayName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
|
||||
{
|
||||
string sql = "select m.*, d.Name from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息状态' and d.Define = 0 where[To] = @UserName or [From] = @UserName";
|
||||
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/Content/images/uploader/default.jpg'), u.DisplayName from[Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息状态' and d.Define = 0 left join Dicts i on i.Category = N'头像地址' and i.Name = N'头像路径' and i.Define = 0 inner join Users u on m.[From] = u.UserName where [To] = @UserName or [From] = @UserName";
|
||||
List<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||
try
|
||||
|
@ -48,7 +48,9 @@ namespace Bootstrap.DataAccess
|
|||
Mark = (int)reader[7],
|
||||
IsDelete = (int)reader[8],
|
||||
Label = (string)reader[9],
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty)
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty),
|
||||
FromIcon = (string)reader[11],
|
||||
FromDisplayName = (string)reader[12]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue