From a2679fde4c02c4fa4829f63089c305b6c050cc9d Mon Sep 17 00:00:00 2001 From: lakshani Date: Mon, 6 Feb 2017 22:23:55 +0530 Subject: [PATCH] added change device status to device view page --- .../service/DeviceManagementProviderServiceImpl.java | 12 ++++++++---- .../jaggeryapps/devicemgt/app/conf/config.json | 1 + .../app/units/cdmf.unit.device.details/details.js | 4 +--- .../overview-section.hbs | 8 ++++---- .../app/units/cdmf.unit.device.view/view.hbs | 1 + .../app/units/cdmf.unit.lib.editable/editable.json | 3 ++- .../cdmf.unit.ui.theme/public/css/custom-desktop.css | 8 ++++++++ 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 45cc2790735..a2946581db7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1979,10 +1979,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv int tenantId = this.getTenantId(); switch (newStatus) { case ACTIVE: - updateEnrollment(deviceId, enrolmentInfo, tenantId); + isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); break; case INACTIVE: - updateEnrollment(deviceId, enrolmentInfo, tenantId); + isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); break; case REMOVED: isDeviceUpdated = disenrollDevice(deviceIdentifier); @@ -1995,12 +1995,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementException { + boolean isUpdatedEnrollment = false; boolean isAutoCommit = true; try { DeviceManagementDAOFactory.openConnection(); isAutoCommit = DeviceManagementDAOFactory.getConnection().getAutoCommit(); DeviceManagementDAOFactory.getConnection().setAutoCommit(true); - enrollmentDAO.updateEnrollment(deviceId, enrolmentInfo, tenantId); + int updatedRows = enrollmentDAO.updateEnrollment(deviceId, enrolmentInfo, tenantId); + if (updatedRows > 0) { + isUpdatedEnrollment = true; + } } catch (SQLException e) { throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); } catch (DeviceManagementDAOException e) { @@ -2014,7 +2018,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } DeviceManagementDAOFactory.closeConnection(); } - return true; + return isUpdatedEnrollment; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 1dab6437de1..858aff57fe1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -83,6 +83,7 @@ "perm:get-activity", "perm:devices:delete", "perm:devices:applications", + "perm:devices:change-status", "perm:devices:effective-policy", "perm:devices:compliance-data", "perm:devices:features", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.details/details.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.details/details.js index 045f9ffecb0..cd1602cd5b8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.details/details.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.details/details.js @@ -18,8 +18,6 @@ function onRequest(context) { var log = new Log("detail.js"); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var permissions = userModule.getUIPermissions(); var device = context.unit.params.device; - return {"device": device, "permissions":permissions}; + return {"device": device}; } \ 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.device.overview-section/overview-section.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.overview-section/overview-section.hbs index f1c54965ea4..c6cea1c6c11 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.overview-section/overview-section.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.overview-section/overview-section.hbs @@ -53,25 +53,25 @@ {{#if permissions.CHANGE_DEVICE_STATUS}} {{#equal device.status "ACTIVE"}} - {{/equal}} {{#equal device.status "INACTIVE"}} - {{/equal}} {{#equal device.status "BLOCKED"}} - {{/equal}} {{#equal device.status "REMOVED"}} - {{/equal}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs index 252d7679ff9..903224be543 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs @@ -15,6 +15,7 @@ specific language governing permissions and limitations under the License. }} +{{unit "cdmf.unit.lib.editable"}} {{#zone "content"}} {{#if deviceFound}} {{#if isAuthorized}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.json index 877ad82b4e1..3fb741b843a 100755 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.json @@ -1,3 +1,4 @@ { - "version": "1.0.0" + "version": "1.0.0", + "index": 40 } \ 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.theme/public/css/custom-desktop.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css index a7114108eee..f85ad9c35e8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css @@ -6580,3 +6580,11 @@ select > option:hover { } /** End **/ + +.editable-input select{ + height: 35px !important; +} +.editable-submit, .editable-cancel{ + padding: 8px 15px !important; + line-height: 0px !important; +}