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(); $this->baseQuery = $this->db->select();
} }
public function __clone()
{
if ($this->baseQuery !== null) {
$this->baseQuery = clone $this->baseQuery;
}
}
/** /**
* Return the raw base query * Return the raw base query
* *

View File

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

View File

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