From 82d967f776694d046f8551320ad046e550e0e924 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 18 Nov 2016 14:42:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG=EF=BC=9A=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E5=89=8D=E5=8F=B05=E4=B8=AA=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Content/css/site.css | 46 +++++++++++----- Bootstrap.Admin/Content/js/common-scripts.js | 54 +++++++++++++++---- Bootstrap.Admin/Content/js/framework.js | 11 ---- .../Controllers/NotificationsController.cs | 4 +- Bootstrap.Admin/Scripts/noti.js | 30 ++++------- .../Views/Admin/Notifications.cshtml | 21 +------- Bootstrap.Admin/Views/Shared/Header.cshtml | 43 +++++++-------- Bootstrap.DataAccess/ExceptionHelper.cs | 7 +-- Bootstrap.DataAccess/Message.cs | 8 +++ Bootstrap.DataAccess/MessageHelper.cs | 6 ++- 10 files changed, 123 insertions(+), 107 deletions(-) diff --git a/Bootstrap.Admin/Content/css/site.css b/Bootstrap.Admin/Content/css/site.css index aadcfd07..1dc7a52e 100644 --- a/Bootstrap.Admin/Content/css/site.css +++ b/Bootstrap.Admin/Content/css/site.css @@ -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; diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js index cd0e51e9..903c2e8f 100644 --- a/Bootstrap.Admin/Content/js/common-scripts.js +++ b/Bootstrap.Admin/Content/js/common-scripts.js @@ -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 = '
  • {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); + // new users + $('#msgHeaderUser').text(result.NewUsersCount); + $('#msgHeaderUserBadge').text(result.NewUsersCount); + var htmlUserTemplate = '
  • {1}({0})
    {3}
  • '; + 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 = '
  • {0}
    {2}
  • '; + 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 = '
  • {0}
    {2}
  • '; + 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 = '
  • avatar{2}{4}{3}
  • '; + 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); + } }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 1a6c0a78..59174481 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -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); \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/NotificationsController.cs b/Bootstrap.Admin/Controllers/NotificationsController.cs index 118f23a5..7701a9b3 100644 --- a/Bootstrap.Admin/Controllers/NotificationsController.cs +++ b/Bootstrap.Admin/Controllers/NotificationsController.cs @@ -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; } diff --git a/Bootstrap.Admin/Scripts/noti.js b/Bootstrap.Admin/Scripts/noti.js index f68ba1d8..cb933b92 100644 --- a/Bootstrap.Admin/Scripts/noti.js +++ b/Bootstrap.Admin/Scripts/noti.js @@ -1,34 +1,23 @@ $(function () { var htmlNewUsers = '
  • {0}{1}{2}
  • '; - var htmlApp = '
  • {0}{1}{2}
  • '; - var htmlDb = '
  • {0}{1}{2}
  • '; 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') }); }); }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Admin/Notifications.cshtml b/Bootstrap.Admin/Views/Admin/Notifications.cshtml index 21b85b09..2d10a432 100644 --- a/Bootstrap.Admin/Views/Admin/Notifications.cshtml +++ b/Bootstrap.Admin/Views/Admin/Notifications.cshtml @@ -18,7 +18,7 @@ @Html.Partial("Navigator", Model) }
    -
    用户注册
    +
    用户注册
      @@ -26,22 +26,3 @@
    -
    -
    程序错误
    -
    -
    -
      -
    -
    -
    -
    -
    -
    数据库错误
    -
    -
    -
      -
    -
    -
    -
    - diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index 09b62698..4e9435fa 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -34,10 +34,10 @@ @@ -46,12 +46,12 @@