diff options
author | Simon Rettberg | 2016-12-02 16:12:36 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-12-02 16:12:36 +0100 |
commit | 2fab92b81927328f9175d2acbb653254cd2e6d2d (patch) | |
tree | 4bd593ddd038960daa1f384ba45e2254e95c23f5 /modules-available | |
parent | Add simple decollapse mechanism for tables: (diff) | |
download | slx-admin-2fab92b81927328f9175d2acbb653254cd2e6d2d.tar.gz slx-admin-2fab92b81927328f9175d2acbb653254cd2e6d2d.tar.xz slx-admin-2fab92b81927328f9175d2acbb653254cd2e6d2d.zip |
[statistics] Use new decollapser on front page
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/statistics/page.inc.php | 17 | ||||
-rw-r--r-- | modules-available/statistics/templates/cpumodels.html | 11 | ||||
-rw-r--r-- | modules-available/statistics/templates/id44.html | 11 | ||||
-rw-r--r-- | modules-available/statistics/templates/memory.html | 11 | ||||
-rw-r--r-- | modules-available/statistics/templates/newclients.html | 18 |
5 files changed, 45 insertions, 23 deletions
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index ab7d589c..02fed85b 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -224,7 +224,7 @@ class Page_Statistics extends Page } - private function capChart(&$json, $cutoff, $minSlice = 0.015) + private function capChart(&$json, &$rows, $cutoff, $minSlice = 0.015) { $total = 0; foreach ($json as $entry) { @@ -243,6 +243,9 @@ class Page_Statistics extends Page ++$id; $accounted += $entry['value']; } + for ($i = $id; $i < count($rows); ++$i) { + $rows[$i]['collapse'] = 'collapse'; + } $json = array_slice($json, 0, $id); if ($accounted / $total < 0.99) { $json[] = array( @@ -333,7 +336,7 @@ class Page_Statistics extends Page ); ++$id; } - $this->capChart($json, 0.92); + $this->capChart($json, $lines, 0.92); Render::addTemplate('cpumodels', array('rows' => $lines, 'query' => $this->query, 'json' => json_encode($json))); } @@ -379,7 +382,7 @@ class Page_Statistics extends Page ); ++$id; } - $this->capChart($json, 0.92); + $this->capChart($json, $data['rows'], 0.92); $data['json'] = json_encode($json); $data['query'] = $this->query; Render::addTemplate('memory', $data); @@ -455,7 +458,7 @@ class Page_Statistics extends Page 'value' => $v, ); } - $this->capChart($json, 0.95); + $this->capChart($json, $data['rows'], 0.95); $data['json'] = json_encode($json); $data['query'] = $this->query; Render::addTemplate('id44', $data); @@ -468,7 +471,7 @@ class Page_Statistics extends Page { $filterSet->makeFragments($where, $join, $sort, $args); - $args['cutoff'] = ceil(time() / 3600) * 3600 - 86400 * 7; + $args['cutoff'] = ceil(time() / 3600) * 3600 - 86400 * 10; $res = Database::simpleQuery("SELECT machineuuid, clientip, hostname, firstseen, mbram, kvmstate, id44mb FROM machine $join" . " WHERE firstseen > :cutoff AND $where ORDER BY firstseen DESC LIMIT 32", $args); @@ -486,7 +489,7 @@ class Page_Statistics extends Page $row['hddclass'] = $this->hddColorClass($row['gbtmp']); $row['kvmicon'] = $row['kvmstate'] === 'ENABLED' ? '✓' : '✗'; if (++$count > 5) { - $row['style'] = 'display:none'; + $row['collapse'] = 'collapse'; } $rows[] = $row; } @@ -535,7 +538,7 @@ class Page_Statistics extends Page $row['hostname'] = $row['clientip']; } if (isset($row['data'])) { - if (!preg_match('/^Disk.*bytes$/m', $row['data'])) { + if (!preg_match('/^(Disk.* bytes|Disk.*\d{5,} sectors)/m', $row['data'])) { $row['nohdd'] = true; } } diff --git a/modules-available/statistics/templates/cpumodels.html b/modules-available/statistics/templates/cpumodels.html index 20da4697..d9b0298b 100644 --- a/modules-available/statistics/templates/cpumodels.html +++ b/modules-available/statistics/templates/cpumodels.html @@ -13,7 +13,7 @@ <th class="text-right text-nowrap">{{lang_modelCount}}</th> </tr> {{#rows}} - <tr id="{{id}}"> + <tr id="{{id}}" class="{{collapse}}"> <td class="text-left text-nowrap filter-col" data-filter-col="systemmodel"> <table style="width:100%; table-layout: fixed;"><tr><td style="overflow:hidden;text-overflow: ellipsis;"> <a class="filter-val" data-filter-val="{{systemmodel}}" href="?do=Statistics&show=stat&filters={{query}}~,~systemmodel={{urlsystemmodel}}">{{systemmodel}}</a> @@ -25,6 +25,15 @@ <td class="text-right">{{count}}</td> </tr> {{/rows}} + <tr class="slx-decollapse"> + <td colspan="3"> + <span class="btn-group btn-group-justified"> + <span class="btn btn-default btn-sm"> + <span class="glyphicon glyphicon-menu-down"></span> + </span> + </span> + </td> + </tr> </table> </div> <div class="col-md-4"> diff --git a/modules-available/statistics/templates/id44.html b/modules-available/statistics/templates/id44.html index 84b515d1..38cf028f 100644 --- a/modules-available/statistics/templates/id44.html +++ b/modules-available/statistics/templates/id44.html @@ -12,13 +12,22 @@ <th class="text-right">{{lang_machineCount}}</th> </tr> {{#rows}} - <tr id="tmpid{{gb}}" class="{{class}}"> + <tr id="tmpid{{gb}}" class="{{class}} {{collapse}}"> <td class="text-left text-nowrap"> <a class="filter-val" data-filter-val="{{gb}}" href="?do=Statistics&show=stat&filters={{query}}~,~hddgb={{gb}}">{{gb}} GiB</a> </td> <td class="text-right">{{count}}</td> </tr> {{/rows}} + <tr class="slx-decollapse"> + <td colspan="2"> + <span class="btn-group btn-group-justified"> + <span class="btn btn-default btn-sm"> + <span class="glyphicon glyphicon-menu-down"></span> + </span> + </span> + </td> + </tr> </table> </div> <div class="col-sm-6"> diff --git a/modules-available/statistics/templates/memory.html b/modules-available/statistics/templates/memory.html index ae040674..f17f55ca 100644 --- a/modules-available/statistics/templates/memory.html +++ b/modules-available/statistics/templates/memory.html @@ -12,13 +12,22 @@ <th class="text-right">{{lang_machineCount}}</th> </tr> {{#rows}} - <tr id="ramid{{gb}}" class="{{class}}"> + <tr id="ramid{{gb}}" class="{{class}} {{collapse}}"> <td class="text-left text-nowrap"> <a class="filter-val" data-filter-val="{{gb}}" href="?do=Statistics&show=stat&filters={{query}}~,~gbram={{gb}}">{{gb}} GiB</a> </td> <td class="text-right">{{count}}</td> </tr> {{/rows}} + <tr class="slx-decollapse"> + <td colspan="2"> + <span class="btn-group btn-group-justified"> + <span class="btn btn-default btn-sm"> + <span class="glyphicon glyphicon-menu-down"></span> + </span> + </span> + </td> + </tr> </table> </div> <div class="col-sm-6"> diff --git a/modules-available/statistics/templates/newclients.html b/modules-available/statistics/templates/newclients.html index e7d79818..c5c704d1 100644 --- a/modules-available/statistics/templates/newclients.html +++ b/modules-available/statistics/templates/newclients.html @@ -4,7 +4,7 @@ {{lang_newMachines}} </div> <div class="panel-body"> - <table class="table table-condensed table-striped" id="newclienttable"> + <table class="table table-condensed table-striped"> <tr> <th>{{lang_machine}}</th> <th class="text-right"></th> @@ -13,7 +13,7 @@ <th class="text-right">HDD</th> </tr> {{#rows}} - <tr style="{{style}}"> + <tr class="{{collapse}}"> <td class="text-nowrap"><a href="?do=Statistics&uuid={{machineuuid}}">{{hostname}}</a></td> <td class="text-right">{{firstseen}}</td> <td class="{{kvmclass}}">{{kvmicon}}</td> @@ -21,23 +21,15 @@ <td class="text-right {{hddclass}}">{{gbtmp}} GiB</td> </tr> {{/rows}} - {{#openbutton}} - <tr> - <td colspan="5" onclick="slxExpandNew(this)"> + <tr class="slx-decollapse"> + <td colspan="5"> <span class="btn-group btn-group-justified"> - <span class="btn btn-default"> + <span class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-menu-down"></span> </span> </span> - <script type="text/javascript"> - function slxExpandNew(b) { - $('#newclienttable').find('tr').show(); - $(b).hide(); - } - </script> </td> </tr> - {{/openbutton}} </table> </div> </div> |