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"
|
||||||
<div id="noNotificationtxt" class="panel-body">
|
id="ast-container">
|
||||||
No unread messages
|
<table width="100%">
|
||||||
</div>
|
<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>
|
</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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,8 +39,8 @@
|
|||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless isCloud}}
|
{{#unless isCloud}}
|
||||||
{{#if permissions.VIEW_DASHBOARD}}
|
{{#if permissions.VIEW_DASHBOARD}}
|
||||||
<!--<li>
|
<!--<li>
|
||||||
<a href="javascript:statisticLoad('/portal/t/{{currentUser.domain}}/dashboards/device-statistics-dashboard/')">
|
<a href="javascript:statisticLoad('/portal/t/{{currentUser.domain}}/dashboards/device-statistics-dashboard/')">
|
||||||
<i class="fw fw-bar-chart"></i>Device Statistics
|
<i class="fw fw-bar-chart"></i>Device Statistics
|
||||||
</a>
|
</a>
|
||||||
@ -65,7 +65,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>-->
|
</li>-->
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
|
|
||||||
@ -126,12 +126,12 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if permissions.IS_ADMIN}}
|
{{#if permissions.IS_ADMIN}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{@app.context}}/device-locations">
|
<a href="{{@app.context}}/device-locations">
|
||||||
<i class="fw fw-map-location"></i>
|
<i class="fw fw-map-location"></i>
|
||||||
Device Locations
|
Device Locations
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
@ -154,15 +154,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
{{#zone "sidePanes"}}
|
{{#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">
|
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 class="sidebar-messages">
|
||||||
</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,12 +102,13 @@ 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(
|
||||||
"<h4 class='text-center'>No New Notifications</h4>" +
|
"<h4 class='text-center'>No New Notifications</h4>" +
|
||||||
"<h5 class='text-center text-muted'>" +
|
"<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>"
|
"</h5>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -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');
|
||||||
@ -490,59 +496,59 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function statisticLoad(redirectUrl) {
|
function statisticLoad(redirectUrl) {
|
||||||
var contentType = "application/json";
|
var contentType = "application/json";
|
||||||
var defaultStatusClasses = "fw fw-stack-1x";
|
var defaultStatusClasses = "fw fw-stack-1x";
|
||||||
var content = $("#statistic-response-template").find(".content");
|
var content = $("#statistic-response-template").find(".content");
|
||||||
var title = content.find("#title");
|
var title = content.find("#title");
|
||||||
var statusIcon = content.find("#status-icon");
|
var statusIcon = content.find("#status-icon");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: redirectUrl,
|
url: redirectUrl,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function () {
|
success: function () {
|
||||||
window.location.href = redirectUrl;
|
window.location.href = redirectUrl;
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
var urix = backendEndBasePath + "/admin/publish-artifact/deploy/device_management";
|
var urix = backendEndBasePath + "/admin/publish-artifact/deploy/device_management";
|
||||||
var device = {};
|
var device = {};
|
||||||
invokerUtil.post(urix, device, function (data) {
|
invokerUtil.post(urix, device, function (data) {
|
||||||
title.html("Deploying statistic artifacts. Please wait...");
|
title.html("Deploying statistic artifacts. Please wait...");
|
||||||
statusIcon.attr("class", defaultStatusClasses + " fw-check");
|
statusIcon.attr("class", defaultStatusClasses + " fw-check");
|
||||||
$(modalPopupContent).html(content.html());
|
$(modalPopupContent).html(content.html());
|
||||||
showPopup();
|
showPopup();
|
||||||
poll(redirectUrl);
|
poll(redirectUrl);
|
||||||
}, function (jqXHR) {
|
}, function (jqXHR) {
|
||||||
title.html("Failed to deploy artifacts, Please contact administrator.");
|
title.html("Failed to deploy artifacts, Please contact administrator.");
|
||||||
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
statusIcon.attr("class", defaultStatusClasses + " fw-error");
|
||||||
$(modalPopupContent).html(content.html());
|
$(modalPopupContent).html(content.html());
|
||||||
showPopup();
|
showPopup();
|
||||||
}, contentType);
|
}, contentType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
var pollingCount = 15;
|
var pollingCount = 15;
|
||||||
function poll(portalUrl) {
|
function poll(portalUrl) {
|
||||||
var content = $("#statistic-response-template").find(".content");
|
var content = $("#statistic-response-template").find(".content");
|
||||||
var title = content.find("#title");
|
var title = content.find("#title");
|
||||||
var defaultStatusClasses = "fw fw-stack-1x";
|
var defaultStatusClasses = "fw fw-stack-1x";
|
||||||
var statusIcon = content.find("#status-icon");
|
var statusIcon = content.find("#status-icon");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: portalUrl,
|
url: portalUrl,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
window.location.href = portalUrl;
|
window.location.href = portalUrl;
|
||||||
},
|
},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: setTimeout(function () {
|
error: setTimeout(function () {
|
||||||
pollingCount = pollingCount - 1;
|
pollingCount = pollingCount - 1;
|
||||||
if (pollingCount > 0) {
|
if (pollingCount > 0) {
|
||||||
poll(portalUrl);
|
poll(portalUrl);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = portalUrl;
|
window.location.href = portalUrl;
|
||||||
}
|
}
|
||||||
}, 5000),
|
}, 5000),
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user