diff --git a/app/main/controller/admin.php b/app/main/controller/admin.php index a2bec7a1..de66a957 100644 --- a/app/main/controller/admin.php +++ b/app/main/controller/admin.php @@ -421,6 +421,13 @@ class Admin extends Controller{ } $f3->set('tplMaps', $data); + + if( !isset($data->corpMaps) ){ + $f3->set('tplNotification', $this->getNotificationObject('No maps found', + 'Only corporation maps could get loaded' , + 'info' + )); + } } /** diff --git a/app/main/controller/controller.php b/app/main/controller/controller.php index 42687aa2..8f3fe943 100644 --- a/app/main/controller/controller.php +++ b/app/main/controller/controller.php @@ -25,6 +25,7 @@ class Controller { const ERROR_SESSION_SUSPECT = 'id: [%45s], ip: [%45s], User-Agent: [%s]'; const ERROR_TEMP_CHARACTER_ID = 'Invalid temp characterId: %s'; + const NOTIFICATION_TYPES = ['danger', 'warning', 'info', 'success']; /** * @var \Base */ @@ -542,6 +543,20 @@ class Controller { return $object; } + /** + * @param string $title + * @param string $message + * @param string $type + * @return \stdClass + */ + protected function getNotificationObject(string $title, $message = '', $type = 'danger') : \stdClass { + $notification = (object) []; + $notification->type = in_array($type, self::NOTIFICATION_TYPES) ? $type : 'danger'; + $notification->title = $title; + $notification->message = $message; + return $notification; + } + /** * get a program URL by alias * -> if no $alias given -> get "default" route (index.php) diff --git a/js/app/map/map.js b/js/app/map/map.js index b08f9b4a..489c44e3 100644 --- a/js/app/map/map.js +++ b/js/app/map/map.js @@ -944,35 +944,70 @@ define([ */ let setMapWrapperObserver = (mapWrapper, mapConfig) => { + /** + * save current map dimension to local storage + * @param entry + */ + let saveMapSize = (entry) => { + let width = ''; + let height = ''; + if(entry.constructor.name === 'HTMLDivElement'){ + width = entry.style.width; + height = entry.style.height; + }else if (entry.constructor.name === 'ResizeObserverEntry'){ + width = entry.target.style.width; + height = entry.target.style.height; + } + + width = parseInt(width.substring(0, width.length - 2)) || 0; + height = parseInt(height.substring(0, height.length - 2)) || 0; + + let promiseStore = MapUtil.getLocaleData('map', mapConfig.config.id ); + promiseStore.then((data) => { + let storeData = true; + + if ( + data && data.style && + data.style.width === width && + data.style.height === height + ) { + // no style changes + storeData = false; + } + + if (storeData) { + MapUtil.storeLocalData('map', mapConfig.config.id, 'style', { + width: width, + height: height + }); + } + }); + }; + // map resize observer ---------------------------------------------------------------------------------------- if(window.ResizeObserver) { + // ResizeObserver() supported let resizeTimer; let wrapperResize = new ResizeObserver(entries => { // jshint ignore:line - /** - * save current map dimension to local storage - * @param entry - */ - let saveMapSize = (entry) => { - return setTimeout(() => { - let width = entry.target.style.width; - let height = entry.target.style.height; - width = parseInt( width.substring(0, width.length - 2) ) || 0; - height = parseInt( height.substring(0, height.length - 2) ) || 0; - - MapUtil.storeLocalData('map', mapConfig.config.id, 'style', { - width: width, - height: height - }); - }, 100); + let checkMapSize = (entry) => { + return setTimeout(saveMapSize, 100, entry); }; for (let entry of entries){ // use timeout to "throttle" save actions clearTimeout(resizeTimer); - resizeTimer = saveMapSize(entry); + resizeTimer = checkMapSize(entry); } }); wrapperResize.observe(mapWrapper[0]); + }else if(requestAnimationFrame){ + // ResizeObserver() not supported + let checkMapSize = (entry) => { + saveMapSize(entry); + return setTimeout(checkMapSize, 500, entry); + }; + + checkMapSize(mapWrapper[0]); } }; diff --git a/public/js/v1.3.4/app/map/map.js b/public/js/v1.3.4/app/map/map.js index b08f9b4a..489c44e3 100644 --- a/public/js/v1.3.4/app/map/map.js +++ b/public/js/v1.3.4/app/map/map.js @@ -944,35 +944,70 @@ define([ */ let setMapWrapperObserver = (mapWrapper, mapConfig) => { + /** + * save current map dimension to local storage + * @param entry + */ + let saveMapSize = (entry) => { + let width = ''; + let height = ''; + if(entry.constructor.name === 'HTMLDivElement'){ + width = entry.style.width; + height = entry.style.height; + }else if (entry.constructor.name === 'ResizeObserverEntry'){ + width = entry.target.style.width; + height = entry.target.style.height; + } + + width = parseInt(width.substring(0, width.length - 2)) || 0; + height = parseInt(height.substring(0, height.length - 2)) || 0; + + let promiseStore = MapUtil.getLocaleData('map', mapConfig.config.id ); + promiseStore.then((data) => { + let storeData = true; + + if ( + data && data.style && + data.style.width === width && + data.style.height === height + ) { + // no style changes + storeData = false; + } + + if (storeData) { + MapUtil.storeLocalData('map', mapConfig.config.id, 'style', { + width: width, + height: height + }); + } + }); + }; + // map resize observer ---------------------------------------------------------------------------------------- if(window.ResizeObserver) { + // ResizeObserver() supported let resizeTimer; let wrapperResize = new ResizeObserver(entries => { // jshint ignore:line - /** - * save current map dimension to local storage - * @param entry - */ - let saveMapSize = (entry) => { - return setTimeout(() => { - let width = entry.target.style.width; - let height = entry.target.style.height; - width = parseInt( width.substring(0, width.length - 2) ) || 0; - height = parseInt( height.substring(0, height.length - 2) ) || 0; - - MapUtil.storeLocalData('map', mapConfig.config.id, 'style', { - width: width, - height: height - }); - }, 100); + let checkMapSize = (entry) => { + return setTimeout(saveMapSize, 100, entry); }; for (let entry of entries){ // use timeout to "throttle" save actions clearTimeout(resizeTimer); - resizeTimer = saveMapSize(entry); + resizeTimer = checkMapSize(entry); } }); wrapperResize.observe(mapWrapper[0]); + }else if(requestAnimationFrame){ + // ResizeObserver() not supported + let checkMapSize = (entry) => { + saveMapSize(entry); + return setTimeout(checkMapSize, 500, entry); + }; + + checkMapSize(mapWrapper[0]); } }; diff --git a/public/templates/admin/maps.html b/public/templates/admin/maps.html index 0ac43fe2..d233eafc 100644 --- a/public/templates/admin/maps.html +++ b/public/templates/admin/maps.html @@ -66,5 +66,7 @@ + + \ No newline at end of file diff --git a/public/templates/admin/notification.html b/public/templates/admin/notification.html new file mode 100644 index 00000000..11072e17 --- /dev/null +++ b/public/templates/admin/notification.html @@ -0,0 +1,9 @@ + +
+
+
+ +
+
+
+
diff --git a/public/templates/modules/notification.html b/public/templates/modules/notification.html new file mode 100644 index 00000000..e7bd8b92 --- /dev/null +++ b/public/templates/modules/notification.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + +
+ {{ @notification->title }} + + {{ @notification->message }} + +
+
\ No newline at end of file