Merge remote-tracking branch 'upstream/master'

revert-70aa11f8
Megala 8 years ago
commit 45cda92082

@ -76,32 +76,69 @@ deviceModule = function () {
function (backendResponse) { function (backendResponse) {
var response = {}; var response = {};
if (backendResponse.status == 200 && backendResponse.responseText) { if (backendResponse.status == 200 && backendResponse.responseText) {
response["status"] = "success";
var device = parse(backendResponse.responseText); var device = parse(backendResponse.responseText);
var propertiesList = device["properties"];
var properties = {}; var filteredDeviceData = {};
for (var i = 0; i < propertiesList.length; i++) { if (device["deviceIdentifier"]) {
properties[propertiesList[i]["name"]] = filteredDeviceData["deviceIdentifier"] = device["deviceIdentifier"];
propertiesList[i]["value"];
} }
var deviceObject = {}; if (device["type"]) {
deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"]; filteredDeviceData["type"] = device["type"];
deviceObject[constants["DEVICE_NAME"]] = device["name"];
deviceObject[constants["DEVICE_OWNERSHIP"]] = device["enrolmentInfo"]["ownership"];
deviceObject[constants["DEVICE_OWNER"]] = device["enrolmentInfo"]["owner"];
deviceObject[constants["DEVICE_STATUS"]] = device["enrolmentInfo"]["status"];
deviceObject[constants["DEVICE_TYPE"]] = device["type"];
if (device["type"] == constants["PLATFORM_IOS"]) {
properties[constants["DEVICE_MODEL"]] = properties[constants["DEVICE_PRODUCT"]];
delete properties[constants["DEVICE_PRODUCT"]];
properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"];
} }
deviceObject[constants["DEVICE_PROPERTIES"]] = properties; if (device["name"]) {
if (device["deviceInfo"]) { filteredDeviceData["name"] = device["name"];
deviceObject[constants["DEVICE_INFO"]] = device["deviceInfo"]; }
if (device["enrolmentInfo"]) {
var enrolmentInfo = {};
if (device["enrolmentInfo"]["status"]) {
enrolmentInfo["status"] = device["enrolmentInfo"]["status"];
}
if (device["enrolmentInfo"]["owner"]) {
enrolmentInfo["owner"] = device["enrolmentInfo"]["owner"];
}
if (device["enrolmentInfo"]["ownership"]) {
enrolmentInfo["ownership"] = device["enrolmentInfo"]["ownership"];
}
filteredDeviceData["enrolmentInfo"] = enrolmentInfo;
}
if (device["properties"] && device["properties"].length > 0) {
var propertiesList = device["properties"];
var properties = {};
for (var i = 0; i < propertiesList.length; i++) {
if (propertiesList[i]["value"]) {
properties[propertiesList[i]["name"]] =
propertiesList[i]["value"];
}
}
filteredDeviceData["initialDeviceInfo"] = properties;
if (properties["DEVICE_INFO"]) {
var initialDeviceInfoList = parse(properties["DEVICE_INFO"]);
var initialDeviceInfo = {};
for (var j = 0; j < initialDeviceInfoList.length; j++) {
if (initialDeviceInfoList[j]["value"]) {
initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
initialDeviceInfoList[j]["value"];
}
}
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"] = initialDeviceInfo;
}
} }
response["content"] = deviceObject; if (filteredDeviceData["type"]) {
if (filteredDeviceData["type"] == constants["PLATFORM_IOS"]) {
if (filteredDeviceData["properties"]) {
filteredDeviceData["properties"]["VENDOR"] = "Apple";
}
}
}
if (device["deviceInfo"]) {
filteredDeviceData["latestDeviceInfo"] = device["deviceInfo"];
}
response["content"] = filteredDeviceData;
response["status"] = "success";
return response; return response;
} else if (backendResponse.status == 401) { } else if (backendResponse.status == 401) {
response["status"] = "unauthorized"; response["status"] = "unauthorized";

Loading…
Cancel
Save