diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java
similarity index 97%
rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java
rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java
index 4ce4ac2147..41cbb1a993 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceTypeManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java
@@ -16,7 +16,7 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
+package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
@@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
@API(name = "Device Type Management", version = "1.0.0", context = "/admin/device-types", tags = {"devicemgt_admin"})
-@Path("/admin/device-types")
+@Path("/device-types")
@Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " +
"type management")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java
similarity index 92%
rename from components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java
rename to components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java
index fdda3bdd88..e38f02a027 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypeManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java
@@ -16,14 +16,14 @@
* under the License.
*
*/
-package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
+package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
-import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypeManagementService;
+import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceTypeManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.GET;
@@ -32,7 +32,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import java.util.List;
-@Path("/admin/device-types")
+@Path("/device-types")
public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementService {
private static Log log = LogFactory.getLog(DeviceTypeManagementServiceImpl.class);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
index 6439eab85e..9e0684004d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml
@@ -107,7 +107,7 @@
View device types
/device-mgt/admin/devices/Admin-DeviceType-View
- /admin/device-types
+ /device-types
GET
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
index 1b128fb450..d225d36995 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -78,7 +78,7 @@
-
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
index 890a7e500e..3aa7af9975 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js
@@ -18,7 +18,7 @@
var WEB_APP_TITLE = "WSO2 CDM";
var WEB_APP_CONTEXT = "/devicemgt";
-var ADMIN_SERVICE_CONTEXT = "/devicemgt_admin";
+var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0";
var USER_SESSION_KEY = "_UUF_USER";
var UNSPECIFIED = "Unspecified";
var httpURL = "httpURL";
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
index 464093343d..8dfdd26f5e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/device.js
@@ -38,6 +38,32 @@ deviceModule = function () {
var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager";
+ /**
+ * Only GET method is implemented for now since there are no other type of methods used this method.
+ * @param url - URL to call the backend without the host
+ * @param method - HTTP Method (GET, POST)
+ * @returns An object with 'status': 'success'|'error', 'content': {}
+ */
+ privateMethods.callBackend = function (url, method) {
+ if (constants["HTTP_GET"] == method) {
+ return serviceInvokers.XMLHttp.get(url,
+ function (backendResponse) {
+ var response = {};
+ response.content = backendResponse.responseText;
+ if (backendResponse.status == 200) {
+ response.status = "success";
+ } else if (backendResponse.status == 400 || backendResponse.status == 401 ||
+ backendResponse.status == 404 || backendResponse.status == 500) {
+ response.status = "error";
+ }
+ return response;
+ }
+ );
+ } else {
+ log.error("Runtime error : This method only support HTTP GET requests.");
+ }
+ };
+
privateMethods.validateAndReturn = function (value) {
return (value == undefined || value == null) ? constants.UNSPECIFIED : value;
};
@@ -289,16 +315,12 @@ deviceModule = function () {
};
publicMethods.getDeviceTypes = function () {
- var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types";
- return serviceInvokers.XMLHttp.get(
- url, function (responsePayload) {
- return responsePayload;
- },
- function (responsePayload) {
- log.error(responsePayload);
- return -1;
- }
- );
+ var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types";
+ var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
+ if (response.status == "success") {
+ response.content = parse(response.content);
+ }
+ return response;
};
//Old methods
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js
index b2c840aae8..e02e286d91 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/user.js
@@ -263,29 +263,30 @@ var userModule = function () {
/**
* Get Platforms.
+ * @deprecated moved this device module under getDeviceTypes.
*/
//TODO Move this piece of logic out of user.js to somewhere else appropriate.
- publicMethods.getPlatforms = function () {
- var carbonUser = session.get(constants["USER_SESSION_KEY"]);
- var utility = require("/app/modules/utility.js")["utility"];
- if (!carbonUser) {
- log.error("User object was not found in the session");
- throw constants["ERRORS"]["USER_NOT_FOUND"];
- }
- try {
- utility.startTenantFlow(carbonUser);
- var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/admin/device-types";
- var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
- if (response.status == "success") {
- response.content = parse(response.content);
- }
- return response;
- } catch (e) {
- throw e;
- } finally {
- utility.endTenantFlow();
- }
- };
+ //publicMethods.getPlatforms = function () {
+ // var carbonUser = session.get(constants["USER_SESSION_KEY"]);
+ // var utility = require("/app/modules/utility.js")["utility"];
+ // if (!carbonUser) {
+ // log.error("User object was not found in the session");
+ // throw constants["ERRORS"]["USER_NOT_FOUND"];
+ // }
+ // try {
+ // utility.startTenantFlow(carbonUser);
+ // var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types";
+ // var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
+ // if (response.status == "success") {
+ // response.content = parse(response.content);
+ // }
+ // return response;
+ // } catch (e) {
+ // throw e;
+ // } finally {
+ // utility.endTenantFlow();
+ // }
+ //};
/**
* Get role
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
index 085f1f5a69..a8277d494a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
@@ -50,21 +50,24 @@ function onRequest(context) {
if (deviceCount > 0) {
page.deviceCount = deviceCount;
var utility = require("/app/modules/utility.js").utility;
- var data = deviceModule.getDeviceTypes();
+ var typesListResponse = deviceModule.getDeviceTypes();
var deviceTypes = [];
- if (data) {
- for (var i = 0; i < data.length; i++) {
- var config = utility.getDeviceTypeConfig(data[i].name);
- if (!config){
- continue;
+ if (typesListResponse["status"] == "success") {
+ var data = typesListResponse["content"];
+ if (data) {
+ for (var i = 0; i < data.length; i++) {
+ var config = utility.getDeviceTypeConfig(data[i].name);
+ if (!config) {
+ continue;
+ }
+ var deviceType = config.deviceType;
+ deviceTypes.push({
+ "type": data[i].name,
+ "category": deviceType.category,
+ "label": deviceType.label,
+ "thumb": utility.getDeviceThumb(data[i].name)
+ });
}
- var deviceType = config.deviceType;
- deviceTypes.push({
- "type": data[i].name,
- "category": deviceType.category,
- "label": deviceType.label,
- "thumb": utility.getDeviceThumb(data[i].name)
- });
}
}
page.deviceTypes = stringify(deviceTypes);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
index fecc522807..eb4c87aeaf 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js
@@ -25,47 +25,49 @@ function onRequest(context) {
var viewModel = {};
var deviceModule = require("/app/modules/device.js").deviceModule;
var utility = require("/app/modules/utility.js").utility;
- var deviceTypes = deviceModule.getDeviceTypes();
+ var typesListResponse = deviceModule.getDeviceTypes();
+ if (typesListResponse["status"] == "success") {
+ var deviceTypes = typesListResponse["content"];
+ if (deviceTypes) {
+ var deviceTypesList = [], virtualDeviceTypesList = [];
+ for (var i = 0; i < deviceTypes.length; i++) {
- if (deviceTypes) {
- var deviceTypesList = [], virtualDeviceTypesList = [];
- for (var i = 0; i < deviceTypes.length; i++) {
-
- var deviceTypeLabel = deviceTypes[i].name;
- var configs = utility.getDeviceTypeConfig(deviceTypeLabel);
- var deviceCategory = "device";
- if (configs) {
- if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]) {
- deviceCategory = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY];
+ var deviceTypeLabel = deviceTypes[i].name;
+ var configs = utility.getDeviceTypeConfig(deviceTypeLabel);
+ var deviceCategory = "device";
+ if (configs) {
+ if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY]) {
+ deviceCategory = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_CATEGORY];
+ }
+ if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
+ deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
+ }
}
- if (configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
- deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
+ if (deviceCategory == 'virtual') {
+ virtualDeviceTypesList.push({
+ "hasCustTemplate": false,
+ "deviceTypeLabel": deviceTypeLabel,
+ "deviceTypeName": deviceTypes[i].name,
+ "deviceCategory": deviceCategory,
+ "deviceTypeId": deviceTypes[i].id,
+ "thumb": utility.getDeviceThumb(deviceTypes[i].name)
+ });
+ } else {
+ deviceTypesList.push({
+ "hasCustTemplate": false,
+ "deviceTypeLabel": deviceTypeLabel,
+ "deviceTypeName": deviceTypes[i].name,
+ "deviceCategory": deviceCategory,
+ "deviceTypeId": deviceTypes[i].id,
+ "thumb": utility.getDeviceThumb(deviceTypes[i].name)
+ });
}
}
- if (deviceCategory == 'virtual') {
- virtualDeviceTypesList.push({
- "hasCustTemplate": false,
- "deviceTypeLabel": deviceTypeLabel,
- "deviceTypeName": deviceTypes[i].name,
- "deviceCategory": deviceCategory,
- "deviceTypeId": deviceTypes[i].id,
- "thumb": utility.getDeviceThumb(deviceTypes[i].name)
- });
- } else {
- deviceTypesList.push({
- "hasCustTemplate": false,
- "deviceTypeLabel": deviceTypeLabel,
- "deviceTypeName": deviceTypes[i].name,
- "deviceCategory": deviceCategory,
- "deviceTypeId": deviceTypes[i].id,
- "thumb": utility.getDeviceThumb(deviceTypes[i].name)
- });
+ if (virtualDeviceTypesList.length > 0) {
+ viewModel.virtualDeviceTypesList = virtualDeviceTypesList;
}
+ viewModel.deviceTypesList = stringify(deviceTypesList);
}
- if (virtualDeviceTypesList.length > 0) {
- viewModel.virtualDeviceTypesList = virtualDeviceTypesList;
- }
- viewModel.deviceTypesList = stringify(deviceTypesList);
} else {
log.error("Unable to fetch device types data");
throw new Error("Unable to fetch device types!");
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs
index abdf6fd598..e4d27bc01d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs
@@ -15,107 +15,109 @@
specific language governing permissions and limitations
under the License.
}}
-
-
-
-
-
+{{#zone "content"}}
+
+
+
+
+
-
- Platform Configurations
-
-
- General and Platform Specific Server Settings for the Tenant
-
-
+
+ Platform Configurations
+
+
+ General and Platform Specific Server Settings for the Tenant
+
+
-
-
+{{/zone}}
{{#zone "bottomJs"}}
{{js "js/platform-configuration.js"}}
{{/zone}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
index 749ee92c15..87105e0686 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.js
@@ -20,15 +20,22 @@ function onRequest(context) {
var utility = require("/app/modules/device.js").utility;
var deviceModule = require("/app/modules/device.js").deviceModule;
//get all device types
- var data = deviceModule.getDeviceTypes();
var deviceTypesArray = [];
- if (data) {
- for (var i = 0; i < data.length; i++) {
- var deviceTypeName = data[i].name;
- var configUnitName = utility.getTenantedDeviceUnitName(deviceTypeName, "platform.configuration");
- if(configUnitName) {
- var deviceTypeConfig = utility.getDeviceTypeConfig(deviceTypeName);
- deviceTypesArray.push({name: deviceTypeName, label:deviceTypeConfig.deviceType.label, unitName : configUnitName});
+ var typesListResponse = deviceModule.getDeviceTypes();
+ if (typesListResponse["status"] == "success") {
+ var data = typesListResponse["content"].deviceTypes;
+ if (data) {
+ for (var i = 0; i < data.length; i++) {
+ var deviceTypeName = data[i];
+ var configUnitName = utility.getTenantedDeviceUnitName(deviceTypeName, "platform.configuration");
+ if (configUnitName) {
+ var deviceTypeConfig = utility.getDeviceTypeConfig(deviceTypeName);
+ deviceTypesArray.push({
+ name: deviceTypeName,
+ label: deviceTypeConfig.deviceType.label,
+ unitName: configUnitName
+ });
+ }
}
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
index f2704873a4..2f739d228a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/public/js/platform-configuration.js
@@ -41,7 +41,7 @@ $(document).ready(function () {
}
invokerUtil.get(
- "/devicemgt_admin/configuration",
+ "/api/device-mgt/v1.0/configuration",
function (data) {
data = JSON.parse(data);
if (data && data.configuration) {
@@ -85,13 +85,13 @@ $(document).ready(function () {
configList.push(monitorFrequency);
addConfigFormData.configuration = configList;
- var addConfigAPI = "/devicemgt_admin/configuration";
- invokerUtil.post(
+ var addConfigAPI = "/api/device-mgt/v1.0/configuration";
+ invokerUtil.put(
addConfigAPI,
addConfigFormData,
- function (data) {
- data = JSON.parse(data);
- if (data.statusCode == responseCodes["SUCCESS"]) {
+ function (data, textStatus, jqXHR) {
+ data = jqXHR.status;
+ if (data == 200) {
$("#config-save-form").addClass("hidden");
$("#record-created-msg").removeClass("hidden");
} else if (data == 500) {
@@ -118,3 +118,12 @@ $(document).ready(function () {
}
});
});
+
+// Start of HTML embedded invoke methods
+var showAdvanceOperation = function (operation, button) {
+ $(button).addClass('selected');
+ $(button).siblings().removeClass('selected');
+ var hiddenOperation = ".wr-hidden-operations-content > div";
+ $(hiddenOperation + '[data-operation="' + operation + '"]').show();
+ $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
+};
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
index 3e09ae185d..e5c8045b4d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
@@ -21,11 +21,11 @@ function onRequest(context) {
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
var utility = require("/app/modules/utility.js").utility;
- var userModule = require("/app/modules/user.js")["userModule"];
+ var deviceModule = require("/app/modules/device.js").deviceModule;
var types = {};
types["types"] = [];
- var typesListResponse = userModule.getPlatforms();
+ var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
for (var type in typesListResponse["content"]) {
var deviceType = typesListResponse["content"][type]["name"];