phpci/PHPCI/View/Project/view.phtml
2014-12-03 13:51:06 +00:00

154 lines
5.2 KiB
PHTML

<script>
var PHPCI_PROJECT_ID = <?php print $project->getId(); ?>;
var PHPCI_PROJECT_BRANCH = '<?php print $branch; ?>';
</script>
<div class="clearfix" style="margin-bottom: 20px;">
<div class="pull-right btn-group">
<a class="btn btn-success" href="<?php print PHPCI_URL . 'project/build/' . $project->getId(); ?>">Build Now</a>
<div class="btn-group branch-btn pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Branch<?php print !empty($branch) ? ': ' . $branch : ''; ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php foreach ($branches as $curbranch) : ?>
<li <?php echo ($curbranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo PHPCI_URL ?>project/view/<?php print $project->getId(); ?>?branch=<?php echo urlencode($curbranch) ?>">
<?php echo $curbranch ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<li><a href="<?php echo PHPCI_URL ?>project/view/<?php print $project->getId(); ?>">All</a></li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-9 col-md-8 col-sm-8">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">Builds</h3>
</div>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Project</th>
<th class="hidden-md hidden-sm hidden-xs">Commit</th>
<th>Branch</th>
<th>Status</th>
<th style="width: 100px"></th>
</tr>
</thead>
<tbody id="latest-builds">
<?php print $builds; ?>
</tbody>
</table>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-4">
<?php if (in_array($project->getType(), array('github', 'gitlab', 'bitbucket'))): ?>
<div class="box box-info">
<div class="box-header">
<h4 class="box-title">Webhooks</h4>
</div>
<div class="box-body">
To automatically build this project when new commits are pushed, add the URL below
<?php
switch($project->getType())
{
case 'github':
$url = PHPCI_URL . 'webhook/github/' . $project->getId();
print ' as a new "Webhook" in the <a href="https://github.com/' . $project->getReference() . '/settings/hooks">Webhooks and Services</a> section of your Github repository.<br><br><strong style="word-wrap: break-word;">' . $url . '</strong>';
break;
case 'gitlab':
$url = PHPCI_URL. 'webhook/gitlab/' . $project->getId();
print ' as a "WebHook URL" in the Web Hooks section of your Gitlab repository.<br><br><strong style="word-wrap: break-word;">' . $url . '</strong>';
break;
case 'bitbucket':
$url = PHPCI_URL . 'webhook/bitbucket/' . $project->getId();
print ' as a "POST" service in the <a href="https://bitbucket.org/' . $project->getReference() . '/admin/services">Services</a> section of your Bitbucket repository.<br><br><strong style="word-wrap: break-word;">' . $url . '</strong>';
break;
}
?>
</div>
</div>
<?php endif; ?>
<?php if ($project->getSshPublicKey()): ?>
<div class="box box-info">
<div class="box-header"><h3 class="box-title"><a data-toggle="collapse" data-parent="#accordion" href="#publicCollapse">Public Key</a></h3></div>
<div class="box-body" style="word-break: break-word;"><?php print $project->getSshPublicKey(); ?></div>
</div>
<?php endif; ?>
</div>
</div>
<?php
print '<div><ul class="pagination">';
$project_url = PHPCI_URL . 'project/view/' . $project->getId() . ((!empty($branch)) ? '/' . urlencode($branch) : '');
if ($page > 1) {
print '<li><a href="' . $project_url . '?p='.($page == 1 ? '1' : $page - 1).'">&laquo; Prev</a></li>';
}
if ($pages > 1) {
$start = $page - 3;
if ($start <= 0) {
$start = 1;
}
$end = $page + 3;
if ($end > $pages) {
$end = $pages;
}
if ($start > 1) {
print '<li><a href="' . $project_url . '">1...</a></li>';
}
for($i = $start; $i <= $end; $i++)
{
if ($pages > $end && $i == $pages) continue;
if ($i == $page) {
print '<li class="bg-blue"><span>' . $i . '</span></li>';
} else {
print '<li><a href="' . $project_url . '?p=' . $i . '">' . $i . '</a></li>';
}
}
if ($pages > $end) {
print '<li><a href="' . $project_url . '?p='.$pages.'">...'.$pages.'</a></li>';
}
}
if ($page < $pages - 1) {
print '<li><a href="' . $project_url . '?p='.($page == $pages ? $pages : $page + 1).'">Next &raquo;</a></li>';
}
print '</ul></div>';
?>