From de29facb5f8f4050fb6d5bfa85ca5f40670e0a84 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Thu, 9 Jan 2020 17:26:11 +0530 Subject: [PATCH] Add new UI method to retrieve device info details of a device --- .../modules/business-controllers/device.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index b561c8a23e..2e80797d88 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -435,5 +435,33 @@ deviceModule = function () { }; + /** + * Retrieve device info details of a device + * @param deviceType - Type of the device i.e ios, android + * @param deviceId - Device ID of te device + */ + publicMethods.getDeviceInfo = function (deviceType, deviceId) { + try { + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/devices/" + deviceType + "/" + deviceId + "/info"; + var response = {}; + return serviceInvokers.XMLHttp.get( + url, + function (backendResponse) { + if (backendResponse.status === 200 && backendResponse.responseText) { + response["status"] = "success"; + response["content"] = parse(backendResponse.responseText); + } else { + log.error("Error occurred while retrieving device info via " + url + ". Error code: " + + backendResponse.status + ". Reason: " + backendResponse.responseText); + response["status"] = "error"; + } + return response; + }); + } catch (e) { + log.error("Error occurred while retrieving device info via " + url, e); + } + }; + return publicMethods; }();