From 3fa513cabd63e38d971f6ac87a9a05bf3b79cff4 Mon Sep 17 00:00:00 2001 From: Madhawa Perera Date: Fri, 9 Mar 2018 17:43:33 +0530 Subject: [PATCH] Fix UI loading issue on Safari 11.0.3 (#1212) * Fix UI loading issue on Safari 11.0.3 Fix the issue of operation logs and location doesn't display on device detail page on safari browser 11.0.3 Fixes wso2/product-iots#1752 * Add comments describing code lines --- .../app/units/cdmf.unit.geo-dashboard/geo-dashboard.hbs | 1 + .../app/units/cdmf.unit.geo-dashboard/public/js/app.js | 3 ++- .../units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.hbs index 151a91e9fd6..cb2a518ef66 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/geo-dashboard.hbs @@ -736,6 +736,7 @@ var geoLocationLink = $(".initGeoLocationLink"); if (geoLocationLink) { geoLocationLink.on('click', function () { + loadGeoFencing(); initializeGeoLocation({{geoServicesEnabled}}); }); geoPublicUri = $("#geo-charts").data("geo-public-uri"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js index 9c9632f3df1..266433f1c44 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/app.js @@ -46,7 +46,8 @@ function initialLoad(geoFencingEnabled) { } function initializeMap() { - if (typeof(map) !== 'undefined') { + ///map.zoomControl is added to fix UI loading issue on Safari + if (typeof(map) !== 'undefined' && map.zoomControl != null) { map.remove(); } if (document.getElementById('map') == null) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js index 5996dbcac35..07a42cefd8a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.geo-dashboard/public/js/geo_fencing.js @@ -23,10 +23,9 @@ var drawnItems; var lastId; var controlDiv; -loadGeoFencing(); - function loadGeoFencing() { - if (map == null) { + ///map.zoomControl is added to fix UI loading issue on Safari + if (map == null || map.zoomControl == null) { setTimeout(loadGeoFencing, 1000); // give everything some time to render } else { map.on('draw:created', function (e) {