diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index b8ccbb8525..b7035a8507 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -31,6 +31,8 @@ abstract class DataView implements Browsable, Filterable, Sortable protected $connection; + protected $isSorted = false; + /** * Create a new view * @@ -99,6 +101,7 @@ public static function fromRequest($request, array $columns = null) protected function applyUrlFilter($request = null) { $url = Url::fromRequest(); + $limit = $url->shift('limit'); $sort = $url->shift('sort'); $dir = $url->shift('dir'); @@ -132,20 +135,19 @@ public static function fromParams(array $params, array $columns = null) } } - $order = isset($params['order']) ? $params['order'] : null; - if ($order !== null) { - if (strtolower($order) === 'desc') { - $order = self::SORT_DESC; - } else { - $order = self::SORT_ASC; - } - } + if (isset($params['sort'])) { - $view->sort( - isset($params['sort']) ? $params['sort'] : null, - $order - ); + $order = isset($params['order']) ? $params['order'] : null; + if ($order !== null) { + if (strtolower($order) === 'desc') { + $order = self::SORT_DESC; + } else { + $order = self::SORT_ASC; + } + } + $view->sort($params['sort'], $order); + } return $view; } @@ -226,6 +228,7 @@ public function sort($column = null, $order = null) foreach ($sortColumns['columns'] as $column) { $this->query->order($column, $order); } + $this->isSorted = true; } return $this; } @@ -285,6 +288,7 @@ public function getMappedField($field) */ public function getQuery() { + if (! $this->isSorted) { $this->sort(); } return $this->query; }