From 1cb969eb6d0e8907779fb7631445bd082fc05794 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Fri, 21 Oct 2016 13:52:33 +0530 Subject: [PATCH 01/15] Fix incorrect spacing --- .../impl/PolicyManagementServiceImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index bb8759e685..3934ceedf1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -231,8 +231,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { policyDeleted = false; } } - if(policyDeleted) { - for(int i : policyIds) { + if (policyDeleted) { + for (int i : policyIds) { Policy policy = pap.getPolicy(i); pap.deletePolicy(policy); } @@ -244,13 +244,16 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } if (policyDeleted) { - return Response.status(Response.Status.OK).entity("Policies have been successfully deleted").build(); + return Response.status(Response.Status.OK).entity("Policies have been successfully " + + "deleted").build(); } else { //TODO:Check of this logic is correct - String ModifiedInvalidPolicyIds = invalidPolicyIds.substring(0, invalidPolicyIds.length()-1); - return Response.status(Response.Status.BAD_REQUEST).entity( - new ErrorResponse.ErrorResponseBuilder().setMessage("Policies with the policy ID " + - ModifiedInvalidPolicyIds + " doesn't exist").build()).build(); + String modifiedInvalidPolicyIds = + invalidPolicyIds.substring(0, invalidPolicyIds.length() - 1); + return Response.status(Response.Status.BAD_REQUEST). + entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage("Policies with the policy ID " + modifiedInvalidPolicyIds + + " doesn't exist").build()).build(); } } From f6ee6aeb8d8222ad994c11a640cf1bb00d089692 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Thu, 13 Oct 2016 19:06:44 +0530 Subject: [PATCH 02/15] Refactoring pages to use new modal unit --- .../cdmf.page.certificates/certificates.hbs | 68 +--- .../public/js/certificate-listing.js | 30 +- .../pages/cdmf.page.group.create/create.hbs | 17 +- .../public/js/group-add.js | 9 +- .../app/pages/cdmf.page.groups/groups.hbs | 209 +--------- .../cdmf.page.groups/public/js/listing.js | 88 ++-- .../app/pages/cdmf.page.policies/policies.hbs | 379 +----------------- .../public/js/policy-list.js | 156 ++++--- .../cdmf.page.roles/public/js/role-listing.js | 22 +- .../app/pages/cdmf.page.roles/roles.hbs | 53 +-- .../cdmf.unit.policy.priority/priority.hbs | 107 +---- .../public/js/policy-priority.js | 41 +- .../permission.hbs | 19 +- .../public/js/bottomJs.js | 10 +- 14 files changed, 250 insertions(+), 958 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs index 801c065221..f963ef9237 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.hbs @@ -16,6 +16,7 @@ under the License. }} {{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -110,73 +111,6 @@ By Serial Number - -
    -
    -
    -
    -

    Do you really want to remove this certificate ?

    - - -
    -
    -
    -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    {{/zone}} {{#zone "bottomJs"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js index 01acf088d1..959a3472da 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js @@ -54,8 +54,11 @@ function hidePopup() { */ function removeCertificate(serialNumber) { var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber; - $(modalPopupContent).html($('#remove-certificate-modal-content').html()); - showPopup(); + modalDialog.header('Do you really want to remove this certificate ?'); + modalDialog.footer(''); + modalDialog.show(); $("a#remove-certificate-yes-link").click(function () { invokerUtil.delete( @@ -63,23 +66,29 @@ function removeCertificate(serialNumber) { function () { $("#" + serialNumber).remove(); var newCertificateListCount = $(".user-list > span").length; - $("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount); - $(modalPopupContent).html($('#remove-certificate-success-content').html()); + $("#certificate-listing-status-msg").text("Total number of Certificates found : " + + newCertificateListCount); + modalDialog.header('Done. Certificate was successfully removed.'); + modalDialog.footer(''); $("a#remove-certificate-success-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }, function () { - $(modalPopupContent).html($('#remove-certificate-error-content').html()); + modalDialog.header('An unexpected error occurred. Please try again later.'); + modalDialog.footer(''); + modalDialog.showAsError(); $("a#remove-certificate-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } ); }); $("a#remove-certificate-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } @@ -103,8 +112,9 @@ function InitiateViewOption() { if ($("#can-view").val()) { $(location).attr('href', $(this).data("url")); } else { - $(modalPopupContent).html($('#errorCertificateView').html()); - showPopup(); + modalDialog.header('Unauthorized action!'); + modalDialog.content('You do not have permission to view this certificate.'); + modalDialog.showAsAWarning(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs index fe9663f24f..8ae4393a8f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs @@ -1,4 +1,5 @@ {{unit "cdmf.unit.ui.title" pageTitle="Group Management"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -55,22 +56,6 @@ - -
    - -
    {{/zone}} {{#zone "bottomJs"}} {{js "js/group-add.js"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js index ae6870abd3..8a40a13f70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js @@ -71,10 +71,13 @@ $(function () { }); function displayErrors(message) { - showPopup(); $('#error-msg').html(message.responseText); - $(modalPopupContent).html($('#group-error-content').html()); + modalDialog.header('Unexpected error occurred!'); + modalDialog.content('

    '); + modalDialog.footer(''); + modalDialog.showAsError(); $("a#group-unexpected-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs index 7ad04791e1..88dd2a4a1c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs @@ -17,8 +17,8 @@ }} {{unit "cdmf.unit.ui.title" pageTitle="Group Management"}} {{unit "cdmf.unit.ui.content.title" pageHeader="Groups"}} - {{unit "cdmf.unit.lib.data-table"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -93,213 +93,6 @@ {{/if}} - -
    -
    -
    -
    -

    Enter user name to manage group sharing

    -
    -
    - - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Select sharing roles

    -
    -
    Loading...
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group sharing updated successfully.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to remove this group from your Group List?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group was successfully removed.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Please enter new name and description for the group

    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group was successfully updated.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Bad Request. Please contact your administrator.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Operation not permitted.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Not found.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group does not exist.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Unexpected error occurred!

    - - -
    -
    -
    -
    diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index bec491c017..2a05f9c45f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -295,9 +295,13 @@ function attachEvents() { $("a.share-group-link").click(function () { var groupName = $(this).data("group-name"); var groupOwner = $(this).data("group-owner"); - $(modalPopupContent).html($('#share-group-w1-modal-content').html()); + modalDialog.header('Enter user name to manage group sharing'); + modalDialog.content(''); + modalDialog.footer(''); $("a#share-group-next-link").show(); - showPopup(); + modalDialog.show(); $("a#share-group-next-link").click(function () { var selectedUser = $('#share-user-selector').val(); if (selectedUser == $("#group-listing").data("current-user")) { @@ -308,7 +312,7 @@ function attachEvents() { } }); $("a#share-group-w1-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); @@ -321,16 +325,18 @@ function attachEvents() { var groupName = $(this).data("group-name"); var groupOwner = $(this).data("group-owner"); - $(modalPopupContent).html($('#remove-group-modal-content').html()); - showPopup(); + modalDialog.header('Do you really want to remove this group from your Group List?'); + modalDialog.footer(''); + modalDialog.show(); $("a#remove-group-yes-link").click(function () { var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); if (xhr.status == 200) { - $(modalPopupContent).html($('#remove-group-200-content').html()); + modalDialog.header('Group was successfully removed.'); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); } else { @@ -345,7 +351,7 @@ function attachEvents() { }); $("a#remove-group-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); @@ -360,10 +366,15 @@ function attachEvents() { var groupOwner = $(this).data("group-owner"); var groupDescription = $(this).data("group-description"); - $(modalPopupContent).html($('#edit-group-modal-content').html()); + modalDialog.header('Please enter new name and description for the group.'); + modalDialog.content('

    '); + modalDialog.footer(''); $('#edit-group-name').val(groupName); $('#edit-group-description').val(groupDescription); - showPopup(); + modalDialog.show(); $("a#edit-group-yes-link").click(function () { var newGroupName = $('#edit-group-name').val(); @@ -373,8 +384,11 @@ function attachEvents() { var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); if (xhr.status == 200) { + modalDialog.hide(); + modalDialog.header('Group was successfully updated.'); + modalDialog.show(); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); } else { @@ -389,14 +403,19 @@ function attachEvents() { }); $("a#edit-group-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); }); } function getAllRoles(groupName, groupOwner, selectedUser) { - $(modalPopupContent).html($('#share-group-w2-modal-content').html()); - $('#user-roles').html('
    '); + modalDialog.header('Select sharing roles'); + modalDialog.content('
    Loading...
    '); + modalDialog.footer(''); + modalDialog.show(); + $('#user-roles').html('
    '); $("a#share-group-yes-link").hide(); var successCallback = function (data, textStatus, xhr) { data = JSON.parse(data); @@ -417,7 +436,7 @@ function getAllRoles(groupName, groupOwner, selectedUser) { }); $("a#share-group-w2-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } @@ -463,15 +482,17 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) { }); $("a#share-group-w2-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } function updateGroupShare(groupName, groupOwner, selectedUser, roles) { var successCallback = function (data) { - $(modalPopupContent).html($('#share-group-200-content').html()); + // $(modalPopupContent).html($('#share-group-200-content').html()); + modalDialog.header('Group sharing updated successfully.'); + modalDialog.show(); setTimeout(function () { - hidePopup(); + modalDialog.hide(); location.reload(false); }, 2000); }; @@ -483,35 +504,44 @@ function updateGroupShare(groupName, groupOwner, selectedUser, roles) { } function displayErrors(jqXHR) { - showPopup(); if (jqXHR.status == 400) { - $(modalPopupContent).html($('#group-400-content').html()); + modalDialog.header('

    Bad Request. Please contact your administrator.

    '); + modalDialog.footer(''); + modalDialog.showAsError(); if (jqXHR.responseText) { $('#error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); } $("a#group-400-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 403) { - $(modalPopupContent).html($('#group-403-content').html()); + modalDialog.header('Operation not permitted.'); + modalDialog.footer(''); + modalDialog.showAsError(); $("a#group-403-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 404) { - $(modalPopupContent).html($('#group-404-content').html()); + modalDialog.header('

    Not found.

    '); + modalDialog.footer(''); + modalDialog.showAsError(); $("#group-404-message").html(jqXHR.responseText); $("a#group-404-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else if (jqXHR.status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); + modalDialog.header('Group does not exist..'); + modalDialog.footer(''); + modalDialog.showAsError(); $("a#group-409-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } else { - $(modalPopupContent).html($('#group-unexpected-error-content').html()); + modalDialog.header('Unexpected error occurred!'); + modalDialog.footer(''); + modalDialog.showAsError(); $("a#group-unexpected-error-link").click(function () { - hidePopup(); + modalDialog.hide(); }); console.log("Error code: " + jqXHR.status); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs index 1eb81672aa..4c5280f154 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs @@ -17,6 +17,7 @@ }} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} {{unit "cdmf.unit.data-tables-extended"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "topCss"}}