Fix the device view related issues

revert-70aa11f8
kamidu 8 years ago
parent 4549452634
commit 120fe530ac

@ -22,7 +22,7 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js').utility; var utility = require('/app/modules/utility.js').utility;
var constants = require('/app/modules/constants.js'); var constants = require('/app/modules/constants.js');
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
// var ArrayList = Packages.java.util.ArrayList; // var ArrayList = Packages.java.util.ArrayList;
@ -33,6 +33,8 @@ deviceModule = function () {
// var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; // var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
// var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; // var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
var deviceManagementService = utility.getDeviceManagementService();
var publicMethods = {}; var publicMethods = {};
var privateMethods = {}; var privateMethods = {};
@ -215,18 +217,20 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js')["utility"]; var utility = require('/app/modules/utility.js')["utility"];
try { try {
utility.startTenantFlow(carbonUser); utility.startTenantFlow(carbonUser);
//var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId;
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/view?type=" + deviceType + "&id=" + deviceId; var url = mdmProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId;
return serviceInvokers.XMLHttp.get( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url,
var device = responsePayload.responseContent; function (backendResponse) {
if (device) { var response = {};
if (backendResponse.status == 200 && backendResponse.responseText) {
response["status"] = "success";
var device = parse(backendResponse.responseText);
var propertiesList = device["properties"]; var propertiesList = device["properties"];
var properties = {}; var properties = {};
if (propertiesList){ for (var i = 0; i < propertiesList.length; i++) {
for (var i = 0; i < propertiesList.length; i++) { properties[propertiesList[i]["name"]] =
properties[propertiesList[i]["name"]] = propertiesList[i]["value"]; propertiesList[i]["value"];
}
} }
var deviceObject = {}; var deviceObject = {};
deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"]; deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"];
@ -241,13 +245,12 @@ deviceModule = function () {
properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"]; properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"];
} }
deviceObject[constants["DEVICE_PROPERTIES"]] = properties; deviceObject[constants["DEVICE_PROPERTIES"]] = properties;
return deviceObject; response["content"] = deviceObject;
return response;
} else {
response["status"] = "error";
return response;
} }
},
function (responsePayload) {
var response = {};
response["status"] = "error";
return response;
} }
); );
} catch (e) { } catch (e) {
@ -310,9 +313,9 @@ deviceModule = function () {
var url; var url;
var license; var license;
if (deviceType == "windows") { if (deviceType == "windows") {
url = devicemgtProps["httpURL"] + "/mdm-windows-agent/services/device/license"; url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license";
} else if (deviceType == "ios") { } else if (deviceType == "ios") {
url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; url = mdmProps["httpsURL"] + "/ios-enrollment/license/";
} }
if (url != null && url != undefined) { if (url != null && url != undefined) {

@ -32,10 +32,12 @@
</div> </div>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "topJs"}}
<script type="text/javascript"> <script type="text/javascript">
var context = "{{@app.context}}" var context = "{{@app.context}}"
</script> </script>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/js.cookie.js"}} {{js "js/js.cookie.js"}}
{{js "js/invoker-lib.js"}} {{js "js/invoker-lib.js"}}
{{/zone}} {{/zone}}

Loading…
Cancel
Save