merge ui fixes

revert-70aa11f8
ayyoob 8 years ago
parent f47d0deb1a
commit ca33f035df

@ -8,6 +8,7 @@ import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -80,8 +81,10 @@ public class HTTPMessageExecutor implements Runnable {
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
log.error("Push Notification message dropped " + url, e); log.error("Push Notification message dropped " + url, e);
throw new InvalidConfigurationException("invalid host: url", e);
} catch (Throwable e) { } catch (Throwable e) {
log.error("Push Notification message dropped ", e); log.error("Push Notification message dropped ", e);
throw new InvalidConfigurationException("Push Notification message dropped, " + e.getMessage(), e);
} finally { } finally {
if (method != null) { if (method != null) {
method.releaseConnection(); method.releaseConnection();

@ -22,6 +22,7 @@ import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
@ -48,10 +49,9 @@ public class HTTPNotificationStrategy implements NotificationStrategy {
public HTTPNotificationStrategy(PushNotificationConfig config) { public HTTPNotificationStrategy(PushNotificationConfig config) {
this.config = config; this.config = config;
} if (this.config == null) {
throw new InvalidConfigurationException("Properties Cannot be found");
@Override }
public void init() {
endpoint = config.getProperties().get(URL_PROPERTY); endpoint = config.getProperties().get(URL_PROPERTY);
if (endpoint == null || endpoint.isEmpty()) { if (endpoint == null || endpoint.isEmpty()) {
throw new InvalidConfigurationException("Property - 'url' cannot be found"); throw new InvalidConfigurationException("Property - 'url' cannot be found");
@ -69,6 +69,11 @@ public class HTTPNotificationStrategy implements NotificationStrategy {
} }
} }
@Override
public void init() {
}
@Override @Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
try { try {

@ -1,46 +0,0 @@
/*
* Copyright (c) 2016, 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
/**
* This exception is thrown whether the mqtt configured with invalid configuration.
*/
public class InvalidConfigurationException extends RuntimeException {
public InvalidConfigurationException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public InvalidConfigurationException(String message, Throwable cause) {
super(message, cause);
}
public InvalidConfigurationException(String msg) {
super(msg);
}
public InvalidConfigurationException() {
super();
}
public InvalidConfigurationException(Throwable cause) {
super(cause);
}
}

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;

@ -1,46 +0,0 @@
/*
* Copyright (c) 2016, 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.
*
*/
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp;
/**
* This exception is thrown whether the xmpp configured with invalid configuration.
*/
public class InvalidConfigurationException extends RuntimeException {
public InvalidConfigurationException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public InvalidConfigurationException(String message, Throwable cause) {
super(message, cause);
}
public InvalidConfigurationException(String msg) {
super(msg);
}
public InvalidConfigurationException() {
super();
}
public InvalidConfigurationException(Throwable cause) {
super(cause);
}
}

@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;

@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
@ -85,7 +86,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
String errorMessage = "The payload of the device enrollment is incorrect."; String errorMessage = "The payload of the device enrollment is incorrect.";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} }
Device existingDevice = dms.getDevice(new DeviceIdentifier(device.getType(), device.getType())); Device existingDevice = dms.getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
if (existingDevice != null && existingDevice.getEnrolmentInfo() != null && existingDevice if (existingDevice != null && existingDevice.getEnrolmentInfo() != null && existingDevice
.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.ACTIVE)) { .getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.ACTIVE)) {
String errorMessage = "An active enrolment exists"; String errorMessage = "An active enrolment exists";
@ -101,6 +102,9 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
device.getDeviceIdentifier() + "'"; device.getDeviceIdentifier() + "'";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (InvalidConfigurationException e) {
log.error("failed to add operation", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} }
} }

@ -485,7 +485,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
analyticsTableRecord.setColumnName(attribute.getName()); analyticsTableRecord.setColumnName(attribute.getName());
analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase()); analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
analyticsTableRecord.setFacet(false); analyticsTableRecord.setFacet(false);
analyticsTableRecord.setIndexed(true); analyticsTableRecord.setIndexed(false);
analyticsTableRecord.setPersist(true); analyticsTableRecord.setPersist(true);
analyticsTableRecord.setPrimaryKey(false); analyticsTableRecord.setPrimaryKey(false);
analyticsTableRecord.setScoreParam(false); analyticsTableRecord.setScoreParam(false);

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
@ -716,6 +717,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
log.error(errorMessage, e); log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
} catch (InvalidConfigurationException e) {
log.error("failed to add operation", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} }
} }
} }

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidConfigurationException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@ -88,6 +89,8 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen
String msg = "Error occurred at server side while adding a device type."; String msg = "Error occurred at server side while adding a device type.";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity(msg).build(); return Response.serverError().entity(msg).build();
} catch (InvalidConfigurationException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
} }
} else { } else {
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
@ -111,6 +114,8 @@ public class DeviceTypeManagementAdminServiceImpl implements DeviceTypeManagemen
String msg = "Error occurred at server side while updating the device type."; String msg = "Error occurred at server side while updating the device type.";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity(msg).build(); return Response.serverError().entity(msg).build();
} catch (InvalidConfigurationException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
} }
} else { } else {
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();

@ -16,10 +16,10 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.http; package org.wso2.carbon.device.mgt.common;
/** /**
* This exception is thrown whether the http configured with invalid configuration. * This exception is thrown when configured with invalid configuration.
*/ */
public class InvalidConfigurationException extends RuntimeException { public class InvalidConfigurationException extends RuntimeException {

@ -121,7 +121,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
"t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
"AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceIdentifier.getType()); stmt.setString(1, deviceIdentifier.getType());
@ -154,7 +154,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_DETAIL dt " +
"WHERE t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID " + "WHERE t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND dt.DEVICE_ID = d.ID " +
"AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" ; "AND dt.UPDATE_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" ;
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
int paramIdx = 1; int paramIdx = 1;
@ -189,7 +189,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
"t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
"AND TENANT_ID = ? AND e.STATUS = ?"; "AND TENANT_ID = ? AND e.STATUS = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceIdentifier.getType()); stmt.setString(1, deviceIdentifier.getType());
@ -223,7 +223,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
"t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? ) d1 WHERE d1.ID = e.DEVICE_ID ORDER BY e.DATE_OF_LAST_UPDATE DESC"; "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? ) d1 WHERE d1.ID = e.DEVICE_ID ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceIdentifier.getType()); stmt.setString(1, deviceIdentifier.getType());
stmt.setString(2, deviceIdentifier.getId()); stmt.setString(2, deviceIdentifier.getId());
@ -253,7 +253,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " +
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " +
"d.ID = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "d.ID = ? AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " +
"AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
@ -317,7 +317,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
"e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " +
"d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + "d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " +
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " + "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " +
"AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; "AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, type); stmt.setString(1, type);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);

@ -387,7 +387,7 @@ deviceModule = function () {
var jwtClient = JWTClientManagerService.getJWTClient(); var jwtClient = JWTClientManagerService.getJWTClient();
// returning access token by JWT grant type // returning access token by JWT grant type
var deviceScope = "device_" + type.replace(" ", "") + "_" + deviceId + " perm:device:enroll " + var deviceScope = "device_" + type.replace(" ", "") + "_" + deviceId + " perm:device:enroll " +
"perm:device:disenroll perm:device:modify perm:device:operations perm:device:publish-event"; "perm:device:disenroll perm:device:modify perm:devices:operations perm:device:publish-event";
var tokenInfo = jwtClient.getAccessToken(config.clientId, config.clientSecret, var tokenInfo = jwtClient.getAccessToken(config.clientId, config.clientSecret,
userName, deviceScope); userName, deviceScope);
config.accessToken = tokenInfo.getAccessToken(); config.accessToken = tokenInfo.getAccessToken();

@ -51,8 +51,7 @@
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Create Device Type</p> <p class="page-sub-title">Create Device Type</p>
<hr/> <hr/>
<div class="row"> <div class="">
<div class="col-lg-8">
<div class="wr-steps"> <div class="wr-steps">
<div class="col-md-6 col-xs-6"> <div class="col-md-6 col-xs-6">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"> <div class="itm-wiz itm-wiz-current" data-step="policy-platform">
@ -70,42 +69,48 @@
</div> </div>
<br/><br/> <br/><br/>
<hr/> <hr/>
<div id="devicetype-create-error-msg" class="alert alert-danger hidden" role="alert"> <div id="devicetype-create-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<label class="wr-input-label"> <label class="wr-input-label">
Name * (eg: firealarm) Name *
</label> </label>
<br> <div class="wr-input-control">
<input aria-describedby="basic-addon1" type="text" id="deviceTypeName" <input placeholder="E.g firealarm" aria-describedby="basic-addon1" type="text" id="deviceTypeName"
data-error-msg="invalid device type name" class="form-control"/> data-error-msg="invalid device type name" class="form-control"/>
</div>
<label class="wr-input-label"> <label class="wr-input-label">
Description * Description *
</label> </label>
<br> <div class="wr-input-control ">
<textarea aria-describedby="basic-addon1" type="text" id="deviceTypeDescription" <textarea aria-describedby="basic-addon1" type="text" id="deviceTypeDescription"
data-error-msg="invalid device type description" data-error-msg="invalid device type description"
class="form-control" rows="3" cols="70"></textarea> class="form-control" rows="3" cols="70"></textarea>
</div>
<label class="wr-input-label">Push Notification Transport</label> <label class="wr-input-label">
Push Notification Transport
</label>
<div class="wr-input-control"> <div class="wr-input-control">
<!--suppress HtmlFormInputWithoutLabel -->
<select id="pushNotification" class="form-control select"> <select id="pushNotification" class="form-control select">
<option>NONE</option> <option>NONE</option>
<option>MQTT</option> <option>MQTT</option>
</select> </select>
</div> </div>
<label class="wr-input-label"> <label class="wr-input-label" for="passcode-policy-min-length">
Features (Definition of the operation from server to device) Features (Definition of the operation from server to device)
<br/> <span class="helper" title="E.g name: fire alarm range control, code: alarm, description: this controls the alarm sound type and range of firealarm">
(eg: name: fire alarm range control, code: alarm, description: this controls the alarm sound type and range of firealarm) <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label> </label>
<br>
<div class="form-group feature_field_wrapper"> <div class="form-group feature_field_wrapper">
<div class="dontfloat" name="deviceFeature"> <div class="row">
<div class="col-xs-3"> <div class="col-xs-3">
<input type="text" class="form-control" id="feature-name" placeholder="name"/> <input type="text" class="form-control" id="feature-name" placeholder="name"/>
</div> </div>
@ -118,71 +123,70 @@
data-error-msg="invalid feature description" data-error-msg="invalid feature description"
class="form-control" rows="1" cols="30"></textarea> class="form-control" rows="1" cols="30"></textarea>
</div> </div>
<button type="button" class="btn btn-default add_feature_button"><i class="fa fa-plus"></i></button> <button type="button" class="wr-btn wr-btn-horizontal add_feature_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
<label class="wr-input-label" for="passcode-policy-min-length">
<br> Attributes
<label class="wr-input-label"> <span class="helper" title="E.g vendor, model_number ...">
Attributes (eg: vendor, model_number ...) <span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label> </label>
<br>
<div class="form-group attribute_field_wrapper"> <div class="form-group attribute_field_wrapper">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat">
<input type="text" class="form-control" name="attribute[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="attribute[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
<div class="hidden-div"> <div class="hidden-div">
<div id="add-attribute-field" name="add-attribute-field"> <div id="add-attribute-field" name="add-attribute-field">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="attribute[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="attribute[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_button"><i class="fa fa-minus"></i></button>
</div> </div>
<button type="button" class="btn btn-default remove_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div> </div>
</div> </div>
<label class="wr-input-label"> <label class="wr-input-label" for="passcode-policy-min-length">
Enrolment Operation (Triggers the operation after the enrolment, eg: alarm) Enrolment Operation
<span class="helper" title="Triggers the operation after the enrolment, E.g alarm">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label> </label>
<br>
<div class="form-group operation_field_wrapper"> <div class="form-group operation_field_wrapper">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat">
<input type="text" class="form-control" name="operation[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="operation[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_operation_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_operation_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
<div class="hidden-div"> <div class="hidden-div">
<div id="add-operation-field" name="add-operation-field"> <div id="add-operation-field" name="add-operation-field">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="operation[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="operation[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_operation_button"><i class="fa fa-minus"></i></button>
</div> </div>
<button type="button" class="btn btn-default remove_operation_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div> </div>
</div> </div>
<label class="wr-input-label">Claimable</label>
<input aria-describedby="basic-addon1" type="checkbox" id="deviceClaimable"/>
</br>
<label class="wr-input-label">Policy Monitoring</label>
<input aria-describedby="basic-addon1" type="checkbox" id="policyMonitoring"/>
</br>
<span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error roleNameEmpty hidden" for="summary"> <label class="error roleNameEmpty hidden" for="summary">
Device Type Name is required, should be in minimum 3 characters long and not include any Device Type Name is required, should be in minimum 3 characters long and not include any
@ -191,7 +195,6 @@
</div> </div>
</div>
<br> <br>
<button id="add-devicetype-btn" class="wr-btn">Add Device Type</button> <button id="add-devicetype-btn" class="wr-btn">Add Device Type</button>
</div> </div>

@ -1,4 +1,6 @@
.wr-btn-horizontal{
padding: 7px 10px;
}
.dontfloat { .dontfloat {
clear:both; clear:both;
@ -8,3 +10,10 @@
display: none; display: none;
} }
.feature-wrapper{
margin-top: 10px;
}
.wr-btn-secondary{
background-color: #617d8b;
}

@ -97,6 +97,7 @@ function formatRepoSelection(user) {
$(document).ready(function () { $(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
var appContext = $("#app-context").data("app-context"); var appContext = $("#app-context").data("app-context");
var maxField = 100; //Input fields increment limitation var maxField = 100; //Input fields increment limitation
@ -126,13 +127,13 @@ $(document).ready(function () {
var addFeatureButton = $('.add_feature_button'); //Add button selector var addFeatureButton = $('.add_feature_button'); //Add button selector
var featureWrapper = $('.feature_field_wrapper'); //Input field wrapper var featureWrapper = $('.feature_field_wrapper'); //Input field wrapper
$(addFeatureButton).click(function(){ //Once add button is clicked $(addFeatureButton).click(function(){ //Once add button is clicked
var featureFieldHtml = ' <div class="dontfloat" name ="deviceFeature"> <div class="col-xs-3"> <input type="text"' + var featureFieldHtml = '<div class="row"><div class="dontfloat feature-wrapper" name ="deviceFeature"> <div class="col-xs-3"> <input type="text"' +
' class="form-control" id="feature-name" placeholder="name"/> </div> <div class="col-xs-4"> ' + ' class="form-control" id="feature-name" placeholder="name"/> </div> <div class="col-xs-4"> ' +
'<input type="text" class="form-control" id="feature-code" placeholder="code"/> </div> ' + '<input type="text" class="form-control" id="feature-code" placeholder="code"/> </div> ' +
'<div class="col-xs-4"> <textarea aria-describedby="basic-addon1" type="text" ' + '<div class="col-xs-4"> <textarea aria-describedby="basic-addon1" type="text" ' +
'id="feature-description" placeholder="description"data-error-msg="invalid ' + 'id="feature-description" placeholder="description"data-error-msg="invalid ' +
'feature description"class="form-control" rows="1" cols="30"></textarea> </div> ' + 'feature description"class="form-control" rows="1" cols="30"></textarea> </div> ' +
'<button type="button" class="btn btn-default remove_feature_button"><i class="fa fa-minus"></i></button> </div>' '<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_feature_button"><i class="fa fa-minus"></i></button> </div></div>'
$(featureWrapper).append(featureFieldHtml); // Add field html $(featureWrapper).append(featureFieldHtml); // Add field html
}); });
$(featureWrapper).on('click', '.remove_feature_button', function(e){ //Once remove button is clicked $(featureWrapper).on('click', '.remove_feature_button', function(e){ //Once remove button is clicked
@ -195,9 +196,6 @@ $(document).ready(function () {
deviceType.deviceTypeMetaDefinition.initialOperationConfig.operations = operationValues; deviceType.deviceTypeMetaDefinition.initialOperationConfig.operations = operationValues;
} }
deviceType.deviceTypeMetaDefinition.policyMonitoringEnabled = $("#policyMonitoring").is(":checked");
deviceType.deviceTypeMetaDefinition.claimable = $("#deviceClaimable").is(":checked");;
var features = []; var features = [];
$('div[name^="deviceFeature"]').each(function() { $('div[name^="deviceFeature"]').each(function() {
var featureName = $(this).find("#feature-name").val(); var featureName = $(this).find("#feature-name").val();

@ -60,31 +60,32 @@
<input aria-describedby="basic-addon1" type="text" id="deviceTypeName" <input aria-describedby="basic-addon1" type="text" id="deviceTypeName"
data-error-msg="invalid device type name" class="form-control hidden-input" value="{{name}}"/> data-error-msg="invalid device type name" class="form-control hidden-input" value="{{name}}"/>
<label class="wr-input-label"> <div class="wr-input-control">
<label class="wr-input-label">
Description * Description *
</label> </label>
<br> <br>
<textarea aria-describedby="basic-addon1" type="text" id="deviceTypeDescription" <textarea aria-describedby="basic-addon1" type="text" id="deviceTypeDescription"
data-error-msg="invalid device type description" data-error-msg="invalid device type description"
class="form-control" rows="3" cols="70">{{type.deviceTypeMetaDefinition.description}}</textarea> class="form-control" rows="3" cols="70">{{type.deviceTypeMetaDefinition.description}}</textarea>
</div>
<label class="wr-input-label">Push Notification Transport</label>
<div class="wr-input-control"> <div class="wr-input-control">
<!--suppress HtmlFormInputWithoutLabel --> <label class="wr-input-label">Push Notification Transport</label>
<select id="pushNotification" class="form-control select"> <div class="wr-input-control">
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}} <!--suppress HtmlFormInputWithoutLabel -->
<option>NONE</option> <select id="pushNotification" class="form-control select">
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}} {{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
<option selected>MQTT</option> <option>NONE</option>
{{/if_eq}} {{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
{{else}} <option selected>MQTT</option>
<option selected>NONE</option> {{/if_eq}}
<option>MQTT</option> {{else}}
{{/if}} <option selected>NONE</option>
<option>MQTT</option>
{{/if}}
</select>
</select> </div>
</div> </div>
<label class="wr-input-label"> <label class="wr-input-label">
@ -94,7 +95,8 @@
<div class="form-group feature_field_wrapper"> <div class="form-group feature_field_wrapper">
{{#if type.deviceTypeMetaDefinition.features}} {{#if type.deviceTypeMetaDefinition.features}}
{{#each type.deviceTypeMetaDefinition.features}} {{#each type.deviceTypeMetaDefinition.features}}
<div class="dontfloat" name ="deviceFeature"> <div class="row">
<div class="dontfloat feature-wrapper" name ="deviceFeature">
<div class="col-xs-3"> <div class="col-xs-3">
<input type="text" class="form-control" id="feature-name" placeholder="name" value="{{this.name}}"/> <input type="text" class="form-control" id="feature-name" placeholder="name" value="{{this.name}}"/>
</div> </div>
@ -105,24 +107,27 @@
<textarea aria-describedby="basic-addon1" type="text" id="feature-description" <textarea aria-describedby="basic-addon1" type="text" id="feature-description"
placeholder="description" data-error-msg="invalid feature description" class="form-control" rows="1" cols="30">{{this.description}}</textarea> placeholder="description" data-error-msg="invalid feature description" class="form-control" rows="1" cols="30">{{this.description}}</textarea>
</div> </div>
<button type="button" class="btn btn-default remove_feature_button"><i class="fa fa-minus"></i></button> <button type="button" class="wr-btn wr-btn-horizontal remove_feature_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div>
{{/each}} {{/each}}
{{/if}} {{/if}}
<div class="dontfloat" name="deviceFeature"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper" name="deviceFeature">
<input type="text" class="form-control" id="feature-name" placeholder="name"/> <div class="col-xs-3">
</div> <input type="text" class="form-control" id="feature-name" placeholder="name"/>
<div class="col-xs-4"> </div>
<input type="text" class="form-control" id="feature-code" placeholder="code"/> <div class="col-xs-4">
</div> <input type="text" class="form-control" id="feature-code" placeholder="code"/>
<div class="col-xs-4"> </div>
<textarea aria-describedby="basic-addon1" type="text" id="feature-description" <div class="col-xs-4">
placeholder="description" <textarea aria-describedby="basic-addon1" type="text" id="feature-description"
data-error-msg="invalid feature description" placeholder="description"
class="form-control" rows="1" cols="30"></textarea> data-error-msg="invalid feature description"
class="form-control" rows="1" cols="30"></textarea>
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_feature_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_feature_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
@ -134,28 +139,34 @@
<div class="form-group attribute_field_wrapper"> <div class="form-group attribute_field_wrapper">
{{#if type.deviceTypeMetaDefinition.properties}} {{#if type.deviceTypeMetaDefinition.properties}}
{{#each type.deviceTypeMetaDefinition.properties}} {{#each type.deviceTypeMetaDefinition.properties}}
<div class="row">
<div class="dontfloat"> <div class="dontfloat">
<div class="col-xs-3"> <div class="col-xs-3">
<input type="text" class="form-control" name="attribute[]" value="{{this}}" /> <input type="text" class="form-control" name="attribute[]" value="{{this}}" />
</div> </div>
<button type="button" class="btn btn-default remove_button"><i class="fa fa-minus"></i></button> <button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div>
{{/each}} {{/each}}
{{/if}} {{/if}}
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="attribute[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="attribute[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
<div class="hidden-div"> <div class="hidden-div">
<div id="add-attribute-field" name="add-attribute-field"> <div id="add-attribute-field" name="add-attribute-field">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="attribute[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="attribute[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_button"><i class="fa fa-minus"></i></button>
</div> </div>
<button type="button" class="btn btn-default remove_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div> </div>
</div> </div>
@ -168,49 +179,38 @@
<div class="form-group operation_field_wrapper"> <div class="form-group operation_field_wrapper">
{{#if type.deviceTypeMetaDefinition.initialOperationConfig}} {{#if type.deviceTypeMetaDefinition.initialOperationConfig}}
{{#each type.deviceTypeMetaDefinition.initialOperationConfig.operations}} {{#each type.deviceTypeMetaDefinition.initialOperationConfig.operations}}
<div class="dontfloat"> <div class="row">
<div class="dontfloat feature-wrapper">
<div class="col-xs-3"> <div class="col-xs-3">
<input type="text" class="form-control" name="operation[]" value="{{this}}"/> <input type="text" class="form-control" name="operation[]" value="{{this}}"/>
</div> </div>
<button type="button" class="btn btn-default remove_operation_button"><i class="fa fa-minus"></i></button> <button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_operation_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div>
{{/each}} {{/each}}
{{/if}} {{/if}}
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="operation[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="operation[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_operation_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_operation_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>
<div class="hidden-div"> <div class="hidden-div">
<div id="add-operation-field" name="add-operation-field"> <div id="add-operation-field" name="add-operation-field">
<div class="dontfloat"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat feature-wrapper">
<input type="text" class="form-control" name="operation[]" /> <div class="col-xs-3">
<input type="text" class="form-control" name="operation[]" />
</div>
<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_operation_button"><i class="fa fa-minus"></i></button>
</div> </div>
<button type="button" class="btn btn-default remove_operation_button"><i class="fa fa-minus"></i></button>
</div> </div>
</div> </div>
</div> </div>
<label class="wr-input-label">Claimable</label>
<input aria-describedby="basic-addon1" type="checkbox" id="deviceClaimable"
{{#if type.deviceTypeMetaDefinition.claimable}}
checked
{{/if}}/>
</br>
<label class="wr-input-label">Policy Monitoring</label>
<input aria-describedby="basic-addon1" type="checkbox" id="policyMonitoring"
{{#if type.deviceTypeMetaDefinition.policyMonitoringEnabled}}
checked
{{/if}}/>
</br>
<span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error roleNameEmpty hidden" for="summary"> <label class="error roleNameEmpty hidden" for="summary">
Device Type Name is required, should be in minimum 3 characters long and not include any Device Type Name is required, should be in minimum 3 characters long and not include any

@ -1,4 +1,6 @@
.wr-btn-horizontal{
padding: 7px 10px;
}
.dontfloat { .dontfloat {
clear:both; clear:both;
@ -11,3 +13,13 @@
.hidden-input { .hidden-input {
display: none; display: none;
} }
.feature-wrapper{
margin-top: 10px;
}
.wr-btn-secondary{
background-color: #617d8b;
}
.wr-btn-secondary{
background-color: #617d8b;
}

@ -123,13 +123,13 @@ $(document).ready(function () {
var addFeatureButton = $('.add_feature_button'); //Add button selector var addFeatureButton = $('.add_feature_button'); //Add button selector
var featureWrapper = $('.feature_field_wrapper'); //Input field wrapper var featureWrapper = $('.feature_field_wrapper'); //Input field wrapper
$(addFeatureButton).click(function(){ //Once add button is clicked $(addFeatureButton).click(function(){ //Once add button is clicked
var featureFieldHtml = ' <div class="dontfloat" name ="deviceFeature"> <div class="col-xs-3"> <input type="text"' + var featureFieldHtml = '<div class="row"><div class="dontfloat feature-wrapper" name ="deviceFeature"> <div class="col-xs-3"> <input type="text"' +
' class="form-control" id="feature-name" placeholder="name"/> </div> <div class="col-xs-4"> ' + ' class="form-control" id="feature-name" placeholder="name"/> </div> <div class="col-xs-4"> ' +
'<input type="text" class="form-control" id="feature-code" placeholder="code"/> </div> ' + '<input type="text" class="form-control" id="feature-code" placeholder="code"/> </div> ' +
'<div class="col-xs-4"> <textarea aria-describedby="basic-addon1" type="text" ' + '<div class="col-xs-4"> <textarea aria-describedby="basic-addon1" type="text" ' +
'id="feature-description" placeholder="description"data-error-msg="invalid ' + 'id="feature-description" placeholder="description"data-error-msg="invalid ' +
'feature description"class="form-control" rows="1" cols="30"></textarea> </div> ' + 'feature description"class="form-control" rows="1" cols="30"></textarea> </div> ' +
'<button type="button" class="btn btn-default remove_feature_button"><i class="fa fa-minus"></i></button> </div>' '<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_feature_button"><i class="fa fa-minus"></i></button> </div></div>'
$(featureWrapper).append(featureFieldHtml); // Add field html $(featureWrapper).append(featureFieldHtml); // Add field html
}); });
@ -196,9 +196,6 @@ $(document).ready(function () {
deviceType.deviceTypeMetaDefinition.initialOperationConfig.operations = operationValues; deviceType.deviceTypeMetaDefinition.initialOperationConfig.operations = operationValues;
} }
deviceType.deviceTypeMetaDefinition.policyMonitoringEnabled = $("#policyMonitoring").is(":checked");
deviceType.deviceTypeMetaDefinition.claimable = $("#deviceClaimable").is(":checked");;
var features = []; var features = [];
$('div[name^="deviceFeature"]').each(function() { $('div[name^="deviceFeature"]').each(function() {
var featureName = $(this).find("#feature-name").val(); var featureName = $(this).find("#feature-name").val();

@ -65,11 +65,11 @@
<!--suppress HtmlFormInputWithoutLabel --> <!--suppress HtmlFormInputWithoutLabel -->
<select id="transport" class="form-control select"> <select id="transport" class="form-control select">
{{#if event}} {{#if event}}
<option {{selected event.transport "MQTT"}}>MQTT</option>
<option {{selected event.transport "HTTP"}}>HTTP</option> <option {{selected event.transport "HTTP"}}>HTTP</option>
<option {{selected event.transport "MQTT"}}>MQTT</option>
{{else}} {{else}}
<option>MQTT</option>
<option>HTTP</option> <option>HTTP</option>
<option>MQTT</option>
{{/if}} {{/if}}
</select> </select>
@ -82,39 +82,43 @@
<div class="form-group event_field_wrapper"> <div class="form-group event_field_wrapper">
{{#if event.eventAttributes}} {{#if event.eventAttributes}}
{{#each event.eventAttributes.attributes}} {{#each event.eventAttributes.attributes}}
<div class="dontfloat" name="deviceEvent"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat" name="deviceEvent">
<input type="text" class="form-control" id="event-name" placeholder="name" value="{{this.name}}"/> <div class="col-xs-3">
<input type="text" class="form-control" id="event-name" placeholder="name" value="{{this.name}}"/>
</div>
<div class="col-xs-4">
<select class="form-control select" id="event-type">
<option {{selected this.type "STRING"}}>STRING</option>
<option {{selected this.type "LONG"}}>LONG</option>
<option {{selected this.type "BOOL"}}>BOOL</option>
<option {{selected this.type "INT"}}>INT</option>
<option {{selected this.type "FLOAT"}}>FLOAT</option>
<option {{selected this.type "DOUBLE"}}>DOUBLE</option>
</select>
</div>
<button type="button" class="wr-btn wr-btn-horizontal remove_event_button"><i class="fa fa-minus"></i></button>
</div> </div>
<div class="col-xs-4">
<select class="form-control select" id="event-type">
<option {{selected this.type "STRING"}}>STRING</option>
<option {{selected this.type "LONG"}}>LONG</option>
<option {{selected this.type "BOOL"}}>BOOL</option>
<option {{selected this.type "INT"}}>INT</option>
<option {{selected this.type "FLOAT"}}>FLOAT</option>
<option {{selected this.type "DOUBLE"}}>DOUBLE</option>
</select>
</div>
<button type="button" class="btn btn-default remove_event_button"><i class="fa fa-minus"></i></button>
</div> </div>
{{/each}} {{/each}}
{{/if}} {{/if}}
<div class="dontfloat" name="deviceEvent"> <div class="row">
<div class="col-xs-3"> <div class="dontfloat event-wrapper" name="deviceEvent">
<input type="text" class="form-control" id="event-name" placeholder="name"/> <div class="col-xs-3">
</div> <input type="text" class="form-control" id="event-name" placeholder="name"/>
<div class="col-xs-4"> </div>
<select class="form-control select" id="event-type"> <div class="col-xs-4">
<option>STRING</option> <select class="form-control select" id="event-type">
<option>LONG</option> <option>STRING</option>
<option>BOOL</option> <option>LONG</option>
<option>INT</option> <option>BOOL</option>
<option>FLOAT</option> <option>INT</option>
<option>DOUBLE</option> <option>FLOAT</option>
</select> <option>DOUBLE</option>
</select>
</div>
<button type="button" class="wr-btn wr-btn-horizontal add_event_button"><i class="fa fa-plus"></i></button>
</div> </div>
<button type="button" class="btn btn-default add_event_button"><i class="fa fa-plus"></i></button>
</div> </div>
</div> </div>

@ -11,3 +11,19 @@
.hidden-input { .hidden-input {
display: none; display: none;
} }
.event-wrapper{
margin-top: 10px;
}
.wr-btn-horizontal{
padding: 7px 10px;
}
.wr-btn-secondary{
background-color: #617d8b;
}
.page-content-wrapper{
height: calc(100vh - 50px);
}

@ -101,12 +101,12 @@ $(document).ready(function () {
var addEventButton = $('.add_event_button'); //Add button selector var addEventButton = $('.add_event_button'); //Add button selector
var eventWrapper = $('.event_field_wrapper'); //Input field wrapper var eventWrapper = $('.event_field_wrapper'); //Input field wrapper
$(addEventButton).click(function(){ //Once add button is clicked $(addEventButton).click(function(){ //Once add button is clicked
var eventFieldHtml = ' <div class="dontfloat" name="deviceEvent"> ' + var eventFieldHtml = '<div class="row"><div class="dontfloat event-wrapper" name="deviceEvent"> ' +
'<div class="col-xs-3"> <input type="text" class="form-control" id="event-name" placeholder="name"/> ' + '<div class="col-xs-3"> <input type="text" class="form-control" id="event-name" placeholder="name"/> ' +
'</div> <div class="col-xs-4"> <select class="form-control select" id="event-type"> ' + '</div> <div class="col-xs-4"> <select class="form-control select" id="event-type"> ' +
'<option>STRING</option> <option>LONG</option> <option>BOOL</option> <option>INT</option> <option>FLOAT</option> ' + '<option>STRING</option> <option>LONG</option> <option>BOOL</option> <option>INT</option> <option>FLOAT</option> ' +
'<option>DOUBLE</option> </select> </div> ' + '<option>DOUBLE</option> </select> </div> ' +
'<button type="button" class="btn btn-default remove_event_button"><i class="fa fa-minus"></i></button> </div>' '<button type="button" class="wr-btn wr-btn-horizontal wr-btn-secondary remove_event_button"><i class="fa fa-minus"></i></button> </div></div>'
$(eventWrapper).append(eventFieldHtml); // Add field html $(eventWrapper).append(eventFieldHtml); // Add field html
}); });

@ -20,6 +20,17 @@
.thumbnail.icon:before { .thumbnail.icon:before {
padding-top: 0; padding-top: 0;
} }
.code-segment{
margin-bottom: 10px;
}
.code-segment span{
display: block;
}
.code-segment code{
padding: 10px;
display: block;
background-color: #f3f3f3;
}
</style> </style>
{{/zone}} {{/zone}}
@ -91,4 +102,87 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">Device Communication</h2>
<hr>
{{#if event}}
<h3 class="uppercase">publish device events :</h3>
{{#if_eq event.transport "MQTT"}}
<div class="code-segment">
<span>MQTT Topic :</span>
<code>{{tenantDomain}}/{{device.type}}/&lt;device_id&gt;/events</code>
</div>
{{#if eventSample}}
<div class="code-segment">
<span>Device Event Payload :</span>
<code>{{eventSample}}</code>
</div>
{{/if}}
{{/if_eq}}
{{#if_eq event.transport "HTTP"}}
<div class="code-segment">
<code> curl -k -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/events/publish/{{device.type}}/{{device.deviceIdentifier}}
-H 'authorization: Bearer %accessToken%'
-H 'content-type: application/json'
-d '{{eventSample}}'
</code>
</div>
{{/if_eq}}
{{/if}}
</br>
<h3 class="uppercase">Retrieve operations</h3>
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
MQTT - {{mqttGateway}}
<div class="code-segment">
<span>MQTT Topic :</span>
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/#</code>
</div>
<div class="code-segment">
<span>Operation Response :</span>
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/update/operation</code>
</div>
<div class="code-segment">
<span>Payload :</span>
<code>{"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}</code>
</div>
<br/>
Topic Structure:
<ul class="list-unstyled">
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke</code>
</li>
</ul>
{{/if_eq}}
{{else}}
<div class="code-segment">
<span>Retrieve pending operation :</span>
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/pending/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</div>
<div class="code-segment">
<span>Retrieve next pending operation :</span>
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/ -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</div>
<div class="code-segment">
<span>Update operation :</span>
<code>curl -k -X PUT {{httpsGateway}}/api/device-mgt/v1.0/device/agent/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"id": 1,"status": "COMPLETED", "payload": "this is my response"}'</code>
</div>
{{/if}}
<br>
<br>
</div>
{{/zone}} {{/zone}}

@ -17,6 +17,7 @@
*/ */
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var process = require("process");
function onRequest(context) { function onRequest(context) {
var log = new Log("device-view.js"); var log = new Log("device-view.js");
@ -65,17 +66,82 @@ function onRequest(context) {
var autoCompleteParams = [ var autoCompleteParams = [
{"name" : "deviceId", "value" : deviceId} {"name" : "deviceId", "value" : deviceId}
]; ];
context.handlebars.registerHelper('if_eq', function(a, b, opts) {
if(a == b) // Or === depending on your needs
return opts.fn(this);
else
return opts.inverse(this);
});
var displayData = {};
var eventRestAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
+ "/events/" + deviceType;
serviceInvokers.XMLHttp.get(
eventRestAPIEndpoint,
function (restAPIResponse) {
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
var typeData = parse(restAPIResponse["responseText"]);
displayData.event = typeData;
var sampleValue = "";
if (typeData.eventAttributes && typeData.eventAttributes.attributes) {
var eventExample = {};
for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) {
var attribute = typeData.eventAttributes.attributes[i];
switch (attribute.type) {
case "STRING":
eventExample[attribute.name] = "string";
sampleValue = sampleValue + "\"string\", ";
break;
case "LONG":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "INT":
eventExample[attribute.name] = 0;
sampleValue = sampleValue + 0 +", ";
break;
case "FLOAT":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "DOUBLE":
eventExample[attribute.name] = 0.0;
sampleValue = sampleValue + 0.0 +", ";
break;
case "BOOL":
eventExample[attribute.name] = false;
sampleValue = sampleValue + false + ", ";
break;
}
}
var sample = eventExample;
if (sampleValue && sampleValue.length > 2) {
displayData.sampleValue = sampleValue.substring(0, sampleValue.length - 2);
}
displayData.eventSample = JSON.stringify(sample);
displayData.mqttGateway = "tcp://" + process.getProperty("mqtt.broker.host") + ":" + process.getProperty("mqtt.broker.port");
displayData.httpsGateway = "https://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.https.port");
}
}
}
);
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
displayData.device = device.content;
displayData.autoCompleteParams = autoCompleteParams;
displayData.encodedFeaturePayloads = "";
displayData.features = featureList;
if (attributes.length === 0 || attributes.length === undefined) { if (attributes.length === 0 || attributes.length === undefined) {
return {"device": device.content, "autoCompleteParams" : autoCompleteParams return displayData;
, "encodedFeaturePayloads": "", "features":featureList};
} else { } else {
return {"device": device.content, "autoCompleteParams" : autoCompleteParams displayData.attributes = attributes;
, "encodedFeaturePayloads": "", "attributes": attributes, "features":featureList}; return displayData;
} }
} else { } else {
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");

@ -78,6 +78,13 @@ function onRequest(context) {
event.value = record["" + attributes[eventAttribute]]; event.value = record["" + attributes[eventAttribute]];
events.push(event); events.push(event);
} }
} else {
for (var eventAttribute in attributes){
var event = {};
event.key = attributes[eventAttribute];
event.value = "-";
events.push(event);
}
} }
} }

@ -4,7 +4,7 @@
<hr> <hr>
</div> </div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 padding-top"> <div class="col-xs-12 col-sm-4 col-md-4 col-lg-3 padding-top add-margin-bottom-5x">
<img src="{{@unit.publicUri}}/images/deviceType.png" class="img-responsive"> <img src="{{@unit.publicUri}}/images/deviceType.png" class="img-responsive">
</div> </div>
@ -18,6 +18,9 @@
<br> <br>
<hr> <hr>
<br> <br>
<a href="#create"
class="btn-operations"><i class="fw fw-add add-margin-1x"></i> Create Device</i>
</a>
<a href="/api-store/apis/info?name=DeviceAgent Service&version=1.0.0&provider=admin" <a href="/api-store/apis/info?name=DeviceAgent Service&version=1.0.0&provider=admin"
class="btn-operations" class="btn-operations"
target="_blank"><i class="fw fw-api add-margin-1x"></i> View API</i> target="_blank"><i class="fw fw-api add-margin-1x"></i> View API</i>
@ -111,17 +114,17 @@
<h2 class="uppercase">How To Enroll a Device</h2> <h2 class="uppercase">How To Enroll a Device</h2>
<hr> <hr>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li class="padding-top-double"><span><h3 class="uppercase">Generate Application</h3></span> <li class="padding-top-double"><span><h4 class="uppercase">Generate Application</h4></span>
<code>curl -k -X POST {{httpsGateway}}/api-application-registration/register -H <code>curl -k -X POST {{httpsGateway}}/api-application-registration/register -H
'authorization: Basic Base64(username:password)' -H 'content-type: application/json' 'authorization: Basic Base64(username:password)' -H 'content-type: application/json'
-d '{ "applicationName":"testme", "isAllowedToAllDomains":false, "tags":["device_agent"]}'</code> -d '{ "applicationName":"testme", "isAllowedToAllDomains":false, "tags":["device_agent"]}'</code>
</li> </li>
<li class="padding-top-double"><span><h3 class="uppercase">Generate Token</h3></span> <li class="padding-top-double"><span><h4 class="uppercase">Generate Token</h4></span>
<code>curl -k -d "grant_type=password&username=%username%&password=%password%&scope=perm:device:enroll perm:device:disenroll perm:device:modify perm:device:operations perm:device:publish-event" <code>curl -k -d "grant_type=password&username=%username%&password=%password%&scope=perm:device:enroll perm:device:disenroll perm:device:modify perm:device:operations perm:device:publish-event"
-H "Authorization: Basic Base64(client_id:client_secret)" -H "Authorization: Basic Base64(client_id:client_secret)"
-H "Content-Type: application/x-www-form-urlencoded" {{httpsGateway}}/token</code> -H "Content-Type: application/x-www-form-urlencoded" {{httpsGateway}}/token</code>
</li> </li>
<li class="padding-top-double"><span><h3 class="uppercase">Create Device</h3></span> <li class="padding-top-double"><span><h4 class="uppercase">Create Device</h4></span>
<code>curl -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/enroll -H 'accept: application/json' <code>curl -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/enroll -H 'accept: application/json'
-H 'authorization: Bearer %accessToken%' -H 'authorization: Bearer %accessToken%'
-H 'content-type: application/json' -d '{ "name": "devicename", "type": "{{deviceType}}", -H 'content-type: application/json' -d '{ "name": "devicename", "type": "{{deviceType}}",
@ -135,10 +138,10 @@
</div> </div>
<hr/> <hr/>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg"> <div id="create" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">Create A Device</h2> <h2 class="uppercase">Create A Device</h2>
<hr> <hr>
<div id="device-create-form" class="container col-centered wr-content"> <div id="device-create-form" class=" wr-content">
<div class="wr-form"> <div class="wr-form">
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
@ -210,80 +213,6 @@
<br> <br>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
<h2 class="uppercase">Device Communication</h2>
<hr>
{{#if event}}
<h3 class="uppercase">publish device events :</h3>
{{#if_eq event.transport "MQTT"}}
MQTT Topic : <code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/events</code>
{{#if eventSample}}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
Device Event Payload
<code>{{eventSample}}</code>
<br>
<br>
</div>
{{/if}}
{{/if_eq}}
{{#if_eq event.transport "HTTP"}}
<code> curl -k -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/events/publish/{{deviceType}}/%deviceId%
-H 'authorization: Bearer %accessToken%'
-H 'content-type: application/json'
-d '{{eventSample}}'
</code>
{{/if_eq}}
{{/if}}
</br>
<h3 class="uppercase">Retrieve operations</h3>
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
MQTT - {{mqttGateway}}
MQTT Topic : <code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/#</code>
<br/>
Operation Response:
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/update/operation</code>
<br/>
Payload : <code>{"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}</code>
<br/>
Topic Structure:
<ul class="list-unstyled">
<li class="padding-top-double">
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/command/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/config/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/profile/&lt;feature_code&gt;/&lt;operation_id&gt;</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/policy/policy_bundle</code>
</li>
<li class="padding-top-double">
<code>{{tenantDomain}}/{{deviceType}}/&lt;device_id&gt;/operation/policy/policy_revoke</code>
</li>
</ul>
{{/if_eq}}
{{else}}
Retrieve pending operation:
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/pending/operations/{{deviceType}}/deviceId
-H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</br>
Retrieve next pending operation:
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/operations/{{deviceType}}/deviceId
-H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
</br>
<code>curl -k -X PUT {{httpsGateway}}/api/device-mgt/v1.0/device/agent/operations/{{deviceType}}/deviceId
-H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"id": 1,"status": "COMPLETED", "payload": "this is my response"}'</code>
{{/if}}
<br>
<br>
</div>
{{#zone "topCss"}} {{#zone "topCss"}}
{{css "css/styles.css"}} {{css "css/styles.css"}}
{{/zone}} {{/zone}}

Loading…
Cancel
Save