mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
* Added a description to the feature implementation
* Added the feature insert, changed the feature_id to int and added device_type to features * Included the updated database file * Developed the feature to view device features * Developed the implementation to call the Operation Manager from the UI
This commit is contained in:
parent
69a822c8d1
commit
3f7b93163b
@ -166,6 +166,7 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
||||
feature.setId(mobileFeature.getId());
|
||||
feature.setDeviceType(mobileFeature.getDeviceType());
|
||||
feature.setName(mobileFeature.getName());
|
||||
feature.setDescription(mobileFeature.getDescription());
|
||||
List<Feature.MetadataEntry> metadataEntries = new ArrayList<Feature.MetadataEntry>();
|
||||
List<MobileFeatureProperty> properties =
|
||||
featurePropertyDAO.getFeaturePropertyOfFeature(mobileFeature.getId());
|
||||
|
||||
Binary file not shown.
@ -20,6 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`DEVICE_TYPE` VARCHAR(45) NOT NULL ,
|
||||
`CODE` VARCHAR(45) NOT NULL ,
|
||||
`NAME` VARCHAR(100) NULL ,
|
||||
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||
@ -74,10 +75,15 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NOT NULL ,
|
||||
`FEATURE_ID` INT NOT NULL ,
|
||||
PRIMARY KEY (`PROPERTY`) ,
|
||||
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||
FOREIGN KEY (`FEATURE_ID` )
|
||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Inserts
|
||||
-- -----------------------------------------------------
|
||||
Insert into MBL_FEATURE (DEVICE_TYPE_ID,CODE, NAME, DESCRIPTION) VALUES ('android', "503A", "DEVICE_LOCK", "Device lock");
|
||||
@ -20,6 +20,7 @@ ENGINE = InnoDB;
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`DEVICE_TYPE_ID` INT NOT NULL,
|
||||
`CODE` VARCHAR(45) NULL,
|
||||
`NAME` VARCHAR(100) NULL,
|
||||
`DESCRIPTION` VARCHAR(200) NULL,
|
||||
@ -97,4 +98,8 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Inserts
|
||||
-- -----------------------------------------------------
|
||||
Insert into MBL_FEATURE (DEVICE_TYPE_ID,CODE, NAME, DESCRIPTION) VALUES ('android', "503A", "DEVICE_LOCK", "Device lock");
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ var uri = request.getRequestURI();
|
||||
var callPath=uri.replace("/cdm/api/","");
|
||||
var log = new Log();
|
||||
var deviceModule = require("/modules/device.js");
|
||||
|
||||
if (uri != null) {
|
||||
var uriMatcher = new URIMatcher(callPath);
|
||||
log.info(callPath);
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
<%
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var verb = request.getMethod();
|
||||
var uri = request.getRequestURI();
|
||||
var callPath=uri.replace("/cdm/api/","");
|
||||
var log = new Log();
|
||||
var deviceModule = require("/modules/device.js");
|
||||
|
||||
if (uri != null) {
|
||||
var uriMatcher = new URIMatcher(callPath);
|
||||
//log.info(callPath);
|
||||
log.info(uriMatcher.match("operation/{type}/{deviceid}/{operation}"));
|
||||
if (uriMatcher.match("operation/{type}/{deviceid}/{operation}")) {
|
||||
|
||||
var deviceId = uriMatcher.elements().deviceid;
|
||||
var type = uriMatcher.elements().type;
|
||||
var operation = uriMatcher.elements().operation;
|
||||
var result = deviceModule.performOperation(deviceId, operation,[],type);
|
||||
<!--log.info(result);-->
|
||||
<!--print(result);-->
|
||||
}
|
||||
}
|
||||
%>
|
||||
@ -21,4 +21,22 @@ function identifierFormatter(value, row, index) {
|
||||
value,
|
||||
'</a>'
|
||||
].join('');
|
||||
}
|
||||
}
|
||||
|
||||
var currentDeviceOperation;
|
||||
var currentDevice;
|
||||
var currentDeviceType;
|
||||
function performOperation(){
|
||||
currentDevice = $("#deviceMain").data("deviceid");
|
||||
currentDeviceType = $("#deviceMain").data("devicetype");
|
||||
$.post("/cdm/api/operation/"+currentDeviceType+"/"+currentDevice+"/"+currentDeviceOperation,function(){
|
||||
$('#confirmModel').modal('hide');
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".device-operation").click(function(){
|
||||
currentDeviceOperation = $(this).data("operation");
|
||||
$('#confirmModel').modal('show');
|
||||
});
|
||||
});
|
||||
@ -1,3 +1,21 @@
|
||||
<%
|
||||
// footer includes
|
||||
%>
|
||||
%>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="confirmModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Operation Confirmation</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Do you wish to perform this operation?
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="performOperation()">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -10,6 +10,10 @@
|
||||
"url": "/dashboard",
|
||||
"path": "/pages/dashboard.jag"
|
||||
},
|
||||
{
|
||||
"url" : "/api/operation/*",
|
||||
"path": "/api/mobile/operation-api.jag"
|
||||
},
|
||||
{
|
||||
"url": "/api/devices/mobile/*",
|
||||
"path": "/api/mobile/device-api.jag"
|
||||
|
||||
@ -19,16 +19,16 @@
|
||||
var utility = require("/modules/utility.js");
|
||||
var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
var DeviceManagerUtil = Packages.org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||
var Operation = Packages.org.wso2.carbon.device.mgt.common.Operation;
|
||||
var Type = Packages.org.wso2.carbon.device.mgt.common.Operation.Type;
|
||||
var Properties = Packages.java.util.Properties;
|
||||
var ArrayList = Packages.java.util.ArrayList;
|
||||
var log = new Log();
|
||||
var deviceManagementService = utility.getDeviceManagementService();
|
||||
|
||||
var listDevices = function () {
|
||||
|
||||
var devices = deviceManagementService.getAllDevices("android");
|
||||
|
||||
var deviceList = [];
|
||||
|
||||
|
||||
for (i = 0; i < devices.size(); i++) {
|
||||
var device = devices.get(i);
|
||||
|
||||
@ -54,10 +54,38 @@ var getDevice = function(type, deviceId){
|
||||
return device;
|
||||
}
|
||||
|
||||
var getOperations = function(type){
|
||||
var features = deviceManagementService.getOperationManager("android").getFeaturesForDeviceType(type);
|
||||
var featuresConverted = [];
|
||||
for (i = 0; i < features.size(); i++) {
|
||||
var feature = features.get(i);
|
||||
featuresConverted.push({
|
||||
"featureName": feature.getName(),
|
||||
"featureDescription": feature.getDescription()
|
||||
});
|
||||
}
|
||||
return featuresConverted;
|
||||
}
|
||||
var performOperation = function(deviceId, featureName, properties, type){
|
||||
var operation = new Operation();
|
||||
operation.setCode(featureName);
|
||||
operation.setType(Type.COMMAND);
|
||||
var props = new Properties();
|
||||
for (i = 0; i < properties.length; i++) {
|
||||
var object = properties[i];
|
||||
props.setProperty(object.key,object.value);
|
||||
}
|
||||
operation.setProperties(props);
|
||||
var deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId)
|
||||
deviceIdentifier.setType(type);
|
||||
var deviceList = new ArrayList();
|
||||
deviceList.add(deviceIdentifier);
|
||||
deviceManagementService.getOperationManager("android").addOperation(operation, deviceList);
|
||||
}
|
||||
|
||||
var viewDevice = function(type, deviceId){
|
||||
|
||||
var device = this.getDevice(type, deviceId);
|
||||
|
||||
var propertiesList = DeviceManagerUtil.convertPropertiesToMap(device.getProperties());
|
||||
var entries = propertiesList.entrySet();
|
||||
var iterator = entries.iterator();
|
||||
|
||||
@ -73,6 +73,7 @@ var title="WSO2 CDM";
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
include("/includes/footer.jag");
|
||||
include("/includes/layout-footer.jag");
|
||||
%>
|
||||
</body>
|
||||
|
||||
@ -35,22 +35,26 @@ var title="WSO2 CDM";
|
||||
var deviceId = uriMatcher.elements().deviceid;
|
||||
var type = uriMatcher.elements().type;
|
||||
var device = deviceModule.viewDevice(type, deviceId);
|
||||
var operations = deviceModule.getOperations("android");
|
||||
%>
|
||||
<div class="container-fluid">
|
||||
<div id="deviceMain" data-deviceId="<%=deviceId%>" data-deviceType="<%=type%>" class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-9 main col-centered">
|
||||
<h2 class="sub-header"><%=device.name%></h2>
|
||||
<div class="row">
|
||||
</div>
|
||||
<div class="row">
|
||||
<button class="device-operation btn btn-default">
|
||||
<%
|
||||
for (i = 0; i < operations.length; i++) {
|
||||
var operation = operations[i]
|
||||
%>
|
||||
<button data-operation="<%=operation.featureName%>" class="device-operation btn btn-default">
|
||||
<img src="/cdm/client/img/operations/lock.png" />
|
||||
<p>Lock</p>
|
||||
</button>
|
||||
<button class="device-operation btn btn-default">
|
||||
<img src="/cdm/client/img/operations/lock.png" />
|
||||
<p>Lock</p>
|
||||
<p><%=operation.featureDescription %></p>
|
||||
</button>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3 device-model-holder well well-lg">
|
||||
@ -97,6 +101,7 @@ var title="WSO2 CDM";
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
include("/includes/footer.jag");
|
||||
include("/includes/layout-footer.jag");
|
||||
%>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user