Merge pull request #49 from charithag/IoTS-1.0.0-M1

Update group with pagination and link fixes
Ruwan 9 years ago
commit f86ce24675

@ -280,22 +280,6 @@ import java.util.List;
}
}
@Path("/device/group/{groupId}/{limit}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Device[] getDevices(@PathParam("groupId") int groupId, @PathParam("limit") int limit){
try{
List<Device> devices = this.getServiceProvider().getDevices(groupId,limit);
return this.getActiveDevices(devices);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
return null;
} finally {
this.endTenantFlow();
}
}
@Path("/device/role/{role}/all")
@GET
@Consumes("application/json")

@ -24,6 +24,7 @@ import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.group.common.DeviceGroup;
import org.wso2.carbon.device.mgt.group.common.GroupManagementException;
import org.wso2.carbon.device.mgt.group.common.GroupUser;
@ -407,14 +408,14 @@ public class GroupManagerService {
return usersArray;
}
@Path("/group/id/{groupId}/device/{limit}")
@Path("/group/id/{groupId}/device/all")
@GET
@Consumes("application/json")
@Produces("application/json")
public Device[] getDevices(@PathParam("groupId") int groupId,@PathParam("limit") int limit) {
public Device[] getDevices(@PathParam("groupId") int groupId) {
Device[] deviceArray = null;
try {
List<Device> devices = this.getServiceProvider().getDevices(groupId,limit);
List<Device> devices = this.getServiceProvider().getDevices(groupId);
deviceArray = new Device[devices.size()];
response.setStatus(Response.Status.OK.getStatusCode());
devices.toArray(deviceArray);
@ -427,6 +428,40 @@ public class GroupManagerService {
return deviceArray;
}
@Path("/group/id/{groupId}/device/count")
@GET
@Consumes("application/json")
@Produces("application/json")
public int getDeviceCount(@PathParam("groupId") int groupId) {
try {
return this.getServiceProvider().getDeviceCount(groupId);
} catch (GroupManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.error(e.getErrorMessage(), e);
return -1;
} finally {
this.endTenantFlow();
}
}
@Path("/group/id/{groupId}/device")
@GET
@Consumes("application/json")
@Produces("application/json")
public PaginationResult getDevices(@PathParam("groupId") int groupId,
@QueryParam("index") int index,
@QueryParam("limit") int limit) {
try {
return this.getServiceProvider().getDevices(groupId, index, limit);
} catch (GroupManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
log.error(e.getErrorMessage(), e);
return null;
} finally {
this.endTenantFlow();
}
}
@Path("/group/id/{groupId}/device/assign")
@PUT
@Consumes("application/json")

@ -1,4 +1,4 @@
<div class="col-lg-12 margin-top-double">
<div class="col-lg-12 margin-top-double" xmlns="http://www.w3.org/1999/html">
<h1 class="grey ">Digital Display</h1>
<hr>
<p class="margin-bottom-double light-grey ">Connect your Digital Display
@ -37,35 +37,30 @@
<h3>Name your device and download the agent from following link.</h3>
<br/>
<form id="downloadForm" method="GET" action="{{@app.context}}/api/devices/sketch/download">
<div class="control-group">
<div class="controls">
<input class="new-device-name" style="color:#3f3f3f;padding:5px"
type="text"
placeholder="Ex. Lobby_DigitalDisplay"
name="deviceName" size="60" required>
<br/>
<input type="hidden" class="deviceType" name="deviceType"
value="digital_display"/>
<input type="hidden" class="sketchType" name="sketchType"
value="digital_display"/>
<div class="sketchTypes" style=" padding-top: 20px; padding-bottom: 5px; font-size: 18px;">
<input type="radio" name="sketchType" id="digital_display"
value="digital_display"><label for="digital_display">digitaldisplay</label>
<div class="control-group">
<div class="controls">
<input class="new-device-name" style="color:#3f3f3f;padding:5px"
type="text"
placeholder="Ex. Lobby_DigitalDisplay"
name="deviceName" size="60" required>
<br/>
<input type="hidden" class="deviceType" name="deviceType"
value="digital_display"/>
<input type="hidden" class="sketchType" name="sketchType"
value="digital_display"/>
</div>
</div>
</div>
<br/>
<div class="buttons">
<a class="btn-operations" onclick="downloadAgent()">Download
Now</a>
&nbsp;&nbsp;
<a href="#" id="download-device-download-link" class="blue-button">
&nbsp;&nbsp;&nbsp;&nbsp;Copy Link&nbsp;&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
</div>
</form>
<br/>
<div class="buttons">
<a class="btn-operations" onclick="downloadAgent()">Download
Now</a>
&nbsp;&nbsp;
<a href="#" id="download-device-download-link" class="blue-button">
&nbsp;&nbsp;&nbsp;&nbsp;Copy Link&nbsp;&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
</div>
</form>
</div>
</div>
</div>
@ -202,7 +197,7 @@
<br/>
<ul>
<p class="padding-top-double"><span class="circle">01</span> <b>Click on the <i>'Create DEB'</i> button above to get the download link for the Digital Display setup files</b></p>
<p class="padding-top-double"><span class="circle">02</span> <i>(The following commands can be issued by directly typing into the terminal of the device or by an <b>'ssh'<b> login from a remote PC)</i></p>
<p class="padding-top-double"><span class="circle">02</span> <i>(The following commands can be issued by directly typing into the terminal of the device or by an <b>'ssh'</b> login from a remote PC)</i></p>
<p class="padding-top-double"><span class="circle">03</span> <b>Download the Digital Display setup files using the following command: 'curl -k < url_link_received_from_the_above_step >> Agent.zip'</b><br/><i>This will download a zip file named 'Agent.zip'</i></p>
</ul>
<br>

@ -33,7 +33,7 @@
<div id="map" class="map-wrapper hidden">
</div>
<a class="padding-left" href="{{@app.context}}/analytics?device.deviceIdentifier={{device.deviceIdentifier}}&device.type={{device.type}}&deviceName={{device.name}}">
<a class="padding-left" href="{{@app.context}}/analytics?deviceId={{device.deviceIdentifier}}&deviceType={{device.type}}&deviceName={{device.name}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-statistics fw-stack-1x"></i>

@ -1,6 +1,6 @@
function onRequest(context) {
var log = new Log("stats.js");
var operationModule = require("/modules/operation.js").operationModule;
var operationModule = require("/app/modules/operation.js").operationModule;
var device = context.unit.params.device;
log.info(device);
var monitor_operations = JSON.stringify(operationModule.getMonitorOperations(device.type));

Loading…
Cancel
Save