close #66 added "additional wormhole info" popover to system info module
This commit is contained in:
@@ -307,8 +307,8 @@ class SystemModel extends BasicModel {
|
||||
|
||||
// check if this system is a wormhole
|
||||
if($this->isWormhole()){
|
||||
$systemStaticModel = self::getNew('SystemStaticModel');
|
||||
$systemStatics = $systemStaticModel->find([
|
||||
$systemWormholeModel = self::getNew('SystemWormholeModel');
|
||||
$systemStatics = $systemWormholeModel->find([
|
||||
'constellationId = :constellationId',
|
||||
':constellationId' => $this->constellationId
|
||||
]);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodus4d
|
||||
* Date: 07.06.15
|
||||
* Time: 18:16
|
||||
*/
|
||||
|
||||
namespace Model;
|
||||
|
||||
|
||||
class SystemStaticModel extends BasicModel {
|
||||
|
||||
protected $table = 'system_static';
|
||||
|
||||
/**
|
||||
* get systemStatic data as object
|
||||
* @return object
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$systemStaticData = (object) [];
|
||||
$systemStaticData->security = $this->security;
|
||||
$systemStaticData->name = $this->name;
|
||||
|
||||
return $systemStaticData;
|
||||
}
|
||||
}
|
||||
32
app/main/model/systemwormholemodel.php
Normal file
32
app/main/model/systemwormholemodel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodus4d
|
||||
* Date: 07.06.15
|
||||
* Time: 18:16
|
||||
*/
|
||||
|
||||
namespace Model;
|
||||
|
||||
|
||||
class SystemWormholeModel extends BasicModel {
|
||||
|
||||
protected $table = 'system_wormhole';
|
||||
|
||||
protected $fieldConf = [
|
||||
'wormholeId' => [
|
||||
'belongs-to-one' => 'Model\WormholeModel'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* get wormhole data as object
|
||||
* @return object
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$systemWormholeData = $this->wormholeId->getData();
|
||||
|
||||
return $systemWormholeData;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ class UserModel extends BasicModel {
|
||||
protected $table = 'user';
|
||||
|
||||
protected $fieldConf = [
|
||||
'lastLogin' => array(
|
||||
'lastLogin' => [
|
||||
'type' => Schema::DT_TIMESTAMP
|
||||
),
|
||||
],
|
||||
'apis' => [
|
||||
'has-many' => ['Model\UserApiModel', 'userId']
|
||||
],
|
||||
|
||||
60
app/main/model/wormholemodel.php
Normal file
60
app/main/model/wormholemodel.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 14.11.2015
|
||||
* Time: 22:21
|
||||
*/
|
||||
|
||||
namespace Model;
|
||||
|
||||
class WormholeModel extends BasicModel {
|
||||
|
||||
protected $table = 'wormhole';
|
||||
|
||||
/**
|
||||
* format mass values
|
||||
* - no decimal separator
|
||||
* - char '.' for thousands separator
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
static function formatMassValue($value){
|
||||
return number_format( $value, 0, '', '.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* get wormhole data as object
|
||||
* @return object
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$systemStaticData = (object) [];
|
||||
$systemStaticData->name = $this->name;
|
||||
$systemStaticData->security = $this->security;
|
||||
|
||||
// total (max) available wormhole mass
|
||||
$systemStaticData->massTotal = (object) [];
|
||||
$systemStaticData->massTotal->value = $this->massTotal;
|
||||
$systemStaticData->massTotal->format = self::formatMassValue($this->massTotal) . ' Kg';
|
||||
|
||||
// individual jump mass (max) per jump
|
||||
$systemStaticData->massIndividual = (object) [];
|
||||
$systemStaticData->massIndividual->value = $this->massIndividual;
|
||||
$systemStaticData->massIndividual->format = self::formatMassValue($this->massIndividual) . ' Kg';
|
||||
|
||||
// lifetime (max) for this wormhole
|
||||
$systemStaticData->maxStableTime = (object) [];
|
||||
$systemStaticData->maxStableTime->value = $this->maxStableTime;
|
||||
$systemStaticData->maxStableTime->format = $this->maxStableTime . ' h';
|
||||
|
||||
// mass regeneration value per day
|
||||
if($this->massRegeneration > 0){
|
||||
$systemStaticData->massRegeneration = (object) [];
|
||||
$systemStaticData->massRegeneration->value = $this->massRegeneration;
|
||||
$systemStaticData->massRegeneration->format = self::formatMassValue($this->massRegeneration) . ' Kg/day';
|
||||
}
|
||||
|
||||
return $systemStaticData;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ define([
|
||||
systemInfoEffectInfoClass: 'pf-system-info-effect', // class for "effect" information element
|
||||
systemInfoStatusLabelClass: 'pf-system-info-status-label', // class for "status" information element
|
||||
systemInfoStatusAttributeName: 'data-status', // attribute name for status label
|
||||
systemInfoWormholeClass: 'pf-system-info-wormhole-', // class prefix for static wormhole element
|
||||
|
||||
// description field
|
||||
descriptionArea: 'pf-system-info-description-area', // class for "description" area
|
||||
@@ -56,6 +57,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* shows the tool action element by animation
|
||||
*/
|
||||
@@ -192,6 +194,14 @@ define([
|
||||
|
||||
parentElement.prepend(moduleElement);
|
||||
|
||||
|
||||
// add security class for statics
|
||||
if(systemData.statics){
|
||||
for(var i = 0; i < systemData.statics.length; i++){
|
||||
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
|
||||
}
|
||||
}
|
||||
|
||||
var effectName = Util.getEffectInfoForSystem(systemData.effect, 'name');
|
||||
var effectClass = Util.getEffectInfoForSystem(systemData.effect, 'class');
|
||||
|
||||
@@ -338,6 +348,15 @@ define([
|
||||
});
|
||||
}
|
||||
|
||||
// init static wormhole information ----------------------------------------------------------
|
||||
if(systemData.statics){
|
||||
for(var i = 0; i < systemData.statics.length; i++){
|
||||
var staticData = systemData.statics[i];
|
||||
var staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
|
||||
staticRowElement.addWormholeInfoTooltip(staticData);
|
||||
}
|
||||
}
|
||||
|
||||
// constellation popover ---------------------------------------------------------------------
|
||||
tempModuleElement.find('a.popup-ajax').popover({
|
||||
html: true,
|
||||
@@ -350,7 +369,6 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function details_in_popup(popoverElement){
|
||||
popoverElement = $(popoverElement);
|
||||
var popover = popoverElement.data('bs.popover');
|
||||
@@ -373,18 +391,12 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
// add security class for statics
|
||||
if(systemData.statics){
|
||||
for(var i = 0; i < systemData.statics.length; i++){
|
||||
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
|
||||
}
|
||||
}
|
||||
|
||||
var moduleData = {
|
||||
system: systemData,
|
||||
tableClass: config.systemInfoTableClass,
|
||||
nameInfoClass: config.systemInfoNameInfoClass,
|
||||
effectInfoClass: config.systemInfoEffectInfoClass,
|
||||
wormholePrefixClass: config.systemInfoWormholeClass,
|
||||
statusInfoClass: config.systemInfoStatusLabelClass,
|
||||
|
||||
systemTypeName: Util.getSystemTypeInfo(systemData.type.id, 'name'),
|
||||
|
||||
@@ -522,7 +522,6 @@ define([
|
||||
};
|
||||
|
||||
requirejs(['text!templates/tooltip/character_info.html', 'mustache'], function(template, Mustache) {
|
||||
|
||||
var content = Mustache.render(template, data);
|
||||
|
||||
element.popover({
|
||||
@@ -541,13 +540,46 @@ define([
|
||||
// set new popover content
|
||||
var popover = element.data('bs.popover');
|
||||
popover.options.content = content;
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* add a wormhole tooltip with wh specific data to elements
|
||||
* @param tooltipData
|
||||
* @returns {*}
|
||||
*/
|
||||
$.fn.addWormholeInfoTooltip = function(tooltipData){
|
||||
return this.each(function() {
|
||||
var element = $(this);
|
||||
|
||||
requirejs(['text!templates/tooltip/wormhole_info.html', 'mustache'], function (template, Mustache) {
|
||||
var content = Mustache.render(template, tooltipData);
|
||||
|
||||
element.popover({
|
||||
placement: 'top',
|
||||
html: true,
|
||||
trigger: 'hover',
|
||||
content: '',
|
||||
container: 'body',
|
||||
title: tooltipData.name +
|
||||
'<span class="pull-right ' + tooltipData.class +'">' + tooltipData.security + '</span>',
|
||||
delay: {
|
||||
show: 250,
|
||||
hide: 0
|
||||
}
|
||||
});
|
||||
|
||||
// set new popover content
|
||||
var popover = element.data('bs.popover');
|
||||
popover.options.content = content;
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* display a custom message (info/warning/error) to a container element
|
||||
* check: $.fn.showFormMessage() for an other way of showing messages
|
||||
|
||||
@@ -87,7 +87,9 @@
|
||||
{{/effectName}}
|
||||
{{#system.statics}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="text-right pf-help {{wormholePrefixClass}}{{name}}">
|
||||
<i class="fa fa-fw fa-question-circle"></i>
|
||||
</td>
|
||||
<td>Static</td>
|
||||
<td class="text-right">{{name}}</td>
|
||||
<td class="text-right {{class}}">{{security}}</td>
|
||||
|
||||
27
public/templates/tooltip/wormhole_info.html
Normal file
27
public/templates/tooltip/wormhole_info.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<table>
|
||||
{{#massTotal}}
|
||||
<tr>
|
||||
<td>Max Stable Mass</td>
|
||||
<td class="text-right">{{format}}</td>
|
||||
</tr>
|
||||
{{/massTotal}}
|
||||
{{#massIndividual}}
|
||||
<tr>
|
||||
<td>Max Jump Mass</td>
|
||||
<td class="text-right">{{format}}</td>
|
||||
</tr>
|
||||
{{/massIndividual}}
|
||||
{{#massRegeneration}}
|
||||
<tr>
|
||||
<td>Max Mass Regeneration</td>
|
||||
<td class="text-right">{{format}}</td>
|
||||
</tr>
|
||||
{{/massRegeneration}}
|
||||
{{#maxStableTime}}
|
||||
<tr>
|
||||
<td>Max Lifetime</td>
|
||||
<td class="text-right">{{format}}</td>
|
||||
</tr>
|
||||
{{/maxStableTime}}
|
||||
</table>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
// system info table
|
||||
.pf-system-info-table{
|
||||
font-size: 11px;
|
||||
white-space: nowrap
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user