Split dashboard into widgets. Add build errors widget.
This commit is contained in:
parent
257aabc113
commit
11f58d7c2b
24 changed files with 793 additions and 328 deletions
13
src/PHPCensor/View/WidgetLastBuilds/index.phtml
Normal file
13
src/PHPCensor/View/WidgetLastBuilds/index.phtml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
use PHPCensor\Helper\Lang;
|
||||
|
||||
?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php Lang::out('latest_builds'); ?></h3>
|
||||
</div>
|
||||
<div class="box-body" id="timeline-box">
|
||||
<?= $timeline ?>
|
||||
</div>
|
||||
</div>
|
||||
117
src/PHPCensor/View/WidgetLastBuilds/update.phtml
Normal file
117
src/PHPCensor/View/WidgetLastBuilds/update.phtml
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
use PHPCensor\Helper\Lang;
|
||||
use PHPCensor\Model\Build;
|
||||
|
||||
/**
|
||||
* @var Build[] $builds
|
||||
*/
|
||||
|
||||
?>
|
||||
<ul class="timeline">
|
||||
<?php $last = new \DateTime('-1 Year'); ?>
|
||||
|
||||
<?php
|
||||
foreach ($builds as $build):
|
||||
$environment = $build->getEnvironment();
|
||||
$branches = $build->getExtra('branches');
|
||||
|
||||
switch ($build->getStatus()) {
|
||||
case Build::STATUS_PENDING:
|
||||
$updated = $build->getCreateDate();
|
||||
$label = Lang::get('pending');
|
||||
$color = 'blue';
|
||||
break;
|
||||
|
||||
case Build::STATUS_RUNNING:
|
||||
$updated = $build->getStartDate();
|
||||
$label = Lang::get('running');
|
||||
$color = 'yellow';
|
||||
break;
|
||||
|
||||
case Build::STATUS_SUCCESS:
|
||||
$updated = $build->getFinishDate();
|
||||
$label = Lang::get('success');
|
||||
$color = 'green';
|
||||
break;
|
||||
|
||||
case Build::STATUS_FAILED:
|
||||
$updated = $build->getFinishDate();
|
||||
$label = Lang::get('failed');
|
||||
$color = 'red';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$updated) {
|
||||
$updated = $build->getCreateDate();
|
||||
}
|
||||
|
||||
if ($updated->format('Y-m-d') != $last->format('Y-m-d')): $last = $updated;
|
||||
?>
|
||||
<li class="time-label">
|
||||
<span class="bg-gray">
|
||||
<?= $last->format('Y-m-d'); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- /.timeline-label -->
|
||||
<!-- timeline item -->
|
||||
<li>
|
||||
<i class="fa fa-<?php print $build->getProject()->getIcon(); ?> bg-<?php print $color; ?>"></i>
|
||||
<div class="timeline-item">
|
||||
<span class="time"><i class="fa fa-clock-o"></i>
|
||||
<?php
|
||||
echo $updated->format('H:i:s');
|
||||
if ($build->getStatus() != Build::STATUS_PENDING) {
|
||||
echo ' — ' . $build->getDuration(); ?> <?= Lang::get('seconds');
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
<h3 class="timeline-header">
|
||||
<a href="<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>">
|
||||
<?= $build->getProject()->getTitle(); ?>
|
||||
</a>
|
||||
<span><?= $environment; ?></span>
|
||||
—
|
||||
<a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>">
|
||||
Build #<?= $build->getId(); ?>
|
||||
</a>
|
||||
—
|
||||
<?php Lang::out($build->getSourceHumanize()); ?>
|
||||
</h3>
|
||||
|
||||
<div class="timeline-body">
|
||||
<a href="<?= $build->getBranchLink();?>"><i class="fa fa-code-fork"></i> <?php echo $build->getBranch(); ?></a>
|
||||
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
|
||||
<?php if ($tag = $build->getTag()): ?> /
|
||||
<a href="<?= $build->getTagLink(); ?>" target="_blank">
|
||||
<i class="fa fa-tag"></i> <?= $tag; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if (!empty($build->getCommitId())) {
|
||||
echo ' — ';
|
||||
echo sprintf(
|
||||
'<a href="%s" target="_blank">%s %s</a>',
|
||||
$build->getCommitLink(),
|
||||
substr($build->getCommitId(), 0, 7),
|
||||
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
|
||||
);
|
||||
if (!empty($build->getCommitMessage())) {
|
||||
echo ' — ';
|
||||
print $build->getCommitMessage();
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<!-- END timeline item -->
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<li>
|
||||
<i class="fa fa-clock-o"></i>
|
||||
</li>
|
||||
</ul>
|
||||
Loading…
Add table
Add a link
Reference in a new issue