Merge pull request #11 from NuwanSameera/IoTS-1.0.0-M1

digital display modifications
Charitha Goonetilleke 9 years ago
commit 2220d2f851

@ -43,20 +43,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/restart-browser")
@POST
public void restartBrowser(@QueryParam("deviceId") String deviceId ,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Restrat Browser : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId +":" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT,"");
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_BROWSER_CONSTANT,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -74,20 +74,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/close-browser")
@POST
public void closeBrowser(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Close Browser : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId +":" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT ,"");
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.CLOSE_BROWSER_CONSTANT ,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -104,20 +104,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/terminate-display")
@POST
public void terminateDisplay(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Terminate Display : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId +":" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT,"");
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.TERMINATE_DISPLAY_CONSTANT,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -134,20 +134,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/restart-display")
@POST
public void restartDisplay(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Restrat Display : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId +":" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT ,"");
sendCommandViaMQTT(owner,deviceId,sessionId +":" + DigitalDisplayConstants.RESTART_DISPLAY_CONSTANT ,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -164,7 +164,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param path page no need to change
* @param attribute this can be path,time or type
@ -178,14 +178,14 @@ public class DigitalDisplayControllerService {
@PathParam("path") String path,
@PathParam("attribute") String attribute,
@PathParam("new-value") String newValue,
@QueryParam("randomId") String randomId,
@QueryParam("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,randomId + ":" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT,params);
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.EDIT_SEQUENCE_CONSTANT,params);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -202,7 +202,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param type type of new resource
* @param time new resource visible time
@ -215,14 +215,14 @@ public class DigitalDisplayControllerService {
@PathParam("type") String type,
@PathParam("time") String time,
@PathParam("path") String path,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Add Sequence : " + deviceId);
try {
String params = type + File.separator + time + File.separator + path;
sendCommandViaMQTT(owner,deviceId,randomId + ":" +
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
@ -239,7 +239,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param type type of the new resource
* @param time new resource visible time
@ -250,7 +250,7 @@ public class DigitalDisplayControllerService {
@POST
public void addNewResourceBefore(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@PathParam("type") String type,
@PathParam("time") String time,
@PathParam("path") String path,
@ -262,7 +262,7 @@ public class DigitalDisplayControllerService {
try {
String params = type + File.separator + time + File.separator + path +
File.separator + "before=" + nextPage;
sendCommandViaMQTT(owner,deviceId,randomId + ":" +
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
@ -280,7 +280,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param type type of the new resource
* @param time new resource visible time
@ -295,7 +295,7 @@ public class DigitalDisplayControllerService {
@PathParam("time") String time,
@PathParam("path") String path,
@PathParam("before-page") String beforePage,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Add Sequence : " + deviceId);
@ -303,7 +303,7 @@ public class DigitalDisplayControllerService {
try {
String params = type + File.separator + time + File.separator + path +
File.separator + "after=" + beforePage;
sendCommandViaMQTT(owner,deviceId,randomId + ":" +
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
DigitalDisplayConstants.ADD_NEW_RESOURCE_CONSTANT,params);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
@ -320,7 +320,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param path path of the page no need to delete
*/
@ -330,13 +330,13 @@ public class DigitalDisplayControllerService {
public void removeResource(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@PathParam("path") String path,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Remove Resource : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId + ":" +
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
DigitalDisplayConstants.REMOVE_RESOURCE_CONSTANT,path);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
@ -354,7 +354,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
* @param directoryName path of the folder need to delete
*/
@ -364,12 +364,12 @@ public class DigitalDisplayControllerService {
public void removeDirectory(@PathParam("directory-name") String directoryName,
@QueryParam("deviceId") String deviceId ,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Remove Directory : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId + ":" +
sendCommandViaMQTT(owner,deviceId,sessionId + ":" +
DigitalDisplayConstants.REMOVE_DIRECTORY_CONSTANT,directoryName);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
@ -387,7 +387,7 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param directoryName path of directory of request file contain
* @param content file name of need to delete
* @param response response type of the method
@ -399,13 +399,13 @@ public class DigitalDisplayControllerService {
@PathParam("content") String content,
@QueryParam("deviceId") String deviceId ,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Remove Content : " + deviceId);
try {
String param = directoryName + File.separator + content;
sendCommandViaMQTT(owner,deviceId,randomId + ":" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT,param);
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.REMOVE_CONTENT_CONSTANT,param);
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -422,20 +422,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/shutdown-display")
@POST
public void shutDownDisplay(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Shut down display : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId + ":" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT,"");
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.SHUTDOWN_DISPLAY_CONSTANT,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
@ -452,20 +452,20 @@ public class DigitalDisplayControllerService {
*
* @param deviceId id of the controlling digital display
* @param owner owner of the digital display
* @param randomId web socket id of the method invoke client
* @param sessionId web socket id of the method invoke client
* @param response response type of the method
*/
@Path("/get-status")
@GET
public void getStatus(@QueryParam("deviceId") String deviceId,
@QueryParam("owner") String owner,
@QueryParam("randomId") String randomId,
@QueryParam("sessionId") String sessionId,
@Context HttpServletResponse response){
log.info("Status : " + deviceId);
try {
sendCommandViaMQTT(owner,deviceId,randomId + ":" + DigitalDisplayConstants.GET_STATUS_CONSTANT,"");
sendCommandViaMQTT(owner,deviceId,sessionId + ":" + DigitalDisplayConstants.GET_STATUS_CONSTANT,"");
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);

@ -5,9 +5,6 @@
<div class="col-lg-12 wr-secondary-bar">
<label class="device-id device-select" data-deviceid="{{device.deviceIdentifier}}" data-type="{{device.type}}">
Device {{device.name}}
<span class="lbl-device">
( {{device.viewModel.vendor}} {{device.viewModel.model}} )
</span>
</label>
</div>
</div>
@ -30,24 +27,15 @@
{{#defineZone "device-detail-properties"}}
<table class="table table-responsive table-striped" id="members">
<tbody>
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px; width: 1%;;">Device</td><td style="padding:10px 15px;">{{device.viewModel.vendor}} {{device.properties.model}}</td></tr>
<tr role="row" class="odd"><td class="sorting_1" style="padding:10px 15px;">Model</td><td style="padding:10px 15px;">{{device.viewModel.model}}</td></tr>
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">IMEI</td><td style="padding:10px 15px;">{{device.viewModel.imei}}</td></tr>
{{#if device.viewModel.udid}}
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">UDID</td><td style="padding:10px 15px;">{{device.viewModel.udid}}</td></tr>
{{/if}}
{{#if device.viewModel.phoneNumber}}
<tr role="row" class="even"><td class="sorting_1" style="padding:10px 15px;">Phone Number</td><td style="padding:10px 15px;">{{device.viewModel.phoneNumber}}</td></tr>
{{/if}}
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i class="fw fw-ok icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
</td>
</tr>
</tbody>
</table>
{{/defineZone}}
@ -58,7 +46,84 @@
</div>
</div>
</div>
<div class="media">
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
<ul class="list-group" role="tablist">
<li class="active"><a class="list-group-item" href="#device_details" role="tab" data-toggle="tab" aria-controls="device_details">Device Details</a></li>
<li><a class="list-group-item" href="#policy_compliance" role="tab" data-toggle="tab" aria-controls="policy_compliance">Policy Compliance</a></li>
<li><a class="list-group-item" href="#device_location" role="tab" data-toggle="tab" aria-controls="device_location">Device Location</a></li>
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab" aria-controls="event_log">Operations Log</a></li>
</ul>
</div>
{{#defineZone "device-detail-properties"}}
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
<div class="panel-group tab-content">
<div id="deviceDetails" class="panel panel-default tab-pane active" id="device_details" role="tabpanel" aria-labelledby="device_details">
<div class="panel-heading">Device Details</div>
</div>
<div class="panel panel-default tab-pane" id="policy_compliance" role="tabpanel" aria-labelledby="policy_compliance">
<div class="panel-heading">Policy Compliance <span><a href="#" id="refresh-policy"><i class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="policy-spinner" class="wr-advance-operations-init hidden">
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp;
Loading Policy Compliance . . .
<br>
<br>
</div>
<div id="policy-list-container">
<div class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
</div>
<div class="panel panel-default tab-pane" id="device_location" role="tabpanel" aria-labelledby="device_location">
<div class="panel-heading">Device Location</div>
<div class="panel-body">
</div>
<div id = "map-error" class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel" aria-labelledby="event_log">
<div class="panel-heading">Operations Log <span><a href="#" id="refresh-operations"><i class="fw fw-refresh"></i></a></span></div>
<div class="panel-body">
<div id="operations-spinner" class="wr-advance-operations-init hidden">
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<i class="fw fw-settings fw-spin fw-2x"></i>
&nbsp;&nbsp;&nbsp;
Loading Operations Log . . .
<br>
<br>
</div>
<div id="operations-log-container">
<div class="panel-body">
Not available yet
</div>
<br class="c-both" />
</div>
</div>
</div>
</div>
</div>
{{/defineZone}}
</div>
</div>
<!-- /content/body -->
</div>
<!-- /content/body -->
</div>
{{#zone "bottomJs"}}
<script id="policy-view" src="{{@unit.publicUri}}/templates/policy-compliance.hbs" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" type="text/x-handlebars-template" ></script>
<script id="applications-list" src="{{@unit.publicUri}}/templates/applications-list.hbs" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" type="text/x-handlebars-template" ></script>
<script id="operations-log" src="{{@unit.publicUri}}/templates/operations-log.hbs" data-device-id="{{device.deviceIdentifier}}" data-device-type="{{device.type}}" type="text/x-handlebars-template" ></script>
{{/zone}}

@ -7,19 +7,9 @@ function onRequest(context) {
var deviceModule = require("/modules/device.js").deviceModule;
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device) {
var viewModel = {};
var deviceInfo = device.properties.DEVICE_INFO;
if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0) {
deviceInfo = parse(stringify(deviceInfo));
viewModel.system = device.properties.IMEI;
viewModel.machine = "digital_display";
viewModel.vendor = device.properties.VENDOR;
}
device.viewModel = viewModel;
if (device && device.status != "error") {
log.info(device);
return {"device": device};
}
context.device = device;
return context;
}
}

@ -17,7 +17,7 @@
<div id="device-location" class="panel-body">
{{#if control_operations}}
{{#each control_operations}}
<form action="{{@app.context}}/api/operations/{{../device.type}}/{{operation}}?deviceId={{../deviceId}}" method="post">
<form action="{{@app.context}}/api/operations/{{../device.type}}/{{operation}}?deviceId={{../device.deviceIdentifier}}" method="post">
<div class="row">
<div class="wr-input-control">
<label class="wr-input-label">{{name}}</label>

Loading…
Cancel
Save