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 " +
|
"OPERATION_CODE, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
|
||||||
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
|
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
|
||||||
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID " +
|
"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.setInt(1, enrolmentId);
|
||||||
stmt.setString(2, Operation.Status.PENDING.toString());
|
stmt.setString(2, Operation.Status.PENDING.toString());
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
|
|||||||
@ -42,10 +42,23 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="wr-hidden-operations-content col-lg-8" id="ast-container">
|
<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">
|
<div id="noNotificationtxt" class="panel-body">
|
||||||
No unread messages
|
No unread messages
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var deviceMgtAPIBaseURI = "/api/device-mgt/v1.0";
|
var deviceMgtAPIBaseURI = "/api/device-mgt/v1.0";
|
||||||
|
var notificationsAvailable = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following function would execute
|
* Following function would execute
|
||||||
@ -42,6 +43,7 @@ function loadNotifications() {
|
|||||||
if (jqXHR.status == 200 && data) {
|
if (jqXHR.status == 200 && data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (data["notifications"] && data["notifications"].length > 0) {
|
if (data["notifications"] && data["notifications"].length > 0) {
|
||||||
|
notificationsAvailable = true;
|
||||||
var viewModel = {};
|
var viewModel = {};
|
||||||
viewModel["notifications"] = data["notifications"];
|
viewModel["notifications"] = data["notifications"];
|
||||||
viewModel["appContext"] = context;
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -160,9 +160,8 @@
|
|||||||
</ul>
|
</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>
|
btn-primary all-notifications">Show All Notifications</a></div>
|
||||||
<div class="text-center"><a class="btn btn-primary"
|
<div id="right-side-pane-notifications-clear" class="text-center hidden"><a class="btn
|
||||||
data-click-event="clear-notification">Clear All
|
btn-primary" data-click-event="clear-notification">Clear All Notifications</a></div>
|
||||||
Notifications</a></div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ var modalPopupContainer = modalPopup + " .modal-content";
|
|||||||
var modalPopupContent = modalPopup + " .modal-content";
|
var modalPopupContent = modalPopup + " .modal-content";
|
||||||
|
|
||||||
var backendEndBasePath = "/api/device-mgt/v1.0";
|
var backendEndBasePath = "/api/device-mgt/v1.0";
|
||||||
|
var notificationsAvailable = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set popup maximum height function.
|
* set popup maximum height function.
|
||||||
@ -101,6 +102,7 @@ function loadNewNotifications() {
|
|||||||
viewModel.context = context;
|
viewModel.context = context;
|
||||||
viewModel.notifications = responsePayload.notifications;
|
viewModel.notifications = responsePayload.notifications;
|
||||||
if (responsePayload.count > 0) {
|
if (responsePayload.count > 0) {
|
||||||
|
notificationsAvailable = true;
|
||||||
$(messageSideBar).html(template(viewModel));
|
$(messageSideBar).html(template(viewModel));
|
||||||
} else {
|
} else {
|
||||||
$(messageSideBar).html(
|
$(messageSideBar).html(
|
||||||
@ -454,6 +456,10 @@ $(document).ready(function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(notificationsAvailable) {
|
||||||
|
$("#right-side-pane-notifications-clear").removeClass("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
$("#right-sidebar").on("click", ".btn", function (e) {
|
$("#right-sidebar").on("click", ".btn", function (e) {
|
||||||
|
|
||||||
var clickEvent = $(this).data('click-event');
|
var clickEvent = $(this).data('click-event');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user