mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding clear notifications button to notification listing page
This commit is contained in:
commit
15991f626d
@ -860,7 +860,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
"OPERATION_CODE, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
|
||||
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
|
||||
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID " +
|
||||
"ORDER BY o.CREATED_TIMESTAMP ASC LIMIT 1");
|
||||
"ORDER BY om.UPDATED_TIMESTAMP ASC LIMIT 1");
|
||||
stmt.setInt(1, enrolmentId);
|
||||
stmt.setString(2, Operation.Status.PENDING.toString());
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
@ -42,10 +42,23 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="wr-hidden-operations-content col-lg-8" id="ast-container">
|
||||
<div id="noNotificationtxt" class="panel-body">
|
||||
No unread messages
|
||||
</div>
|
||||
<div class="wr-hidden-operations-content col-lg-8" style="padding: 5px"
|
||||
id="ast-container">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div id="noNotificationtxt" class="panel-body">
|
||||
No unread messages
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div id="notification-clear-button" class="hidden"><a
|
||||
class="btn btn-primary"
|
||||
data-click-event="clear-notification">Clear All
|
||||
Notifications</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
var deviceMgtAPIBaseURI = "/api/device-mgt/v1.0";
|
||||
var notificationsAvailable = false;
|
||||
|
||||
/**
|
||||
* Following function would execute
|
||||
@ -42,6 +43,7 @@ function loadNotifications() {
|
||||
if (jqXHR.status == 200 && data) {
|
||||
data = JSON.parse(data);
|
||||
if (data["notifications"] && data["notifications"].length > 0) {
|
||||
notificationsAvailable = true;
|
||||
var viewModel = {};
|
||||
viewModel["notifications"] = data["notifications"];
|
||||
viewModel["appContext"] = context;
|
||||
@ -119,4 +121,36 @@ $(document).ready(function () {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if(notificationsAvailable) {
|
||||
$("#notification-clear-button").removeClass("hidden");
|
||||
}
|
||||
|
||||
$("#ast-container").on("click", ".btn", function (e) {
|
||||
|
||||
var clickEvent = $(this).data('click-event');
|
||||
|
||||
if(clickEvent == "clear-notification"){
|
||||
e.preventDefault();
|
||||
var markAsReadNotificationsAPI = "/api/device-mgt/v1.0/notifications/clear-all";
|
||||
var messageSideBar = ".sidebar-messages";
|
||||
var clickEvent = $(this).data('click-event');
|
||||
var eventHandler = $(this);
|
||||
|
||||
invokerUtil.put(
|
||||
markAsReadNotificationsAPI,
|
||||
null,
|
||||
function (data) {
|
||||
$('.message').remove();
|
||||
$("#notification-bubble").html(0);
|
||||
}, function () {
|
||||
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" +
|
||||
" try again</p></li>";
|
||||
$(messageSideBar).html(content);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -39,8 +39,8 @@
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#unless isCloud}}
|
||||
{{#if permissions.VIEW_DASHBOARD}}
|
||||
<!--<li>
|
||||
{{#if permissions.VIEW_DASHBOARD}}
|
||||
<!--<li>
|
||||
<a href="javascript:statisticLoad('/portal/t/{{currentUser.domain}}/dashboards/device-statistics-dashboard/')">
|
||||
<i class="fw fw-bar-chart"></i>Device Statistics
|
||||
</a>
|
||||
@ -65,7 +65,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</li>-->
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
|
||||
@ -126,12 +126,12 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if permissions.IS_ADMIN}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/device-locations">
|
||||
<i class="fw fw-map-location"></i>
|
||||
Device Locations
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{@app.context}}/device-locations">
|
||||
<i class="fw fw-map-location"></i>
|
||||
Device Locations
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
|
||||
|
||||
@ -154,15 +154,14 @@
|
||||
</ul>
|
||||
{{/zone}}
|
||||
{{#zone "sidePanes"}}
|
||||
<div class="sidebar-wrapper sidebar-wrapper-animation-fix" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}"
|
||||
<div class="sidebar-wrapper sidebar-wrapper-animation-fix" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}"
|
||||
data-side="right" data-width="320" data-sidebar-fixed="true" data-top="90" data-fixed-offset="90" data-offset-top="50" data-spy="affix">
|
||||
<ul class="sidebar-messages">
|
||||
</ul>
|
||||
<div class="text-center"><a href="{{@app.context}}/notification-listing" class="btn
|
||||
<div class="text-center"><a href="{{@app.context}}/notification-listing" class="btn
|
||||
btn-primary all-notifications">Show All Notifications</a></div>
|
||||
<div class="text-center"><a class="btn btn-primary"
|
||||
data-click-event="clear-notification">Clear All
|
||||
Notifications</a></div>
|
||||
<div id="right-side-pane-notifications-clear" class="text-center hidden"><a class="btn
|
||||
btn-primary" data-click-event="clear-notification">Clear All Notifications</a></div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
|
||||
@ -21,6 +21,7 @@ var modalPopupContainer = modalPopup + " .modal-content";
|
||||
var modalPopupContent = modalPopup + " .modal-content";
|
||||
|
||||
var backendEndBasePath = "/api/device-mgt/v1.0";
|
||||
var notificationsAvailable = false;
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
@ -101,12 +102,13 @@ function loadNewNotifications() {
|
||||
viewModel.context = context;
|
||||
viewModel.notifications = responsePayload.notifications;
|
||||
if (responsePayload.count > 0) {
|
||||
notificationsAvailable = true;
|
||||
$(messageSideBar).html(template(viewModel));
|
||||
} else {
|
||||
$(messageSideBar).html(
|
||||
"<h4 class='text-center'>No New Notifications</h4>" +
|
||||
"<h5 class='text-center text-muted'>" +
|
||||
"Check this section for error notifications<br>related to device operations" +
|
||||
"Check this section for error notifications<br>related to device operations" +
|
||||
"</h5>"
|
||||
);
|
||||
}
|
||||
@ -454,6 +456,10 @@ $(document).ready(function () {
|
||||
);
|
||||
});
|
||||
|
||||
if(notificationsAvailable) {
|
||||
$("#right-side-pane-notifications-clear").removeClass("hidden");
|
||||
}
|
||||
|
||||
$("#right-sidebar").on("click", ".btn", function (e) {
|
||||
|
||||
var clickEvent = $(this).data('click-event');
|
||||
@ -490,59 +496,59 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
function statisticLoad(redirectUrl) {
|
||||
var contentType = "application/json";
|
||||
var defaultStatusClasses = "fw fw-stack-1x";
|
||||
var content = $("#statistic-response-template").find(".content");
|
||||
var title = content.find("#title");
|
||||
var statusIcon = content.find("#status-icon");
|
||||
var contentType = "application/json";
|
||||
var defaultStatusClasses = "fw fw-stack-1x";
|
||||
var content = $("#statistic-response-template").find(".content");
|
||||
var title = content.find("#title");
|
||||
var statusIcon = content.find("#status-icon");
|
||||
|
||||
$.ajax({
|
||||
url: redirectUrl,
|
||||
type: "GET",
|
||||
success: function () {
|
||||
window.location.href = redirectUrl;
|
||||
},
|
||||
error: function() {
|
||||
var urix = backendEndBasePath + "/admin/publish-artifact/deploy/device_management";
|
||||
var device = {};
|
||||
invokerUtil.post(urix, device, function (data) {
|
||||
title.html("Deploying statistic artifacts. Please wait...");
|
||||
statusIcon.attr("class", defaultStatusClasses + " fw-check");
|
||||
$(modalPopupContent).html(content.html());
|
||||
showPopup();
|
||||
poll(redirectUrl);
|
||||
}, function (jqXHR) {
|
||||
title.html("Failed to deploy artifacts, Please contact administrator.");
|
||||
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
||||
$(modalPopupContent).html(content.html());
|
||||
showPopup();
|
||||
}, contentType);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: redirectUrl,
|
||||
type: "GET",
|
||||
success: function () {
|
||||
window.location.href = redirectUrl;
|
||||
},
|
||||
error: function() {
|
||||
var urix = backendEndBasePath + "/admin/publish-artifact/deploy/device_management";
|
||||
var device = {};
|
||||
invokerUtil.post(urix, device, function (data) {
|
||||
title.html("Deploying statistic artifacts. Please wait...");
|
||||
statusIcon.attr("class", defaultStatusClasses + " fw-check");
|
||||
$(modalPopupContent).html(content.html());
|
||||
showPopup();
|
||||
poll(redirectUrl);
|
||||
}, function (jqXHR) {
|
||||
title.html("Failed to deploy artifacts, Please contact administrator.");
|
||||
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
||||
$(modalPopupContent).html(content.html());
|
||||
showPopup();
|
||||
}, contentType);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
var pollingCount = 15;
|
||||
function poll(portalUrl) {
|
||||
var content = $("#statistic-response-template").find(".content");
|
||||
var title = content.find("#title");
|
||||
var defaultStatusClasses = "fw fw-stack-1x";
|
||||
var statusIcon = content.find("#status-icon");
|
||||
$.ajax({
|
||||
url: portalUrl,
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
window.location.href = portalUrl;
|
||||
},
|
||||
dataType: "json",
|
||||
error: setTimeout(function () {
|
||||
pollingCount = pollingCount - 1;
|
||||
if (pollingCount > 0) {
|
||||
poll(portalUrl);
|
||||
} else {
|
||||
window.location.href = portalUrl;
|
||||
}
|
||||
}, 5000),
|
||||
timeout: 5000
|
||||
});
|
||||
var content = $("#statistic-response-template").find(".content");
|
||||
var title = content.find("#title");
|
||||
var defaultStatusClasses = "fw fw-stack-1x";
|
||||
var statusIcon = content.find("#status-icon");
|
||||
$.ajax({
|
||||
url: portalUrl,
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
window.location.href = portalUrl;
|
||||
},
|
||||
dataType: "json",
|
||||
error: setTimeout(function () {
|
||||
pollingCount = pollingCount - 1;
|
||||
if (pollingCount > 0) {
|
||||
poll(portalUrl);
|
||||
} else {
|
||||
window.location.href = portalUrl;
|
||||
}
|
||||
}, 5000),
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user