|
|
|
@ -120,15 +120,37 @@ if (uriMatcher.match("/{context}/api/device/sketch/download/{downloadId}")) {
|
|
|
|
|
//URL: https://localhost:9443/devicecloud/manager/devices/username/{username}
|
|
|
|
|
deviceCloudService = carbonHttpsServletTransport + "/devicecloud/device_manager";
|
|
|
|
|
listAllDevicesEndPoint = deviceCloudService + "/devices/username/" + user.username;
|
|
|
|
|
|
|
|
|
|
var data = {};
|
|
|
|
|
//XMLHTTPRequest's GET
|
|
|
|
|
try {
|
|
|
|
|
result = get(listAllDevicesEndPoint, data, "json");
|
|
|
|
|
}catch(err){
|
|
|
|
|
log.error("Error occured while retrieveing all devices with username: "+user.username);
|
|
|
|
|
result=[];
|
|
|
|
|
result = get(listAllDevicesEndPoint, {}, "json");
|
|
|
|
|
var ownDevices = result.data;
|
|
|
|
|
|
|
|
|
|
var allDevices = [];
|
|
|
|
|
deviceCloudService = carbonHttpsServletTransport + "/devicecloud/group_manager";
|
|
|
|
|
var endPoint = deviceCloudService + "/group/all";
|
|
|
|
|
var data = {"username": user.username};
|
|
|
|
|
var groups = get(endPoint, data, "json").data;
|
|
|
|
|
|
|
|
|
|
for (var g in groups) {
|
|
|
|
|
endPoint = deviceCloudService + "/group/id/" + groups[g].id + "/device/all";
|
|
|
|
|
data = {"username": user.username};
|
|
|
|
|
var deviceInGroup = get(endPoint, data, "json").data;
|
|
|
|
|
groups[g].devices = deviceInGroup;
|
|
|
|
|
allDevices.push(groups[g]);
|
|
|
|
|
for (var od in ownDevices) {
|
|
|
|
|
for (var gd in deviceInGroup) {
|
|
|
|
|
if (deviceInGroup[gd].deviceIdentifier == ownDevices[od].deviceIdentifier) {
|
|
|
|
|
ownDevices[od].deviceIdentifier = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var unsharedDevices = [];
|
|
|
|
|
for (var od in ownDevices) {
|
|
|
|
|
if (ownDevices[od].deviceIdentifier != -1){
|
|
|
|
|
unsharedDevices.push(ownDevices[od]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allDevices.push({id: 0, devices: unsharedDevices});
|
|
|
|
|
result.data = allDevices;
|
|
|
|
|
|
|
|
|
|
} else if (uriMatcher.match("/{context}/api/devices/types")) {
|
|
|
|
|
|
|
|
|
|