- Fixed some _PHP_ autoloading issues

This commit is contained in:
Mark Friedrich
2019-12-20 14:16:55 +01:00
parent ce62ed0f2d
commit c91bcbe246
14 changed files with 1015 additions and 954 deletions

View File

@@ -9,8 +9,9 @@
namespace Exodus4D\Pathfinder\Controller\Api;
use Exodus4D\Pathfinder\Lib\Config;
use Exodus4D\Pathfinder\Controller;
use Exodus4D\Pathfinder\Lib\Cron;
use Exodus4D\Pathfinder\Lib\Format\Number;
use Exodus4D\Pathfinder\Controller;
use Exodus4D\Pathfinder\Model;
class Setup extends Controller\Controller {
@@ -91,7 +92,7 @@ class Setup extends Controller\Controller {
],
'tplCounter' => $this->counter(),
'tplConvertBytes' => function(){
return call_user_func_array([\lib\format\Number::instance(), 'bytesToString'], func_get_args());
return call_user_func_array([Number::instance(), 'bytesToString'], func_get_args());
}
];
return \Template::instance()->render('templates/ui/cron_table_row.html', null, $tplData, 0);

View File

@@ -15,6 +15,7 @@ use Exodus4D\Pathfinder\Lib\Db\Sql;
use Exodus4D\Pathfinder\Lib\Config;
use Exodus4D\Pathfinder\Lib\Cron;
use Exodus4D\Pathfinder\Lib\Util;
use Exodus4D\Pathfinder\Lib\Format\Number;
use Exodus4D\Pathfinder\Model\Pathfinder;
use Exodus4D\Pathfinder\Model\Universe;
use Exodus4D\Pathfinder\Controller\Ccp\Universe as UniverseController;
@@ -174,7 +175,7 @@ class Setup extends Controller {
$f3->set('tplCounter', $this->counter());
$f3->set('tplConvertBytes', function(){
return call_user_func_array([\lib\format\Number::instance(), 'bytesToString'], func_get_args());
return call_user_func_array([Number::instance(), 'bytesToString'], func_get_args());
});
// render view
@@ -754,20 +755,20 @@ class Setup extends Controller {
],
'maxMemory' => [
'label' => 'maxmemory',
'required' => \lib\format\Number::instance()->bytesToString($f3->get('REQUIREMENTS.REDIS.MAX_MEMORY')),
'version' => \lib\format\Number::instance()->bytesToString($redisMemoryInfo['maxmemory']),
'required' => Number::instance()->bytesToString($f3->get('REQUIREMENTS.REDIS.MAX_MEMORY')),
'version' => Number::instance()->bytesToString($redisMemoryInfo['maxmemory']),
'check' => $redisMemoryInfo['maxmemory'] >= $f3->get('REQUIREMENTS.REDIS.MAX_MEMORY'),
'tooltip' => 'Max memory limit for Redis'
],
'usedMemory' => [
'label' => 'used_memory',
'version' => \lib\format\Number::instance()->bytesToString($redisMemoryInfo['used_memory']),
'version' => Number::instance()->bytesToString($redisMemoryInfo['used_memory']),
'check' => $redisMemoryInfo['used_memory'] < $redisMemoryInfo['maxmemory'],
'tooltip' => 'Current memory used by Redis'
],
'usedMemoryPeak' => [
'label' => 'used_memory_peak',
'version' => \lib\format\Number::instance()->bytesToString($redisMemoryInfo['used_memory_peak']),
'version' => Number::instance()->bytesToString($redisMemoryInfo['used_memory_peak']),
'check' => $redisMemoryInfo['used_memory_peak'] <= $redisMemoryInfo['maxmemory'],
'tooltip' => 'Peak memory used by Redis'
],
@@ -1125,7 +1126,7 @@ class Setup extends Controller {
// get table data from model
foreach($dbData['models'] as $model){
$tableConfig = call_user_func($model . '::resolveConfiguration');
$tableConfig = call_user_func(Config::withNamespace($model) . '::resolveConfiguration');
$requiredTables[$tableConfig['table']] = [
'model' => $model,
'name' => $tableConfig['table'],
@@ -1221,7 +1222,7 @@ class Setup extends Controller {
$currentColType = $currentColumns[$columnName]['type'];
$currentNullable = $currentColumns[$columnName]['nullable'];
$hasNullable = $currentNullable ? '1' : '0';
$currentColIndexData = call_user_func($data['model'] . '::indexExists', [$columnName]);
$currentColIndexData = call_user_func(Config::withNamespace($data['model']) . '::indexExists', [$columnName]);
$currentColIndex = is_array($currentColIndexData);
$hasIndex = ($currentColIndex) ? '1' : '0';
$hasUnique = ($currentColIndexData['unique']) ? '1' : '0';
@@ -1938,7 +1939,7 @@ class Setup extends Controller {
}
$bytesAll += $bytes;
$dirAll[$key]['size'] = ($maxHit ? '>' : '') . \lib\format\Number::instance()->bytesToString($bytes);
$dirAll[$key]['size'] = ($maxHit ? '>' : '') . Number::instance()->bytesToString($bytes);
$dirAll[$key]['task'] = [
[
'action' => http_build_query([
@@ -1953,7 +1954,7 @@ class Setup extends Controller {
}
return [
'sizeAll' => ($maxHitAll ? '>' : '') . \lib\format\Number::instance()->bytesToString($bytesAll),
'sizeAll' => ($maxHitAll ? '>' : '') . Number::instance()->bytesToString($bytesAll),
'dirAll' => $dirAll
];
}

View File

@@ -8,6 +8,7 @@
namespace Exodus4D\Pathfinder\Cron;
use Exodus4D\Pathfinder\Lib\Format\Number;
use Exodus4D\Pathfinder\Model\Pathfinder;
abstract class AbstractCron {
@@ -201,7 +202,7 @@ abstract class AbstractCron {
$text = sprintf(self::LOG_TEXT_BASE,
$state['count'], $state['importCount'], $percent, $state['total'],
\lib\format\Number::instance()->bytesToString($memPeak), $duration
Number::instance()->bytesToString($memPeak), $duration
);
$text .= $logText ? $logText: '';

View File

@@ -569,7 +569,7 @@ class Config extends \Prefab {
if($matches = (bool)preg_match('/^(\w+)\h*=\h*(.+)/', strtolower(trim($dsn)), $parts)){
$conf['type'] = $parts[1];
if($conf['type'] == 'redis'){
list($conf['host'], $conf['port'], $conf['db']) = explode(':', $parts[2]) + [1 => 6379, 2 => null];
[$conf['host'], $conf['port'], $conf['db']] = explode(':', $parts[2]) + [1 => 6379, 2 => null];
}elseif($conf['type'] == 'folder'){
$conf['folder'] = $parts[2];
}
@@ -641,6 +641,11 @@ class Config extends \Prefab {
return $format;
}
/**
* @param $fromExists
* @param int $ttlMax
* @return int
*/
static function ttlLeft($fromExists, int $ttlMax) : int {
$ttlMax = max($ttlMax, 0);
if($fromExists){
@@ -655,4 +660,16 @@ class Config extends \Prefab {
return $ttlMax;
}
}
/**
* @param string|null $class
* @return string
*/
static function withNamespace(?string $class) : string {
$path = [\Base::instance()->get('NAMESPACE')];
if($class){
$path[] = $class;
}
return implode('\\', $path);
}
}

View File

@@ -1,7 +1,7 @@
<?php
namespace lib\format;
namespace Exodus4D\Pathfinder\Lib\Format;
class Number extends \Prefab {

View File

@@ -85,8 +85,8 @@ API_CACHE = {{@CACHE}}
SESSION_CACHE = mysql
; Callback functions ==============================================================================
ONERROR = Exodus4D\Pathfinder\Controller\Controller->showError
UNLOAD = Exodus4D\Pathfinder\Controller\Controller->unload
ONERROR = {{ @NAMESPACE }}\Controller\Controller->showError
UNLOAD = {{ @NAMESPACE }}\Controller\Controller->unload
; Path configurations =============================================================================
; All path configurations are relative to BASE dir and should NOT be changed

View File

@@ -25,48 +25,48 @@ downtime = 0 11 * * *
[CRON.jobs]
; delete EOL connections
deleteEolConnections = Cron\MapUpdate->deleteEolConnections, @fiveMinutes
deleteEolConnections = {{ @NAMESPACE }}\Cron\MapUpdate->deleteEolConnections, @fiveMinutes
; delete expired wh connections
deleteExpiredConnections = Cron\MapUpdate->deleteExpiredConnections, @hourly
deleteExpiredConnections = {{ @NAMESPACE }}\Cron\MapUpdate->deleteExpiredConnections, @hourly
; delete character log data
deleteLogData = Cron\CharacterUpdate->deleteLogData, @instant
deleteLogData = {{ @NAMESPACE }}\Cron\CharacterUpdate->deleteLogData, @instant
; delete expired signatures
deleteSignatures = Cron\MapUpdate->deleteSignatures, @halfHour
deleteSignatures = {{ @NAMESPACE }}\Cron\MapUpdate->deleteSignatures, @halfHour
; import system data (jump, kill,..) from CCP API
importSystemData = Cron\CcpSystemsUpdate->importSystemData, @halfPastHour
importSystemData = {{ @NAMESPACE }}\Cron\CcpSystemsUpdate->importSystemData, @halfPastHour
; disable outdated maps
deactivateMapData = Cron\MapUpdate->deactivateMapData, @hourly
deactivateMapData = {{ @NAMESPACE }}\Cron\MapUpdate->deactivateMapData, @hourly
; clean up character data (kick, ban,..)
cleanUpCharacterData = Cron\CharacterUpdate->cleanUpCharacterData, @hourly
cleanUpCharacterData = {{ @NAMESPACE }}\Cron\CharacterUpdate->cleanUpCharacterData, @hourly
; delete disabled maps
deleteMapData = Cron\MapUpdate->deleteMapData, @downtime
deleteMapData = {{ @NAMESPACE }}\Cron\MapUpdate->deleteMapData, @downtime
; delete expired character cookie authentication data
deleteAuthenticationData = Cron\CharacterUpdate->deleteAuthenticationData, @downtime
deleteAuthenticationData = {{ @NAMESPACE }}\Cron\CharacterUpdate->deleteAuthenticationData, @downtime
; delete expired cache files
deleteExpiredCacheData = Cron\Cache->deleteExpiredCacheData, @downtime
deleteExpiredCacheData = {{ @NAMESPACE }}\Cron\Cache->deleteExpiredCacheData, @downtime
; delete old statistics (activity log) data
deleteStatisticsData = Cron\StatisticsUpdate->deleteStatisticsData, @weekly
deleteStatisticsData = {{ @NAMESPACE }}\Cron\StatisticsUpdate->deleteStatisticsData, @weekly
; truncate map history log files
truncateMapHistoryLogFiles = Cron\MapHistory->truncateMapHistoryLogFiles, @halfHour
truncateMapHistoryLogFiles = {{ @NAMESPACE }}\Cron\MapHistory->truncateMapHistoryLogFiles, @halfHour
; sync "sovereignty" and "faction warfare" data from CCP´s ESI API
updateSovereigntyData = Cron\Universe->updateSovereigntyData, @halfPastHour
updateSovereigntyData = {{ @NAMESPACE }}\Cron\Universe->updateSovereigntyData, @halfPastHour
; sync static system data from CCP´s ESI API
; -> Job is WIP!
;updateUniverseSystems = Cron\Universe->updateUniverseSystems, @instant
;updateUniverseSystems = {{ @NAMESPACE }}\Cron\Universe->updateUniverseSystems, @instant
; bootstrap job for "eve_universe" DB from CCP´s ESI API
; -> Only for development! This job is used to build the initial export/sql/eve_universe.sql
;setup = Cron\Universe->setup, @instant
;setup = {{ @NAMESPACE }}\Cron\Universe->setup, @instant

View File

@@ -3,25 +3,25 @@
[routes]
; DB setup setup
; IMPORTANT: remove/comment this line after setup/update is finished!
GET @setup: /setup [sync] = Exodus4D\Pathfinder\Controller\Setup->init
GET @setup: /setup [sync] = {{ @NAMESPACE }}\Controller\Setup->init
; login (index) page
GET @login: / [sync] = Exodus4D\Pathfinder\Controller\AppController->init
GET @login: / [sync] = {{ @NAMESPACE }}\Controller\AppController->init
; CCP SSO redirect
GET @sso: /sso/@action [sync] = Exodus4D\Pathfinder\Controller\Ccp\Sso->@action
GET @sso: /sso/@action [sync] = {{ @NAMESPACE }}\Controller\Ccp\Sso->@action
; map page
GET @map: /map* [sync] = Exodus4D\Pathfinder\Controller\MapController->init
GET @map: /map* [sync] = {{ @NAMESPACE }}\Controller\MapController->init
; admin panel
GET @admin: /admin* [sync] = Exodus4D\Pathfinder\Controller\Admin->dispatch
GET @admin: /admin* [sync] = {{ @NAMESPACE }}\Controller\Admin->dispatch
; AJAX API wildcard endpoints (not cached, throttled)
GET|POST /api/@controller/@action [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1 [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = Exodus4D\Pathfinder\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1 [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
; onUnload route or final map sync (@see https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon)
POST /api/map/updateUnloadData = Exodus4D\Pathfinder\Controller\Api\map->updateUnloadData, 0, 512
POST /api/map/updateUnloadData = {{ @NAMESPACE }}\Controller\Api\map->updateUnloadData, 0, 512
[maps]
; REST API wildcard endpoints (not cached, throttled)
/api/rest/@controller* [ajax] = Exodus4D\Pathfinder\Controller\Api\Rest\@controller, 0, 512
/api/rest/@controller/@id [ajax] = Exodus4D\Pathfinder\Controller\Api\Rest\@controller, 0, 512
/api/rest/@controller* [ajax] = {{ @NAMESPACE }}\Controller\Api\Rest\@controller, 0, 512
/api/rest/@controller/@id [ajax] = {{ @NAMESPACE }}\Controller\Api\Rest\@controller, 0, 512

View File

@@ -11,6 +11,7 @@ if(file_exists($composerAutoloader)){
}
$f3 = \Base::instance();
$f3->set('NAMESPACE', __NAMESPACE__);
// load main config
$f3->config('app/config.ini', true);

View File

@@ -202,315 +202,322 @@ define([
* @param mapData
*/
$.fn.initSystemInfoTable = function(mapData){
let systemsElement = $(this).empty();
let tableApi = Util.getDataTableInstance(config.tableId, mapData.config.id, '', 'systems');
let systemTable = $('<table>', {
id: Util.getTableId(config.tableId, 'systems', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
systemsElement.append(systemTable);
if(tableApi){
tableApi.clear();
tableApi.rows.add(mapData.data.systems);
tableApi.draw();
}else{
let systemsElement = $(this);
systemsElement.showLoadingAnimation(config.loadingOptions);
let systemTable = $('<table>', {
id: Util.getTableId(config.tableId, 'systems', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
systemsElement.append(systemTable);
systemTable.on('init.dt', function(){
systemsElement.hideLoadingAnimation();
systemsElement.showLoadingAnimation(config.loadingOptions);
// init table tooltips
let tooltipElements = systemsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
systemTable.on('init.dt', function(){
systemsElement.hideLoadingAnimation();
let systemsDataTable = systemTable.DataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [15, 'desc'],
hover: false,
data: mapData.data.systems,
columnDefs: [],
language: {
emptyTable: 'Map is empty',
zeroRecords: 'No systems found',
lengthMenu: 'Show _MENU_ systems',
info: 'Showing _START_ to _END_ of _TOTAL_ systems'
},
columns: [
{
name: 'type',
title: 'type',
width: 25,
className: ['min-screen-l'].join(' '),
data: 'type',
render: {
_: (cellData, type, rowData, meta) => {
return MapUtil.getSystemTypeInfo(cellData.id, 'name');
}
}
},{
name: 'security',
title: '',
width: 1,
data: 'security',
render: {
display: (cellData, type, rowData, meta) => {
let securityClass = Util.getSecurityClassForSystem(cellData);
return '<span class="' + securityClass + '">' + cellData + '</span>';
}
}
},{
name: 'trueSec',
title: 'sec',
width: 18,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'trueSec',
render: {
display: (cellData, type, rowData, meta) => {
let systemTrueSecClass = Util.getTrueSecClassForSystem(cellData);
return '<span class="' + systemTrueSecClass + '">' + cellData.toFixed(1) + '</span>';
}
}
},{
name: 'shattered',
title: '<i class="fas fa-chart-pie" title="shattered" data-toggle="tooltip"></i>',
width: 10,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'shattered',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '<i class="fas fa-chart-pie fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>';
// init table tooltips
let tooltipElements = systemsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
let systemsDataTable = systemTable.DataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [15, 'desc'],
hover: false,
data: mapData.data.systems,
columnDefs: [],
language: {
emptyTable: 'Map is empty',
zeroRecords: 'No systems found',
lengthMenu: 'Show _MENU_ systems',
info: 'Showing _START_ to _END_ of _TOTAL_ systems'
},
columns: [
{
name: 'type',
title: 'type',
width: 25,
className: ['min-screen-l'].join(' '),
data: 'type',
render: {
_: (cellData, type, rowData, meta) => {
return MapUtil.getSystemTypeInfo(cellData.id, 'name');
}
return value;
}
}
},{
name: 'name',
title: 'system',
data: 'name',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.id});
});
}
},{
name: 'alias',
title: 'alias',
data: 'alias',
render: {
_: (cellData, type, rowData, meta) => {
return (cellData === rowData.name) ? '' : cellData;
}
}
},{
name: 'region',
title: 'region',
data: 'region.name',
className: 'min-screen-l',
},{
name: 'sovereignty',
title: 'sov.',
width: 30,
className: 'text-center',
data: 'sovereignty.alliance.ticker',
defaultContent: '',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '&lt;' + cellData + '&gt;';
},{
name: 'security',
title: '',
width: 1,
data: 'security',
render: {
display: (cellData, type, rowData, meta) => {
let securityClass = Util.getSecurityClassForSystem(cellData);
return '<span class="' + securityClass + '">' + cellData + '</span>';
}
return value;
}
}
},{
name: 'planets',
title: '<i class="fas fa-circle" title="planets" data-toggle="tooltip"></i>',
width: 10,
className: ['text-right', config.systemInfoPlanetsClass, Util.config.helpDefaultClass, Util.config.popoverTriggerClass].join(' '),
searchable: false,
orderSequence: ['desc', 'asc'],
data: 'planets',
render: {
_: (cellData, type, rowData, meta) => {
return cellData.length;
}
}
},{
name: 'status',
title: '<i class="far fa-square" title="system&nbsp;status" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'status.id',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemStatusClass = Util.getStatusInfoForSystem(cellData, 'class');
if(systemStatusClass !== ''){
value = '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>';
},{
name: 'trueSec',
title: 'sec',
width: 18,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'trueSec',
render: {
display: (cellData, type, rowData, meta) => {
let systemTrueSecClass = Util.getTrueSecClassForSystem(cellData);
return '<span class="' + systemTrueSecClass + '">' + cellData.toFixed(1) + '</span>';
}
return value;
}
}
},{
name: 'effect',
title: '<i class="fas fa-square" title="system&nbsp;effect" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'effect',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemEffectClass = MapUtil.getEffectInfoForSystem(cellData, 'class');
if(systemEffectClass !== ''){
value = '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>';
}
return value;
}
}
},{
name: 'statics',
title: 'statics',
width: 30,
searchable: false,
data: 'statics',
render: {
_: (cellData, type, rowData, meta) => {
let statics = [];
for(let wormholeName of cellData){
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
statics.push('<span class="' + wormholeData.class + '">' + wormholeData.security + '</span>');
}
return statics.join('&nbsp;&nbsp;');
}
}
},{
name: 'position',
title: '<i class="fas fa-map-marker-alt" title="your&nbsp;position" data-toggle="tooltip"></i>',
width: 8,
className: 'text-center',
searchable: false,
data: 'currentUser',
defaultContent: false,
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === true){
value = '<i class="fas fa-map-marker-alt fa-fw"></i>';
}
return value;
}
}
},{
name: 'userCount',
title: '<i class="fas fa-plane" title="active&nbsp;pilots" data-toggle="tooltip"></i>',
width: 12,
className: 'text-center',
searchable: false,
data: 'userCount',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData > 0){
value = cellData;
}
return value;
}
}
},{
name: 'locked',
title: '<i class="fas fa-lock" title="system&nbsp;locked" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'locked',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === 1){
value = '<i class="fas fa-lock fa-fw"></i>';
}
return value;
}
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated.updated',
defaultContent: '',
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
let confirmationSettings = {
placement: 'left',
title: 'Delete system',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
let activeMap = Util.getMapModule().getActiveMap();
let systemElement = $('#' + MapUtil.getSystemId(mapData.config.id, rowData.id) );
if(systemElement.length){
// trigger system delete event
activeMap.trigger('pf:deleteSystems', [{
systems: [systemElement[0]],
callback: function(deletedSystems){
// callback function after ajax "delete" success
// check if system was deleted
if(deletedSystems.length === 1){
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
// refresh connection table (connections might have changed) --------------
let connectionsElement = $('#' + config.mapInfoConnectionsId);
let mapDataNew = activeMap.getMapDataFromClient(['hasId']);
connectionsElement.initConnectionInfoTable(mapDataNew);
}else{
// error
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
}
}
}]);
},{
name: 'shattered',
title: '<i class="fas fa-chart-pie" title="shattered" data-toggle="tooltip"></i>',
width: 10,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'shattered',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '<i class="fas fa-chart-pie fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>';
}
return value;
}
};
}
},{
name: 'name',
title: 'system',
data: 'name',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.id});
});
}
},{
name: 'alias',
title: 'alias',
data: 'alias',
render: {
_: (cellData, type, rowData, meta) => {
return (cellData === rowData.name) ? '' : cellData;
}
}
},{
name: 'region',
title: 'region',
data: 'region.name',
className: 'min-screen-l',
},{
name: 'sovereignty',
title: 'sov.',
width: 30,
className: 'text-center',
data: 'sovereignty.alliance.ticker',
defaultContent: '',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '&lt;' + cellData + '&gt;';
}
return value;
}
}
},{
name: 'planets',
title: '<i class="fas fa-circle" title="planets" data-toggle="tooltip"></i>',
width: 10,
className: ['text-right', config.systemInfoPlanetsClass, Util.config.helpDefaultClass, Util.config.popoverTriggerClass].join(' '),
searchable: false,
orderSequence: ['desc', 'asc'],
data: 'planets',
render: {
_: (cellData, type, rowData, meta) => {
return cellData.length;
}
}
},{
name: 'status',
title: '<i class="far fa-square" title="system&nbsp;status" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'status.id',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemStatusClass = Util.getStatusInfoForSystem(cellData, 'class');
if(systemStatusClass !== ''){
value = '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>';
}
return value;
}
}
},{
name: 'effect',
title: '<i class="fas fa-square" title="system&nbsp;effect" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'effect',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemEffectClass = MapUtil.getEffectInfoForSystem(cellData, 'class');
if(systemEffectClass !== ''){
value = '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>';
}
return value;
}
}
},{
name: 'statics',
title: 'statics',
width: 30,
searchable: false,
data: 'statics',
render: {
_: (cellData, type, rowData, meta) => {
let statics = [];
for(let wormholeName of cellData){
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
statics.push('<span class="' + wormholeData.class + '">' + wormholeData.security + '</span>');
}
return statics.join('&nbsp;&nbsp;');
}
}
},{
name: 'position',
title: '<i class="fas fa-map-marker-alt" title="your&nbsp;position" data-toggle="tooltip"></i>',
width: 8,
className: 'text-center',
searchable: false,
data: 'currentUser',
defaultContent: false,
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === true){
value = '<i class="fas fa-map-marker-alt fa-fw"></i>';
}
return value;
}
}
},{
name: 'userCount',
title: '<i class="fas fa-plane" title="active&nbsp;pilots" data-toggle="tooltip"></i>',
width: 12,
className: 'text-center',
searchable: false,
data: 'userCount',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData > 0){
value = cellData;
}
return value;
}
}
},{
name: 'locked',
title: '<i class="fas fa-lock" title="system&nbsp;locked" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'locked',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === 1){
value = '<i class="fas fa-lock fa-fw"></i>';
}
return value;
}
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated.updated',
defaultContent: '',
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
let confirmationSettings = {
placement: 'left',
title: 'Delete system',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
let activeMap = Util.getMapModule().getActiveMap();
let systemElement = $('#' + MapUtil.getSystemId(mapData.config.id, rowData.id) );
if(systemElement.length){
// trigger system delete event
activeMap.trigger('pf:deleteSystems', [{
systems: [systemElement[0]],
callback: function(deletedSystems){
// callback function after ajax "delete" success
// check if system was deleted
if(deletedSystems.length === 1){
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
// refresh connection table (connections might have changed) --------------
let connectionsElement = $('#' + config.mapInfoConnectionsId);
let mapDataNew = activeMap.getMapDataFromClient(['hasId']);
connectionsElement.initConnectionInfoTable(mapDataNew);
}else{
// error
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
}
}
}]);
}
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
}
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
});
});
}
};
/**
@@ -518,179 +525,188 @@ define([
* @param mapData
*/
$.fn.initConnectionInfoTable = function(mapData){
let connectionsElement = $(this).empty();
let tableApi = Util.getDataTableInstance(config.tableId, mapData.config.id, '', 'connections');
let connectionTable = $('<table>', {
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
connectionsElement.append(connectionTable);
if(tableApi){
tableApi.clear();
tableApi.rows.add(mapData.data.connections);
tableApi.draw();
}else{
let connectionsElement = $(this);
connectionsElement.showLoadingAnimation(config.loadingOptions);
let connectionTable = $('<table>', {
id: Util.getTableId(config.tableId, 'connections', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
connectionsElement.append(connectionTable);
// table init complete
connectionTable.on('init.dt', function(){
connectionsElement.hideLoadingAnimation();
connectionsElement.showLoadingAnimation(config.loadingOptions);
// init table tooltips
let tooltipElements = connectionsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
// table init complete
connectionTable.on('init.dt', function(){
connectionsElement.hideLoadingAnimation();
// connections table ------------------------------------------------------------------------------------------
let connectionDataTable = connectionTable.dataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [ 6, 'desc' ],
autoWidth: false,
hover: false,
data: mapData.data.connections,
columnDefs: [],
language: {
emptyTable: 'No connections',
zeroRecords: 'No connections found',
lengthMenu: 'Show _MENU_ connections',
info: 'Showing _START_ to _END_ of _TOTAL_ connections'
},
columns: [
{
name: 'scope',
title: 'scope',
width: 50,
orderable: true,
data: 'scope',
render: {
display: (cellData, type, rowData, meta) => {
return MapUtil.getScopeInfoForConnection(cellData, 'label');
}
}
},{
name: 'sourceName',
title: 'source system',
data: 'sourceName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.source});
});
}
},{
name: 'sourceBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.source',
className: 'text-right',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'connection',
title: 'connection',
width: 80,
className: 'text-center',
orderable: false,
searchable: false,
data: 'type',
render: {
display: (cellData, type, rowData, meta) => {
let connectionClasses = MapUtil.getConnectionFakeClassesByTypes(cellData);
connectionClasses = connectionClasses.join(' ');
return '<div class="' + connectionClasses + '"></div>';
}
}
},{
name: 'targetBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.target',
className: 'text-left',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'targetName',
title: 'target system',
data: 'targetName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.target});
});
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
if(rowData.scope.scope_sort === 'wh'){
// highlight cell
let diff = new Date().getTime() - cellData * 1000;
let dateDiff = new Date(diff);
if(dateDiff.getUTCDate() > 1){
$(cell).addClass('txt-color txt-color-warning');
// init table tooltips
let tooltipElements = connectionsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
// connections table ------------------------------------------------------------------------------------------
let connectionDataTable = connectionTable.dataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [ 6, 'desc' ],
autoWidth: false,
hover: false,
data: mapData.data.connections,
columnDefs: [],
language: {
emptyTable: 'No connections',
zeroRecords: 'No connections found',
lengthMenu: 'Show _MENU_ connections',
info: 'Showing _START_ to _END_ of _TOTAL_ connections'
},
columns: [
{
name: 'scope',
title: 'scope',
width: 50,
orderable: true,
data: 'scope',
render: {
display: (cellData, type, rowData, meta) => {
return MapUtil.getScopeInfoForConnection(cellData, 'label');
}
}
}
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
let confirmationSettings = {
placement: 'left',
title: 'Delete connection',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
// deleteSignatures(row);
let connection = $().getConnectionById(mapData.config.id, rowData.id);
MapUtil.deleteConnections([connection], () => {
// callback function after ajax "delete" success
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
});
},{
name: 'sourceName',
title: 'source system',
data: 'sourceName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.source});
});
}
},{
name: 'sourceBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.source',
className: 'text-right',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
};
}
},{
name: 'connection',
title: 'connection',
width: 80,
className: 'text-center',
orderable: false,
searchable: false,
data: 'type',
render: {
display: (cellData, type, rowData, meta) => {
let connectionClasses = MapUtil.getConnectionFakeClassesByTypes(cellData);
connectionClasses = connectionClasses.join(' ');
return '<div class="' + connectionClasses + '"></div>';
}
}
},{
name: 'targetBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.target',
className: 'text-left',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'targetName',
title: 'target system',
data: 'targetName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.target});
});
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
if(rowData.scope.scope_sort === 'wh'){
// highlight cell
let diff = new Date().getTime() - cellData * 1000;
let dateDiff = new Date(diff);
if(dateDiff.getUTCDate() > 1){
$(cell).addClass('txt-color txt-color-warning');
}
}
}
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
let confirmationSettings = {
placement: 'left',
title: 'Delete connection',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
// deleteSignatures(row);
let connection = $().getConnectionById(mapData.config.id, rowData.id);
MapUtil.deleteConnections([connection], () => {
// callback function after ajax "delete" success
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
});
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
}
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
});
});
}
};
/**

View File

@@ -22,11 +22,13 @@ define([
dialogMapDownloadContainerId: 'pf-map-dialog-download', // id for the "download" container
// new map form
newNameInputId: 'pf-map-dialog-new-name-input', // id for "name" input
newIconSelectId: 'pf-map-dialog-new-icon-select', // id for "icon" select
newScopeSelectId: 'pf-map-dialog-new-scope-select', // id for "scope" select
newTypeSelectId: 'pf-map-dialog-new-type-select', // id for "type" select
// edit map form
editNameInputId: 'pf-map-dialog-edit-name-input', // id for "name" input
editIconSelectId: 'pf-map-dialog-edit-icon-select', // id for "icon" select
editScopeSelectId: 'pf-map-dialog-edit-scope-select', // id for "scope" select
editTypeSelectId: 'pf-map-dialog-edit-type-select', // id for "type" select
@@ -136,6 +138,7 @@ define([
// render "new map" tab content -----------------------------------------------------------------------
let mapFormDataNew = $.extend({}, mapFormData, {
hasRightMapForm: hasRightMapCreate,
nameInputId: config.newNameInputId,
iconSelectId: config.newIconSelectId,
scopeSelectId: config.newScopeSelectId,
typeSelectId: config.newTypeSelectId
@@ -145,6 +148,7 @@ define([
// render "edit map" tab content ----------------------------------------------------------------------
let mapFormDataEdit = $.extend({}, mapFormData, {
hasRightMapForm: hasRightMapUpdate,
nameInputId: config.editNameInputId,
iconSelectId: config.editIconSelectId,
scopeSelectId: config.editScopeSelectId,
typeSelectId: config.editTypeSelectId

View File

@@ -202,315 +202,322 @@ define([
* @param mapData
*/
$.fn.initSystemInfoTable = function(mapData){
let systemsElement = $(this).empty();
let tableApi = Util.getDataTableInstance(config.tableId, mapData.config.id, '', 'systems');
let systemTable = $('<table>', {
id: Util.getTableId(config.tableId, 'systems', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
systemsElement.append(systemTable);
if(tableApi){
tableApi.clear();
tableApi.rows.add(mapData.data.systems);
tableApi.draw();
}else{
let systemsElement = $(this);
systemsElement.showLoadingAnimation(config.loadingOptions);
let systemTable = $('<table>', {
id: Util.getTableId(config.tableId, 'systems', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
systemsElement.append(systemTable);
systemTable.on('init.dt', function(){
systemsElement.hideLoadingAnimation();
systemsElement.showLoadingAnimation(config.loadingOptions);
// init table tooltips
let tooltipElements = systemsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
systemTable.on('init.dt', function(){
systemsElement.hideLoadingAnimation();
let systemsDataTable = systemTable.DataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [15, 'desc'],
hover: false,
data: mapData.data.systems,
columnDefs: [],
language: {
emptyTable: 'Map is empty',
zeroRecords: 'No systems found',
lengthMenu: 'Show _MENU_ systems',
info: 'Showing _START_ to _END_ of _TOTAL_ systems'
},
columns: [
{
name: 'type',
title: 'type',
width: 25,
className: ['min-screen-l'].join(' '),
data: 'type',
render: {
_: (cellData, type, rowData, meta) => {
return MapUtil.getSystemTypeInfo(cellData.id, 'name');
}
}
},{
name: 'security',
title: '',
width: 1,
data: 'security',
render: {
display: (cellData, type, rowData, meta) => {
let securityClass = Util.getSecurityClassForSystem(cellData);
return '<span class="' + securityClass + '">' + cellData + '</span>';
}
}
},{
name: 'trueSec',
title: 'sec',
width: 18,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'trueSec',
render: {
display: (cellData, type, rowData, meta) => {
let systemTrueSecClass = Util.getTrueSecClassForSystem(cellData);
return '<span class="' + systemTrueSecClass + '">' + cellData.toFixed(1) + '</span>';
}
}
},{
name: 'shattered',
title: '<i class="fas fa-chart-pie" title="shattered" data-toggle="tooltip"></i>',
width: 10,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'shattered',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '<i class="fas fa-chart-pie fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>';
// init table tooltips
let tooltipElements = systemsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
let systemsDataTable = systemTable.DataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [15, 'desc'],
hover: false,
data: mapData.data.systems,
columnDefs: [],
language: {
emptyTable: 'Map is empty',
zeroRecords: 'No systems found',
lengthMenu: 'Show _MENU_ systems',
info: 'Showing _START_ to _END_ of _TOTAL_ systems'
},
columns: [
{
name: 'type',
title: 'type',
width: 25,
className: ['min-screen-l'].join(' '),
data: 'type',
render: {
_: (cellData, type, rowData, meta) => {
return MapUtil.getSystemTypeInfo(cellData.id, 'name');
}
return value;
}
}
},{
name: 'name',
title: 'system',
data: 'name',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.id});
});
}
},{
name: 'alias',
title: 'alias',
data: 'alias',
render: {
_: (cellData, type, rowData, meta) => {
return (cellData === rowData.name) ? '' : cellData;
}
}
},{
name: 'region',
title: 'region',
data: 'region.name',
className: 'min-screen-l',
},{
name: 'sovereignty',
title: 'sov.',
width: 30,
className: 'text-center',
data: 'sovereignty.alliance.ticker',
defaultContent: '',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '&lt;' + cellData + '&gt;';
},{
name: 'security',
title: '',
width: 1,
data: 'security',
render: {
display: (cellData, type, rowData, meta) => {
let securityClass = Util.getSecurityClassForSystem(cellData);
return '<span class="' + securityClass + '">' + cellData + '</span>';
}
return value;
}
}
},{
name: 'planets',
title: '<i class="fas fa-circle" title="planets" data-toggle="tooltip"></i>',
width: 10,
className: ['text-right', config.systemInfoPlanetsClass, Util.config.helpDefaultClass, Util.config.popoverTriggerClass].join(' '),
searchable: false,
orderSequence: ['desc', 'asc'],
data: 'planets',
render: {
_: (cellData, type, rowData, meta) => {
return cellData.length;
}
}
},{
name: 'status',
title: '<i class="far fa-square" title="system&nbsp;status" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'status.id',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemStatusClass = Util.getStatusInfoForSystem(cellData, 'class');
if(systemStatusClass !== ''){
value = '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>';
},{
name: 'trueSec',
title: 'sec',
width: 18,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'trueSec',
render: {
display: (cellData, type, rowData, meta) => {
let systemTrueSecClass = Util.getTrueSecClassForSystem(cellData);
return '<span class="' + systemTrueSecClass + '">' + cellData.toFixed(1) + '</span>';
}
return value;
}
}
},{
name: 'effect',
title: '<i class="fas fa-square" title="system&nbsp;effect" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'effect',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemEffectClass = MapUtil.getEffectInfoForSystem(cellData, 'class');
if(systemEffectClass !== ''){
value = '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>';
}
return value;
}
}
},{
name: 'statics',
title: 'statics',
width: 30,
searchable: false,
data: 'statics',
render: {
_: (cellData, type, rowData, meta) => {
let statics = [];
for(let wormholeName of cellData){
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
statics.push('<span class="' + wormholeData.class + '">' + wormholeData.security + '</span>');
}
return statics.join('&nbsp;&nbsp;');
}
}
},{
name: 'position',
title: '<i class="fas fa-map-marker-alt" title="your&nbsp;position" data-toggle="tooltip"></i>',
width: 8,
className: 'text-center',
searchable: false,
data: 'currentUser',
defaultContent: false,
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === true){
value = '<i class="fas fa-map-marker-alt fa-fw"></i>';
}
return value;
}
}
},{
name: 'userCount',
title: '<i class="fas fa-plane" title="active&nbsp;pilots" data-toggle="tooltip"></i>',
width: 12,
className: 'text-center',
searchable: false,
data: 'userCount',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData > 0){
value = cellData;
}
return value;
}
}
},{
name: 'locked',
title: '<i class="fas fa-lock" title="system&nbsp;locked" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'locked',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === 1){
value = '<i class="fas fa-lock fa-fw"></i>';
}
return value;
}
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated.updated',
defaultContent: '',
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
let confirmationSettings = {
placement: 'left',
title: 'Delete system',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
let activeMap = Util.getMapModule().getActiveMap();
let systemElement = $('#' + MapUtil.getSystemId(mapData.config.id, rowData.id) );
if(systemElement.length){
// trigger system delete event
activeMap.trigger('pf:deleteSystems', [{
systems: [systemElement[0]],
callback: function(deletedSystems){
// callback function after ajax "delete" success
// check if system was deleted
if(deletedSystems.length === 1){
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
// refresh connection table (connections might have changed) --------------
let connectionsElement = $('#' + config.mapInfoConnectionsId);
let mapDataNew = activeMap.getMapDataFromClient(['hasId']);
connectionsElement.initConnectionInfoTable(mapDataNew);
}else{
// error
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
}
}
}]);
},{
name: 'shattered',
title: '<i class="fas fa-chart-pie" title="shattered" data-toggle="tooltip"></i>',
width: 10,
className: ['text-center', 'min-screen-l'].join(' '),
searchable: false,
data: 'shattered',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '<i class="fas fa-chart-pie fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>';
}
return value;
}
};
}
},{
name: 'name',
title: 'system',
data: 'name',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.id});
});
}
},{
name: 'alias',
title: 'alias',
data: 'alias',
render: {
_: (cellData, type, rowData, meta) => {
return (cellData === rowData.name) ? '' : cellData;
}
}
},{
name: 'region',
title: 'region',
data: 'region.name',
className: 'min-screen-l',
},{
name: 'sovereignty',
title: 'sov.',
width: 30,
className: 'text-center',
data: 'sovereignty.alliance.ticker',
defaultContent: '',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData){
value = '&lt;' + cellData + '&gt;';
}
return value;
}
}
},{
name: 'planets',
title: '<i class="fas fa-circle" title="planets" data-toggle="tooltip"></i>',
width: 10,
className: ['text-right', config.systemInfoPlanetsClass, Util.config.helpDefaultClass, Util.config.popoverTriggerClass].join(' '),
searchable: false,
orderSequence: ['desc', 'asc'],
data: 'planets',
render: {
_: (cellData, type, rowData, meta) => {
return cellData.length;
}
}
},{
name: 'status',
title: '<i class="far fa-square" title="system&nbsp;status" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'status.id',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemStatusClass = Util.getStatusInfoForSystem(cellData, 'class');
if(systemStatusClass !== ''){
value = '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>';
}
return value;
}
}
},{
name: 'effect',
title: '<i class="fas fa-square" title="system&nbsp;effect" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'effect',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
let systemEffectClass = MapUtil.getEffectInfoForSystem(cellData, 'class');
if(systemEffectClass !== ''){
value = '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>';
}
return value;
}
}
},{
name: 'statics',
title: 'statics',
width: 30,
searchable: false,
data: 'statics',
render: {
_: (cellData, type, rowData, meta) => {
let statics = [];
for(let wormholeName of cellData){
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
statics.push('<span class="' + wormholeData.class + '">' + wormholeData.security + '</span>');
}
return statics.join('&nbsp;&nbsp;');
}
}
},{
name: 'position',
title: '<i class="fas fa-map-marker-alt" title="your&nbsp;position" data-toggle="tooltip"></i>',
width: 8,
className: 'text-center',
searchable: false,
data: 'currentUser',
defaultContent: false,
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === true){
value = '<i class="fas fa-map-marker-alt fa-fw"></i>';
}
return value;
}
}
},{
name: 'userCount',
title: '<i class="fas fa-plane" title="active&nbsp;pilots" data-toggle="tooltip"></i>',
width: 12,
className: 'text-center',
searchable: false,
data: 'userCount',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData > 0){
value = cellData;
}
return value;
}
}
},{
name: 'locked',
title: '<i class="fas fa-lock" title="system&nbsp;locked" data-toggle="tooltip"></i>',
width: 10,
className: 'text-center',
searchable: false,
data: 'locked',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData === 1){
value = '<i class="fas fa-lock fa-fw"></i>';
}
return value;
}
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated.updated',
defaultContent: '',
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
let confirmationSettings = {
placement: 'left',
title: 'Delete system',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
let activeMap = Util.getMapModule().getActiveMap();
let systemElement = $('#' + MapUtil.getSystemId(mapData.config.id, rowData.id) );
if(systemElement.length){
// trigger system delete event
activeMap.trigger('pf:deleteSystems', [{
systems: [systemElement[0]],
callback: function(deletedSystems){
// callback function after ajax "delete" success
// check if system was deleted
if(deletedSystems.length === 1){
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
Util.showNotify({title: 'System deleted', text: rowData.name, type: 'success'});
// refresh connection table (connections might have changed) --------------
let connectionsElement = $('#' + config.mapInfoConnectionsId);
let mapDataNew = activeMap.getMapDataFromClient(['hasId']);
connectionsElement.initConnectionInfoTable(mapDataNew);
}else{
// error
Util.showNotify({title: 'Failed to delete system', text: rowData.name, type: 'error'});
}
}
}]);
}
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
}
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
});
});
}
};
/**
@@ -518,179 +525,188 @@ define([
* @param mapData
*/
$.fn.initConnectionInfoTable = function(mapData){
let connectionsElement = $(this).empty();
let tableApi = Util.getDataTableInstance(config.tableId, mapData.config.id, '', 'connections');
let connectionTable = $('<table>', {
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
connectionsElement.append(connectionTable);
if(tableApi){
tableApi.clear();
tableApi.rows.add(mapData.data.connections);
tableApi.draw();
}else{
let connectionsElement = $(this);
connectionsElement.showLoadingAnimation(config.loadingOptions);
let connectionTable = $('<table>', {
id: Util.getTableId(config.tableId, 'connections', mapData.config.id, ''),
class: ['compact', 'stripe', 'order-column', 'row-border'].join(' ')
});
connectionsElement.append(connectionTable);
// table init complete
connectionTable.on('init.dt', function(){
connectionsElement.hideLoadingAnimation();
connectionsElement.showLoadingAnimation(config.loadingOptions);
// init table tooltips
let tooltipElements = connectionsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
// table init complete
connectionTable.on('init.dt', function(){
connectionsElement.hideLoadingAnimation();
// connections table ------------------------------------------------------------------------------------------
let connectionDataTable = connectionTable.dataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [ 6, 'desc' ],
autoWidth: false,
hover: false,
data: mapData.data.connections,
columnDefs: [],
language: {
emptyTable: 'No connections',
zeroRecords: 'No connections found',
lengthMenu: 'Show _MENU_ connections',
info: 'Showing _START_ to _END_ of _TOTAL_ connections'
},
columns: [
{
name: 'scope',
title: 'scope',
width: 50,
orderable: true,
data: 'scope',
render: {
display: (cellData, type, rowData, meta) => {
return MapUtil.getScopeInfoForConnection(cellData, 'label');
}
}
},{
name: 'sourceName',
title: 'source system',
data: 'sourceName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.source});
});
}
},{
name: 'sourceBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.source',
className: 'text-right',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'connection',
title: 'connection',
width: 80,
className: 'text-center',
orderable: false,
searchable: false,
data: 'type',
render: {
display: (cellData, type, rowData, meta) => {
let connectionClasses = MapUtil.getConnectionFakeClassesByTypes(cellData);
connectionClasses = connectionClasses.join(' ');
return '<div class="' + connectionClasses + '"></div>';
}
}
},{
name: 'targetBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.target',
className: 'text-left',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'targetName',
title: 'target system',
data: 'targetName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.target});
});
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
if(rowData.scope.scope_sort === 'wh'){
// highlight cell
let diff = new Date().getTime() - cellData * 1000;
let dateDiff = new Date(diff);
if(dateDiff.getUTCDate() > 1){
$(cell).addClass('txt-color txt-color-warning');
// init table tooltips
let tooltipElements = connectionsElement.find('[data-toggle="tooltip"]');
tooltipElements.tooltip();
});
// connections table ------------------------------------------------------------------------------------------
let connectionDataTable = connectionTable.dataTable({
pageLength: 20,
paging: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'All']],
ordering: true,
order: [ 6, 'desc' ],
autoWidth: false,
hover: false,
data: mapData.data.connections,
columnDefs: [],
language: {
emptyTable: 'No connections',
zeroRecords: 'No connections found',
lengthMenu: 'Show _MENU_ connections',
info: 'Showing _START_ to _END_ of _TOTAL_ connections'
},
columns: [
{
name: 'scope',
title: 'scope',
width: 50,
orderable: true,
data: 'scope',
render: {
display: (cellData, type, rowData, meta) => {
return MapUtil.getScopeInfoForConnection(cellData, 'label');
}
}
}
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
let confirmationSettings = {
placement: 'left',
title: 'Delete connection',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
// deleteSignatures(row);
let connection = $().getConnectionById(mapData.config.id, rowData.id);
MapUtil.deleteConnections([connection], () => {
// callback function after ajax "delete" success
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
});
},{
name: 'sourceName',
title: 'source system',
data: 'sourceName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.source});
});
}
},{
name: 'sourceBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.source',
className: 'text-right',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
};
}
},{
name: 'connection',
title: 'connection',
width: 80,
className: 'text-center',
orderable: false,
searchable: false,
data: 'type',
render: {
display: (cellData, type, rowData, meta) => {
let connectionClasses = MapUtil.getConnectionFakeClassesByTypes(cellData);
connectionClasses = connectionClasses.join(' ');
return '<div class="' + connectionClasses + '"></div>';
}
}
},{
name: 'targetBubble',
title: '<i class="fas fa-globe" title="bubbled" data-toggle="tooltip"></i>',
width: 10,
data: 'endpoints.target',
className: 'text-left',
render: {
display: (cellData, type, rowData, meta) => {
let value = '';
if(cellData.types.includes('bubble')){
value = '<span class="pf-endpoint-bubble"></span>';
}
return value;
}
}
},{
name: 'targetName',
title: 'target system',
data: 'targetName',
className: [config.tableCellLinkClass].join(' '),
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
// select system
$(cell).on('click', function(e){
Util.triggerMenuAction(Util.getMapModule().getActiveMap(), 'SelectSystem', {systemId: rowData.target});
});
}
},{
name: 'updated',
title: 'updated',
width: 80,
searchable: false,
className: ['text-right', config.tableCellCounterClass].join(' '),
data: 'updated',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
if(rowData.scope.scope_sort === 'wh'){
// highlight cell
let diff = new Date().getTime() - cellData * 1000;
let dateDiff = new Date(diff);
if(dateDiff.getUTCDate() > 1){
$(cell).addClass('txt-color txt-color-warning');
}
}
}
},{
name: 'action',
title: '',
orderable: false,
searchable: false,
width: 10,
className: ['text-center', config.tableCellActionClass].join(' '),
data: null,
defaultContent: '<i class="fas fa-times txt-color txt-color-redDark"></i>',
createdCell: function(cell, cellData, rowData, rowIndex, colIndex){
let tempTableElement = this;
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
let confirmationSettings = {
placement: 'left',
title: 'Delete connection',
template: Util.getConfirmationTemplate(null, {
size: 'small',
noTitle: true
}),
onConfirm: function(e, target){
let deleteRowElement = $(target).parents('tr');
// deleteSignatures(row);
let connection = $().getConnectionById(mapData.config.id, rowData.id);
MapUtil.deleteConnections([connection], () => {
// callback function after ajax "delete" success
// remove table row
tempTableElement.DataTable().rows(deleteRowElement).remove().draw();
});
}
};
// init confirmation dialog
$(cell).confirmation(confirmationSettings);
}
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
],
initComplete: function(settings){
Counter.initTableCounter(this, ['updated:name']);
}
});
});
}
};
/**

View File

@@ -22,11 +22,13 @@ define([
dialogMapDownloadContainerId: 'pf-map-dialog-download', // id for the "download" container
// new map form
newNameInputId: 'pf-map-dialog-new-name-input', // id for "name" input
newIconSelectId: 'pf-map-dialog-new-icon-select', // id for "icon" select
newScopeSelectId: 'pf-map-dialog-new-scope-select', // id for "scope" select
newTypeSelectId: 'pf-map-dialog-new-type-select', // id for "type" select
// edit map form
editNameInputId: 'pf-map-dialog-edit-name-input', // id for "name" input
editIconSelectId: 'pf-map-dialog-edit-icon-select', // id for "icon" select
editScopeSelectId: 'pf-map-dialog-edit-scope-select', // id for "scope" select
editTypeSelectId: 'pf-map-dialog-edit-type-select', // id for "type" select
@@ -136,6 +138,7 @@ define([
// render "new map" tab content -----------------------------------------------------------------------
let mapFormDataNew = $.extend({}, mapFormData, {
hasRightMapForm: hasRightMapCreate,
nameInputId: config.newNameInputId,
iconSelectId: config.newIconSelectId,
scopeSelectId: config.newScopeSelectId,
typeSelectId: config.newTypeSelectId
@@ -145,6 +148,7 @@ define([
// render "edit map" tab content ----------------------------------------------------------------------
let mapFormDataEdit = $.extend({}, mapFormData, {
hasRightMapForm: hasRightMapUpdate,
nameInputId: config.editNameInputId,
iconSelectId: config.editIconSelectId,
scopeSelectId: config.editScopeSelectId,
typeSelectId: config.editTypeSelectId

View File

@@ -16,9 +16,9 @@
</div>
<div class="col-xs-6 col-sm-9">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<label for="{{nameInputId}}" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input name="name" type="text" class="form-control" id="name" value="" placeholder="Map name" data-error="Name required" data-minlength="3" data-minlength-error="Min. of 3 characters" required>
<input name="name" type="text" class="form-control" id="{{nameInputId}}" value="" placeholder="Map name" data-error="Name required" data-minlength="3" data-minlength-error="Min. of 3 characters" required>
<span class="note help-block with-errors">Choose a meaningful name</span>
</div>
</div>