mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
parent
d1f9c5ff0d
commit
f2f1e12b8e
@ -8,7 +8,7 @@ use Icinga\Application\Icinga;
|
|||||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||||
use Zend_Paginator;
|
use Zend_Paginator;
|
||||||
|
|
||||||
class PivotTable
|
class PivotTable implements Sortable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The query to fetch as pivot table
|
* The query to fetch as pivot table
|
||||||
@ -17,20 +17,6 @@ class PivotTable
|
|||||||
*/
|
*/
|
||||||
protected $baseQuery;
|
protected $baseQuery;
|
||||||
|
|
||||||
/**
|
|
||||||
* The query to fetch the x axis labels
|
|
||||||
*
|
|
||||||
* @var SimpleQuery
|
|
||||||
*/
|
|
||||||
protected $xAxisQuery;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The query to fetch the y axis labels
|
|
||||||
*
|
|
||||||
* @var SimpleQuery
|
|
||||||
*/
|
|
||||||
protected $yAxisQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column that contains the labels for the x axis
|
* The column that contains the labels for the x axis
|
||||||
*
|
*
|
||||||
@ -59,6 +45,27 @@ class PivotTable
|
|||||||
*/
|
*/
|
||||||
protected $yAxisFilter;
|
protected $yAxisFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The query to fetch the x axis labels
|
||||||
|
*
|
||||||
|
* @var SimpleQuery
|
||||||
|
*/
|
||||||
|
protected $xAxisQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The query to fetch the y axis labels
|
||||||
|
*
|
||||||
|
* @var SimpleQuery
|
||||||
|
*/
|
||||||
|
protected $yAxisQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Column for sorting the result set
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $order = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new pivot table
|
* Create a new pivot table
|
||||||
*
|
*
|
||||||
@ -73,6 +80,31 @@ class PivotTable
|
|||||||
$this->yAxisColumn = $yAxisColumn;
|
$this->yAxisColumn = $yAxisColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return $this->order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function hasOrder()
|
||||||
|
{
|
||||||
|
return ! empty($this->order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function order($field, $direction = null)
|
||||||
|
{
|
||||||
|
$this->order[$field] = $direction;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filter to apply on the query for the x axis
|
* Set the filter to apply on the query for the x axis
|
||||||
*
|
*
|
||||||
@ -137,9 +169,10 @@ class PivotTable
|
|||||||
$this->xAxisQuery->addFilter($this->xAxisFilter);
|
$this->xAxisQuery->addFilter($this->xAxisFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->xAxisQuery->hasOrder($this->xAxisColumn)) {
|
$this->xAxisQuery->order(
|
||||||
$this->xAxisQuery->order($this->xAxisColumn, 'asc');
|
$this->xAxisColumn,
|
||||||
}
|
isset($this->order[$this->xAxisColumn]) ? $this->order[$this->xAxisColumn] : self::SORT_ASC
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->xAxisQuery;
|
return $this->xAxisQuery;
|
||||||
@ -161,9 +194,10 @@ class PivotTable
|
|||||||
$this->yAxisQuery->addFilter($this->yAxisFilter);
|
$this->yAxisQuery->addFilter($this->yAxisFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->yAxisQuery->hasOrder($this->yAxisColumn)) {
|
$this->yAxisQuery->order(
|
||||||
$this->yAxisQuery->order($this->yAxisColumn, 'asc');
|
$this->yAxisColumn,
|
||||||
}
|
isset($this->order[$this->yAxisColumn]) ? $this->order[$this->yAxisColumn] : self::SORT_ASC
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->yAxisQuery;
|
return $this->yAxisQuery;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user