Merge pull request #826 from exodus4d/develop

v1.5.3
This commit is contained in:
Mark Friedrich
2019-07-27 15:59:19 +02:00
committed by GitHub
72 changed files with 194 additions and 88 deletions

View File

@@ -948,7 +948,7 @@ class Map extends Controller\AccessController {
$targetSystemId = (int)$targetLog->systemId;
// get 'character log' from source system. If not log found -> assume $sourceLog == $targetLog
$sourceLog = $character->getLogPrevSystem($targetSystemId) ? : $targetLog;
$sourceLog = $character->getLogPrevSystem($map->_id, $targetSystemId) ? : $targetLog;
$sourceSystemId = (int)$sourceLog->systemId;
if($sourceSystemId){
@@ -1020,12 +1020,12 @@ class Map extends Controller\AccessController {
break;
case 'k-space':
if($sameSystem){
if( !$sourceSystem->isWormhole() ){
if($sourceSystem->isKspace()){
$addSourceSystem = true;
}
}elseif(
!$sourceSystem->isWormhole() ||
!$targetSystem->isWormhole()
$sourceSystem->isKspace() ||
$targetSystem->isKspace()
){
$addSourceSystem = true;
$addTargetSystem = true;
@@ -1035,7 +1035,7 @@ class Map extends Controller\AccessController {
case 'wh':
default:
if($sameSystem){
if( $sourceSystem->isWormhole() ){
if($sourceSystem->isWormhole()){
$addSourceSystem = true;
}
}elseif(

View File

@@ -11,6 +11,11 @@ namespace Model\Pathfinder;
use DB\SQL\Schema;
/**
* Class CharacterLogModel
* @package Model\Pathfinder
* @property CharacterModel $characterId
*/
class CharacterLogModel extends AbstractPathfinderModel {
/**
@@ -244,26 +249,11 @@ class CharacterLogModel extends AbstractPathfinderModel {
* @param string $action
*/
protected function updateLogsHistory(string $action){
// add new log history entry if 'systemId' changed
// -> if e.g. 'shipTypeId', 'stationId',.. changed -> no new entry (for now)
if(
!empty($this->fieldChanges) &&
array_key_exists('systemId', $this->fieldChanges) && // new history entry
$this->valid() &&
is_object($this->characterId)
){
$oldLog = clone $this;
// get 'updated' timestamp and reapply after __set() fields data
// -> because any __set() call updates 'updated' col
$updated = $oldLog->updated;
foreach($this->fieldChanges as $key => $change){
if($oldLog->exists($key)){
$oldLog->$key = $change['old'];
}
}
$oldLog->updated = $updated;
$oldLog->characterId->updateLogsHistory($oldLog, $action);
$this->characterId->updateLogsHistory($this, $action);
}
}

View File

@@ -33,8 +33,9 @@ class CharacterModel extends AbstractPathfinderModel {
/**
* max count of historic character logs
* -> this includes logs where just e.g. shipTypeId has changed but no systemId change!
*/
const MAX_LOG_HISTORY_DATA = 5;
const MAX_LOG_HISTORY_DATA = 10;
/**
* TTL for historic character logs
@@ -249,7 +250,7 @@ class CharacterModel extends AbstractPathfinderModel {
}
if($addLogHistoryData && $characterData->log){
$characterData->logHistory = $this->getLogsHistory();
$characterData->logHistory = $this->getLogHistoryJumps($characterData->log->system->id);
}
// temp "authStatus" should not be cached
@@ -1033,12 +1034,34 @@ class CharacterModel extends AbstractPathfinderModel {
}
/**
* filter'character log' history data by $callback
* get 'character log' history data. Filter all data that does not represent a 'jump' (systemId change)
* -> e.g. If just 'shipTypeId' has changed, this entry is filtered
* @param int $systemIdPrev
* @return array
*/
protected function getLogHistoryJumps(int $systemIdPrev = 0) : array {
return $this->filterLogsHistory(function(array $historyEntry) use (&$systemIdPrev) : bool {
$addEntry = false;
if(
!empty($historySystemId = (int)$historyEntry['log']['system']['id']) &&
$historySystemId !== $systemIdPrev
){
$addEntry = true;
$systemIdPrev = $historySystemId;
}
return $addEntry;
});
}
/**
* filter 'character log' history data by $callback
* -> reindex array keys! Otherwise json_encode() on result would return object!
* @param \Closure $callback
* @return array
*/
protected function filterLogsHistory(\Closure $callback) : array {
return array_filter($this->getLogsHistory() , $callback);
return array_values(array_filter($this->getLogsHistory() , $callback));
}
/**
@@ -1056,27 +1079,83 @@ class CharacterModel extends AbstractPathfinderModel {
* @param CharacterLogModel $characterLog
* @param string $action
*/
public function updateLogsHistory(CharacterLogModel $characterLog, string $action = 'update'){
public function updateLogsHistory(CharacterLogModel $characterLog, string $action = 'update') : void {
if(
!$this->dry() &&
$this->valid() &&
$this->_id === $characterLog->get('characterId', true)
){
$logHistoryData = $this->getLogsHistory();
$task = 'add';
$mapIds = [];
$historyLog = $characterLog->getDataAsArray();
if($logHistoryData = $this->getLogsHistory()){
// skip logging if no relevant fields changed
list($historyEntryPrev) = $logHistoryData;
if($historyLogPrev = $historyEntryPrev['log']){
if(
$historyLog['system']['id'] === $historyLogPrev['system']['id'] &&
$historyLog['ship']['typeId'] === $historyLogPrev['ship']['typeId'] &&
$historyLog['station']['id'] === $historyLogPrev['station']['id'] &&
$historyLog['structure']['id'] === $historyLogPrev['structure']['id']
){
// no changes in 'relevant' fields -> just update timestamp
$task = 'update';
$mapIds = (array)$historyEntryPrev['mapIds'];
}
}
}
$historyEntry = [
'stamp' => strtotime($characterLog->updated),
'action' => $action,
'log' => $characterLog->getDataAsArray()
'mapIds' => $mapIds,
'log' => $historyLog
];
array_unshift($logHistoryData, $historyEntry);
if($task == 'update'){
$logHistoryData[0] = $historyEntry;
}else{
array_unshift($logHistoryData, $historyEntry);
// limit max history data
array_splice($logHistoryData, self::MAX_LOG_HISTORY_DATA);
// limit max history data
array_splice($logHistoryData, self::MAX_LOG_HISTORY_DATA);
}
$this->updateCacheData($logHistoryData, self::DATA_CACHE_KEY_LOG_HISTORY, self::TTL_LOG_HISTORY);
}
}
/**
* try to update existing 'character log' history entry (replace data)
* -> matched by 'stamp' timestamp
* @param array $historyEntry
* @return bool
*/
protected function updateLogHistoryEntry(array $historyEntry) : bool {
$updated = false;
if(
$this->valid() &&
($logHistoryData = $this->getLogsHistory())
){
$map = function(array $entry) use ($historyEntry, &$updated) : array {
if($entry['stamp'] === $historyEntry['stamp']){
$updated = true;
$entry = $historyEntry;
}
return $entry;
};
$logHistoryData = array_map($map, $logHistoryData);
if($updated){
$this->updateCacheData($logHistoryData, self::DATA_CACHE_KEY_LOG_HISTORY, self::TTL_LOG_HISTORY);
}
}
return $updated;
}
/**
* broadcast characterData
*/
@@ -1145,24 +1224,48 @@ class CharacterModel extends AbstractPathfinderModel {
/**
* get the first matched (most recent) log entry before $systemId.
* -> The returned log entry *might* be previous system for this character
* @param int $mapId
* @param int $systemId
* @return CharacterLogModel|null
*/
public function getLogPrevSystem(int $systemId) : ?CharacterLogModel {
$logHistoryData = $this->filterLogsHistory(function(array $historyEntry) use ($systemId) : bool {
return (
!empty($historySystemId = (int)$historyEntry['log']['system']['id']) &&
$historySystemId !== $systemId
);
});
public function getLogPrevSystem(int $mapId, int $systemId) : ?CharacterLogModel {
$characterLog = null;
if(!empty($historyEntry = reset($logHistoryData))){
/**
* @var $characterLog CharacterLogModel
*/
$characterLog = $this->rel('characterLog');
$characterLog->setData($historyEntry['log']);
if($mapId && $systemId){
$skipRest = false;
$logHistoryData = $this->filterLogsHistory(function(array $historyEntry) use ($mapId, $systemId, &$skipRest) : bool {
$addEntry = false;
if(in_array($mapId, (array)$historyEntry['mapIds'], true)){
$skipRest = true;
}
if(
!$skipRest &&
!empty($historySystemId = (int)$historyEntry['log']['system']['id']) &&
$historySystemId !== $systemId
){
$addEntry = true;
$skipRest = true;
}
return $addEntry;
});
if(
!empty($historyEntry = reset($logHistoryData)) &&
is_array($historyEntry['mapIds'])
){
/**
* @var $characterLog CharacterLogModel
*/
$characterLog = $this->rel('characterLog');
$characterLog->setData($historyEntry['log']);
// mark $historyEntry data as "checked" for $mapId
array_push($historyEntry['mapIds'], $mapId);
$this->updateLogHistoryEntry($historyEntry);
}
}
return $characterLog;

View File

@@ -656,7 +656,7 @@ class SystemModel extends AbstractMapTrackingModel {
}
/**
* check whether this system is a wormhole
* check whether this system is in w-space
* @return bool
*/
public function isWormhole() : bool {
@@ -664,7 +664,15 @@ class SystemModel extends AbstractMapTrackingModel {
}
/**
* check whether this system is an Abyss system
* check whether this system is in k-space
* @return bool
*/
public function isKspace() : bool {
return ($this->typeId->id === 2);
}
/**
* check whether this system is in a-space
* @return bool
*/
public function isAbyss() : bool {

View File

@@ -14,7 +14,7 @@ NAME = Pathfinder
; e.g. public/js/vX.X.X/app.js
; Syntax: String (current version)
; Default: v1.5.0
VERSION = v1.5.2
VERSION = v1.5.3
; Contact information [optional]
; Shown on 'licence', 'contact' page.

View File

@@ -93,7 +93,8 @@ let trackTable = {
// https://www.npmjs.com/package/uglify-es
let uglifyJsOptions = {
warnings: true,
toplevel: false
toplevel: false,
ecma: 8
};
// Sourcemaps options

View File

@@ -237,7 +237,7 @@ define([
// open Overlay -------------------------------------------------------------------------------------------
if( !isOpen(overlay) ){
let promiseStore = MapUtil.getLocaleData('map', mapId);
promiseStore.then(function(dataStore){
promiseStore.then(dataStore => {
if(
dataStore &&
dataStore.showLocal

View File

@@ -214,7 +214,7 @@ define([
// loop all active pilots and build cache-key
let cacheArray = [];
for(let tempUserData of data.user){
cacheArray.push(tempUserData.id + '_' + tempUserData.log.ship.id);
cacheArray.push(tempUserData.id + '_' + tempUserData.log.ship.typeId);
}
// make sure cacheArray values are sorted for key comparison
@@ -223,9 +223,8 @@ define([
// we need to add "view mode" option to key
// -> if view mode change detected -> key no longer valid
cacheArray.unshift(compactView ? 'compact' : 'default');
let cacheKey = cacheArray.join('_').hashCode();
let cacheKey = compactView ? 'compact' : 'default';
cacheKey += '_' + cacheArray.join('_').hashCode();
// check for if cacheKey has changed
if(cacheKey !== oldCacheKey){
@@ -2772,11 +2771,12 @@ define([
// update "local" overlay for this map
mapContainer.on('pf:updateLocal', function(e, userData){
let mapElement = $(this);
let mapOverlay = MapOverlayUtil.getMapOverlay(mapElement, 'local');
let mapId = Util.getObjVal(userData, 'config.id') || 0;
if(userData && userData.config && userData.config.id){
let currentMapData = Util.getCurrentMapData(userData.config.id);
if(mapId){
let mapElement = $(this);
let mapOverlay = MapOverlayUtil.getMapOverlay(mapElement, 'local');
let currentMapData = Util.getCurrentMapData(mapId);
let currentCharacterLog = Util.getCurrentCharacterLog();
let clearLocal = true;
@@ -2785,7 +2785,7 @@ define([
currentCharacterLog &&
currentCharacterLog.system
){
let currentSystemData = currentMapData.data.systems.filter(function(system){
let currentSystemData = currentMapData.data.systems.filter(system => {
return system.systemId === currentCharacterLog.system.id;
});

View File

@@ -980,7 +980,7 @@ define([
if(changes.charactersIds){
updateTasks.push(updateHeaderCharacterSwitch(userData, changes.characterId));
}
if(changes.characterSystemId || changes.characterShipType){
if(changes.characterSystemId || changes.characterShipType || changes.characterLogHistory){
updateTasks.push(updateHeaderCharacterLocation(userData, changes.characterShipType));
}

View File

@@ -761,12 +761,12 @@ define([
let currentLocationData = Util.getCurrentLocationData();
if(
currentLocationData.id &&
currentLocationData.id !== systemData.id
currentLocationData.id !== systemData.systemId
){
let systemNameStr = (systemData.name === systemData.alias) ? '"' + systemData.name + '"' : '"' + systemData.alias + '" (' + systemData.name + ')';
systemNameStr = '<span class="txt-color txt-color-warning">' + systemNameStr + '</span>';
let msg = 'Update structures in ' + systemNameStr + ' ? This not your current location, "' + currentLocationData.name + '" !';
let msg = 'Update structures in ' + systemNameStr + ' ? This is not your current location, "' + currentLocationData.name + '" !';
bootbox.confirm(msg, result => {
if(result){
saveStructureData(structureData, context);

View File

@@ -742,12 +742,12 @@ define([
let currentLocationData = Util.getCurrentLocationData();
if(
currentLocationData.id &&
currentLocationData.id !== systemData.id
currentLocationData.id !== systemData.systemId
){
let systemNameStr = (systemData.name === systemData.alias) ? '"' + systemData.name + '"' : '"' + systemData.alias + '" (' + systemData.name + ')';
systemNameStr = '<span class="txt-color txt-color-warning">' + systemNameStr + '</span>';
let msg = 'Update signatures in ' + systemNameStr + ' ? This not your current location, "' + currentLocationData.name + '" !';
let msg = 'Update signatures in ' + systemNameStr + ' ? This is not your current location, "' + currentLocationData.name + '" !';
bootbox.confirm(msg, function(result){
if(result){
saveSignatureData(signatureData);

View File

@@ -1568,13 +1568,17 @@ define([
let oldCharactersIds = (getObjVal(oldUserData, 'characters') || []).map(data => data.id).sort();
let newCharactersIds = (getObjVal(newUserData, 'characters') || []).map(data => data.id).sort();
let oldHistoryLogStamps = (getObjVal(oldUserData, 'character.logHistory') || []).map(data => data.stamp).sort();
let newHistoryLogStamps = (getObjVal(newUserData, 'character.logHistory') || []).map(data => data.stamp).sort();
return {
userId: valueChanged('id'),
characterId: valueChanged('character.id'),
characterLogLocation: valueChanged('character.logLocation'),
characterSystemId: valueChanged('character.log.system.id'),
characterShipType: valueChanged('character.log.ship.typeId'),
charactersIds: oldCharactersIds.toString() !== newCharactersIds.toString()
charactersIds: oldCharactersIds.toString() !== newCharactersIds.toString(),
characterLogHistory: oldHistoryLogStamps.toString() !== newHistoryLogStamps.toString()
};
};

View File

@@ -8,19 +8,19 @@
"main": "index.php",
"dependencies": {},
"devDependencies": {
"ansi-colors": "^3.2.4",
"ansi-colors": "^4.1.1",
"fancy-log": "^1.3.3",
"file-extension": "^4.0.5",
"flat": "^4.1.0",
"gulp": "next",
"gulp-brotli": "1.2.x",
"gulp": "^4.0.2",
"gulp-brotli": "^1.2.2",
"gulp-bytediff": "1.0.x",
"gulp-clean-css": "^4.0.0",
"gulp-clean-css": "^4.2.0",
"gulp-compass": "2.1.x",
"gulp-debug": "^4.0.0",
"gulp-filter": "5.1.x",
"gulp-filter": "^6.0.0",
"gulp-gzip": "1.x.x",
"gulp-if": "2.0.x",
"gulp-if": "^3.0.0",
"gulp-jshint": "2.1.x",
"gulp-rename": "^1.4.0",
"gulp-requirejs-optimize": "1.3.x",
@@ -30,9 +30,9 @@
"jshint-stylish": "^2.x.x",
"lodash.padend": "4.6.x",
"node-notifier": "^5.4.0",
"pretty-bytes": "^5.1.0",
"pretty-bytes": "^5.3.0",
"promised-del": "1.0.x",
"slash": "2.x.x",
"slash": "^3.0.0",
"terminal-table": "0.0.x",
"uglify-es": "^3.0.x"
},

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
<div id="{{id}}" class="alert alert-warning">
<div class="ui-pnotify-icon"><span class="fas fa-exclamation fa-fw fa-lg"></span></div>
<h4 class="ui-pnotify-title">Scheduled maintenance: Update v1.5.1 <i class="fas fa-long-arrow-alt-right"></i> v1.5.2; Shutdown: ~21:30 (UTC). ETA ~22:00 (UTC)</h4>
<h4 class="ui-pnotify-title">Scheduled maintenance: Update v1.5.2 <i class="fas fa-long-arrow-alt-right"></i> v1.5.3; Shutdown: ~13:00 (UTC). ETA ~13:30 (UTC)</h4>
</div>

View File

@@ -10,13 +10,13 @@
<div class="row">
<div class="col-sm-6">
<ul class="list-unstyled text-left">
<li><i class="fas fa-fw fa-angle-right"></i>New connection "size" flags for wormholes <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/568" rel="noopener">#568</a></li>
<li><i class="fas fa-fw fa-angle-right"></i>New "jump history" breadcrumb added to header <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/812" rel="noopener">#812</a></li>
<li><i class="fas fa-fw fa-angle-right"></i>Fixed duplicated wormhole jump logs <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/822" rel="noopener">#822</a></li>
<li><i class="fas fa-fw fa-angle-right"></i>Fixed issue where systems can not be delete <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/820" rel="noopener">#820</a></li>
</ul>
</div>
<div class="col-sm-6">
<ul class="list-unstyled text-left">
<li><i class="fas fa-fw fa-angle-right"></i>New map "zoom" and map "move" options <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/791" rel="noopener">#791</a></li>
<li><i class="fas fa-fw fa-angle-right"></i>Fixed "empty system body" shows <a target="_blank" href="//github.com/exodus4d/pathfinder/issues/823" rel="noopener">#823</a></li>
<li><i class="fas fa-fw fa-angle-double-right"></i>Many more improvements/fixes. Complete <a href="javascript:void(0)" class="pf-navbar-version-info">changelog</a></li>
</ul>
</div>