From: Sebastien D. <sde...@us...> - 2005-01-05 15:43:46
|
Update of /cvsroot/tslogparser/tslogparser/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9370/admin Modified Files: index.php Log Message: Administrative user interface defined Index: index.php =================================================================== RCS file: /cvsroot/tslogparser/tslogparser/admin/index.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- index.php 4 Jan 2005 17:46:13 -0000 1.4 +++ index.php 5 Jan 2005 15:43:35 -0000 1.5 @@ -50,38 +50,223 @@ This file allows an admin to list the current releases and runs, to delete some entries or to add new ones. - It also shows the supported modules, the currently selected one - and can provide additional information on any module -*/ + We create an array with: + ---------------------------------------------------------------------------------- + | modules | TS releases | TS description | RUNs | RUN Descriptions | + ---------------------------------------------------------------------------------- + | opts | 1.5.0 | This is the... | Fedora Core 3 | Run on IA32 ... | + | <info> | <delete*> | <edit> | <delete> | <edit> | + | | | |----------------------------------| + | | | | Solaris 10 | Run on ... | + | | | | <delete> | <edit> | + | | | |----------------------------------| + | | | | <add new> | | + | |-------------------------------------------------------------------| + | | <add new> | | | | + |--------------------------------------------------------------------------------| + | ltp | 200412 | This is... | <add new> | | + | <info> | <delete> | <edit> | | | + | |-------------------------------------------------------------------| + | | <add new> | | | | + |--------------------------------------------------------------------------------| + | nfsv4 | <add new> | | | | + | <info> | | | | | + |--------------------------------------------------------------------------------| -/* List the known modules */ -?> -<table border="0" align="right"> - <tr> - <td><i>Loaded plug-ins:</td> -<?php + */ +/* Query the modules list first */ $modules=$tslp->list_modules(); -sort($modules); -foreach($modules as $module) + +/* Then list the releases and runs from the database */ +$sql= " SELECT ver_name, ver_comment, ver_id, ver_module " + ." FROM opts_versions" + ." ORDER BY ver_id DESC"; +$release_table = db_execute_select($sql); + +$sql= " SELECT DISTINCT run_id, run_name, run_comments" + ." FROM opts_run" + ." ORDER BY run_id"; +$allrun_table = db_execute_select($sql); +$orphaned=array(); +foreach ($allrun_table as $myrow) + $orphaned[$myrow["run_id"]]=$myrow["run_name"]; + +$sql= " SELECT DISTINCT run_name, run_id, run_comments, ver_name, ver_module " + ." FROM opts_run, opts_run_results, opts_version_descriptions, opts_versions " + ." WHERE run_id=res_run" + ." AND res_testcase=descr_id" + ." AND descr_version=ver_id" + ." ORDER BY ver_name"; +$run_table = db_execute_select($sql); + +/* Sort all this information into an array */ +$DATA=array(); +foreach ($modules as $module) + $DATA[$module]=array( "module"=>strip_tags($tslp->module_info("title", $module)), + "TS"=>array(), + "count"=>1); /* We count the "add new TS line here" */ +foreach ($release_table as $release) { - echo " <td>\n"; - echo " <a title=\"".strip_tags($tslp->module_info( "title", $module ))."\"> <b>$module</b></a>\n"; - echo " </td>\n"; + if (!isset($DATA[$release["ver_module"]]["TS"])) + /* This release' module is not available */ + $DATA[$release["ver_module"]]=array("TS"=>array(), "count"=>0); + + $DATA[$release["ver_module"]]["TS"][$release["ver_name"]]= + array("id"=>$release["ver_id"], + "comment"=>$release["ver_comment"], + "RUNS"=>array(), + "count"=>1); /* count the "add new run" here */ + + $DATA[$release["ver_module"]]["count"] += 1; } +foreach ($run_table as $run) +{ + unset($orphaned[$run["run_id"]]); + if (!isset($DATA[$run["ver_module"]])) + /* This run's module is not available -- really abnormal */ + $DATA[$run["ver_module"]]=array("TS"=>array(),"count"=>0); + if (!isset($DATA[$run["ver_module"]]["TS"][$run["ver_name"]])) + /* This run belongs to no testsuite */ + $DATA[$run["ver_module"]]["TS"][$run["ver_name"]]=array("RUNS"=>array(),"count"=>0); + $DATA[$run["ver_module"]]["TS"][$run["ver_name"]]["RUNS"][$run["run_id"]]= + array( "run_name"=>$run["run_name"], + "run_comments"=>$run["run_comments"]); + $DATA[$release["ver_module"]]["count"] += 1; + $DATA[$release["ver_module"]]["TS"][$run["ver_name"]]["count"] += 1; +} + +//echo "<hr><pre>\n"; +//print_r($DATA); +//echo "</pre><hr>\n"; + +if ($orphaned) +{ + echo "<p>The database contains <b>".count($orphaned)."</b> orphaned runs.</p>\n"; +} + +/* We're ready to build the array */ ?> +<table border="1" valign="top"> + <tr> + <td title="TestSuite Module" align="center"><b>Module</b></td> + <td title="TestSuite Release Name" align="center"><b>TS Release</b></td> + <td title="TestSuite Decription" align="center"><b>TS Description</b></td> + <td title="Execution Log Name" align="center"><b>RUN</b></td> + <td title="Execution Log Description" align="center"><b>RUN Description</b></td> </tr> -</table> <?php -/* Then list the releases and runs from the database */ -$TS_releases=query_version(); -echo "<pre>\n"; -print_r($TS_releases); -echo "</pre>\n"; + /* Output the array content */ + foreach ($DATA as $module => $mod_data) + { + $plugged=isset($mod_data["module"]); + $tags=0; + echo " <tr>\n"; + echo " <td"; + if ($mod_data["count"]) + echo " rowspan=\"".$mod_data["count"]."\""; + if ($plugged) + echo " title=\"".$mod_data["module"]."\""; + echo " align=\"center\" valign=\"top\">\n"; + echo "<p>".$module."</p>\n"; + if ($plugged) + echo "<p><a href=\"module_info.php?module=$module\">About...</a></p>\n"; + else + echo "<p>Unsupported module</p>\n"; + echo " </td>\n"; -?> + if ($plugged) + { + echo " <td align=\"center\" colspan=\"2\">\n"; + echo " <form method=\"GET\">\n"; + echo " <input type=\"hidden\" name=\"module\" value=\"$module\">\n"; + echo " <input type=\"submit\" name=\"add_ts\" value=\"Add New Testsuite Version\">\n"; + echo " </form>\n"; + echo " </td>\n"; + echo " <td colspan=\"2\"> </td>\n"; + echo " </tr>\n"; + } + + foreach ($mod_data["TS"] as $ts_name => $ts_data) + { + if ($plugged || ($tags > 0)) + echo " <tr>\n"; + + $known=isset($ts_data["id"]); + if ($plugged && $known) + { + echo " <form method=\"GET\">\n"; + echo " <input type=\"hidden\" name=\"module\" value=\"$module\">\n"; + echo " <input type=\"hidden\" name=\"tsid\" value=\"".$ts_data["id"]."\">\n"; + } + + echo " <td"; + if ($ts_data["count"]) + echo " rowspan=\"".$ts_data["count"]."\""; + echo " align=\"center\" valign=\"top\">\n"; + echo "<p><code>".$ts_name."</code></p>\n"; + if (!$known) + echo " <p><i>Unknown TS</i></p>\n"; + else + { + echo " <p><input type=\"Submit\" name=\"delete_ts\" value=\"Delete\""; + if ((!$plugged) || ($ts_data["count"] > 1)) + echo " disabled"; + echo "></p>\n"; + } + echo " </td>\n"; + + echo " <td"; + if ($ts_data["count"]) + echo " rowspan=\"".$ts_data["count"]."\""; + echo " valign=\"top\" align=\"center\">\n"; + echo "<p><font size='-1'>".$ts_data["comment"]."</font></p>\n"; + if ($known) + { + echo " <p><input type=\"Submit\" name=\"edit_ts\" value=\"Edit\""; + if (!$plugged) + echo " disabled"; + echo "></p>\n"; + } + echo "</td>\n"; + /* Add new run if we are in a known TS */ + if ($known) + { + echo " <td align=\"center\" colspan=\"2\">"; + echo " <input type=\"submit\" name=\"add_run\" value=\"Add New Logfile\"></td>\n"; + echo " </tr>\n"; + } + echo "</form>\n"; + + foreach ($ts_data["RUNS"] as $run_id => $run_data) + { + if ($known || ($tags > 1)) + echo " <tr>\n"; + echo " <form method=\"GET\">\n"; + echo " <input type=\"hidden\" name=\"runid\" value=\"".$run_id."\">\n"; + + echo " <td valign=\"top\" align=\"center\">\n"; + echo " <p><code>".$run_data["run_name"]."</code></p>\n"; + echo " <p><input type=\"submit\" name=\"Delete\" value=\"Delete\"></p>\n"; + echo " </td>\n"; + echo " <td valign=\"top\" align=\"center\">\n"; + echo " <p><font size='-1'>".$run_data["run_comments"]."</font></p>\n"; + echo " <p><input type=\"submit\" name=\"Edit\" value=\"Edit\"></p>\n"; + echo " </td>\n"; + echo " </form>\n"; + echo " </tr>\n"; + $tags = 2; + } + + $tags = 1; + } + } +?> +</table> + <?php +/* End of file */ db_fini(); require($root."footer.inc.php"); ?> |