From 2ffb9ffc7640cce4d90f60594f1c1db5936a5867 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Fri, 17 Apr 2020 14:12:30 +0200 Subject: [PATCH] - Minor performance improvements, --- app/Controller/Api/Universe.php | 7 ++++++- app/Model/Pathfinder/SystemModel.php | 19 +++++++++++++++---- composer-dev.json | 1 + composer.json | 1 + js/app/lib/dragSelect.js | 3 ++- js/app/ui/dialog/map_info.js | 9 ++++++--- js/app/ui/form_element.js | 2 +- public/js/v2.0.1/app/lib/dragSelect.js | 3 ++- public/js/v2.0.1/app/ui/dialog/map_info.js | 9 ++++++--- public/js/v2.0.1/app/ui/form_element.js | 2 +- sass/layout/_shadow.scss | 14 -------------- 11 files changed, 41 insertions(+), 29 deletions(-) delete mode 100644 sass/layout/_shadow.scss diff --git a/app/Controller/Api/Universe.php b/app/Controller/Api/Universe.php index 907cb62d..f91df14e 100644 --- a/app/Controller/Api/Universe.php +++ b/app/Controller/Api/Universe.php @@ -49,6 +49,8 @@ class Universe extends Controller\AccessController { $search = isset($params['arg1']) ? (string)$params['arg1'] : ''; $morePages = false; $count = 0; + // reduce returned system data to required keys (save bandwidth) + $allowedProperties = array_flip(['id', 'name', 'trueSec', 'security', 'effect', 'shattered']); $return = (object) []; $return->results = []; @@ -82,11 +84,14 @@ class Universe extends Controller\AccessController { $endCount = $offset + self::PAGE_SIZE_SYSTEMS; $morePages = $endCount < $count; + /** + * @var Model\Universe\SystemModel[] $systems + */ $systems = $system->find($filter, $options); if($systems){ foreach($systems as $system){ if($systemData = $system->fromIndex()){ - $return->results[] = $systemData; + $return->results[] = (object)array_intersect_key((array)$systemData, $allowedProperties); } } } diff --git a/app/Model/Pathfinder/SystemModel.php b/app/Model/Pathfinder/SystemModel.php index a038b2b8..8cb9f7c9 100644 --- a/app/Model/Pathfinder/SystemModel.php +++ b/app/Model/Pathfinder/SystemModel.php @@ -207,8 +207,6 @@ class SystemModel extends AbstractMapTrackingModel { $data->name = $this->name; $data->security = $this->security; $data->trueSec = $this->trueSec; - $data->effect = $this->effect; - $data->shattered = $this->shattered; $data->constellation = (object) []; $data->constellation->id = $this->constellationId; @@ -218,8 +216,21 @@ class SystemModel extends AbstractMapTrackingModel { $data->region->id = $this->regionId; $data->region->name = $this->region; - $data->planets = $this->planets ? : []; - $data->statics = $this->statics ? : []; + if($this->planets){ + $data->planets = $this->planets; + } + + if($this->statics){ + $data->statics = $this->statics; + } + + if($this->effect){ + $data->effect = $this->effect; + } + + if($this->shattered){ + $data->shattered = $this->shattered; + } if(is_object($sovereignty = $this->sovereignty)){ $data->sovereignty = $sovereignty; diff --git a/composer-dev.json b/composer-dev.json index 99022100..9bfd4e28 100644 --- a/composer-dev.json +++ b/composer-dev.json @@ -20,6 +20,7 @@ "Exodus4D\\Pathfinder\\": "app/" } }, + "readme": "README.md", "repositories": [ { "type": "vcs", diff --git a/composer.json b/composer.json index 933bc3ba..4c261b64 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "Exodus4D\\Pathfinder\\": "app/" } }, + "readme": "README.md", "require": { "php-64bit": ">=7.2", "ext-pdo": "*", diff --git a/js/app/lib/dragSelect.js b/js/app/lib/dragSelect.js index a2998679..35c2abdf 100644 --- a/js/app/lib/dragSelect.js +++ b/js/app/lib/dragSelect.js @@ -87,7 +87,7 @@ define(['app/lib/eventHandler'], (EventHandler) => { this.setTargetDimensions(); EventHandler.addEventListener(this._config.target, this.getNamespaceEvent('mousedown'), this.onMouseDown.bind(this), {passive: false}); - EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mousemove'), this.onMouseMove.bind(this), {passive: false}); + EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mousemove'), this.onMouseMove.bind(this), {passive: true}); EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mouseup'), this.onMouseUp.bind(this), {passive: true}); } @@ -104,6 +104,7 @@ define(['app/lib/eventHandler'], (EventHandler) => { onMouseMove(e){ if(this._mouseIsDown){ e.preventDefault(); + e.stopPropagation(); if(this._animationFrameId){ cancelAnimationFrame(this._animationFrameId); diff --git a/js/app/ui/dialog/map_info.js b/js/app/ui/dialog/map_info.js index 05136621..2d8a5333 100644 --- a/js/app/ui/dialog/map_info.js +++ b/js/app/ui/dialog/map_info.js @@ -357,6 +357,7 @@ define([ className: 'text-center', searchable: false, data: 'effect', + defaultContent: '', render: { display: (cellData, type, rowData, meta) => { let value = ''; @@ -376,9 +377,11 @@ define([ render: { _: (cellData, type, rowData, meta) => { let statics = []; - for(let wormholeName of cellData){ - let wormholeData = Object.assign({}, Init.wormholes[wormholeName]); - statics.push('' + wormholeData.security + ''); + if(Array.isArray(cellData)) { + for (let wormholeName of cellData) { + let wormholeData = Object.assign({}, Init.wormholes[wormholeName]); + statics.push('' + wormholeData.security + ''); + } } return statics.join('  '); } diff --git a/js/app/ui/form_element.js b/js/app/ui/form_element.js index 814ed2de..01f957e3 100644 --- a/js/app/ui/form_element.js +++ b/js/app/ui/form_element.js @@ -392,7 +392,7 @@ define([ let disabled = false; let trueSec = parseFloat(item.trueSec); let secClass = Util.getSecurityClassForSystem(item.security); - let trueSecClass = Util.getTrueSecClassForSystem( trueSec ); + let trueSecClass = Util.getTrueSecClassForSystem(trueSec); let effectClass = MapUtil.getEffectInfoForSystem(item.effect, 'class'); // check if system is dialed diff --git a/public/js/v2.0.1/app/lib/dragSelect.js b/public/js/v2.0.1/app/lib/dragSelect.js index a2998679..35c2abdf 100644 --- a/public/js/v2.0.1/app/lib/dragSelect.js +++ b/public/js/v2.0.1/app/lib/dragSelect.js @@ -87,7 +87,7 @@ define(['app/lib/eventHandler'], (EventHandler) => { this.setTargetDimensions(); EventHandler.addEventListener(this._config.target, this.getNamespaceEvent('mousedown'), this.onMouseDown.bind(this), {passive: false}); - EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mousemove'), this.onMouseMove.bind(this), {passive: false}); + EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mousemove'), this.onMouseMove.bind(this), {passive: true}); EventHandler.addEventListener(this._config.container, this.getNamespaceEvent('mouseup'), this.onMouseUp.bind(this), {passive: true}); } @@ -104,6 +104,7 @@ define(['app/lib/eventHandler'], (EventHandler) => { onMouseMove(e){ if(this._mouseIsDown){ e.preventDefault(); + e.stopPropagation(); if(this._animationFrameId){ cancelAnimationFrame(this._animationFrameId); diff --git a/public/js/v2.0.1/app/ui/dialog/map_info.js b/public/js/v2.0.1/app/ui/dialog/map_info.js index 05136621..2d8a5333 100644 --- a/public/js/v2.0.1/app/ui/dialog/map_info.js +++ b/public/js/v2.0.1/app/ui/dialog/map_info.js @@ -357,6 +357,7 @@ define([ className: 'text-center', searchable: false, data: 'effect', + defaultContent: '', render: { display: (cellData, type, rowData, meta) => { let value = ''; @@ -376,9 +377,11 @@ define([ render: { _: (cellData, type, rowData, meta) => { let statics = []; - for(let wormholeName of cellData){ - let wormholeData = Object.assign({}, Init.wormholes[wormholeName]); - statics.push('' + wormholeData.security + ''); + if(Array.isArray(cellData)) { + for (let wormholeName of cellData) { + let wormholeData = Object.assign({}, Init.wormholes[wormholeName]); + statics.push('' + wormholeData.security + ''); + } } return statics.join('  '); } diff --git a/public/js/v2.0.1/app/ui/form_element.js b/public/js/v2.0.1/app/ui/form_element.js index 814ed2de..01f957e3 100644 --- a/public/js/v2.0.1/app/ui/form_element.js +++ b/public/js/v2.0.1/app/ui/form_element.js @@ -392,7 +392,7 @@ define([ let disabled = false; let trueSec = parseFloat(item.trueSec); let secClass = Util.getSecurityClassForSystem(item.security); - let trueSecClass = Util.getTrueSecClassForSystem( trueSec ); + let trueSecClass = Util.getTrueSecClassForSystem(trueSec); let effectClass = MapUtil.getEffectInfoForSystem(item.effect, 'class'); // check if system is dialed diff --git a/sass/layout/_shadow.scss b/sass/layout/_shadow.scss deleted file mode 100644 index b7a4f633..00000000 --- a/sass/layout/_shadow.scss +++ /dev/null @@ -1,14 +0,0 @@ -.pf-shadow { - position: relative; - - &:before { - content: ''; - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - z-index: -1; - box-shadow: 0px 0px 10px 5px #000; - } -} \ No newline at end of file