From 528837ce1fde52375e79608ffbdbd491efcb3b32 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 19 Feb 2018 19:49:45 +0530 Subject: [PATCH 1/2] Fixing platform filtering not working correctly Resolves https://github.com/wso2/product-iots/issues/1689 --- .../devicemgt/app/pages/cdmf.page.devices/public/js/listing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index 26f3ea8ec67..a8834496fec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -440,7 +440,7 @@ function loadDevices(searchType, searchParam) { break; case 4: $(this).attr('data-grid-label', "Type"); - $(this).attr('data-search', deviceType); + $(this).attr('data-search', getDeviceTypeLabel(deviceType)); $(this).attr('data-display', getDeviceTypeLabel(deviceType)); break; case 5: From 49f97f02e8f0a1cdab4a367742025214d37f50df Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Tue, 20 Feb 2018 14:28:03 +0530 Subject: [PATCH 2/2] Fixing platform filtering not working correctly Resolves https://github.com/wso2/product-iots/issues/1689 --- .../devicemgt/api/data-tables-invoker-api.jag | 5 +++-- .../pages/cdmf.page.devices/public/js/listing.js | 2 +- .../public/js/dataTables.extended.js | 8 +++++++- .../js/dataTables.extended.serversidepaging.js | 16 +++++++--------- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag index a22707aa808..a0ddd0e294f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag @@ -61,14 +61,15 @@ if (uriMatcher.match("/{context}/api/data-tables/invoker/filters")) { if (deviceTypesRes.status === "success") { var deviceTypes = deviceTypesRes["content"]["deviceTypes"]; for (i = 0; i < deviceTypes.length; i++) { - var deviceTypeLabel = deviceTypes[i]; + var deviceTypeName = deviceTypes[i]; + var deviceTypeLabel = deviceTypeName; var configs = utility.getDeviceTypeConfig(deviceTypeLabel); if (configs) { 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]; } } - result.deviceTypes.push(deviceTypeLabel); + result.deviceTypes.push({"name": deviceTypeLabel, "value": deviceTypeName}); } } //Adding policy compliance diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index a8834496fec..26f3ea8ec67 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -440,7 +440,7 @@ function loadDevices(searchType, searchParam) { break; case 4: $(this).attr('data-grid-label', "Type"); - $(this).attr('data-search', getDeviceTypeLabel(deviceType)); + $(this).attr('data-search', deviceType); $(this).attr('data-display', getDeviceTypeLabel(deviceType)); break; case 5: diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js index 14cd5f88850..d33cc3b4dfe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js @@ -121,7 +121,13 @@ $.fn.datatables_extended = function (settings) { } else if (filterColumn.eq(column.index()).hasClass('data-platform')) { for(i = 0; i < cachedFilterRes.deviceTypes.length; i++){ var deviceTypes = cachedFilterRes.deviceTypes[i]; - select.append('') + var name = deviceTypes; + var value = deviceTypes; + if (deviceTypes.name && deviceTypes.value) { + name = deviceTypes.name; + value = deviceTypes.value; + } + select.append('') } } else if (filterColumn.eq(column.index()).hasClass('data-compliance')) { for(i = 0; i < cachedFilterRes.deviceTypes.length; i++){ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js index 2bf0713a3e3..85af438c1cb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js @@ -147,10 +147,6 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter } else { $("#operation-guide").addClass("hidden"); $("#operation-bar").removeClass("hidden"); - //noinspection JSUnresolvedFunction - if (deviceType && ownership) { - loadOperationBar(deviceType, ownership, operationBarModeConstants.BULK); - } } } @@ -162,10 +158,6 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter } else { $("#operation-guide").addClass("hidden"); $("#operation-bar").removeClass("hidden"); - //noinspection JSUnresolvedFunction - if (deviceType && ownership) { - loadOperationBar(deviceType, ownership, operationBarModeConstants.BULK); - } } } }); @@ -197,7 +189,13 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter } else if (filterColumn.eq(column.index()).hasClass('data-platform')) { for(i = 0; i < cachedFilterRes.deviceTypes.length; i++){ var deviceTypes = cachedFilterRes.deviceTypes[i]; - select.append('') + var name = deviceTypes; + var value = deviceTypes; + if (deviceTypes.name && deviceTypes.value) { + name = deviceTypes.name; + value = deviceTypes.value; + } + select.append('') } } else if (filterColumn.eq(column.index()).hasClass('data-compliance')) { for(i = 0; i < cachedFilterRes.deviceTypes.length; i++){