diff --git a/Bootstrap.Admin/wwwroot/js/common-scripts.js b/Bootstrap.Admin/wwwroot/js/common-scripts.js
index 91fcb733..3f347cdc 100644
--- a/Bootstrap.Admin/wwwroot/js/common-scripts.js
+++ b/Bootstrap.Admin/wwwroot/js/common-scripts.js
@@ -20,6 +20,22 @@
return html;
};
+ var setBadge = function (source) {
+ var data = $.extend({
+ TasksCount: 0,
+ AppExceptionsCount: 0,
+ DbExceptionsCount: 0,
+ MessagesCount: 0,
+ NewUsersCount: 0
+ }, source);
+ $('#msgHeaderTaskBadge').text(data.TasksCount === 0 ? "" : data.TasksCount);
+ $('#msgHeaderUserBadge').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount);
+ $('#msgHeaderAppBadge').text(data.AppExceptionsCount === 0 ? "" : data.AppExceptionsCount);
+ $('#msgHeaderDbBadge').text(data.DbExceptionsCount === 0 ? "" : data.DbExceptionsCount);
+ $('#msgHeaderMsgBadge').text(data.MessagesCount === 0 ? "" : data.MessagesCount);
+ $('#logoutNoti').text(data.NewUsersCount === 0 ? "" : data.NewUsersCount);
+ };
+
$.fn.extend({
nestMenu: function (callback) {
var $this = $(this);
@@ -35,6 +51,7 @@
});
},
clearWidgetItems: function () {
+ setBadge(false);
this.children('.dropdown').each(function () {
$(this).children('.dropdown-menu').each(function () {
$(this).children('a').remove();
@@ -48,11 +65,13 @@
$.bc({
url: Notifications.url,
callback: function (result) {
- $('#logoutNoti').text(result.NewUsersCount === 0 ? "" : result.NewUsersCount);
that.clearWidgetItems();
+ if (!result) return;
+
+ setBadge(result);
+
// tasks
$('#msgHeaderTask').text(result.TasksCount);
- $('#msgHeaderTaskBadge').text(result.TasksCount === 0 ? "" : result.TasksCount);
var htmlUserTemplate = '
{0}-{2}{1}%';
var html = result.Tasks.map(function (u) {
return $.format(htmlUserTemplate, u.TaskName, u.TaskProgress, u.AssignDisplayName, u.Id, $.formatUrl('Admin/Tasks'));
@@ -61,7 +80,6 @@
// new users
$('#msgHeaderUser').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'));
@@ -70,7 +88,6 @@
// apps
$('#msgHeaderApp').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'));
@@ -79,7 +96,6 @@
// dbs
$('#msgHeaderDb').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'));
@@ -88,7 +104,6 @@
// messages
$('#msgHeaderMsg').text(result.MessagesCount);
- $('#msgHeaderMsgBadge').text(result.MessagesCount === 0 ? "" : result.MessagesCount);
htmlUserTemplate = '
{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'));
diff --git a/Bootstrap.Admin/wwwroot/js/login.js b/Bootstrap.Admin/wwwroot/js/login.js
index d8f98df8..8be7b874 100644
--- a/Bootstrap.Admin/wwwroot/js/login.js
+++ b/Bootstrap.Admin/wwwroot/js/login.js
@@ -14,7 +14,7 @@
$('#btnSubmit').on('click', function () {
$.bc({
- url: 'api/New',
+ url: "api/New/",
data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() },
modal: '#dialogNew',
method: "post",
diff --git a/Bootstrap.Admin/wwwroot/js/noti.js b/Bootstrap.Admin/wwwroot/js/noti.js
index 09434336..08acf5d4 100644
--- a/Bootstrap.Admin/wwwroot/js/noti.js
+++ b/Bootstrap.Admin/wwwroot/js/noti.js
@@ -1,8 +1,9 @@
$(function () {
$('.site-footer').footer();
+ var apiUrl = "api/New/";
var $table = $('table').smartTable({
- url: Notifications.url + "newusers",
+ url: apiUrl,
sidePagination: "client",
showToggle: false,
showRefresh: false,
@@ -23,7 +24,7 @@
var id = $this.attr('data-id');
var result = $this.attr('data-result');
$.bc({
- id: id, url: 'api/New/', method: "put", data: { Id: id, UserStatus: result }, title: result === "ApproveUser" ? "授权用户" : "拒绝用户",
+ id: id, url: apiUrl, method: "put", data: { Id: id, UserStatus: result }, title: result === "ApproveUser" ? "授权用户" : "拒绝用户",
callback: function (result) {
if (!result) return;
$table.bootstrapTable('refresh');