Returning correct representation of the device to template.

merge-requests/1/head
Rasika Perera 8 years ago
parent 52dfcecb62
commit 17dd96aa10

@ -31,7 +31,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUrl": devicemgtProps["httpsURL"] + "/android_sense/stats/" + deviceId + "/sensors/" "backendApiUrl": devicemgtProps["httpsURL"] + "/android_sense/stats/" + deviceId + "/sensors/"
}; };
} else { } else {

@ -29,7 +29,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/", "backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/",
"autoCompleteParams": autoCompleteParams "autoCompleteParams": autoCompleteParams
}; };

@ -33,7 +33,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" + deviceId "backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" + deviceId
}; };
} else { } else {

@ -28,7 +28,7 @@ function onRequest(context) {
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") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams}; return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams};
} 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!");
exit(); exit();

@ -33,7 +33,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" + deviceId "backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" + deviceId
}; };
} else { } else {

@ -28,7 +28,7 @@ function onRequest(context) {
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") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams}; return {"device": device.content, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams};
} 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!");
exit(); exit();

@ -33,7 +33,7 @@ function onRequest(context) {
var device = deviceModule.viewDevice(deviceType, deviceId); var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") { if (device && device.status != "error") {
return { return {
"device": device, "device": device.content,
"backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" + deviceId "backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" + deviceId
}; };
} else { } else {

@ -23,7 +23,7 @@ function onRequest(context) {
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)["content"];
if (device) { if (device) {
var viewModel = {}; var viewModel = {};

Loading…
Cancel
Save