Changeset 1141

Show
Ignore:
Timestamp:
11/24/06 15:04:51 (6 years ago)
Author:
benoitg
Message:
  • Show the gateway id in the technical nodelist.
Location:
trunk/wifidog-auth
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1140 r1141  
    55        * Make the google-map locator for nodes use the network center coordinates. 
    66          This change makes it usable when you didn't use the geocoder first.  
     7        * Show the gateway id in the technical nodelist. 
    78         
    892006-11-22 Benoit Grégoire  <bock@step.polymtl.ca> 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1134 r1141  
    173173    $sql = ''; 
    174174    $db = AbstractDb :: getObject(); 
    175     $db->execSqlUniqueRes("SELECT * FROM schema_info WHERE tag='schema_version'", $row, false); 
     175    $db->execSqlUniqueRes("SELECT * FROM schema_info WHERE tag='schema_version'", $row, false);//Re-check the schema version, it could have been updated by another thread 
    176176    $schema_version = $row['value']; 
    177177 
  • trunk/wifidog-auth/wifidog/node_list.php

    r1135 r1141  
    11<?php 
     2 
    23 
    34/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    5253 * Load required files 
    5354 */ 
    54 require_once(dirname(__FILE__) . '/include/common.php'); 
     55require_once (dirname(__FILE__) . '/include/common.php'); 
    5556 
    56 require_once('include/common_interface.php'); 
    57 require_once('classes/Node.php'); 
    58 require_once('classes/Utils.php'); 
    59 $smarty = SmartyWifidog::getObject(); 
    60 $db = AbstractDb::getObject(); 
     57require_once ('include/common_interface.php'); 
     58require_once ('classes/Node.php'); 
     59require_once ('classes/Utils.php'); 
     60$smarty = SmartyWifidog :: getObject(); 
     61$db = AbstractDb :: getObject(); 
    6162 
    6263// Set the sort parameter, defaults to name 
    63 if (empty ($_REQUEST["sort_by"])) 
    64 { 
     64if (empty ($_REQUEST["sort_by"])) { 
    6565    $sort_by_param = DEFAULT_SORT_BY_PARAM; 
    6666    $sort_by_using_sql = true; 
    6767} 
    68 else 
    69 { 
     68else { 
    7069    // Validate sort parameters 
    71     switch ($_REQUEST["sort_by"]) 
    72     { 
     70    switch ($_REQUEST["sort_by"]) { 
    7371        // SQL sort parameters 
    7472        case "last_heartbeat_user_agent" : 
    75                 case "name" : 
    76                 case "creation_date" : 
    77                         // Fall-through valid parameters 
    78                         $sort_by_param = $_REQUEST["sort_by"]; 
    79                         $sort_by_using_sql = true; 
    80                         break; 
    81                 // Abstraction-driven sort parameters 
    82                 case "node_id" : 
    83                 case "num_online_users" : 
    84                         $sort_by_param = $_REQUEST["sort_by"]; 
    85                         $sort_by_using_sql = false; 
    86                         break; 
    87                 default : 
    88                         $sort_by_param = DEFAULT_SORT_BY_PARAM; 
    89                         $sort_by_using_sql = true; 
    90         } 
    91 } 
    92  
    93 // Check if ordering should ignore uppper and lower case 
    94 if ($sort_by_param == "name" || $sort_by_param == "node_id") { 
    95     $sort_by_param = "lower(" . $sort_by_param . ")"; 
     73        case "name" : 
     74        case "creation_date" : 
     75        case "gw_id" : 
     76            // Fall-through valid parameters 
     77            $sort_by_param = $_REQUEST["sort_by"]; 
     78            $sort_by_using_sql = true; 
     79            break; 
     80            // Abstraction-driven sort parameters 
     81        case "node_id" : 
     82        case "num_online_users" : 
     83            $sort_by_param = $_REQUEST["sort_by"]; 
     84            $sort_by_using_sql = false; 
     85            break; 
     86        default : 
     87            $sort_by_param = DEFAULT_SORT_BY_PARAM; 
     88            $sort_by_using_sql = true; 
     89    } 
    9690} 
    9791 
    9892// Sort according to above instructions 
    99 if ($sort_by_using_sql === true) 
    100     $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY {$sort_by_param}"; 
    101 else 
    102     $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY ".DEFAULT_SORT_BY_PARAM; 
     93if ($sort_by_using_sql === true) { 
     94    // Check if ordering should ignore uppper and lower case 
     95    if ($sort_by_param == "name" || $sort_by_param == "node_id") { 
     96        $sort_by_param_sql = "lower(" . $sort_by_param . ")"; 
     97    } 
     98    else { 
     99        $sort_by_param_sql = $sort_by_param; 
     100    } 
     101    $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY {$sort_by_param_sql}"; 
     102} 
     103else { 
     104    $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY " . DEFAULT_SORT_BY_PARAM; 
     105} 
    103106$nodes_results = null; 
    104107$db->execSql($sql, $nodes_results, false); 
     
    107110    throw new Exception(_("No nodes could not be found in the database")); 
    108111 
    109 $deploymentStatuses = array( 
    110     "DEPLOYED" => _("Deployed"), 
    111     "IN_PLANNING" => _("In planning"), 
    112     "IN_TESTING" => _("In testing"), 
    113     "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
    114     "PERMANENTLY_CLOSED" => _("Permanently closed"), 
    115     "TEMPORARILY_CLOSED" => _("Temporarily closed") 
    116     ); 
     112$deploymentStatuses = array ( 
     113    "DEPLOYED" => _("Deployed" 
     114), "IN_PLANNING" => _("In planning"), "IN_TESTING" => _("In testing"), "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), "PERMANENTLY_CLOSED" => _("Permanently closed"), "TEMPORARILY_CLOSED" => _("Temporarily closed")); 
    117115 
    118116$nodes_list = array (); 
    119 foreach ($nodes_results as $node_row) 
    120 { 
     117foreach ($nodes_results as $node_row) { 
    121118    $node = Node :: getObject($node_row['node_id']); 
    122119    $node_row['duration'] = $db->GetDurationArrayFromIntervalStr($node_row['since_last_heartbeat']); 
     
    128125 
    129126// Sort using PHP 
    130 if ($sort_by_using_sql === false) 
    131 { 
     127if ($sort_by_using_sql === false) { 
    132128    // Using natural-sort algorithm . 
    133     switch ($sort_by_param) 
    134     { 
     129    switch ($sort_by_param) { 
    135130        case "node_id" : 
    136             Utils::natsort2d($nodes_list, "node_id"); 
     131            Utils :: natsort2d($nodes_list, "node_id"); 
    137132            break; 
    138133        case "num_online_users" : 
    139             Utils::natsort2d($nodes_list, "num_online_users"); 
     134            Utils :: natsort2d($nodes_list, "num_online_users"); 
    140135            break; 
    141136    } 
     
    146141$smarty->assign("sort_by_param", $sort_by_param); 
    147142 
    148 require_once('classes/MainUI.php'); 
     143require_once ('classes/MainUI.php'); 
    149144 
    150 $ui = MainUI::getObject(); 
     145$ui = MainUI :: getObject(); 
    151146$ui->addContent('main_area_middle', $smarty->fetch("templates/node_list.html")); 
    152147$ui->display(); 
     
    159154 * End: 
    160155 */ 
    161  
    162156?> 
  • trunk/wifidog-auth/wifidog/templates/node_list.html

    r1138 r1141  
    88                                {if $sort_by_param == "last_heartbeat_user_agent"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 
    99                        </th> 
     10                        {* <th> 
     11                                <a href="?sort_by=node_id">{"Node id"|_}</a> 
     12                                {if $sort_by_param == "node_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 
     13                        </th> *} 
    1014                        <th> 
    11                                 <a href="?sort_by=node_id">{"Id"|_}</a> 
    12                                 {if $sort_by_param == "node_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 
     15                                <a href="?sort_by=gw_id">{"Gateway id"|_}</a> 
     16                                {if $sort_by_param == "gw_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 
    1317                        </th> 
    1418                        <th> 
     
    3842                    {$nodes[node].last_heartbeat_user_agent} 
    3943                    </td> 
    40                     <td>{$nodes[node].node_id}</td> 
     44                    {* <td>{$nodes[node].node_id}</td> *} 
     45                    <td>{$nodes[node].gw_id}</td> 
    4146                    <td>{$nodes[node].name}</td> 
    4247                    <td>