|
|
@ -22,6 +22,15 @@ var modalPopup = ".wr-modalpopup",
|
|
|
|
|
|
|
|
|
|
|
|
var emmAdminBasePath = "/api/device-mgt/v1.0";
|
|
|
|
var emmAdminBasePath = "/api/device-mgt/v1.0";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//function openCollapsedNav() {
|
|
|
|
|
|
|
|
// $(".wr-hidden-nav-toggle-btn").addClass("active");
|
|
|
|
|
|
|
|
// $("#hiddenNav").slideToggle("slideDown", function () {
|
|
|
|
|
|
|
|
// if ($(this).css("display") == "none") {
|
|
|
|
|
|
|
|
// $(".wr-hidden-nav-toggle-btn").removeClass("active");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* set popup maximum height function.
|
|
|
|
* set popup maximum height function.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -50,74 +59,93 @@ function hidePopup() {
|
|
|
|
$(modalPopup).hide();
|
|
|
|
$(modalPopup).hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var updateNotificationCount = function (data, textStatus, jqXHR) {
|
|
|
|
/*
|
|
|
|
|
|
|
|
* QR-code generation function.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function generateQRCode(qrCodeClass) {
|
|
|
|
|
|
|
|
var enrollmentURL = $("#qr-code-modal").data("enrollment-url");
|
|
|
|
|
|
|
|
$(qrCodeClass).qrcode({
|
|
|
|
|
|
|
|
text: enrollmentURL,
|
|
|
|
|
|
|
|
width: 200,
|
|
|
|
|
|
|
|
height: 200
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggleEnrollment() {
|
|
|
|
|
|
|
|
$(".modalpopup-content").html($("#qr-code-modal").html());
|
|
|
|
|
|
|
|
generateQRCode(".modalpopup-content .qr-code");
|
|
|
|
|
|
|
|
showPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateNotificationCountOnSuccess = function (data, textStatus, jqXHR) {
|
|
|
|
|
|
|
|
var notificationBubble = "#notification-bubble";
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
var responsePayload = JSON.parse(data);
|
|
|
|
var responsePayload = JSON.parse(data);
|
|
|
|
var newNotificationsCount = responsePayload.count;
|
|
|
|
var newNotificationsCount = responsePayload["count"];
|
|
|
|
if (newNotificationsCount > 0) {
|
|
|
|
if (newNotificationsCount > 0) {
|
|
|
|
$("#notification-bubble").html(newNotificationsCount);
|
|
|
|
$(notificationBubble).html(newNotificationsCount);
|
|
|
|
|
|
|
|
$(notificationBubble).show();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(notificationBubble).hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// $("#notification-bubble").html("Error");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function loadNotificationsPanel() {
|
|
|
|
function updateNotificationCountOnError() {
|
|
|
|
if ("true" == $("#right-sidebar").attr("is-authorized")) {
|
|
|
|
var notificationBubble = "#notification-bubble";
|
|
|
|
var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
|
|
|
|
$(notificationBubble).html("Error");
|
|
|
|
invokerUtil.get(serviceURL, updateNotificationCount, hideNotificationCount);
|
|
|
|
$(notificationBubble).show();
|
|
|
|
loadNewNotifications();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$("#notification-bubble-wrapper").remove();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hideNotificationCount(jqXHR) {
|
|
|
|
function loadNewNotificationsOnSideViewPanel() {
|
|
|
|
if (jqXHR.status == 404) {
|
|
|
|
if ($("#right-sidebar").attr("is-authorized") == "false") {
|
|
|
|
// this means "no new notifications to show"
|
|
|
|
$("#notification-bubble-wrapper").remove();
|
|
|
|
$("#notification-bubble").hide();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$("#notification-bubble").html("Error");
|
|
|
|
var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
|
|
|
|
|
|
|
|
invokerUtil.get(serviceURL, updateNotificationCountOnSuccess, updateNotificationCountOnError);
|
|
|
|
|
|
|
|
loadNewNotifications();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadNewNotifications() {
|
|
|
|
function loadNewNotifications() {
|
|
|
|
var messageSideBar = ".sidebar-messages";
|
|
|
|
var messageSideBar = ".sidebar-messages";
|
|
|
|
if ($("#right-sidebar").attr("is-authorized") == "true") {
|
|
|
|
if ($("#right-sidebar").attr("is-authorized") == "false") {
|
|
|
|
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications.</h4>");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
var notifications = $("#notifications");
|
|
|
|
var notifications = $("#notifications");
|
|
|
|
var currentUser = notifications.data("currentUser");
|
|
|
|
var currentUser = notifications.data("currentUser");
|
|
|
|
|
|
|
|
|
|
|
|
$.template("notification-listing", notifications.attr("src"), function (template) {
|
|
|
|
$.template("notification-listing", notifications.attr("src"), function (template) {
|
|
|
|
var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
|
|
|
|
var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
|
|
|
|
|
|
|
|
invokerUtil.get(
|
|
|
|
var successCallback = function (data, textStatus, jqXHR) {
|
|
|
|
serviceURL,
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
// on success
|
|
|
|
var viewModel = {};
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
var responsePayload = JSON.parse(data);
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
|
|
|
|
var viewModel = {};
|
|
|
|
if (responsePayload.notifications) {
|
|
|
|
var responsePayload = JSON.parse(data);
|
|
|
|
viewModel.notifications = responsePayload.notifications;
|
|
|
|
if (responsePayload["notifications"]) {
|
|
|
|
if (responsePayload.count > 0) {
|
|
|
|
if (responsePayload.count > 0) {
|
|
|
|
$(messageSideBar).html(template(viewModel));
|
|
|
|
viewModel["notifications"] = responsePayload["notifications"];
|
|
|
|
|
|
|
|
$(messageSideBar).html(template(viewModel));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(messageSideBar).html("<h4 class='text-center'>No new notifications found...</h4>");
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$(messageSideBar).html("<h4 class='text-center'>No new notifications found...</h4>");
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error " +
|
|
|
|
|
|
|
|
"occurred while loading new notifications.</h4>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while loading new notifications.</h4>");
|
|
|
|
},
|
|
|
|
|
|
|
|
// on error
|
|
|
|
|
|
|
|
function (jqXHR) {
|
|
|
|
|
|
|
|
if (jqXHR.status = 500) {
|
|
|
|
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " +
|
|
|
|
|
|
|
|
"to retrieve any new notifications.</h4>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
);
|
|
|
|
var errorCallback = function (jqXHR) {
|
|
|
|
|
|
|
|
if (jqXHR.status = 500) {
|
|
|
|
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " +
|
|
|
|
|
|
|
|
"to retrieve any new notifications.</h4>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
invokerUtil.get(serviceURL, successCallback, errorCallback);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications</h4>");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -178,8 +206,7 @@ $.sidebar_toggle = function (action, target, container) {
|
|
|
|
if (buttonParent.is('li')) {
|
|
|
|
if (buttonParent.is('li')) {
|
|
|
|
if (relationship !== '') {
|
|
|
|
if (relationship !== '') {
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
|
|
|
|
attr('aria-expanded', 'false');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonParent.addClass("active");
|
|
|
|
buttonParent.addClass("active");
|
|
|
|
buttonParent.attr('aria-expanded', 'true');
|
|
|
|
buttonParent.attr('aria-expanded', 'true');
|
|
|
@ -217,8 +244,7 @@ $.sidebar_toggle = function (action, target, container) {
|
|
|
|
if ($(button).parent().is('li')) {
|
|
|
|
if ($(button).parent().is('li')) {
|
|
|
|
if (relationship !== '') {
|
|
|
|
if (relationship !== '') {
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
|
|
|
|
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
|
|
|
|
attr('aria-expanded', 'false');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -317,24 +343,32 @@ $.fn.collapse_nav_sub = function () {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
loadNotificationsPanel();
|
|
|
|
|
|
|
|
$.sidebar_toggle();
|
|
|
|
$.sidebar_toggle();
|
|
|
|
|
|
|
|
if (typeof $.fn.collapse == 'function') {
|
|
|
|
|
|
|
|
$('.navbar-collapse.tiles').on('shown.bs.collapse', function () {
|
|
|
|
|
|
|
|
$(this).collapse_nav_sub();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadNewNotificationsOnSideViewPanel();
|
|
|
|
$("#right-sidebar").on("click", ".new-notification", function () {
|
|
|
|
$("#right-sidebar").on("click", ".new-notification", function () {
|
|
|
|
var notificationId = $(this).data("id");
|
|
|
|
var notificationId = $(this).data("id");
|
|
|
|
var redirectUrl = $(this).data("url");
|
|
|
|
var redirectUrl = $(this).data("url");
|
|
|
|
var markAsReadNotificationsAPI = "/mdm-admin/notifications/" + notificationId + "/CHECKED";
|
|
|
|
var markAsReadNotificationsEpr = emmAdminBasePath + "/notifications/" + notificationId + "/mark-checked";
|
|
|
|
var messageSideBar = ".sidebar-messages";
|
|
|
|
var messageSideBar = ".sidebar-messages";
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
markAsReadNotificationsAPI,
|
|
|
|
markAsReadNotificationsEpr,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
|
|
|
|
// on success
|
|
|
|
function (data) {
|
|
|
|
function (data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (data.statusCode == responseCodes["ACCEPTED"]) {
|
|
|
|
if (data.statusCode == responseCodes["ACCEPTED"]) {
|
|
|
|
location.href = redirectUrl;
|
|
|
|
location.href = redirectUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
// on error
|
|
|
|
|
|
|
|
function () {
|
|
|
|
var content = "<li class='message message-danger'><h4><i class='icon fw fw-error'></i>Warning</h4>" +
|
|
|
|
var content = "<li class='message message-danger'><h4><i class='icon fw fw-error'></i>Warning</h4>" +
|
|
|
|
"<p>Unexpected error occurred while loading notification. Please refresh the page and" +
|
|
|
|
"<p>Unexpected error occurred while loading notification. Please refresh the page and" +
|
|
|
|
" try again</p></li>";
|
|
|
|
" try again</p></li>";
|
|
|
@ -342,10 +376,4 @@ $(document).ready(function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof $.fn.collapse == 'function') {
|
|
|
|
|
|
|
|
$('.navbar-collapse.tiles').on('shown.bs.collapse', function () {
|
|
|
|
|
|
|
|
$(this).collapse_nav_sub();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|