added change device status to device view page

merge-requests/7/head
lakshani 8 years ago
parent 2d83033b26
commit a2679fde4c

@ -1979,10 +1979,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
int tenantId = this.getTenantId(); int tenantId = this.getTenantId();
switch (newStatus) { switch (newStatus) {
case ACTIVE: case ACTIVE:
updateEnrollment(deviceId, enrolmentInfo, tenantId); isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId);
break; break;
case INACTIVE: case INACTIVE:
updateEnrollment(deviceId, enrolmentInfo, tenantId); isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId);
break; break;
case REMOVED: case REMOVED:
isDeviceUpdated = disenrollDevice(deviceIdentifier); isDeviceUpdated = disenrollDevice(deviceIdentifier);
@ -1995,12 +1995,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId) private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId)
throws DeviceManagementException { throws DeviceManagementException {
boolean isUpdatedEnrollment = false;
boolean isAutoCommit = true; boolean isAutoCommit = true;
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
isAutoCommit = DeviceManagementDAOFactory.getConnection().getAutoCommit(); isAutoCommit = DeviceManagementDAOFactory.getConnection().getAutoCommit();
DeviceManagementDAOFactory.getConnection().setAutoCommit(true); DeviceManagementDAOFactory.getConnection().setAutoCommit(true);
enrollmentDAO.updateEnrollment(deviceId, enrolmentInfo, tenantId); int updatedRows = enrollmentDAO.updateEnrollment(deviceId, enrolmentInfo, tenantId);
if (updatedRows > 0) {
isUpdatedEnrollment = true;
}
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); throw new DeviceManagementException("Error occurred while opening a connection to the data source", e);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
@ -2014,7 +2018,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
return true; return isUpdatedEnrollment;
} }

@ -83,6 +83,7 @@
"perm:get-activity", "perm:get-activity",
"perm:devices:delete", "perm:devices:delete",
"perm:devices:applications", "perm:devices:applications",
"perm:devices:change-status",
"perm:devices:effective-policy", "perm:devices:effective-policy",
"perm:devices:compliance-data", "perm:devices:compliance-data",
"perm:devices:features", "perm:devices:features",

@ -18,8 +18,6 @@
function onRequest(context) { function onRequest(context) {
var log = new Log("detail.js"); 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; var device = context.unit.params.device;
return {"device": device, "permissions":permissions}; return {"device": device};
} }

@ -53,25 +53,25 @@
{{#if permissions.CHANGE_DEVICE_STATUS}} {{#if permissions.CHANGE_DEVICE_STATUS}}
{{#equal device.status "ACTIVE"}}<span><i id="statusIcon" {{#equal device.status "ACTIVE"}}<span><i id="statusIcon"
class="fw fw-success icon-success"></i> class="fw fw-success icon-success"></i>
<a href="#" id="status" data-type="select" data-pk="1" data-url="/post" <a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status" data-title="Select status"
selectedValue="Active"></a> selectedValue="Active"></a>
</span>{{/equal}} </span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i id="statusIcon" {{#equal device.status "INACTIVE"}}<span><i id="statusIcon"
class="fw fw-warning icon-warning"></i> class="fw fw-warning icon-warning"></i>
<a href="#" id="status" data-type="select" data-pk="1" data-url="/post" <a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status" data-title="Select status"
selectedValue="Inactive"></a> selectedValue="Inactive"></a>
</span>{{/equal}} </span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i id="statusIcon" {{#equal device.status "BLOCKED"}}<span><i id="statusIcon"
class="fw fw-remove icon-danger"></i> class="fw fw-remove icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1" data-url="/post" <a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status" data-title="Select status"
selectedValue="Blocked"></a> selectedValue="Blocked"></a>
</span>{{/equal}} </span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i id="statusIcon" {{#equal device.status "REMOVED"}}<span><i id="statusIcon"
class="fw fw-delete icon-danger"></i> class="fw fw-delete icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1" data-url="/post" <a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status" data-title="Select status"
selectedValue="Removed"></a> selectedValue="Removed"></a>
</span>{{/equal}} </span>{{/equal}}

@ -15,6 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.lib.editable"}}
{{#zone "content"}} {{#zone "content"}}
{{#if deviceFound}} {{#if deviceFound}}
{{#if isAuthorized}} {{#if isAuthorized}}

@ -6580,3 +6580,11 @@ select > option:hover {
} }
/** End **/ /** End **/
.editable-input select{
height: 35px !important;
}
.editable-submit, .editable-cancel{
padding: 8px 15px !important;
line-height: 0px !important;
}

Loading…
Cancel
Save