- reduced number of parallel ajax calls by 1, when a system becomes active. (/api/signature/getAll no longer required -> removed)

- improved UI performance with long loading "description" textarea, closed #459
- fixed a bug where system panels no longer get updated when switching between map tabs
- fixed a bug where "Intel/Structure" data not get removed from table when structure get removed
This commit is contained in:
Mark Friedrich
2018-07-08 19:27:40 +02:00
parent ab5ec91f60
commit 32eacc4bc2
22 changed files with 594 additions and 464 deletions

View File

@@ -891,6 +891,8 @@ class Map extends Controller\AccessController {
// data for currently selected system
$return->system = $system->getData();
$return->system->signatures = $system->getSignaturesData();
$return->system->structures = $system->getStructuresData();
}
}
}

View File

@@ -13,40 +13,6 @@ use Model;
class Signature extends Controller\AccessController {
/**
* get signature data for systems
* -> return value of this is limited to a "SINGLE" system
* @param \Base $f3
* @throws \Exception
*/
public function getAll(\Base $f3){
$signatureData = [];
$systemIds = (array)$f3->get('POST.systemIds');
if( !empty($systemIds) ){
$activeCharacter = $this->getCharacter();
/**
* @var Model\SystemModel $system
*/
$system = Model\BasicModel::getNew('SystemModel');
foreach($systemIds as $systemId){
$system->getById($systemId);
if(
!$system->dry() &&
$system->hasAccess($activeCharacter)
){
$signatureData = $system->getSignaturesData();
}
$system->reset();
}
}
echo json_encode($signatureData);
}
/**
* save or update a full signature data set
* or save/update just single or multiple signature data

View File

@@ -43,7 +43,6 @@ define(['jquery'], ($) => {
saveConnection: '/api/connection/save', // ajax URL - save new connection to map
deleteConnection: '/api/connection/delete', // ajax URL - delete connection from map
// signature API
getSignatures: '/api/signature/getAll', // ajax URL - get all signature data for system
saveSignatureData: '/api/signature/save', // ajax URL - save signature data for system
deleteSignatureData: '/api/signature/delete', // ajax URL - delete signature data for system
// structure API

View File

@@ -416,6 +416,7 @@ define([
// check if system is "active"
if( system.hasClass(config.systemActiveClass) ){
delete Init.currentSystemData;
// get parent Tab Content and fire clear modules event
let tabContentElement = MapUtil.getTabContentElementByMapElement( system );
$(tabContentElement).trigger('pf:removeSystemModules');

View File

@@ -550,6 +550,13 @@ define([
// set current system active
system.addClass(config.systemActiveClass);
// collect all required data from map module to update the info element
// store them global and assessable for each module
Util.setCurrentSystemData({
systemData: system.getSystemData(),
mapId: parseInt( system.attr('data-mapid') )
});
};
/**
@@ -640,16 +647,7 @@ define([
setSystemActive(map, system);
// get parent Tab Content and fire update event
let tabContentElement = getTabContentElementByMapElement( system );
// collect all required data from map module to update the info element
// store them global and assessable for each module
Util.setCurrentSystemData({
systemData: system.getSystemData(),
mapId: parseInt( system.attr('data-mapid') )
});
$(tabContentElement).trigger('pf:drawSystemModules');
getTabContentElementByMapElement(system).trigger('pf:drawSystemModules');
};
/**
@@ -1332,6 +1330,39 @@ define([
return url;
};
/**
* request system data
* @param requestData
* @param context
* @returns {Promise<any>}
*/
let requestSystemData = (requestData, context) => {
let requestSystemDataExecutor = (resolve, reject) => {
$.ajax({
url: Init.path.getSystemData,
type: 'POST',
dataType: 'json',
data: requestData,
context: context
}).done(function(data){
if(data.system){
resolve({
action: 'systemData',
context: this,
data: data.system
});
}else{
console.warn('Missing systemData in response!', requestData);
}
}).fail(function( jqXHR, status, error) {
console.warn('Fail request systemData!', requestData);
});
};
return new Promise(requestSystemDataExecutor);
};
return {
config: config,
mapOptions: mapOptions,
@@ -1350,6 +1381,7 @@ define([
getEffectInfoForSystem: getEffectInfoForSystem,
toggleSystemsSelect: toggleSystemsSelect,
toggleConnectionActive: toggleConnectionActive,
setSystemActive: setSystemActive,
showSystemInfo: showSystemInfo,
showConnectionInfo: showConnectionInfo,
getConnectionsByType: getConnectionsByType,
@@ -1374,6 +1406,7 @@ define([
deleteLocalData: deleteLocalData,
getSystemId: getSystemId,
checkRight: checkRight,
getMapDeeplinkUrl: getMapDeeplinkUrl
getMapDeeplinkUrl: getMapDeeplinkUrl,
requestSystemData: requestSystemData
};
});

View File

@@ -353,7 +353,7 @@ define([
// get updated map data
let updatedMapData = {
mapData: mapModule.getMapModuleDataForUpdate(),
mapData: ModuleMap.getMapModuleDataForUpdate(mapModule),
getUserData: Util.getCurrentUserData() ? 0 : 1
};

View File

@@ -127,7 +127,7 @@ define([
* @param data
*/
let updateSystemModules = (tabContentElement, data) => {
let systemModules = [SystemInfoModule, SystemSignatureModule];
let systemModules = [SystemInfoModule, SystemSignatureModule, SystemIntelModule];
updateModules(tabContentElement, systemModules, data);
};
@@ -148,7 +148,7 @@ define([
* @param tabContentElement
*/
let removeSystemModules = (tabContentElement) => {
let systemModules = [SystemInfoModule, SystemGraphModule, SystemSignatureModule, SystemRouteModule, SystemKillboardModule];
let systemModules = [SystemInfoModule, SystemGraphModule, SystemSignatureModule, SystemRouteModule, SystemIntelModule, SystemKillboardModule];
removeModules(tabContentElement, systemModules);
};
@@ -198,90 +198,103 @@ define([
*/
let drawModule = (parentElement, Module, mapId, data) => {
/**
* show/render a Module
* @param parentElement
* @param Module
* @param mapId
* @param data
*/
let showPanel = (parentElement, Module, mapId, data) => {
let moduleElement = Module.getModule(parentElement, mapId, data);
if (moduleElement) {
// store Module object to DOM element for further access
moduleElement.data('module', Module);
moduleElement.data('data', data);
moduleElement.addClass([config.moduleClass, Module.config.moduleTypeClass].join(' '));
moduleElement.css({opacity: 0}); // will be animated
let drawModuleExecutor = (resolve, reject) => {
/**
* show/render a Module
* @param parentElement
* @param Module
* @param mapId
* @param data
*/
let showPanel = (parentElement, Module, mapId, data) => {
let moduleElement = Module.getModule(parentElement, mapId, data);
if (moduleElement) {
// store Module object to DOM element for further access
moduleElement.data('module', Module);
moduleElement.data('data', data);
moduleElement.addClass([config.moduleClass, Module.config.moduleTypeClass].join(' '));
moduleElement.css({opacity: 0}); // will be animated
// check module position from local storage
let promiseStore = MapUtil.getLocaleData('map', mapId);
promiseStore.then(function (dataStore) {
let Module = this.moduleElement.data('module');
let defaultPosition = Module.config.modulePosition || 0;
// check module position from local storage
let promiseStore = MapUtil.getLocaleData('map', mapId);
promiseStore.then(function (dataStore) {
let Module = this.moduleElement.data('module');
let defaultPosition = Module.config.modulePosition || 0;
// check for stored module order in indexDB (client) ----------------------------------------------
let key = 'modules_cell_' + this.parentElement.attr('data-position');
if (
dataStore &&
dataStore[key]
) {
let positionIndex = dataStore[key].indexOf(Module.config.moduleName);
if (positionIndex !== -1) {
// first index (0) => is position 1
defaultPosition = positionIndex + 1;
}
}
// find correct position for new moduleElement ----------------------------------------------------
let position = getModulePosition(this.parentElement, defaultPosition);
this.moduleElement.attr('data-position', defaultPosition);
this.moduleElement.attr('data-module', Module.config.moduleName);
// insert at correct position ---------------------------------------------------------------------
let prevModuleElement = this.parentElement.find('.' + config.moduleClass + ':nth-child(' + position + ')');
if (prevModuleElement.length) {
this.moduleElement.insertAfter(prevModuleElement);
} else {
this.parentElement.prepend(this.moduleElement);
}
if (typeof Module.beforeShow === 'function') {
Module.beforeShow(this.moduleElement, moduleElement.data('data'));
}
// show animation ---------------------------------------------------------------------------------
this.moduleElement.velocity({
opacity: [1, 0],
translateY: [0, +20]
}, {
duration: Init.animationSpeed.mapModule,
easing: 'easeOutSine',
complete: function (moduleElement) {
moduleElement = $(moduleElement);
let Module = $(moduleElement).data('module');
if (typeof Module.initModule === 'function') {
Module.initModule(moduleElement, mapId, moduleElement.data('data'));
// check for stored module order in indexDB (client) ----------------------------------------------
let key = 'modules_cell_' + this.parentElement.attr('data-position');
if (
dataStore &&
dataStore[key]
) {
let positionIndex = dataStore[key].indexOf(Module.config.moduleName);
if (positionIndex !== -1) {
// first index (0) => is position 1
defaultPosition = positionIndex + 1;
}
}
});
}.bind({
parentElement: parentElement,
moduleElement: moduleElement
}));
// find correct position for new moduleElement ----------------------------------------------------
let position = getModulePosition(this.parentElement, defaultPosition);
this.moduleElement.attr('data-position', defaultPosition);
this.moduleElement.attr('data-module', Module.config.moduleName);
// insert at correct position ---------------------------------------------------------------------
let prevModuleElement = this.parentElement.find('.' + config.moduleClass + ':nth-child(' + position + ')');
if (prevModuleElement.length) {
this.moduleElement.insertAfter(prevModuleElement);
} else {
this.parentElement.prepend(this.moduleElement);
}
if (typeof Module.beforeShow === 'function') {
Module.beforeShow(this.moduleElement, moduleElement.data('data'));
}
// show animation ---------------------------------------------------------------------------------
this.moduleElement.velocity({
opacity: [1, 0],
translateY: [0, +20]
}, {
duration: Init.animationSpeed.mapModule,
easing: 'easeOutSine',
complete: function (moduleElement) {
moduleElement = $(moduleElement);
let Module = $(moduleElement).data('module');
if (typeof Module.initModule === 'function') {
Module.initModule(moduleElement, mapId, moduleElement.data('data'));
}
resolve({
action: 'drawModule',
data: {
module: Module
}
});
}
});
}.bind({
parentElement: parentElement,
moduleElement: moduleElement
}));
}
};
// check if module already exists
let moduleElement = parentElement.find('.' + Module.config.moduleTypeClass);
if (moduleElement.length > 0) {
removeModule(moduleElement, Module, () => {
showPanel(parentElement, Module, mapId, data);
});
} else {
showPanel(parentElement, Module, mapId, data);
}
};
// check if module already exists
let moduleElement = parentElement.find('.' + Module.config.moduleTypeClass);
if (moduleElement.length > 0) {
removeModule(moduleElement, Module, () => {
showPanel(parentElement, Module, mapId, data);
});
} else {
showPanel(parentElement, Module, mapId, data);
}
return new Promise(drawModuleExecutor);
};
/**
@@ -289,30 +302,60 @@ define([
* @param tabContentElement
*/
let drawSystemModules = (tabContentElement) => {
require(['datatables.loader'], function(){
let currentSystemData = Util.getCurrentSystemData();
// get grid cells
let promiseDrawAll = [];
// request "additional" system data (e.g. Structures, Description)
// -> this is used to update some modules after initial draw
let promiseRequestData = MapUtil.requestSystemData({
mapId: currentSystemData.mapId,
systemId: currentSystemData.systemData.id
});
// draw modules -------------------------------------------------------------------------------------------
let firstCell = tabContentElement.find('.' + config.mapTabContentCellFirst);
let secondCell = tabContentElement.find('.' + config.mapTabContentCellSecond);
// draw system info module
drawModule(firstCell, SystemInfoModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseInfo = drawModule(firstCell, SystemInfoModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system graph module
drawModule(firstCell, SystemGraphModule, currentSystemData.mapId, currentSystemData.systemData);
// draw signature table module
drawModule(firstCell, SystemSignatureModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseSignature = drawModule(firstCell, SystemSignatureModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system routes module
drawModule(secondCell, SystemRouteModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system intel module
drawModule(secondCell, SystemIntelModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseIntel = drawModule(secondCell, SystemIntelModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system killboard module
drawModule(secondCell, SystemKillboardModule, currentSystemData.mapId, currentSystemData.systemData);
// update some modules ------------------------------------------------------------------------------------
promiseDrawAll.push(promiseRequestData, promiseInfo, promiseSignature, promiseIntel);
// update "some" modules after draw AND additional system data was requested
Promise.all(promiseDrawAll).then(payload => {
// get systemData from first Promise (ajax call)
let responseData = payload.shift();
if(responseData.data){
let systemData = responseData.data;
// update all Modules
let modules = [];
for(let responseData of payload){
modules.push(responseData.data.module);
}
updateModules(tabContentElement, modules, systemData);
}
});
});
};
@@ -680,6 +723,12 @@ define([
let mapWrapperElement = mapElement.closest('.mCustomScrollbar');
mapWrapperElement.mCustomScrollbar('update');
// if there is an already an "active" system -> setCurrentSystemData for that again
let activeSystem = mapElement.find('.' + MapUtil.config.systemActiveClass + ':first');
if(activeSystem.length){
MapUtil.setSystemActive(mapConfig.map, activeSystem);
}
// change url to unique map URL
if (history.pushState) {
let mapUrl = MapUtil.getMapDeeplinkUrl(mapConfig.config.id);
@@ -698,11 +747,14 @@ define([
// skip "add button"
if(newMapId > 0){
// delete currentSystemData -> will be set for new map (if there is is an active system)
delete Init.currentSystemData;
let currentTabContentElement = $('#' + config.mapTabIdPrefix + oldMapId);
// disable scrollbar for map that will be hidden. "freeze" current state
let mapWrapperElement = currentTabContentElement.find('.' + config.mapWrapperClass);
$(mapWrapperElement).mCustomScrollbar('disable', false);
mapWrapperElement.mCustomScrollbar('disable', false);
}
});
@@ -1216,19 +1268,18 @@ define([
/**
* collect all data (systems/connections) for export/save from each active map in the map module
* if no change detected -> do not attach map data to return array
* @param mapModule
* @returns {Array}
*/
$.fn.getMapModuleDataForUpdate = function(){
let getMapModuleDataForUpdate = mapModule => {
// get all active map elements for module
let mapElements = $(this).getMaps();
let mapElements = mapModule.getMaps();
let data = [];
for(let i = 0; i < mapElements.length; i++){
// get all changed (system / connection) data from this map
let mapData = $(mapElements[i]).getMapDataFromClient({forceData: false, checkForChange: true});
if(mapData !== false){
if(
mapData.data.systems.length > 0 ||
mapData.data.connections.length > 0
@@ -1245,6 +1296,7 @@ define([
updateTabData: updateTabData,
updateMapModule: updateMapModule,
updateActiveMapUserData: updateActiveMapUserData,
updateSystemModulesData: updateSystemModulesData
updateSystemModulesData: updateSystemModulesData,
getMapModuleDataForUpdate: getMapModuleDataForUpdate
};
});

View File

@@ -146,7 +146,7 @@ define([
nameRowElement.addCharacterInfoTooltip( tooltipData );
}
moduleElement.find('.' + config.descriptionArea).hideLoadingAnimation();
moduleElement.hideLoadingAnimation();
};
/**

View File

@@ -104,19 +104,25 @@ define([
if(rowId){
// update row
let api = context.tableApi.row('#' + rowId).data(structureData);
api.nodes().to$().data('animationStatus', 'changed').destroyTimestampCounter();
let api = context.tableApi.row('#' + rowId);
let rowData = api.data();
// check for update
if(rowData.updated.updated !== structureData.updated.updated){
// row data changed -> update
api.data(structureData);
api.nodes().to$().data('animationStatus', 'changed').destroyTimestampCounter();
notificationCounter.changed++;
}
touchedRows.push(api.id());
notificationCounter.changed++;
}else{
// insert new row
//context.tableApi.row.add(structureData).nodes().to$().data('animationStatus', 'added');
let api = context.tableApi.row.add(structureData);
api.nodes().to$().data('animationStatus', 'added');
notificationCounter.added++;
touchedRows.push(api.id());
notificationCounter.added++;
}
}
}
@@ -125,7 +131,9 @@ define([
}
if(context.removeMissing){
notificationCounter.deleted += context.tableApi.rows((idx, data, node) => !touchedRows.includes(node.id)).remove().ids().count();
let api = context.tableApi.rows((idx, data, node) => !touchedRows.includes(node.id));
notificationCounter.deleted += api.ids().count();
api.remove();
}
context.tableApi.draw();
@@ -650,16 +658,10 @@ define([
}
},
initComplete: function(settings){
let tableApi = this.api();
// initial structure data request
getStructureData({
mapId: mapId,
systemId: systemData.id
},{
moduleElement: moduleElement,
tableApi: tableApi
}, callbackAddStructureRows);
// table data is load in updateModule() method
// -> no need to trigger additional ajax call here for data
// -> in case table update failed -> each if this initComplete() function finished before table updata
// e.g. return now promise in getModule() function
}
});
@@ -669,6 +671,8 @@ define([
container: 'body'
});
moduleElement.showLoadingAnimation();
return moduleElement;
};
@@ -742,6 +746,28 @@ define([
}
};
/**
* update trigger function for this module
* compare data and update module
* @param moduleElement
* @param systemData
*/
let updateModule = (moduleElement, systemData) => {
// update structure table data
let structureTableElement = moduleElement.find('.' + config.systemStructuresTableClass);
let tableApi = structureTableElement.DataTable();
let context = {
tableApi: tableApi,
removeMissing: true
};
callbackUpdateStructureRows(context, systemData);
moduleElement.hideLoadingAnimation();
};
/**
* init intel module
* @param moduleElement
@@ -787,7 +813,8 @@ define([
return {
config: config,
getModule: getModule,
initModule: initModule
initModule: initModule,
updateModule: updateModule
};
});

View File

@@ -219,7 +219,7 @@ define([
* @param tableApi
* @returns {Array}
*/
let getTableData = function(tableApi){
let getTableData = tableApi => {
let tableData = [];
if(tableApi){
@@ -266,7 +266,7 @@ define([
* @param cellIndex
* @param data
*/
let updateSignatureCell = function(tableApi, rowElement, cellIndex, data){
let updateSignatureCell = (tableApi, rowElement, cellIndex, data) => {
let rowIndex = tableApi.row( rowElement ).index();
let updateCell = tableApi.cell( rowIndex, cellIndex );
let updateCellElement = updateCell.nodes().to$();
@@ -296,6 +296,7 @@ define([
updateSignatureTable(moduleElement, systemData.signatures, true);
}
moduleElement.hideLoadingAnimation();
};
/**
@@ -425,7 +426,7 @@ define([
/**
* lock system signature table for
*/
let lockSignatureTable = function(){
let lockSignatureTable = () => {
disableTableUpdate = true;
};
@@ -434,7 +435,7 @@ define([
* -> make table "update-able" again
* @param instant
*/
let unlockSignatureTable = function(instant){
let unlockSignatureTable = instant =>{
if(disableTableUpdate === true){
if(instant === true){
disableTableUpdate = false;
@@ -442,7 +443,6 @@ define([
// wait until add/remove animations are finished before enable table for auto update again
setTimeout(function(){ disableTableUpdate = false; }, 2000);
}
}
};
@@ -584,8 +584,6 @@ define([
moduleElement: moduleElement
}
}).done(function(responseData){
unlockSignatureTable(true);
// updates table with new/updated signature information
updateSignatureTable(this.moduleElement, responseData.signatures, false);
}).fail(function( jqXHR, status, error) {
@@ -637,7 +635,7 @@ define([
* @param clipboard
* @returns {Array}
*/
let parseSignatureString = function(systemData, clipboard){
let parseSignatureString = (systemData, clipboard) => {
let signatureData = [];
if(clipboard.length){
@@ -710,7 +708,7 @@ define([
* @param options
* @returns {Array}
*/
let formatSignatureData = function(systemData, signatureData, options){
let formatSignatureData = (systemData, signatureData, options) => {
let formattedData = [];
@@ -862,7 +860,7 @@ define([
* @param options
* @returns {*|jQuery}
*/
let getLabeledButton = function(options){
let getLabeledButton = options => {
let buttonClasses = ['btn', 'btn-sm', 'btn-labeled'];
@@ -918,7 +916,7 @@ define([
* @param tableApi
* @returns {*}
*/
let getRows = function(tableApi){
let getRows = tableApi => {
let rows = tableApi.rows();
return rows;
};
@@ -928,7 +926,7 @@ define([
* @param tableApi
* @returns {*}
*/
let getSelectedRows = function(tableApi){
let getSelectedRows = tableApi => {
let selectedRows = tableApi.rows('.selected');
return selectedRows;
};
@@ -937,7 +935,7 @@ define([
* check the "delete signature" button. show/hide the button if a signature is selected
* @param moduleElement
*/
let checkDeleteSignaturesButton = function(moduleElement){
let checkDeleteSignaturesButton = moduleElement => {
moduleElement = $(moduleElement);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
@@ -979,11 +977,11 @@ define([
/**
* draw signature table toolbar (add signature button, scan progress bar
* @param moduleElement
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableToolbar = function(mapId, systemData){
let moduleElement = $(this);
let drawSignatureTableToolbar = (moduleElement, mapId, systemData) => {
// add toolbar buttons for table ------------------------------------------------------------------------------
let tableToolbar = $('<div>', {
@@ -1144,7 +1142,7 @@ define([
* @param element
* @param title
*/
let updateTooltip = function(element, title){
let updateTooltip = (element, title) => {
$(element).attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
.tooltip('setContent');
};
@@ -1589,7 +1587,7 @@ define([
* @param groupId
* @returns {Array}
*/
let getAllSignatureNames = function(systemData, systemTypeId, areaId, groupId){
let getAllSignatureNames = (systemData, systemTypeId, areaId, groupId) => {
let newSelectOptions = [];
let cacheKey = [systemTypeId, areaId, groupId].join('_');
let newSelectOptionsCount = 0;
@@ -1731,7 +1729,7 @@ define([
* @param obj
* @returns {number}
*/
let sumSignaturesRecursive = function(key, obj){
let sumSignaturesRecursive = (key, obj) => {
let sum = 0;
for (let prop in obj) {
@@ -1752,7 +1750,7 @@ define([
* @param systemTypeId
* @returns {{}}
*/
let getFrigateHolesBySystem = function(systemTypeId){
let getFrigateHolesBySystem = systemTypeId => {
let signatureNames = {};
if(Init.frigateWormholes[systemTypeId]){
@@ -1767,7 +1765,7 @@ define([
* @param tableApi
* @param rows
*/
let deleteSignatures = function(tableApi, rows){
let deleteSignatures = (tableApi, rows) => {
let deletedSignatures = 0;
let moduleElement = $('.' + config.moduleTypeClass);
@@ -1941,15 +1939,42 @@ define([
}
};
/**
* draw a signature table with data
* get unique column data from column object for select filter options
* @param column
* @returns {{}}
*/
let getColumnTableDataForFilter = column => {
// get all available options from column
let source = {};
column.data().unique().sort((a,b) => {
// sort alphabetically
let valA = a.filter.toLowerCase();
let valB = b.filter.toLowerCase();
if(valA < valB) return -1;
if(valA > valB) return 1;
return 0;
}).each(callData => {
if(callData.filter){
source[callData.filter] = callData.filter;
}
});
// add empty option
source[0] = '';
return source;
};
/**
* draw empty signature table
* @param moduleElement
* @param mapId
* @param signatureData
* @param systemData
*/
$.fn.drawSignatureTable = function(mapId, signatureData, systemData){
let moduleElement = $(this);
let drawSignatureTable = (moduleElement, mapId, systemData) => {
// setup filter select in footer
// column indexes that need a filter select
let filterColumnIndexes = [2];
@@ -1972,7 +1997,6 @@ define([
moduleElement.append(table);
let dataTableOptions = {
data: signatureData,
drawCallback: function(settings){
this.api().columns(filterColumnIndexes).every(function(){
let column = this;
@@ -2017,46 +2041,13 @@ define([
let signatureTable = table.dataTable(dataTableOptions);
let signatureTableApi = signatureTable.api();
setDataTableInstance(mapId, systemData.id, 'primary', signatureTableApi);
// make Table editable
signatureTable.makeEditable(signatureTableApi, systemData);
moduleElement.updateScannedSignaturesBar({showNotice: true});
};
/**
* get unique column data from column object for select filter options
* @param column
* @returns {{}}
*/
let getColumnTableDataForFilter = function(column){
// get all available options from column
let source = {};
column.data().unique().sort(function(a,b){
// sort alphabetically
let valA = a.filter.toLowerCase();
let valB = b.filter.toLowerCase();
if(valA < valB) return -1;
if(valA > valB) return 1;
return 0;
}).each(function(callData){
if(callData.filter){
source[callData.filter] = callData.filter;
}
});
// add empty option
source[0] = '';
return source;
};
/**
* setup dataTable options for all signatureTables
* @param systemData
*/
let initSignatureDataTable = function(systemData){
let initSignatureDataTable = systemData => {
$.extend( true, $.fn.dataTable.defaults, {
pageLength: -1,
@@ -2319,7 +2310,7 @@ define([
* @param moduleElement
* @param systemData
*/
let setModuleObserver = function(moduleElement, systemData){
let setModuleObserver = (moduleElement, systemData) => {
let tablePrimaryElement = moduleElement.find('.' + config.sigTablePrimaryClass);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
@@ -2362,7 +2353,7 @@ define([
* init callback
* @param moduleElement
* @param mapId
* @param connectionData
* @param systemData
*/
let initModule = (moduleElement, mapId, systemData) => {
unlockSignatureTable(true);
@@ -2393,41 +2384,19 @@ define([
moduleElement.data('mapId', mapId);
moduleElement.data('systemId', systemData.id);
moduleElement.showLoadingAnimation();
// init dataTables
initSignatureDataTable(systemData);
// draw "new signature" add table -----------------------------------------------------------------------------
// draw "new signature" add table
drawSignatureTableToolbar(moduleElement, mapId, systemData);
moduleElement.drawSignatureTableToolbar(mapId, systemData);
// draw signature table
drawSignatureTable(moduleElement, mapId, systemData);
// request signature data for system --------------------------------------------------------------------------
let requestData = {
systemIds: [systemData.id]
};
$.ajax({
type: 'POST',
url: Init.path.getSignatures,
data: requestData,
dataType: 'json',
context: {
mapId: mapId,
systemData: systemData
}
}).done(function(signatureData){
let signatureTableData = formatSignatureData(this.systemData, signatureData, fullSignatureOptions);
// draw signature table
moduleElement.drawSignatureTable(this.mapId, signatureTableData, this.systemData);
// set module observer
setModuleObserver(moduleElement, this.systemData);
}).fail(function( jqXHR, status, error) {
let reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': Get signatures', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
// set module observer
setModuleObserver(moduleElement, systemData);
return moduleElement;
};

View File

@@ -109,7 +109,7 @@ define([
class: [config.ajaxOverlayWrapperClass].join(' ')
}).append(
$('<i>', {
class: ['fas', 'fa-fw', iconSize, 'fa-sync', 'fa-spin'].join(' ')
class: ['fas', iconSize, 'fa-sync', 'fa-spin'].join(' ')
})
)
);
@@ -132,7 +132,6 @@ define([
return this.each(function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
if(overlay.length){
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!

File diff suppressed because one or more lines are too long

View File

@@ -43,7 +43,6 @@ define(['jquery'], ($) => {
saveConnection: '/api/connection/save', // ajax URL - save new connection to map
deleteConnection: '/api/connection/delete', // ajax URL - delete connection from map
// signature API
getSignatures: '/api/signature/getAll', // ajax URL - get all signature data for system
saveSignatureData: '/api/signature/save', // ajax URL - save signature data for system
deleteSignatureData: '/api/signature/delete', // ajax URL - delete signature data for system
// structure API

View File

@@ -416,6 +416,7 @@ define([
// check if system is "active"
if( system.hasClass(config.systemActiveClass) ){
delete Init.currentSystemData;
// get parent Tab Content and fire clear modules event
let tabContentElement = MapUtil.getTabContentElementByMapElement( system );
$(tabContentElement).trigger('pf:removeSystemModules');

View File

@@ -550,6 +550,13 @@ define([
// set current system active
system.addClass(config.systemActiveClass);
// collect all required data from map module to update the info element
// store them global and assessable for each module
Util.setCurrentSystemData({
systemData: system.getSystemData(),
mapId: parseInt( system.attr('data-mapid') )
});
};
/**
@@ -640,16 +647,7 @@ define([
setSystemActive(map, system);
// get parent Tab Content and fire update event
let tabContentElement = getTabContentElementByMapElement( system );
// collect all required data from map module to update the info element
// store them global and assessable for each module
Util.setCurrentSystemData({
systemData: system.getSystemData(),
mapId: parseInt( system.attr('data-mapid') )
});
$(tabContentElement).trigger('pf:drawSystemModules');
getTabContentElementByMapElement(system).trigger('pf:drawSystemModules');
};
/**
@@ -1332,6 +1330,41 @@ define([
return url;
};
let requestSystemData = (requestData, context) => {
let requestSystemDataExecutor = (resolve, reject) => {
$.ajax({
url: Init.path.getSystemData,
type: 'POST',
dataType: 'json',
data: requestData,
context: context
}).done(function(data){
if(data.system){
resolve({
action: 'systemData',
context: this,
data: data.system
});
}else{
console.warn('Missing systemData in response!', requestData);
}
}).fail(function( jqXHR, status, error) {
/*
}
let reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': System intel data', text: reason, type: 'warning'});
$(document).setProgramStatus('problem'); */
}).always(function(){
// hide loading animation
// this.moduleElement.hideLoadingAnimation();
});
};
return new Promise(requestSystemDataExecutor);
};
return {
config: config,
mapOptions: mapOptions,
@@ -1350,6 +1383,7 @@ define([
getEffectInfoForSystem: getEffectInfoForSystem,
toggleSystemsSelect: toggleSystemsSelect,
toggleConnectionActive: toggleConnectionActive,
setSystemActive: setSystemActive,
showSystemInfo: showSystemInfo,
showConnectionInfo: showConnectionInfo,
getConnectionsByType: getConnectionsByType,
@@ -1374,6 +1408,7 @@ define([
deleteLocalData: deleteLocalData,
getSystemId: getSystemId,
checkRight: checkRight,
getMapDeeplinkUrl: getMapDeeplinkUrl
getMapDeeplinkUrl: getMapDeeplinkUrl,
requestSystemData: requestSystemData
};
});

View File

@@ -353,7 +353,7 @@ define([
// get updated map data
let updatedMapData = {
mapData: mapModule.getMapModuleDataForUpdate(),
mapData: ModuleMap.getMapModuleDataForUpdate(mapModule),
getUserData: Util.getCurrentUserData() ? 0 : 1
};

View File

@@ -127,7 +127,7 @@ define([
* @param data
*/
let updateSystemModules = (tabContentElement, data) => {
let systemModules = [SystemInfoModule, SystemSignatureModule];
let systemModules = [SystemInfoModule, SystemSignatureModule, SystemIntelModule];
updateModules(tabContentElement, systemModules, data);
};
@@ -148,7 +148,7 @@ define([
* @param tabContentElement
*/
let removeSystemModules = (tabContentElement) => {
let systemModules = [SystemInfoModule, SystemGraphModule, SystemSignatureModule, SystemRouteModule, SystemKillboardModule];
let systemModules = [SystemInfoModule, SystemGraphModule, SystemSignatureModule, SystemRouteModule, SystemIntelModule, SystemKillboardModule];
removeModules(tabContentElement, systemModules);
};
@@ -198,90 +198,103 @@ define([
*/
let drawModule = (parentElement, Module, mapId, data) => {
/**
* show/render a Module
* @param parentElement
* @param Module
* @param mapId
* @param data
*/
let showPanel = (parentElement, Module, mapId, data) => {
let moduleElement = Module.getModule(parentElement, mapId, data);
if (moduleElement) {
// store Module object to DOM element for further access
moduleElement.data('module', Module);
moduleElement.data('data', data);
moduleElement.addClass([config.moduleClass, Module.config.moduleTypeClass].join(' '));
moduleElement.css({opacity: 0}); // will be animated
let drawModuleExecutor = (resolve, reject) => {
/**
* show/render a Module
* @param parentElement
* @param Module
* @param mapId
* @param data
*/
let showPanel = (parentElement, Module, mapId, data) => {
let moduleElement = Module.getModule(parentElement, mapId, data);
if (moduleElement) {
// store Module object to DOM element for further access
moduleElement.data('module', Module);
moduleElement.data('data', data);
moduleElement.addClass([config.moduleClass, Module.config.moduleTypeClass].join(' '));
moduleElement.css({opacity: 0}); // will be animated
// check module position from local storage
let promiseStore = MapUtil.getLocaleData('map', mapId);
promiseStore.then(function (dataStore) {
let Module = this.moduleElement.data('module');
let defaultPosition = Module.config.modulePosition || 0;
// check module position from local storage
let promiseStore = MapUtil.getLocaleData('map', mapId);
promiseStore.then(function (dataStore) {
let Module = this.moduleElement.data('module');
let defaultPosition = Module.config.modulePosition || 0;
// check for stored module order in indexDB (client) ----------------------------------------------
let key = 'modules_cell_' + this.parentElement.attr('data-position');
if (
dataStore &&
dataStore[key]
) {
let positionIndex = dataStore[key].indexOf(Module.config.moduleName);
if (positionIndex !== -1) {
// first index (0) => is position 1
defaultPosition = positionIndex + 1;
}
}
// find correct position for new moduleElement ----------------------------------------------------
let position = getModulePosition(this.parentElement, defaultPosition);
this.moduleElement.attr('data-position', defaultPosition);
this.moduleElement.attr('data-module', Module.config.moduleName);
// insert at correct position ---------------------------------------------------------------------
let prevModuleElement = this.parentElement.find('.' + config.moduleClass + ':nth-child(' + position + ')');
if (prevModuleElement.length) {
this.moduleElement.insertAfter(prevModuleElement);
} else {
this.parentElement.prepend(this.moduleElement);
}
if (typeof Module.beforeShow === 'function') {
Module.beforeShow(this.moduleElement, moduleElement.data('data'));
}
// show animation ---------------------------------------------------------------------------------
this.moduleElement.velocity({
opacity: [1, 0],
translateY: [0, +20]
}, {
duration: Init.animationSpeed.mapModule,
easing: 'easeOutSine',
complete: function (moduleElement) {
moduleElement = $(moduleElement);
let Module = $(moduleElement).data('module');
if (typeof Module.initModule === 'function') {
Module.initModule(moduleElement, mapId, moduleElement.data('data'));
// check for stored module order in indexDB (client) ----------------------------------------------
let key = 'modules_cell_' + this.parentElement.attr('data-position');
if (
dataStore &&
dataStore[key]
) {
let positionIndex = dataStore[key].indexOf(Module.config.moduleName);
if (positionIndex !== -1) {
// first index (0) => is position 1
defaultPosition = positionIndex + 1;
}
}
});
}.bind({
parentElement: parentElement,
moduleElement: moduleElement
}));
// find correct position for new moduleElement ----------------------------------------------------
let position = getModulePosition(this.parentElement, defaultPosition);
this.moduleElement.attr('data-position', defaultPosition);
this.moduleElement.attr('data-module', Module.config.moduleName);
// insert at correct position ---------------------------------------------------------------------
let prevModuleElement = this.parentElement.find('.' + config.moduleClass + ':nth-child(' + position + ')');
if (prevModuleElement.length) {
this.moduleElement.insertAfter(prevModuleElement);
} else {
this.parentElement.prepend(this.moduleElement);
}
if (typeof Module.beforeShow === 'function') {
Module.beforeShow(this.moduleElement, moduleElement.data('data'));
}
// show animation ---------------------------------------------------------------------------------
this.moduleElement.velocity({
opacity: [1, 0],
translateY: [0, +20]
}, {
duration: Init.animationSpeed.mapModule,
easing: 'easeOutSine',
complete: function (moduleElement) {
moduleElement = $(moduleElement);
let Module = $(moduleElement).data('module');
if (typeof Module.initModule === 'function') {
Module.initModule(moduleElement, mapId, moduleElement.data('data'));
}
resolve({
action: 'drawModule',
data: {
module: Module
}
});
}
});
}.bind({
parentElement: parentElement,
moduleElement: moduleElement
}));
}
};
// check if module already exists
let moduleElement = parentElement.find('.' + Module.config.moduleTypeClass);
if (moduleElement.length > 0) {
removeModule(moduleElement, Module, () => {
showPanel(parentElement, Module, mapId, data);
});
} else {
showPanel(parentElement, Module, mapId, data);
}
};
// check if module already exists
let moduleElement = parentElement.find('.' + Module.config.moduleTypeClass);
if (moduleElement.length > 0) {
removeModule(moduleElement, Module, () => {
showPanel(parentElement, Module, mapId, data);
});
} else {
showPanel(parentElement, Module, mapId, data);
}
return new Promise(drawModuleExecutor);
};
/**
@@ -289,30 +302,60 @@ define([
* @param tabContentElement
*/
let drawSystemModules = (tabContentElement) => {
require(['datatables.loader'], function(){
let currentSystemData = Util.getCurrentSystemData();
// get grid cells
let promiseDrawAll = [];
// request "additional" system data (e.g. Structures, Description)
// -> this is used to update some modules after initial draw
let promiseRequestData = MapUtil.requestSystemData({
mapId: currentSystemData.mapId,
systemId: currentSystemData.systemData.id
});
// draw modules -------------------------------------------------------------------------------------------
let firstCell = tabContentElement.find('.' + config.mapTabContentCellFirst);
let secondCell = tabContentElement.find('.' + config.mapTabContentCellSecond);
// draw system info module
drawModule(firstCell, SystemInfoModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseInfo = drawModule(firstCell, SystemInfoModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system graph module
drawModule(firstCell, SystemGraphModule, currentSystemData.mapId, currentSystemData.systemData);
// draw signature table module
drawModule(firstCell, SystemSignatureModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseSignature = drawModule(firstCell, SystemSignatureModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system routes module
drawModule(secondCell, SystemRouteModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system intel module
drawModule(secondCell, SystemIntelModule, currentSystemData.mapId, currentSystemData.systemData);
let promiseIntel = drawModule(secondCell, SystemIntelModule, currentSystemData.mapId, currentSystemData.systemData);
// draw system killboard module
drawModule(secondCell, SystemKillboardModule, currentSystemData.mapId, currentSystemData.systemData);
// update some modules ------------------------------------------------------------------------------------
promiseDrawAll.push(promiseRequestData, promiseInfo, promiseSignature, promiseIntel);
// update "some" modules after draw AND additional system data was requested
Promise.all(promiseDrawAll).then(payload => {
// get systemData from first Promise (ajax call)
let responseData = payload.shift();
if(responseData.data){
let systemData = responseData.data;
// update all Modules
let modules = [];
for(let responseData of payload){
modules.push(responseData.data.module);
}
updateModules(tabContentElement, modules, systemData);
}
});
});
};
@@ -680,6 +723,12 @@ define([
let mapWrapperElement = mapElement.closest('.mCustomScrollbar');
mapWrapperElement.mCustomScrollbar('update');
// if there is an already an "active" system -> setCurrentSystemData for that again
let activeSystem = mapElement.find('.' + MapUtil.config.systemActiveClass + ':first');
if(activeSystem.length){
MapUtil.setSystemActive(mapConfig.map, activeSystem);
}
// change url to unique map URL
if (history.pushState) {
let mapUrl = MapUtil.getMapDeeplinkUrl(mapConfig.config.id);
@@ -698,11 +747,14 @@ define([
// skip "add button"
if(newMapId > 0){
// delete currentSystemData -> will be set for new map (if there is is an active system)
delete Init.currentSystemData;
let currentTabContentElement = $('#' + config.mapTabIdPrefix + oldMapId);
// disable scrollbar for map that will be hidden. "freeze" current state
let mapWrapperElement = currentTabContentElement.find('.' + config.mapWrapperClass);
$(mapWrapperElement).mCustomScrollbar('disable', false);
mapWrapperElement.mCustomScrollbar('disable', false);
}
});
@@ -1216,19 +1268,18 @@ define([
/**
* collect all data (systems/connections) for export/save from each active map in the map module
* if no change detected -> do not attach map data to return array
* @param mapModule
* @returns {Array}
*/
$.fn.getMapModuleDataForUpdate = function(){
let getMapModuleDataForUpdate = mapModule => {
// get all active map elements for module
let mapElements = $(this).getMaps();
let mapElements = mapModule.getMaps();
let data = [];
for(let i = 0; i < mapElements.length; i++){
// get all changed (system / connection) data from this map
let mapData = $(mapElements[i]).getMapDataFromClient({forceData: false, checkForChange: true});
if(mapData !== false){
if(
mapData.data.systems.length > 0 ||
mapData.data.connections.length > 0
@@ -1245,6 +1296,7 @@ define([
updateTabData: updateTabData,
updateMapModule: updateMapModule,
updateActiveMapUserData: updateActiveMapUserData,
updateSystemModulesData: updateSystemModulesData
updateSystemModulesData: updateSystemModulesData,
getMapModuleDataForUpdate: getMapModuleDataForUpdate
};
});

View File

@@ -146,7 +146,7 @@ define([
nameRowElement.addCharacterInfoTooltip( tooltipData );
}
moduleElement.find('.' + config.descriptionArea).hideLoadingAnimation();
moduleElement.hideLoadingAnimation();
};
/**

View File

@@ -104,19 +104,25 @@ define([
if(rowId){
// update row
let api = context.tableApi.row('#' + rowId).data(structureData);
api.nodes().to$().data('animationStatus', 'changed').destroyTimestampCounter();
let api = context.tableApi.row('#' + rowId);
let rowData = api.data();
// check for update
if(rowData.updated.updated !== structureData.updated.updated){
// row data changed -> update
api.data(structureData);
api.nodes().to$().data('animationStatus', 'changed').destroyTimestampCounter();
notificationCounter.changed++;
}
touchedRows.push(api.id());
notificationCounter.changed++;
}else{
// insert new row
//context.tableApi.row.add(structureData).nodes().to$().data('animationStatus', 'added');
let api = context.tableApi.row.add(structureData);
api.nodes().to$().data('animationStatus', 'added');
notificationCounter.added++;
touchedRows.push(api.id());
notificationCounter.added++;
}
}
}
@@ -125,7 +131,9 @@ define([
}
if(context.removeMissing){
notificationCounter.deleted += context.tableApi.rows((idx, data, node) => !touchedRows.includes(node.id)).remove().ids().count();
let api = context.tableApi.rows((idx, data, node) => !touchedRows.includes(node.id));
notificationCounter.deleted += api.ids().count();
api.remove();
}
context.tableApi.draw();
@@ -650,16 +658,10 @@ define([
}
},
initComplete: function(settings){
let tableApi = this.api();
// initial structure data request
getStructureData({
mapId: mapId,
systemId: systemData.id
},{
moduleElement: moduleElement,
tableApi: tableApi
}, callbackAddStructureRows);
// table data is load in updateModule() method
// -> no need to trigger additional ajax call here for data
// -> in case table update failed -> each if this initComplete() function finished before table updata
// e.g. return now promise in getModule() function
}
});
@@ -669,6 +671,8 @@ define([
container: 'body'
});
moduleElement.showLoadingAnimation();
return moduleElement;
};
@@ -742,6 +746,28 @@ define([
}
};
/**
* update trigger function for this module
* compare data and update module
* @param moduleElement
* @param systemData
*/
let updateModule = (moduleElement, systemData) => {
// update structure table data
let structureTableElement = moduleElement.find('.' + config.systemStructuresTableClass);
let tableApi = structureTableElement.DataTable();
let context = {
tableApi: tableApi,
removeMissing: true
};
callbackUpdateStructureRows(context, systemData);
moduleElement.hideLoadingAnimation();
};
/**
* init intel module
* @param moduleElement
@@ -787,7 +813,8 @@ define([
return {
config: config,
getModule: getModule,
initModule: initModule
initModule: initModule,
updateModule: updateModule
};
});

View File

@@ -219,7 +219,7 @@ define([
* @param tableApi
* @returns {Array}
*/
let getTableData = function(tableApi){
let getTableData = tableApi => {
let tableData = [];
if(tableApi){
@@ -266,7 +266,7 @@ define([
* @param cellIndex
* @param data
*/
let updateSignatureCell = function(tableApi, rowElement, cellIndex, data){
let updateSignatureCell = (tableApi, rowElement, cellIndex, data) => {
let rowIndex = tableApi.row( rowElement ).index();
let updateCell = tableApi.cell( rowIndex, cellIndex );
let updateCellElement = updateCell.nodes().to$();
@@ -296,6 +296,7 @@ define([
updateSignatureTable(moduleElement, systemData.signatures, true);
}
moduleElement.hideLoadingAnimation();
};
/**
@@ -425,7 +426,7 @@ define([
/**
* lock system signature table for
*/
let lockSignatureTable = function(){
let lockSignatureTable = () => {
disableTableUpdate = true;
};
@@ -434,7 +435,7 @@ define([
* -> make table "update-able" again
* @param instant
*/
let unlockSignatureTable = function(instant){
let unlockSignatureTable = instant =>{
if(disableTableUpdate === true){
if(instant === true){
disableTableUpdate = false;
@@ -442,7 +443,6 @@ define([
// wait until add/remove animations are finished before enable table for auto update again
setTimeout(function(){ disableTableUpdate = false; }, 2000);
}
}
};
@@ -584,8 +584,6 @@ define([
moduleElement: moduleElement
}
}).done(function(responseData){
unlockSignatureTable(true);
// updates table with new/updated signature information
updateSignatureTable(this.moduleElement, responseData.signatures, false);
}).fail(function( jqXHR, status, error) {
@@ -637,7 +635,7 @@ define([
* @param clipboard
* @returns {Array}
*/
let parseSignatureString = function(systemData, clipboard){
let parseSignatureString = (systemData, clipboard) => {
let signatureData = [];
if(clipboard.length){
@@ -710,7 +708,7 @@ define([
* @param options
* @returns {Array}
*/
let formatSignatureData = function(systemData, signatureData, options){
let formatSignatureData = (systemData, signatureData, options) => {
let formattedData = [];
@@ -862,7 +860,7 @@ define([
* @param options
* @returns {*|jQuery}
*/
let getLabeledButton = function(options){
let getLabeledButton = options => {
let buttonClasses = ['btn', 'btn-sm', 'btn-labeled'];
@@ -918,7 +916,7 @@ define([
* @param tableApi
* @returns {*}
*/
let getRows = function(tableApi){
let getRows = tableApi => {
let rows = tableApi.rows();
return rows;
};
@@ -928,7 +926,7 @@ define([
* @param tableApi
* @returns {*}
*/
let getSelectedRows = function(tableApi){
let getSelectedRows = tableApi => {
let selectedRows = tableApi.rows('.selected');
return selectedRows;
};
@@ -937,7 +935,7 @@ define([
* check the "delete signature" button. show/hide the button if a signature is selected
* @param moduleElement
*/
let checkDeleteSignaturesButton = function(moduleElement){
let checkDeleteSignaturesButton = moduleElement => {
moduleElement = $(moduleElement);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
@@ -979,11 +977,11 @@ define([
/**
* draw signature table toolbar (add signature button, scan progress bar
* @param moduleElement
* @param mapId
* @param systemData
*/
$.fn.drawSignatureTableToolbar = function(mapId, systemData){
let moduleElement = $(this);
let drawSignatureTableToolbar = (moduleElement, mapId, systemData) => {
// add toolbar buttons for table ------------------------------------------------------------------------------
let tableToolbar = $('<div>', {
@@ -1144,7 +1142,7 @@ define([
* @param element
* @param title
*/
let updateTooltip = function(element, title){
let updateTooltip = (element, title) => {
$(element).attr('data-container', 'body').attr('title', title.toUpperCase()).tooltip('fixTitle')
.tooltip('setContent');
};
@@ -1589,7 +1587,7 @@ define([
* @param groupId
* @returns {Array}
*/
let getAllSignatureNames = function(systemData, systemTypeId, areaId, groupId){
let getAllSignatureNames = (systemData, systemTypeId, areaId, groupId) => {
let newSelectOptions = [];
let cacheKey = [systemTypeId, areaId, groupId].join('_');
let newSelectOptionsCount = 0;
@@ -1731,7 +1729,7 @@ define([
* @param obj
* @returns {number}
*/
let sumSignaturesRecursive = function(key, obj){
let sumSignaturesRecursive = (key, obj) => {
let sum = 0;
for (let prop in obj) {
@@ -1752,7 +1750,7 @@ define([
* @param systemTypeId
* @returns {{}}
*/
let getFrigateHolesBySystem = function(systemTypeId){
let getFrigateHolesBySystem = systemTypeId => {
let signatureNames = {};
if(Init.frigateWormholes[systemTypeId]){
@@ -1767,7 +1765,7 @@ define([
* @param tableApi
* @param rows
*/
let deleteSignatures = function(tableApi, rows){
let deleteSignatures = (tableApi, rows) => {
let deletedSignatures = 0;
let moduleElement = $('.' + config.moduleTypeClass);
@@ -1941,15 +1939,42 @@ define([
}
};
/**
* draw a signature table with data
* get unique column data from column object for select filter options
* @param column
* @returns {{}}
*/
let getColumnTableDataForFilter = column => {
// get all available options from column
let source = {};
column.data().unique().sort((a,b) => {
// sort alphabetically
let valA = a.filter.toLowerCase();
let valB = b.filter.toLowerCase();
if(valA < valB) return -1;
if(valA > valB) return 1;
return 0;
}).each(callData => {
if(callData.filter){
source[callData.filter] = callData.filter;
}
});
// add empty option
source[0] = '';
return source;
};
/**
* draw empty signature table
* @param moduleElement
* @param mapId
* @param signatureData
* @param systemData
*/
$.fn.drawSignatureTable = function(mapId, signatureData, systemData){
let moduleElement = $(this);
let drawSignatureTable = (moduleElement, mapId, systemData) => {
// setup filter select in footer
// column indexes that need a filter select
let filterColumnIndexes = [2];
@@ -1972,7 +1997,6 @@ define([
moduleElement.append(table);
let dataTableOptions = {
data: signatureData,
drawCallback: function(settings){
this.api().columns(filterColumnIndexes).every(function(){
let column = this;
@@ -2017,46 +2041,13 @@ define([
let signatureTable = table.dataTable(dataTableOptions);
let signatureTableApi = signatureTable.api();
setDataTableInstance(mapId, systemData.id, 'primary', signatureTableApi);
// make Table editable
signatureTable.makeEditable(signatureTableApi, systemData);
moduleElement.updateScannedSignaturesBar({showNotice: true});
};
/**
* get unique column data from column object for select filter options
* @param column
* @returns {{}}
*/
let getColumnTableDataForFilter = function(column){
// get all available options from column
let source = {};
column.data().unique().sort(function(a,b){
// sort alphabetically
let valA = a.filter.toLowerCase();
let valB = b.filter.toLowerCase();
if(valA < valB) return -1;
if(valA > valB) return 1;
return 0;
}).each(function(callData){
if(callData.filter){
source[callData.filter] = callData.filter;
}
});
// add empty option
source[0] = '';
return source;
};
/**
* setup dataTable options for all signatureTables
* @param systemData
*/
let initSignatureDataTable = function(systemData){
let initSignatureDataTable = systemData => {
$.extend( true, $.fn.dataTable.defaults, {
pageLength: -1,
@@ -2319,7 +2310,7 @@ define([
* @param moduleElement
* @param systemData
*/
let setModuleObserver = function(moduleElement, systemData){
let setModuleObserver = (moduleElement, systemData) => {
let tablePrimaryElement = moduleElement.find('.' + config.sigTablePrimaryClass);
let signatureTableApi = getDataTableInstanceByModuleElement(moduleElement, 'primary');
@@ -2362,7 +2353,7 @@ define([
* init callback
* @param moduleElement
* @param mapId
* @param connectionData
* @param systemData
*/
let initModule = (moduleElement, mapId, systemData) => {
unlockSignatureTable(true);
@@ -2393,41 +2384,19 @@ define([
moduleElement.data('mapId', mapId);
moduleElement.data('systemId', systemData.id);
moduleElement.showLoadingAnimation();
// init dataTables
initSignatureDataTable(systemData);
// draw "new signature" add table -----------------------------------------------------------------------------
// draw "new signature" add table
drawSignatureTableToolbar(moduleElement, mapId, systemData);
moduleElement.drawSignatureTableToolbar(mapId, systemData);
// draw signature table
drawSignatureTable(moduleElement, mapId, systemData);
// request signature data for system --------------------------------------------------------------------------
let requestData = {
systemIds: [systemData.id]
};
$.ajax({
type: 'POST',
url: Init.path.getSignatures,
data: requestData,
dataType: 'json',
context: {
mapId: mapId,
systemData: systemData
}
}).done(function(signatureData){
let signatureTableData = formatSignatureData(this.systemData, signatureData, fullSignatureOptions);
// draw signature table
moduleElement.drawSignatureTable(this.mapId, signatureTableData, this.systemData);
// set module observer
setModuleObserver(moduleElement, this.systemData);
}).fail(function( jqXHR, status, error) {
let reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': Get signatures', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
// set module observer
setModuleObserver(moduleElement, systemData);
return moduleElement;
};

View File

@@ -109,7 +109,7 @@ define([
class: [config.ajaxOverlayWrapperClass].join(' ')
}).append(
$('<i>', {
class: ['fas', 'fa-fw', iconSize, 'fa-sync', 'fa-spin'].join(' ')
class: ['fas', iconSize, 'fa-sync', 'fa-spin'].join(' ')
})
)
);
@@ -132,7 +132,6 @@ define([
return this.each(function(){
let loadingElement = $(this);
let overlay = loadingElement.find('.' + config.ajaxOverlayClass );
if(overlay.length){
// important: "stop" is required to stop "show" animation
// -> otherwise "complete" callback is not fired!

View File

@@ -8,7 +8,7 @@
// dynamic area specific for the description field
.pf-system-info-description-area{
min-height: 123px;
min-height: 124px;
// textarea system description
.editable-container{