phpci/PHPCI/View/SummaryTable.phtml

98 lines
2.9 KiB
PHTML
Raw Normal View History

2013-06-05 07:23:47 +02:00
<?php
2013-10-08 14:52:05 +02:00
foreach($projects as $project):
$statuses = array();
$successes = 0;
$failures = 0;
$health = '';
$subcls = '';
$cls = '';
2013-06-05 07:23:47 +02:00
2013-10-08 14:52:05 +02:00
$success = null;
$failure = null;
2013-06-05 07:23:47 +02:00
2013-10-08 14:52:05 +02:00
if (count($builds[$project->getId()])) {
2013-06-05 07:23:47 +02:00
2013-10-08 14:52:05 +02:00
// Use the latest build information to determine current status:
$latestBuild = $builds[$project->getId()][0];
2013-06-05 07:45:04 +02:00
2013-10-08 14:52:05 +02:00
switch ($latestBuild->getStatus()) {
case 0:
$cls = 'active';
$status = 'Pending';
break;
2013-06-05 07:45:04 +02:00
2013-10-08 14:52:05 +02:00
case 1:
$cls = 'warning';
$status = 'Running';
break;
2013-06-05 07:45:04 +02:00
2013-10-08 14:52:05 +02:00
case 2:
$cls = 'success';
$status = 'Success';
break;
2013-06-05 07:23:47 +02:00
2013-10-08 14:52:05 +02:00
case 3:
$cls = 'danger';
$status = 'Failed';
break;
}
2013-06-09 21:29:49 +02:00
2013-10-08 14:52:05 +02:00
// Use the last 5 builds to determine project health:
$successes = 0;
$failures = 0;
2013-10-08 14:52:05 +02:00
foreach ($builds[$project->getId()] as $build) {
switch ($build->getStatus()) {
case 0:
$statuses[] = 'pending';
break;
case 1:
$statuses[] = 'running';
break;
case 2:
$successes++;
$statuses[] = 'ok';
$success = is_null($success) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $success;
2013-10-08 14:52:05 +02:00
break;
case 3:
$failures++;
$statuses[] = 'failed';
$failure = is_null($failure) && !is_null($build->getFinished()) ? $build->getFinished()->format('Y-m-d H:i:s') : $failure;
2013-10-08 14:52:05 +02:00
break;
}
}
}
2013-10-08 14:52:05 +02:00
if ($failures == 0) {
$health = 'Good';
$subcls = 'success';
} elseif ($failures > $successes) {
$health = 'Bad';
$subcls = 'danger';
} else {
$health = 'Warning';
$subcls = 'warning';
2013-06-09 21:29:49 +02:00
}
2013-06-05 07:23:47 +02:00
?>
<tr class="<?php print $cls; ?>">
2013-06-09 21:29:49 +02:00
<td>
2014-01-28 22:27:39 +01:00
<span class='label label-<?php echo $subcls ?>'>
<?php echo $health ?>
2013-06-09 21:29:49 +02:00
</span>
</td>
2014-01-28 22:27:39 +01:00
<td><a href='<?php echo PHPCI_URL ?>project/view/<?php echo $project->getId() ?>'><?php echo htmlspecialchars($project->getTitle()) ?></a></td>
2013-10-08 14:52:05 +02:00
<td><?php print is_null($success) ? 'Never' : $success; ?></td>
<td><?php print is_null($failure) ? 'Never' : $failure; ?></td>
2013-06-09 21:29:49 +02:00
<td>
2013-10-08 14:52:05 +02:00
<?php
foreach ($statuses as $status) {
print '<img alt="'.$status.'" src="' . PHPCI_URL . 'assets/img/icon-build-' . $status . '.png">';
}
?>
2013-06-09 21:29:49 +02:00
</td>
2014-04-30 15:13:07 +02:00
<td><a class="btn btn-default btn-sm" href='<?php echo PHPCI_URL ?>project/build/<?php echo $project->getId(); ?>'>build now &raquo;</a></td>
2013-06-05 07:23:47 +02:00
</tr>
<?php endforeach; ?>