diff options
author | Simon Rettberg | 2020-04-21 18:16:36 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-04-21 18:16:36 +0200 |
commit | d6bbb4d57a086dfaf5f0a1ebf8913577568ae887 (patch) | |
tree | 95f7c80a38bfb02b1dd5c1c796e9d333d26d0ff5 /modules-available/statistics/pages | |
parent | [statistics] New filter UI (diff) | |
download | slx-admin-d6bbb4d57a086dfaf5f0a1ebf8913577568ae887.tar.gz slx-admin-d6bbb4d57a086dfaf5f0a1ebf8913577568ae887.tar.xz slx-admin-d6bbb4d57a086dfaf5f0a1ebf8913577568ae887.zip |
[statistics] Refactor filter creation (Part 1)
Filter classes are now instances of their respective classes, to move
more logic into those classes. A bind method is used for assigning
actual operator and argument values.
renderFilterBox() is still a little too messy, maybe a clever class for
mapping a (bound) filter to data for mustache will come in handy here.
Diffstat (limited to 'modules-available/statistics/pages')
-rw-r--r-- | modules-available/statistics/pages/list.inc.php | 5 | ||||
-rw-r--r-- | modules-available/statistics/pages/summary.inc.php | 19 |
2 files changed, 12 insertions, 12 deletions
diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index a709ab3d..7b8e8f5f 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -15,7 +15,6 @@ class SubPage $filters = StatisticsFilter::parseQuery(); $filterSet = new StatisticsFilterSet($filters); - $filterSet->setSort($sortColumn, $sortDirection); if (!$filterSet->setAllowedLocationsFromPermission('view.list')) { Message::addError('main.no-permission'); @@ -32,7 +31,7 @@ class SubPage private static function showMachineList($filterSet) { Module::isAvailable('js_stupidtable'); - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $xtra = ''; if ($filterSet->isNoId44Filter()) { $xtra .= ', data'; @@ -47,7 +46,7 @@ class SubPage m.logintime, m.state, m.currentuser, m.realcores, m.mbram, m.kvmstate, m.cpumodel, m.id44mb, m.hostname, m.notes IS NOT NULL AS hasnotes, m.badsectors, Count(s.machineuuid) AS confvars $xtra FROM machine m LEFT JOIN setting_machine s USING (machineuuid) - $join WHERE $where GROUP BY m.machineuuid $sort", $args); + $join WHERE $where GROUP BY m.machineuuid", $args); $rows = array(); $singleMachine = 'none'; // TODO: Cannot disable checkbox for those where user has no permission, since we got multiple actions now diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php index c2e3ac80..ead62a26 100644 --- a/modules-available/statistics/pages/summary.inc.php +++ b/modules-available/statistics/pages/summary.inc.php @@ -17,7 +17,6 @@ class SubPage $filters = StatisticsFilter::parseQuery(); $filterSet = new StatisticsFilterSet($filters); - $filterSet->setSort($sortColumn, $sortDirection); if (!$filterSet->setAllowedLocationsFromPermission('view.summary')) { Message::addError('main.no-permission'); @@ -47,7 +46,7 @@ class SubPage */ private static function showSummary($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $known = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE $where", $args); $on = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE state IN ('IDLE', 'OCCUPIED') AND ($where)", $args); $used = Database::queryFirst("SELECT Count(*) AS val FROM machine m $join WHERE state = 'OCCUPIED' AND ($where)", $args); @@ -100,7 +99,7 @@ class SubPage */ private static function showSystemModels($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $res = Database::simpleQuery('SELECT systemmodel, Round(AVG(realcores)) AS cores, Count(*) AS `count` FROM machine m' . " $join WHERE $where GROUP BY systemmodel ORDER BY `count` DESC, systemmodel ASC", $args); $lines = array(); @@ -130,8 +129,9 @@ class SubPage */ private static function showMemory($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); - $res = Database::simpleQuery("SELECT mbram, Count(*) AS `count` FROM machine m $join WHERE $where GROUP BY mbram", $args); + $filterSet->makeFragments($where, $join, $args); + $res = Database::simpleQuery("SELECT mbram, Count(*) AS `count` FROM machine m $join + WHERE $where GROUP BY mbram", $args); $lines = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { $gb = (int)ceil($row['mbram'] / 1024); @@ -174,9 +174,10 @@ class SubPage */ private static function showKvmState($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $colors = array('UNKNOWN' => '#666', 'UNSUPPORTED' => '#ea5', 'DISABLED' => '#e55', 'ENABLED' => '#6d6'); - $res = Database::simpleQuery("SELECT kvmstate, Count(*) AS `count` FROM machine m $join WHERE $where GROUP BY kvmstate ORDER BY `count` DESC", $args); + $res = Database::simpleQuery("SELECT kvmstate, Count(*) AS `count` FROM machine m $join + WHERE $where GROUP BY kvmstate ORDER BY `count` DESC", $args); $lines = array(); $json = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { @@ -195,7 +196,7 @@ class SubPage */ private static function showId44($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $res = Database::simpleQuery("SELECT id44mb, Count(*) AS `count` FROM machine m $join WHERE $where GROUP BY id44mb", $args); $lines = array(); $total = 0; @@ -245,7 +246,7 @@ class SubPage */ private static function showLatestMachines($filterSet) { - $filterSet->makeFragments($where, $join, $sort, $args); + $filterSet->makeFragments($where, $join, $args); $args['cutoff'] = ceil(time() / 3600) * 3600 - 86400 * 10; $res = Database::simpleQuery("SELECT machineuuid, clientip, hostname, firstseen, mbram, kvmstate, id44mb FROM machine m $join" |