various: formatting, cleanup
This commit is contained in:
parent
d795ad3c8e
commit
2ef30f5f12
|
@ -35,7 +35,14 @@ class DashboardController extends ActionController
|
||||||
$this->setAutorefreshInterval(10);
|
$this->setAutorefreshInterval(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mainDashboards = ['Objects', 'Alerts', 'Automation', 'Deployment', 'Director', 'Data'];
|
$mainDashboards = [
|
||||||
|
'Objects',
|
||||||
|
'Alerts',
|
||||||
|
'Automation',
|
||||||
|
'Deployment',
|
||||||
|
'Director',
|
||||||
|
'Data',
|
||||||
|
];
|
||||||
$this->setTitle($this->translate('Icinga Director - Main Dashboard'));
|
$this->setTitle($this->translate('Icinga Director - Main Dashboard'));
|
||||||
$names = $this->params->getValues('name', $mainDashboards);
|
$names = $this->params->getValues('name', $mainDashboards);
|
||||||
if (! $this->params->has('name')) {
|
if (! $this->params->has('name')) {
|
||||||
|
|
|
@ -15,10 +15,10 @@ class IcingaObjectFilterRenderer
|
||||||
/** @var IcingaObjectQuery */
|
/** @var IcingaObjectQuery */
|
||||||
protected $query;
|
protected $query;
|
||||||
|
|
||||||
protected $columnMap = array(
|
protected $columnMap = [
|
||||||
'host.name' => 'host.object_name',
|
'host.name' => 'host.object_name',
|
||||||
'service.name' => 'service.object_name',
|
'service.name' => 'service.object_name',
|
||||||
);
|
];
|
||||||
|
|
||||||
public function __construct(Filter $filter, IcingaObjectQuery $query)
|
public function __construct(Filter $filter, IcingaObjectQuery $query)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ class IcingaObjectQuery
|
||||||
if (! $this->hasJoinedVar($name)) {
|
if (! $this->hasJoinedVar($name)) {
|
||||||
$type = $this->type;
|
$type = $this->type;
|
||||||
$alias = $this->safeVarAlias($name);
|
$alias = $this->safeVarAlias($name);
|
||||||
$varAlias = $alias . '_v';
|
$varAlias = "v_$alias";
|
||||||
// TODO: optionally $varRelation = sprintf('icinga_%s_resolved_var', $type);
|
// TODO: optionally $varRelation = sprintf('icinga_%s_resolved_var', $type);
|
||||||
$varRelation = sprintf('icinga_%s_var', $type);
|
$varRelation = sprintf('icinga_%s_var', $type);
|
||||||
$idCol = sprintf('%s.%s_id', $alias, $type);
|
$idCol = sprintf('%s.%s_id', $alias, $type);
|
||||||
|
@ -97,6 +97,12 @@ class IcingaObjectQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug only
|
||||||
|
public function getSql()
|
||||||
|
{
|
||||||
|
return (string) $this->baseQuery;
|
||||||
|
}
|
||||||
|
|
||||||
public function listNames()
|
public function listNames()
|
||||||
{
|
{
|
||||||
return $this->db->fetchCol(
|
return $this->db->fetchCol(
|
||||||
|
@ -141,7 +147,6 @@ class IcingaObjectQuery
|
||||||
*/
|
*/
|
||||||
public function getAliasForRequiredFilterColumn($column)
|
public function getAliasForRequiredFilterColumn($column)
|
||||||
{
|
{
|
||||||
$dot = strpos($column, '.');
|
|
||||||
list($key, $sub) = $this->splitFilterKey($column);
|
list($key, $sub) = $this->splitFilterKey($column);
|
||||||
if ($sub === null) {
|
if ($sub === null) {
|
||||||
return $key;
|
return $key;
|
||||||
|
@ -169,9 +174,9 @@ class IcingaObjectQuery
|
||||||
{
|
{
|
||||||
$dot = strpos($key, '.');
|
$dot = strpos($key, '.');
|
||||||
if ($dot === false) {
|
if ($dot === false) {
|
||||||
return array($key, null);
|
return [$key, null];
|
||||||
} else {
|
} else {
|
||||||
return array(substr($key, 0, $dot), substr($key, $dot + 1));
|
return [substr($key, 0, $dot), substr($key, $dot + 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,10 @@ class IcingaFlatVar extends DbObject
|
||||||
{
|
{
|
||||||
protected $table = 'icinga_flat_var';
|
protected $table = 'icinga_flat_var';
|
||||||
|
|
||||||
protected $keyName = array(
|
protected $keyName = [
|
||||||
'checksum',
|
'var_checksum',
|
||||||
'flatname_checksum'
|
'flatname_checksum'
|
||||||
);
|
];
|
||||||
|
|
||||||
protected $defaultProperties = [
|
protected $defaultProperties = [
|
||||||
'var_checksum' => null,
|
'var_checksum' => null,
|
||||||
|
@ -39,18 +39,18 @@ class IcingaFlatVar extends DbObject
|
||||||
|
|
||||||
public static function forCustomVar(CustomVariable $var, Db $db)
|
public static function forCustomVar(CustomVariable $var, Db $db)
|
||||||
{
|
{
|
||||||
$flat = array();
|
$flat = [];
|
||||||
$varSum = $var->checksum();
|
$varSum = $var->checksum();
|
||||||
$var->flatten($flat, $var->getKey());
|
$var->flatten($flat, $var->getKey());
|
||||||
$flatVars = array();
|
$flatVars = [];
|
||||||
|
|
||||||
foreach ($flat as $name => $value) {
|
foreach ($flat as $name => $value) {
|
||||||
$flatVar = static::create(array(
|
$flatVar = static::create([
|
||||||
'var_checksum' => $varSum,
|
'var_checksum' => $varSum,
|
||||||
'flatname_checksum' => sha1($name, true),
|
'flatname_checksum' => sha1($name, true),
|
||||||
'flatname' => $name,
|
'flatname' => $name,
|
||||||
'flatvalue' => $value,
|
'flatvalue' => $value,
|
||||||
), $db);
|
], $db);
|
||||||
|
|
||||||
$flatVar->store();
|
$flatVar->store();
|
||||||
$flatVars[] = $flatVar;
|
$flatVars[] = $flatVar;
|
||||||
|
|
|
@ -29,7 +29,7 @@ class IcingaVar extends DbObject
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CustomVariable $var
|
* @param CustomVariable $customVar
|
||||||
* @param Db $db
|
* @param Db $db
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
|
|
Loading…
Reference in New Issue