From e5c73cedf15d01a1f91d8dc7ff8a4046a8ad41c2 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Thu, 6 Sep 2018 14:56:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA=E6=A8=A1=E5=9D=97=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A7=92=E8=89=B2=E5=88=A4=E6=96=AD=EF=BC=8C=E9=9D=9E?= =?UTF-8?q?Administrators=E4=B8=8D=E6=8F=90=E7=A4=BA=E6=B6=88=E6=81=AF?= =?UTF-8?q?=EF=BC=8Cbadge=E4=B8=BA=E9=9B=B6=E6=97=B6=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/NotificationsController.cs | 2 ++ Bootstrap.Admin/wwwroot/js/common-scripts.js | 36 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Bootstrap.Admin/Controllers/Api/NotificationsController.cs b/Bootstrap.Admin/Controllers/Api/NotificationsController.cs index 878d8661..06124094 100644 --- a/Bootstrap.Admin/Controllers/Api/NotificationsController.cs +++ b/Bootstrap.Admin/Controllers/Api/NotificationsController.cs @@ -20,6 +20,8 @@ namespace Bootstrap.Admin.Controllers.Api public Notifications Get() { var ret = new Notifications(); + if (!User.IsInRole("Administrators")) return ret; + // New Users var user = UserHelper.RetrieveNewUsers(); ret.Users = user.Take(6).ToList(); diff --git a/Bootstrap.Admin/wwwroot/js/common-scripts.js b/Bootstrap.Admin/wwwroot/js/common-scripts.js index 7d70622e..a1491b56 100644 --- a/Bootstrap.Admin/wwwroot/js/common-scripts.js +++ b/Bootstrap.Admin/wwwroot/js/common-scripts.js @@ -2,7 +2,7 @@ var cascadeMenu = function (menus) { var html = ""; $.each(menus, function (index, menu) { - if (menu.Menus.length == 0) { + if (menu.Menus.length === 0) { html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); } else { @@ -13,7 +13,7 @@ }; var cascadeSubMenu = function (menus) { - var html = "" + var html = ""; $.each(menus, function (index, menu) { html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); }); @@ -50,7 +50,7 @@ $.extend({ pullNotification: function (nav) { - if (nav.length == 0) return; + if (nav.length === 0) return; var uri = "ws://" + window.location.host + $.formatUrl("WS"); var socket = new WebSocket(uri); @@ -67,7 +67,7 @@ toastr.info(msg, "新用户注册"); break; } - }; + } if (result.length > 0) nav.reloadWidget(); }; } @@ -81,11 +81,11 @@ swal: false, method: 'GET', callback: function (result) { - $('#logoutNoti').text(result.NewUsersCount); + $('#logoutNoti').text(result.NewUsersCount === 0 ? "" : result.NewUsersCount); that.resetWidget(); // tasks $('#msgHeaderTask').text(result.TasksCount); - $('#msgHeaderTaskBadge').text(result.TasksCount); + $('#msgHeaderTaskBadge').text(result.TasksCount === 0 ? "" : result.TasksCount); var htmlUserTemplate = '{0}-{2}{1}%
    {1}% 完成
    '; var html = result.Tasks.map(function (u) { return $.format(htmlUserTemplate, u.TaskName, u.TaskProgress, u.AssignDisplayName, u.Id, $.formatUrl('Admin/Tasks')); @@ -94,7 +94,7 @@ // new users $('#msgHeaderUser').text(result.NewUsersCount); - $('#msgHeaderUserBadge').text(result.NewUsersCount); + $('#msgHeaderUserBadge').text(result.NewUsersCount === 0 ? "" : result.NewUsersCount); htmlUserTemplate = '
    {1}({0})
    {3}
    '; html = result.Users.map(function (u) { return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Description, u.Period, $.formatUrl('Admin/Notifications')); @@ -103,7 +103,7 @@ // apps $('#msgHeaderApp').text(result.AppExceptionsCount); - $('#msgHeaderAppBadge').text(result.AppExceptionsCount); + $('#msgHeaderAppBadge').text(result.AppExceptionsCount === 0 ? "" : result.AppExceptionsCount); htmlUserTemplate = '
    {0}
    {2}
    '; html = result.Apps.map(function (u) { return $.format(htmlUserTemplate, u.ExceptionType, u.Message, u.Period, $.formatUrl('Admin/Exceptions')); @@ -112,7 +112,7 @@ // dbs $('#msgHeaderDb').text(result.DbExceptionsCount); - $('#msgHeaderDbBadge').text(result.DbExceptionsCount); + $('#msgHeaderDbBadge').text(result.DbExceptionsCount === 0 ? "" : result.DbExceptionsCount); htmlUserTemplate = '
    {0}
    {2}
    '; html = result.Dbs.map(function (u) { return $.format(htmlUserTemplate, u.ErrorPage, u.Message, u.Period, $.formatUrl('Admin/Exceptions')); @@ -121,7 +121,7 @@ // messages $('#msgHeaderMsg').text(result.MessagesCount); - $('#msgHeaderMsgBadge').text(result.MessagesCount); + $('#msgHeaderMsgBadge').text(result.MessagesCount === 0 ? "" : 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, $.formatUrl('Admin/Messages')); @@ -149,7 +149,7 @@ $(function () { "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" - } + }; var $sidebar = $("#sidebar"); var $main = $('#main-content'); @@ -180,7 +180,7 @@ $(function () { } $sidebar.on('click', 'a.dcjq-parent', function () { - var o = ($(this).offset()); + var o = $(this).offset(); diff = 110 - o.top; if (diff > 0) $sidebar.scrollTo("-=" + Math.abs(diff), 500); @@ -189,14 +189,14 @@ $(function () { }); $('.sidebar-toggle-box').on('click', function () { - if ($sidebar.is(":visible") === true) { + if ($sidebar.is(":visible")) { $main.addClass('closed').removeClass('open'); - $sidebar.parent().toggleClass('open') - $(window).width() <= 768 ? setTimeout(function () { $sidebar.hide() }, 400) : $sidebar.hide(); + $sidebar.parent().toggleClass('open'); + $(window).width() <= 768 ? setTimeout(function () { $sidebar.hide(); }, 400) : $sidebar.hide(); } else { - $sidebar.show() - $sidebar.parent().toggleClass('open') - $(window).width() <= 768 ? setTimeout(function () { $main.addClass('open').removeClass('closed') }, 400) : $main.addClass('open').removeClass('closed'); + $sidebar.show(); + $sidebar.parent().toggleClass('open'); + $(window).width() <= 768 ? setTimeout(function () { $main.addClass('open').removeClass('closed'); }, 400) : $main.addClass('open').removeClass('closed'); } });