Make filtering/sorting of the servicematrix work

refs #4180
This commit is contained in:
Johannes Meyer 2014-03-12 15:20:33 +01:00
parent 71f4b6960b
commit 0a5c2c5bd7
3 changed files with 28 additions and 7 deletions

View File

@ -80,6 +80,13 @@ class Query extends BaseQuery
$this->baseQuery = $this->db->select();
}
public function __clone()
{
if ($this->baseQuery !== null) {
$this->baseQuery = clone $this->baseQuery;
}
}
/**
* Return the raw base query
*

View File

@ -9,10 +9,25 @@ use Icinga\Data\BaseQuery;
class PivotTable
{
/**
* The query to fetch as pivot table
*
* @var BaseQuery
*/
protected $query;
/**
* The column to use for the x axis
*
* @var string
*/
protected $xAxisColumn;
/**
* The column to use for the y axis
*
* @var string
*/
protected $yAxisColumn;
protected $limit;
@ -101,8 +116,8 @@ class PivotTable
*/
protected function fetchXAxis()
{
$queryClass = get_class($this->query);
$query = new $queryClass($this->query->getDatasource(), array($this->xAxisColumn));
$query = clone $this->query;
$query->setColumns(array($this->xAxisColumn));
return $query->fetchColumn();
}
@ -111,8 +126,8 @@ class PivotTable
*/
protected function fetchYAxis()
{
$queryClass = get_class($this->query);
$query = new $queryClass($this->query->getDatasource(), array($this->yAxisColumn));
$query = clone $this->query;
$query->setColumns(array($this->yAxisColumn));
return $query->fetchColumn();
}

View File

@ -476,9 +476,8 @@ class Monitoring_ListController extends Controller
$this->setupFilterControl($dataview, 'servicematrix');
$this->setupSortControl(
array(
'service_state' => 'Service status',
'service_description' => 'Service description',
'host_name' => 'Hostname'
'host_name' => 'Hostname',
'service_description' => 'Service description'
)
);