Merge "Revert "Minor updates to info file""
[pharos.git] / tools / infra-dashboard / pages / ci_pods.php
1 <script type="text/javascript">
2     $(document).ready(function() {
3         $('#example').DataTable( {
4             "order": [[ 3, "desc" ],[ 2, "desc" ]]
5         } );
6     } );
7 </script>
8
9 <?php
10     include '../utils/jenkinsAdapter.php';
11     include '../utils/database.php';
12
13     connectDB();
14     $result = mysql_query("SELECT * FROM resource, pod WHERE resource.resource_id=pod.resource_id;");
15     closeDB();
16
17     echo '<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">';
18     echo "<thead>";
19     echo "<tr>";
20     echo "<th>Name</th>";
21     echo "<th>Slave Name</th>";
22     echo "<th>Status</th>";
23     echo "<th>Installer</th>";
24     echo "<th>Scenario</th>";
25     echo "<th>Branch</th>";
26     echo "<th>Job</th>";
27     echo "</tr>";
28     echo "</thead>";
29     echo "<tbody>";
30
31     while ($row = mysql_fetch_array($result)) {
32         $slave = $row{'slavename'};
33         if (! isCiPod($slave)) continue;
34
35         $slave_url = getSlaveUrl($slave);
36         $status = getSlaveStatus($slave);
37
38         $job_name = "";
39         $job_installer = "";
40         $job_branch = "";
41         $job_url = "";
42         $job_scenario = "";
43         $job_type = "";
44
45         if ($status == 'online'){
46             $job_params = getJJob($slave);
47             $job_name = $job_params['name'];
48             $job_installer = $job_params['installer'];
49             $job_branch = $job_params['branch'];
50             $job_url = $job_params['url']."lastBuild/consoleFull";
51             $job_scenario = $job_params['scenario'];
52             $job_type = $job_params['type'];
53         }
54
55         echo "<tr>";
56         echo "<th><a target='_blank' href='".$row{'link'}."'>".$row{'name'}."</a></th>";
57         echo "<th><a target='_blank' href='".$slave_url."'>".$slave."</a></th>";
58         if ($status == "online") $color = "#BEFAAA";
59         else $color = "#FAAAAB";
60         echo "<th style='background-color: ".$color.";'>".$status."</th>";
61         if ($job_type == "0") $class = "blink_me";
62         else $class="";
63         echo "<th class='".$class."'>".$job_installer."</th>";
64         echo "<th class='".$class."'>".$job_scenario."</th>";
65         echo "<th class='".$class."'>".$job_branch."</th>";
66   $green = '#33cc00';
67   $grey = '#646F73';
68   $red = '#FF5555';
69   $orange = '#EDD62B';
70         if ($job_type == "0") { // job running
71             echo "<th><a class='blink_me' style='font-size:12px;color:".$grey.";' target='_blank' href='".$job_url."'>".$job_name."</a></th>";
72         }
73         else if ($job_type == "1") {// last job successful
74             echo "<th><a style='font-size:12px;color:".$green.";' target='_blank' href='".$job_url."'>".$job_name."</a></th>";
75         }
76         else if ($job_type == "2") {// last job failed
77             echo "<th><a style='font-size:12px;color:".$red."' target='_blank' href='".$job_url."'>".$job_name."</a></th>";
78         }
79         else if ($job_type == "3") {// last job is unstable
80             echo "<th><a style='font-size:12px;color:".$orange."' target='_blank' href='".$job_url."'>".$job_name."</a></th>";
81   }
82         else {
83             echo "<th><a style='font-size:12px;' target='_blank' href='".$job_url."'>".$job_name."</a></th>";
84         }
85         echo "</tr>";
86     }
87     echo '</tbody>';
88     echo '</table>';
89
90
91 ?>