diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 500e48b0ee..a243d91093 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -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(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs index b0ca5a7e98..3f29f25235 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs @@ -42,10 +42,23 @@ -
-
- No unread messages -
+
+ + + + + +
+
+ No unread messages +
+
+ +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 6958dbd4f4..d5b776e747 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -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 = "
  • Warning

    " + + "

    Unexpected error occurred while loading notification. Please refresh the page and" + + " try again

  • "; + $(messageSideBar).html(content); + } + ); + } + + }); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs index d18685ec40..a486eafe7f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs @@ -39,8 +39,8 @@ {{/if}} {{#unless isCloud}} - {{#if permissions.VIEW_DASHBOARD}} - - {{/if}} + {{/if}} {{/unless}} @@ -126,12 +126,12 @@ {{/if}} {{/if}} {{#if permissions.IS_ADMIN}} -
  • - - - Device Locations - -
  • +
  • + + + Device Locations + +
  • {{/if}} @@ -154,15 +154,14 @@ {{/zone}} {{#zone "sidePanes"}} - {{/zone}} {{#zone "bottomJs"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js index c13d4ca235..3fb25289ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/js/nav-menu.js @@ -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( "

    No New Notifications

    " + "
    " + - "Check this section for error notifications
    related to device operations" + + "Check this section for error notifications
    related to device operations" + "
    " ); } @@ -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"); - - $.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 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); + } + }); } 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 + }); }