From a6cede63b37bf5f2ddd6d53a53ff641331923985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Mon, 2 Mar 2009 14:20:19 +0000 Subject: [PATCH] Added sorting of columns on ldapstatus page... git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1361 44740490-163a-0410-bde0-09ae8108e29a --- modules/ldapstatus/templates/ldapstatus.php | 30 +++++++++------- modules/ldapstatus/www/index.php | 39 +++++++++++++++++++-- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/modules/ldapstatus/templates/ldapstatus.php b/modules/ldapstatus/templates/ldapstatus.php index 2fb613e05..9bf913c30 100644 --- a/modules/ldapstatus/templates/ldapstatus.php +++ b/modules/ldapstatus/templates/ldapstatus.php @@ -31,17 +31,17 @@ $this->includeAtTemplateBase('includes/header.php'); <table class="attributes" style="font-size: small; width: 100%; border: 1px solid #aaa"> <tr> <th>Name of institusion</th> - <th>Conf</th> - <th>Ping</th> - <th colspan="3">Cert</th> - <th>Admin</th> - <th>S=bogus</th> - <th>test</th> - <th>S=test</th> - <th>T-bind()</th> - <th>Org-info</th> - <th>Meta</th> - <th>Time</th> + <th><a href="?sort=conf">Conf</a></th> + <th><a href="?sort=ping">Ping</a></th> + <th colspan="3"><a href="?sort=cert">Cert</a></th> + <th><a href="?sort=adminBind">Admin</a></th> + <th><a href="?sort=ldapSearchBogus">S=bogus</a></th> + <th><a href="?sort=configTest">test</a></th> + <th><a href="?sort=ldapSearchTestUser">S=test</a></th> + <th><a href="?sort=ldapBindTestUser">T-bind()</a></th> + <th><a href="?sort=getTestOrg">Org-info</a></th> + <th><a href="?sort=configMeta">Meta</a></th> + <th><a href="?sort=time">Time</a></th> </tr> <?php @@ -116,8 +116,14 @@ foreach($this->data['sortedOrgIndex'] as $orgkey) { showRes('configMeta', $res, $this); + if ($res['time'] > 2.0) { + echo('<td style="text-align: right; color: #700">' . ceil($res['time']*1000) . ' ms</td>'); + } else if ($res['time'] > 0.3) { + echo('<td style="text-align: right">' . ceil($res['time']*1000) . ' ms</td>'); + } else { + echo('<td style="text-align: right; color: #060">' . ceil($res['time']*1000) . ' ms</td>'); + } - echo('<td style="text-align: right">' . ceil($res['time']*1000) . ' ms</td>'); echo('</tr>'); if ($this->data['showcomments'] && array_key_exists('comment', $this->data['orgconfig'][$orgkey])) { diff --git a/modules/ldapstatus/www/index.php b/modules/ldapstatus/www/index.php index d98e1f42d..205b64af9 100644 --- a/modules/ldapstatus/www/index.php +++ b/modules/ldapstatus/www/index.php @@ -170,10 +170,45 @@ $session->setData('module:ldapstatus', 'results', $results); $lightCounter = array(0,0,0); -function resultCode($res) { + + +function resultCode($res, $sortby = NULL) { global $lightCounter; $code = ''; $columns = array('config', 'ping', 'cert', 'adminBind', 'ldapSearchBogus', 'configTest', 'ldapSearchTestUser', 'ldapBindTestUser', 'getTestOrg', 'configMeta'); + + if (!empty($sortby) && in_array($sortby, $columns)) { + + + if (array_key_exists($sortby, $res)) { + + if ($res[$sortby][0]) { + $code .= '0'; + } else { + $code .= '2'; + } + + } else { + $code .= '1'; + } + + if ($sortby == 'cert') { + if (array_key_exists($sortby, $res) && isset($res[$sortby]['expire'])) + $code .= sprintf("%05s", (99999 - $res[$sortby]['expire']) ); + else + $code .= '-----'; + } + + $code .= '|'; + } + if ($sortby === 'time') { + if (array_key_exists($sortby, $res)) + $code .= sprintf("%05s", floor(1000*$res[$sortby]) ); + else + $code .= '-----'; + $code .= '|'; + } + foreach ($columns AS $c) { if (array_key_exists($c, $res)) { if ($res[$c][0]) { @@ -195,7 +230,7 @@ function resultCode($res) { $ressortable = array(); foreach ($results AS $key => $res) { - $ressortable[$key] = resultCode($res[0]); + $ressortable[$key] = resultCode($res[0], (isset($_REQUEST['sort']) ? $_REQUEST['sort'] : NULL)); } arsort($ressortable); #echo '<pre>'; print_r($ressortable); exit; -- GitLab