diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js index 61c094c3b6..0ca5ddc820 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js @@ -51,7 +51,10 @@ var operationsLogTable = "#operations-log-table"; if (update) { operationTable = $(operationsLogTable).DataTable(); - operationTable.ajax.reload(false); + $("#operations-spinner").removeClass("hidden"); + operationTable.ajax.reload(function ( json ) { + $("#operations-spinner").addClass("hidden"); + }, false); return; } operationTable = $(operationsLogTable).datatables_extended({ @@ -142,53 +145,54 @@ function (template) { var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; - invokerUtil.get( getEffectivePolicyURL, // success-callback function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - data = JSON.parse(data); + if (jqXHR.status == 200) { $("#policy-spinner").addClass("hidden"); - if (data["active"] == true) { - activePolicy = data; - invokerUtil.get( - getDeviceComplianceURL, - // success-callback - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var viewModel = {}; - viewModel["policy"] = activePolicy; - viewModel["deviceType"] = deviceType; - data = JSON.parse(data); - var content; - if (data["complianceData"]) { - if (data["complianceData"]["complianceFeatures"] && - data["complianceData"]["complianceFeatures"].length > 0) { - viewModel["compliance"] = "NON-COMPLIANT"; - viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; - content = template(viewModel); - $("#policy-list-container").html(content); + if(data){ + data = JSON.parse(data); + if (data["active"] == true) { + activePolicy = data; + invokerUtil.get( + getDeviceComplianceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var viewModel = {}; + viewModel["policy"] = activePolicy; + viewModel["deviceType"] = deviceType; + data = JSON.parse(data); + var content; + if (data["complianceData"]) { + if (data["complianceData"]["complianceFeatures"] && + data["complianceData"]["complianceFeatures"].length > 0) { + viewModel["compliance"] = "NON-COMPLIANT"; + viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; + content = template(viewModel); + $("#policy-list-container").html(content); + } else { + viewModel["compliance"] = "COMPLIANT"; + content = template(viewModel); + $("#policy-list-container").html(content); + $("#policy-compliance-table").addClass("hidden"); + } } else { - viewModel["compliance"] = "COMPLIANT"; - content = template(viewModel); - $("#policy-list-container").html(content); - $("#policy-compliance-table").addClass("hidden"); + $("#policy-list-container"). + html("
This device " + + "has no policy applied.
This device " + - "has no policy applied.
Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.
Loading policy compliance related data " + - "was not successful. please try refreshing data in a while.
'+ loadingText +'
' + - ''+ loadingText +'
' + + '' + + ''; if (action === 'show') { $(this).prepend(html).addClass('loading'); @@ -230,13 +230,13 @@ var responsiveTextRatio = 0.2, responsive: false, autoWidth: false, dom:'<"dataTablesTop"' + - 'f' + - '<"dataTables_toolbar">' + - '>' + - 'rt' + - '<"dataTablesBottom"' + - 'lip' + - '>', + 'f' + + '<"dataTables_toolbar">' + + '>' + + 'rt' + + '<"dataTablesBottom"' + + 'lip' + + '>', language: { searchPlaceholder: 'Filter by ...', search: '' @@ -244,6 +244,7 @@ var responsiveTextRatio = 0.2, initComplete: function(){ var ROW_SELECTED_CLASS = 'DTTT_selected'; + var table = this; this.api().columns().every(function(){ @@ -301,7 +302,7 @@ var responsiveTextRatio = 0.2, var search_input = $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input'); search_input.before('').removeClass('input-sm'); - // Create sorting dropdown menu for list table advance operations + // Create sorting dropdown menu for list table advance operations var dropdownmenu = $(' '); $('.sort-row th', elem).each(function(){ if(!$(this).hasClass('no-sort')){ @@ -313,19 +314,19 @@ var responsiveTextRatio = 0.2, if (!table.hasClass('no-toolbar')) { if (table.hasClass('sorting-enabled')) { return ' ' + '' + + '' + + '' + + '' + + '