diff --git a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java index 7245068b9f..012dd0a1c3 100644 --- a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java +++ b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay.api/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/api/DigitalDisplayControllerService.java @@ -11,9 +11,7 @@ import org.wso2.carbon.device.mgt.iot.digitaldisplay.constants.DigitalDisplayCon import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.File; /** * Created by nuwan on 11/13/15. @@ -48,15 +46,15 @@ public class DigitalDisplayControllerService { */ @Path("/restart-browser") @POST - public void restartBrowser(@QueryParam("deviceId") String deviceId , - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void restartBrowser(@FormParam("deviceId") String deviceId , + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Restrat Browser : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT,""); + sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT + ":",""); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -79,15 +77,15 @@ public class DigitalDisplayControllerService { */ @Path("/close-browser") @POST - public void closeBrowser(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void closeBrowser(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Close Browser : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT ,""); + sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT + ":" ,""); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -109,15 +107,15 @@ public class DigitalDisplayControllerService { */ @Path("/terminate-display") @POST - public void terminateDisplay(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void terminateDisplay(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Terminate Display : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT,""); + sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT +":" ,""); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -139,15 +137,15 @@ public class DigitalDisplayControllerService { */ @Path("/restart-display") @POST - public void restartDisplay(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void restartDisplay(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Restrat Display : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT ,""); + sendCommandViaMQTT(owner,deviceId,sessionId +"::" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT + ":" ,""); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -171,21 +169,20 @@ public class DigitalDisplayControllerService { * @param newValue page is used to replace path */ @Path("/edit-content") - @PUT - @Produces(MediaType.APPLICATION_JSON) - public void editContent(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("path") String path, - @QueryParam("attribute") String attribute, - @QueryParam("new-value") String newValue, - @QueryParam("sessionId") String sessionId, + @POST + public void editContent(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("path") String path, + @FormParam("attribute") String attribute, + @FormParam("new-value") String newValue, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Edit Content Display Id - " + deviceId + " by " + owner); try { - String params = path + File.separator + attribute + File.separator + newValue; - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT,params); + String params = path + "|" + attribute + "|" + newValue; + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT +":" ,params); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -210,20 +207,20 @@ public class DigitalDisplayControllerService { */ @Path("/add-resource") @POST - public void addNewResource(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("type") String type, - @QueryParam("time") String time, - @QueryParam("path") String path, - @QueryParam("sessionId") String sessionId, + public void addNewResource(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("type") String type, + @FormParam("time") String time, + @FormParam("path") String path, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Add Sequence : " + deviceId); try { - String params = type + File.separator + time + File.separator + path; - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + - DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params); + String params = type + "|" + time + "|" + path; + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + + DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT +":" ,params); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -248,22 +245,22 @@ public class DigitalDisplayControllerService { */ @Path("/add-resource-before") @POST - public void addNewResourceBefore(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, - @QueryParam("type") String type, - @QueryParam("time") String time, - @QueryParam("path") String path, - @QueryParam("next-page") String nextPage, + public void addNewResourceBefore(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, + @FormParam("type") String type, + @FormParam("time") String time, + @FormParam("path") String path, + @FormParam("next-page") String nextPage, @Context HttpServletResponse response){ log.info("Add Sequence : " + deviceId); try { - String params = type + File.separator + time + File.separator + path + - File.separator + "before=" + nextPage; - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + - DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params); + String params = type + "|" + time + "|" + path + + "|" + "before=" + nextPage; + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + + DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT +":" ,params); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -289,22 +286,22 @@ public class DigitalDisplayControllerService { */ @Path("/add-resource-next") @POST - public void addNewResourceAfter(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("type") String type, - @QueryParam("time") String time, - @QueryParam("path") String path, - @QueryParam("before-page") String beforePage, - @QueryParam("sessionId") String sessionId, + public void addNewResourceAfter(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("type") String type, + @FormParam("time") String time, + @FormParam("path") String path, + @FormParam("before-page") String beforePage, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Add Sequence : " + deviceId); try { - String params = type + File.separator + time + File.separator + path + - File.separator + "after=" + beforePage; - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + - DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params); + String params = type + "|" + time + "|" + path + + "|" + "after=" + beforePage; + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + + DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT + ":",params); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -325,19 +322,18 @@ public class DigitalDisplayControllerService { * @param path path of the page no need to delete */ @Path("/remove-resource") - @DELETE - @Produces(MediaType.APPLICATION_JSON) - public void removeResource(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("path") String path, - @QueryParam("sessionId") String sessionId, + @POST + public void removeResource(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("path") String path, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Remove Resource : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + - DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT,path); + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + + DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT + ":",path); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -359,18 +355,17 @@ public class DigitalDisplayControllerService { * @param directoryName path of the folder need to delete */ @Path("/remove-directory") - @DELETE - @Produces(MediaType.APPLICATION_JSON) - public void removeDirectory(@QueryParam("directory-name") String directoryName, - @QueryParam("deviceId") String deviceId , - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + @POST + public void removeDirectory(@FormParam("directory-name") String directoryName, + @FormParam("deviceId") String deviceId , + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Remove Directory : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + - DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT,directoryName); + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + + DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT + ":",directoryName); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -393,19 +388,18 @@ public class DigitalDisplayControllerService { * @param response response type of the method */ @Path("/remove-content") - @DELETE - @Produces(MediaType.APPLICATION_JSON) - public void removeContent(@QueryParam("directory_name") String directoryName, - @QueryParam("content") String content, - @QueryParam("deviceId") String deviceId , - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + @POST + public void removeContent(@FormParam("directory-name") String directoryName, + @FormParam("content") String content, + @FormParam("deviceId") String deviceId , + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Remove Content : " + deviceId); try { - String param = directoryName + File.separator + content; - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT,param); + String param = directoryName + "|" + content; + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT + ":",param); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -427,15 +421,15 @@ public class DigitalDisplayControllerService { */ @Path("/shutdown-display") @POST - public void shutDownDisplay(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void shutDownDisplay(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Shut down display : " + deviceId); try { - sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT,""); + sendCommandViaMQTT(owner,deviceId,sessionId + "::" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT + ":" ,""); response.setStatus(Response.Status.OK.getStatusCode()); } catch (DeviceManagementException e) { log.error(e); @@ -457,9 +451,9 @@ public class DigitalDisplayControllerService { */ @Path("/get-status") @GET - public void getStatus(@QueryParam("deviceId") String deviceId, - @QueryParam("owner") String owner, - @QueryParam("sessionId") String sessionId, + public void getStatus(@FormParam("deviceId") String deviceId, + @FormParam("owner") String owner, + @FormParam("sessionId") String sessionId, @Context HttpServletResponse response){ log.info("Status : " + deviceId); diff --git a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/constants/DigitalDisplayConstants.java b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/constants/DigitalDisplayConstants.java index d73335ca73..8c9e978edc 100644 --- a/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/constants/DigitalDisplayConstants.java +++ b/components/device-mgt-iot-digitaldisplay/org.wso2.carbon.device.mgt.iot.digitaldisplay/src/main/java/org/wso2/carbon/device/mgt/iot/digitaldisplay/constants/DigitalDisplayConstants.java @@ -21,9 +21,6 @@ public class DigitalDisplayConstants { public final static String DEVICE_TYPE = "digital_display"; public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME"; public final static String DEVICE_PLUGIN_DEVICE_ID = "DIGITAL_DISPLAY_DEVICE_ID"; - - public final static String MQTT_BROKER_END_POINT = "tcp://204.232.188.214:1883"; - public final static String SHUTDOWN_DISPLAY_CONSTANT = "shutdown_display"; public final static String RESTART_DISPLAY_CONSTANT = "restart_display"; public final static String REMOVE_DIRECTORY_CONSTANT = "remove_dir_and_content"; @@ -35,7 +32,6 @@ public class DigitalDisplayConstants { public final static String ADD_NEW_RESOURCE_CONSTANT = "add_new_resource"; public final static String REMOVE_RESOURCE_CONSTANT = "remove_resources"; public final static String GET_STATUS_CONSTANT = "get_status"; - public final static String PUBLISH_TOPIC = "wso2/iot/%s/digital_display/%s/digital_display_subscriber"; } diff --git a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.device-view/device-view.hbs b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.device-view/device-view.hbs index 6dbc983b7d..3bdf40f59a 100644 --- a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.device-view/device-view.hbs +++ b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.digital_display.device-view/device-view.hbs @@ -1,3 +1,4 @@ + {{unit "cdmf.unit.lib.service-invoker-utility"}} {{unit "cdmf.unit.lib.handlebars"}} {{#defineZone "device-detail-top"}} @@ -27,34 +28,34 @@ {{#defineZone "device-detail-properties"}} - - - - + + + +
Status - {{#equal device.status "ACTIVE"}} Active{{/equal}} - {{#equal device.status "INACTIVE"}} Inactive{{/equal}} - {{#equal device.status "BLOCKED"}} Blocked{{/equal}} - {{#equal device.status "REMOVED"}} Removed{{/equal}} -
Status + {{#equal device.status "ACTIVE"}} Active{{/equal}} + {{#equal device.status "INACTIVE"}} Inactive{{/equal}} + {{#equal device.status "BLOCKED"}} Blocked{{/equal}} + {{#equal device.status "REMOVED"}} Removed{{/equal}} +
{{/defineZone}}
Operations
- {{unit "iot.unit.device.operation" device=device}} + {{unit "iot.unit.device.digitaldisplay.operation" device=device}}
-
-
- -
+
+ {{#defineZone "device-detail-properties"}}
@@ -126,4 +127,4 @@ -{{/zone}} \ No newline at end of file +{{/zone}} diff --git a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.hbs b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.hbs new file mode 100644 index 0000000000..4e7ef45a33 --- /dev/null +++ b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.hbs @@ -0,0 +1,88 @@ + + + +
+ +
+
+ {{#if control_operations}} + {{#each control_operations}} +
+
+
+ + + + + {{#if editcontent}} + + + + {{/if}} + + {{#if add}} + + + + {{/if}} + + {{#if before}} + + {{/if}} + {{#if after}} + + {{/if}} + {{#if removeresource}} + + {{/if}} + {{#if remove}} + + {{/if}} + {{#if content}} + + {{/if}} + + + + + +
+
+
+ {{/each}} + {{/if}} +
+
+
diff --git a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.js b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.js new file mode 100644 index 0000000000..47e5aff43d --- /dev/null +++ b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.js @@ -0,0 +1,6 @@ +function onRequest(context) { + var operationModule = require("/app/modules/operation.js").operationModule; + var device = context.unit.params.device; + var control_operations = operationModule.getControlOperations(device.type); + return {"control_operations": control_operations, "device": device}; +} \ No newline at end of file diff --git a/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.json b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.json new file mode 100644 index 0000000000..688e939808 --- /dev/null +++ b/features/device-mgt-iot-digitaldisplay-feature/org.wso2.carbon.device.mgt.iot.digitaldisplay.feature/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.digitaldisplay.operation/operation.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file