2018-06-07 00:45:47 +08:00
|
|
|
|
(function ($) {
|
|
|
|
|
var cascadeMenu = function (menus) {
|
|
|
|
|
var html = "";
|
|
|
|
|
$.each(menus, function (index, menu) {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
if (menu.Menus.length === 0) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><div class="checkbox"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><div class="radio"><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{5}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><div class="checkbox"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><div class="radio"><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><span class="menuType">{6}</span><span class="menuOrder">{5}</span></div><ol class="dd-list">{4}</ol></li>', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, menu.CategoryName);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return html;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var cascadeSubMenu = function (menus) {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
var html = "";
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.each(menus, function (index, menu) {
|
|
|
|
|
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><div class="checkbox"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><div class="radio"><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label></div><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName);
|
|
|
|
|
});
|
|
|
|
|
return html;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$.fn.extend({
|
|
|
|
|
nestMenu: function (callback) {
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
$.bc({
|
2018-06-08 07:43:00 +08:00
|
|
|
|
id: 0, url: Menu.url, data: { type: "user" }, swal: false,
|
2018-06-07 00:45:47 +08:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
var html = "";
|
|
|
|
|
if ($.isArray(result)) html = cascadeMenu(result);
|
|
|
|
|
$this.find('ol:first').html(html);
|
|
|
|
|
$this.nestable();
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2018-09-06 15:47:07 +08:00
|
|
|
|
clearWidgetItems: function () {
|
|
|
|
|
this.children('.dropdown').each(function () {
|
|
|
|
|
$(this).children('.dropdown-menu').each(function () {
|
|
|
|
|
$(this).children('a').remove();
|
|
|
|
|
});
|
2018-06-07 00:45:47 +08:00
|
|
|
|
});
|
2018-09-06 15:47:07 +08:00
|
|
|
|
return this;
|
|
|
|
|
},
|
2018-06-07 00:45:47 +08:00
|
|
|
|
reloadWidget: function () {
|
2018-08-09 22:36:07 +08:00
|
|
|
|
if (this.length === 0) return this;
|
|
|
|
|
var that = this;
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$.bc({
|
|
|
|
|
url: Notifications.url,
|
|
|
|
|
swal: false,
|
|
|
|
|
method: 'GET',
|
|
|
|
|
callback: function (result) {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#logoutNoti').text(result.NewUsersCount === 0 ? "" : result.NewUsersCount);
|
2018-09-06 15:47:07 +08:00
|
|
|
|
that.clearWidgetItems();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
// tasks
|
|
|
|
|
$('#msgHeaderTask').text(result.TasksCount);
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#msgHeaderTaskBadge').text(result.TasksCount === 0 ? "" : result.TasksCount);
|
2018-08-26 19:23:37 +08:00
|
|
|
|
var htmlUserTemplate = '<a class="dropdown-item" href="{4}?id={3}"><span class="desc">{0}-{2}</span><span class="percent">{1}%</span></span><div class="progress progress-striped"><div class="progress-bar" role="progressbar" aria-valuenow="{1}" aria-valuemin="0" aria-valuemax="100" style="width: {1}%"><span class="sr-only">{1}% 完成</span></div></div></a>';
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var html = result.Tasks.map(function (u) {
|
2018-08-26 19:23:37 +08:00
|
|
|
|
return $.format(htmlUserTemplate, u.TaskName, u.TaskProgress, u.AssignDisplayName, u.Id, $.formatUrl('Admin/Tasks'));
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}).join('');
|
|
|
|
|
$(html).insertAfter($('#msgHeaderTaskContent'));
|
|
|
|
|
|
|
|
|
|
// new users
|
|
|
|
|
$('#msgHeaderUser').text(result.NewUsersCount);
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#msgHeaderUserBadge').text(result.NewUsersCount === 0 ? "" : result.NewUsersCount);
|
2018-08-26 19:23:37 +08:00
|
|
|
|
htmlUserTemplate = '<a class="dropdown-item" href="{4}"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{2}" class="content">{1}({0})</div><span class="small italic">{3}</span></a>';
|
2018-06-07 00:45:47 +08:00
|
|
|
|
html = result.Users.map(function (u) {
|
2018-08-26 19:23:37 +08:00
|
|
|
|
return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Description, u.Period, $.formatUrl('Admin/Notifications'));
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}).join('');
|
|
|
|
|
$(html).insertAfter($('#msgHeaderUserContent'));
|
|
|
|
|
|
|
|
|
|
// apps
|
|
|
|
|
$('#msgHeaderApp').text(result.AppExceptionsCount);
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#msgHeaderAppBadge').text(result.AppExceptionsCount === 0 ? "" : result.AppExceptionsCount);
|
2018-08-26 19:23:37 +08:00
|
|
|
|
htmlUserTemplate = '<a class="dropdown-item" href="{3}"><span class="label label-warning"><i class="fa fa-bug"></i></span><div title="{1}" class="content">{0}</div><span class="small italic">{2}</span></a>';
|
2018-06-07 00:45:47 +08:00
|
|
|
|
html = result.Apps.map(function (u) {
|
2018-08-26 19:23:37 +08:00
|
|
|
|
return $.format(htmlUserTemplate, u.ExceptionType, u.Message, u.Period, $.formatUrl('Admin/Exceptions'));
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}).join('');
|
|
|
|
|
$(html).insertAfter($('#msgHeaderAppContent'));
|
|
|
|
|
|
|
|
|
|
// dbs
|
|
|
|
|
$('#msgHeaderDb').text(result.DbExceptionsCount);
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#msgHeaderDbBadge').text(result.DbExceptionsCount === 0 ? "" : result.DbExceptionsCount);
|
2018-08-26 19:23:37 +08:00
|
|
|
|
htmlUserTemplate = '<a class="dropdown-item" href="{3}"><span class="label label-danger"><i class="fa fa-bolt"></i></span><div title="{1}" class="content">{0}</div><span class="small italic">{2}</span></a>';
|
2018-06-07 00:45:47 +08:00
|
|
|
|
html = result.Dbs.map(function (u) {
|
2018-08-26 19:23:37 +08:00
|
|
|
|
return $.format(htmlUserTemplate, u.ErrorPage, u.Message, u.Period, $.formatUrl('Admin/Exceptions'));
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}).join('');
|
|
|
|
|
$(html).insertAfter($('#msgHeaderDbContent'));
|
|
|
|
|
|
|
|
|
|
// messages
|
|
|
|
|
$('#msgHeaderMsg').text(result.MessagesCount);
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$('#msgHeaderMsgBadge').text(result.MessagesCount === 0 ? "" : result.MessagesCount);
|
2018-08-26 19:23:37 +08:00
|
|
|
|
htmlUserTemplate = '<a class="dropdown-item" href="{6}?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>';
|
2018-06-07 00:45:47 +08:00
|
|
|
|
html = result.Messages.map(function (u) {
|
2018-08-26 19:23:37 +08:00
|
|
|
|
return $.format(htmlUserTemplate, u.Id, u.FromIcon, u.FromDisplayName, u.Title, u.Period, u.Content, $.formatUrl('Admin/Messages'));
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}).join('');
|
|
|
|
|
$(html).insertAfter($('#msgHeaderMsgContent'));
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-08-09 22:36:07 +08:00
|
|
|
|
return this;
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
toastr.options = {
|
|
|
|
|
"closeButton": true,
|
|
|
|
|
"debug": false,
|
|
|
|
|
"progressBar": true,
|
|
|
|
|
"positionClass": "toast-bottom-right",
|
|
|
|
|
"onclick": null,
|
|
|
|
|
"showDuration": "600",
|
|
|
|
|
"hideDuration": "2000",
|
2018-09-07 15:53:16 +08:00
|
|
|
|
"timeOut": "4000",
|
2018-06-07 00:45:47 +08:00
|
|
|
|
"extendedTimeOut": "1000",
|
|
|
|
|
"showEasing": "swing",
|
|
|
|
|
"hideEasing": "linear",
|
|
|
|
|
"showMethod": "fadeIn",
|
|
|
|
|
"hideMethod": "fadeOut"
|
2018-09-06 14:56:16 +08:00
|
|
|
|
};
|
2018-06-07 00:45:47 +08:00
|
|
|
|
|
|
|
|
|
var $sidebar = $("#sidebar");
|
|
|
|
|
var $main = $('#main-content');
|
|
|
|
|
var $breadNav = $('#breadNav');
|
|
|
|
|
|
|
|
|
|
$('#nav-accordion').dcAccordion({
|
|
|
|
|
autoExpand: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// custom scrollbar
|
|
|
|
|
if (!$.browser.versions.ios) $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', scrollspeed: 60 });
|
|
|
|
|
|
|
|
|
|
$("#gotoTop").on('click', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
$('#main-content, .content-body, body').animate({
|
|
|
|
|
scrollTop: 0
|
|
|
|
|
}, 200);
|
|
|
|
|
});
|
2018-08-03 19:40:01 +08:00
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
|
|
|
|
|
// breadcrumb
|
|
|
|
|
var arch = $('#nav-accordion').find('a.active').last();
|
2018-08-06 03:03:29 +08:00
|
|
|
|
if (arch.text() !== "") $breadNav.removeClass('d-none').text(arch.text());
|
2018-06-07 00:45:47 +08:00
|
|
|
|
var top = (arch.offset() || { top: 0 }).top;
|
|
|
|
|
if (top > 0) {
|
|
|
|
|
var middle = $('header').outerHeight() + $sidebar.outerHeight() / 2;
|
|
|
|
|
if (top > middle) $sidebar.animate({ scrollTop: top + arch.outerHeight() / 2 - middle }, 500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sidebar.on('click', 'a.dcjq-parent', function () {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
var o = $(this).offset();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
diff = 110 - o.top;
|
|
|
|
|
if (diff > 0)
|
|
|
|
|
$sidebar.scrollTo("-=" + Math.abs(diff), 500);
|
|
|
|
|
else
|
|
|
|
|
$sidebar.scrollTo("+=" + Math.abs(diff), 500);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.sidebar-toggle-box').on('click', function () {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
if ($sidebar.is(":visible")) {
|
2018-06-07 00:45:47 +08:00
|
|
|
|
$main.addClass('closed').removeClass('open');
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$sidebar.parent().toggleClass('open');
|
|
|
|
|
$(window).width() <= 768 ? setTimeout(function () { $sidebar.hide(); }, 400) : $sidebar.hide();
|
2018-06-07 00:45:47 +08:00
|
|
|
|
} else {
|
2018-09-06 14:56:16 +08:00
|
|
|
|
$sidebar.show();
|
|
|
|
|
$sidebar.parent().toggleClass('open');
|
|
|
|
|
$(window).width() <= 768 ? setTimeout(function () { $main.addClass('open').removeClass('closed'); }, 400) : $main.addClass('open').removeClass('closed');
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2018-08-05 15:31:21 +08:00
|
|
|
|
$('[data-toggle="dropdown"].dropdown-select').dropdown('select');
|
2018-06-07 00:45:47 +08:00
|
|
|
|
|
|
|
|
|
// load widget data
|
2018-09-07 15:53:16 +08:00
|
|
|
|
$('.header .nav').reloadWidget().socketHandler({
|
|
|
|
|
onmessage: function (e) {
|
|
|
|
|
var result = JSON.parse(e.data);
|
|
|
|
|
for (index in result) {
|
|
|
|
|
var cate = result[index].Category;
|
|
|
|
|
var msg = result[index].Message;
|
|
|
|
|
switch (cate) {
|
|
|
|
|
case "Notification":
|
|
|
|
|
toastr.error(msg, "应用程序出现错误");
|
|
|
|
|
break;
|
|
|
|
|
case "Users":
|
|
|
|
|
toastr.success(msg, "新用户注册");
|
|
|
|
|
break;
|
|
|
|
|
case "Exception":
|
|
|
|
|
toastr.warning(msg, "程序发生异常");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (result.length > 0) this.reloadWidget();
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-11-16 23:47:01 +08:00
|
|
|
|
});
|