diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java index 21e729293d..ad174a51e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java @@ -216,5 +216,12 @@ public class NotificationManagementServiceImplTests { " as added no. of records."); } + @Test(dependsOnMethods = "updateStatusofAllNotification", description = "this tries to " + + "update the status of all notifications") + public void updateStatusOfAllNotifications() throws NotificationManagementException { + Assert.assertTrue(notificationManagementService.updateAllNotifications(Notification + .Status.CHECKED, -1234)); + } + } 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 3f29f25235..8d5b105188 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 @@ -44,21 +44,6 @@
- - - - - -
-
- No unread messages -
-
- -
@@ -68,8 +53,13 @@ {{/zone}} {{#zone "bottomJs"}} - + {{js "js/notification-listing.js"}} {{/zone}} \ No newline at end of file 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 d5b776e747..ce06cd5d4f 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 @@ -29,30 +29,74 @@ function InitiateViewOption() { } function loadNotifications() { - var deviceListing = $("#notification-listing"); - var deviceListingSrc = deviceListing.attr("src"); - var currentUser = deviceListing.data("currentUser"); + var deviceListingNew = $("#notification-listing-new"); + var deviceListingNewSrc = deviceListingNew.attr("src"); + + var deviceListingAll = $("#notification-listing-all"); + var deviceListingAllSrc = deviceListingAll.attr("src"); + $.template( - "notification-listing", - deviceListingSrc, + "notification-listing-new", + deviceListingNewSrc, function (template) { invokerUtil.get( - deviceMgtAPIBaseURI + "/notifications", + deviceMgtAPIBaseURI + "/notifications?status=NEW", // on success function (data, textStatus, jqXHR) { if (jqXHR.status == 200 && data) { data = JSON.parse(data); - if (data["notifications"] && data["notifications"].length > 0) { + if (data["notifications"]) { notificationsAvailable = true; var viewModel = {}; viewModel["notifications"] = data["notifications"]; viewModel["appContext"] = context; var content = template(viewModel); - $("#ast-container").html(content); + $("#ast-container").append(content); var settings = { "sorting" : false }; $("#unread-notifications").datatables_extended(settings); + + /** + * append advance operations to list table toolbar + */ + $('#unread-notifications_wrapper').find('.dataTablesTop' + + ' .dataTables_toolbar').html( + "Clear All" + + " Notifications" + ); + } + } + }, + // on error + function (jqXHR) { + console.log(jqXHR.status); + } + ); + } + ); + + $.template( + "notification-listing-all", + deviceListingAllSrc, + function (template) { + invokerUtil.get( + deviceMgtAPIBaseURI + "/notifications", + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + if (data["notifications"]) { + notificationsAvailable = true; + var viewModel = {}; + viewModel["notifications"] = data["notifications"]; + viewModel["appContext"] = context; + var content = template(viewModel); + $("#ast-container").append(content); + var settings = { + "sorting" : false + }; $("#all-notifications").datatables_extended(settings); } } @@ -70,16 +114,9 @@ function loadNotifications() { function showAdvanceOperation(operation, button) { $(button).addClass('selected'); $(button).siblings().removeClass('selected'); - if ($(button).attr("id") == 'allNotifications') { - $("#noNotificationtxt").html('You do not have any notifications '); - } else if ($(button).attr("id") == 'unReadNotifications') { - $("#noNotificationtxt").html('You do not have any unread notifications '); - } else { - $("#noNotificationtxt").html('You do not have any unread notifications '); - } var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); + $(hiddenOperation + '[data-operation="' + operation + '"]').show(); } $(document).ready(function () { @@ -143,6 +180,10 @@ $(document).ready(function () { function (data) { $('.message').remove(); $("#notification-bubble").html(0); + var undreadNotifications = $("#unread-notifications"); + undreadNotifications.find("tbody").empty(); + undreadNotifications.find("tbody").append("No data" + + " available in table"); }, function () { var content = "
  • Warning

    " + "

    Unexpected error occurred while loading notification. Please refresh the page and" + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-all.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-all.hbs new file mode 100644 index 0000000000..b5a6adab35 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-all.hbs @@ -0,0 +1,42 @@ + +

    +
    +
    + + + + + + + + + + + {{#if notifications}} + {{#each notifications}} + + + + + {{/each}} + {{else}} +
    + You do not have any notifications +
    + {{/if}} +
    + +
    DescriptionAction
    {{description}} + + + + + + +
    +
    +
    +
    + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-new.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-new.hbs new file mode 100644 index 0000000000..8bdc4a5276 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing-new.hbs @@ -0,0 +1,44 @@ + +
    +
    +
    + + + + + + + + + + + {{#if notifications}} + {{#each notifications}} + {{#equal "NEW" status }} + + + + + {{/equal}} + {{/each}} + {{else}} +
    + You do not have any unread notifications +
    + {{/if}} +
    + +
    DescriptionAction
    {{description}} + + + + + + +
    +
    +
    +
    + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs deleted file mode 100644 index cd1f8196ce..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs +++ /dev/null @@ -1,75 +0,0 @@ - -
    -
    -
    - - - - - - - - - - - {{#each notifications}} - {{#equal "NEW" status }} - - - - - {{/equal}} - {{/each}} -
    - -
    DescriptionAction
    {{description}} - - - - - - -
    -
    -
    -
    - - - -
    -
    -
    - - - - - - - - - - - {{#each notifications}} - - - - - {{/each}} -
    - -
    DescriptionAction
    {{description}} - - - - - - -
    -
    -
    -
    - \ No newline at end of file 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 a486eafe7f..886bb4ccbe 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 @@ -160,7 +160,7 @@ - {{/zone}} 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 3fb25289ac..0e4fb7b580 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,7 +21,6 @@ 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. @@ -102,7 +101,6 @@ function loadNewNotifications() { viewModel.context = context; viewModel.notifications = responsePayload.notifications; if (responsePayload.count > 0) { - notificationsAvailable = true; $(messageSideBar).html(template(viewModel)); } else { $(messageSideBar).html( @@ -456,10 +454,6 @@ $(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'); 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/templates/notifications.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/templates/notifications.hbs index f447dc9a73..21fbb9b0b0 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/templates/notifications.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/public/templates/notifications.hbs @@ -6,7 +6,7 @@ {{deviceType}} : {{deviceName}}