Refactored 'build/view' action.
This commit is contained in:
parent
5ac0cfba44
commit
1fe8d68f03
|
@ -498,3 +498,17 @@ var Lang = {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jquery(document).ready(function() {
|
||||||
|
jquery('#delete-build').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var buildId = this.data('buildId');
|
||||||
|
var projectId = this.data('projectId');
|
||||||
|
|
||||||
|
confirmDelete(APP_URL + 'build/delete/' + buildId)
|
||||||
|
.onCloseConfirmed = function () {
|
||||||
|
window.location = APP_URL + 'project/view/' + projectId;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -10,6 +10,7 @@ use PHPCensor\Helper\AnsiConverter;
|
||||||
use PHPCensor\Helper\Lang;
|
use PHPCensor\Helper\Lang;
|
||||||
use PHPCensor\Http\Response\RedirectResponse;
|
use PHPCensor\Http\Response\RedirectResponse;
|
||||||
use PHPCensor\Model\Build;
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Model\Project;
|
||||||
use PHPCensor\Model\User;
|
use PHPCensor\Model\User;
|
||||||
use PHPCensor\Service\BuildService;
|
use PHPCensor\Service\BuildService;
|
||||||
use PHPCensor\WebController;
|
use PHPCensor\WebController;
|
||||||
|
@ -47,8 +48,6 @@ class BuildController extends WebController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View a specific build.
|
|
||||||
*
|
|
||||||
* @param integer $buildId
|
* @param integer $buildId
|
||||||
*
|
*
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
|
@ -143,6 +142,77 @@ class BuildController extends WebController
|
||||||
$this->layout->actions = $actions;
|
$this->layout->actions = $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $buildId
|
||||||
|
*
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function viewLog($buildId)
|
||||||
|
{
|
||||||
|
$build = BuildFactory::getBuildById($buildId);
|
||||||
|
|
||||||
|
if (!$build) {
|
||||||
|
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Project $project */
|
||||||
|
$project = Factory::getStore('Project')->getByPrimaryKey($build->getProjectId());
|
||||||
|
|
||||||
|
/** @var \PHPCensor\Store\BuildErrorStore $errorStore */
|
||||||
|
$errorStore = Factory::getStore('BuildError');
|
||||||
|
|
||||||
|
$this->view->build = $build;
|
||||||
|
$this->view->totalErrors = $errorStore->getErrorTotalForBuild($build->getId());
|
||||||
|
|
||||||
|
$this->layout->title = Lang::get('build_n', $buildId);
|
||||||
|
$this->layout->subtitle = $build->getProjectTitle();
|
||||||
|
|
||||||
|
switch ($build->getStatus()) {
|
||||||
|
case 0:
|
||||||
|
$this->layout->skin = 'blue';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
$this->layout->skin = 'yellow';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
$this->layout->skin = 'green';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
$this->layout->skin = 'red';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rebuildLabel = Lang::get('rebuild_now');
|
||||||
|
$rebuildLink = APP_URL . 'build/rebuild/' . $build->getId();
|
||||||
|
|
||||||
|
$deleteLabel = Lang::get('delete_build');
|
||||||
|
$deleteLink = APP_URL . 'build/delete/' . $build->getId();
|
||||||
|
|
||||||
|
$actions = '';
|
||||||
|
if (!$project->getArchived()) {
|
||||||
|
$actions .= sprintf(
|
||||||
|
'<a class="btn btn-default" href="%s">%s</a>',
|
||||||
|
$rebuildLink,
|
||||||
|
$rebuildLabel
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->currentUserIsAdmin()) {
|
||||||
|
$actions .= sprintf(
|
||||||
|
'<a class="btn btn-danger" id="delete-build" data-build-id="%s" data-project-id="%s" href="%s">%s</a>',
|
||||||
|
$build->getId(),
|
||||||
|
$build->getProjectId(),
|
||||||
|
$deleteLink,
|
||||||
|
$deleteLabel
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->layout->actions = $actions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of the JS plugins to include.
|
* Returns an array of the JS plugins to include.
|
||||||
* @return array
|
* @return array
|
||||||
|
|
|
@ -21,7 +21,9 @@ foreach ($errors as $error):
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($error->getIsNew()): ?>
|
<?php if ($error->getIsNew()): ?>
|
||||||
<span class="label label-danger"><?= Lang::get('new'); ?></span>
|
<span class="label label-danger">
|
||||||
|
<?= Lang::get('new'); ?>
|
||||||
|
</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -29,19 +31,25 @@ foreach ($errors as $error):
|
||||||
<?= Lang::get($error->getSeverityString()); ?>
|
<?= Lang::get($error->getSeverityString()); ?>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td><?= Lang::get($error->getPlugin()); ?></td>
|
<td>
|
||||||
<td><a href="<?= $link; ?>"><?= $error->getFile(); ?></a></td>
|
<?= Lang::get($error->getPlugin()); ?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= $link; ?>">
|
<a href="<?= $link; ?>">
|
||||||
<?php
|
<?= $error->getFile(); ?>
|
||||||
if ($error->getLineStart() == $error->getLineEnd() || !$error->getLineEnd()) {
|
|
||||||
echo $error->getLineStart();
|
|
||||||
} else {
|
|
||||||
echo ($error->getLineStart() . ' - ' . $error->getLineEnd());
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="visible-line-breaks"><?= htmlspecialchars(trim($error->getMessage())); ?></td>
|
<td>
|
||||||
|
<a href="<?= $link; ?>">
|
||||||
|
<?php if ($error->getLineStart() == $error->getLineEnd() || !$error->getLineEnd()): ?>
|
||||||
|
<?= $error->getLineStart(); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= ($error->getLineStart() . ' - ' . $error->getLineEnd()); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="visible-line-breaks">
|
||||||
|
<?= htmlspecialchars(trim($error->getMessage())); ?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
205
src/View/Build/viewLog.phtml
Normal file
205
src/View/Build/viewLog.phtml
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPCensor\Helper\Lang;
|
||||||
|
use PHPCensor\Model\Build;
|
||||||
|
use PHPCensor\Helper\AnsiConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Build $build
|
||||||
|
* @var integer $totalErrors
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title">
|
||||||
|
<?= Lang::get('build_details'); ?>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box-body no-padding">
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('project'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<a href="<?= APP_URL . 'project/view/' . $build->getProjectId(); ?>">
|
||||||
|
<i class="fa fa-<?= $build->getProject()->getIcon(); ?>"></i>
|
||||||
|
<?= $build->getProject()->getTitle(); ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('branch'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
|
||||||
|
<a href="<?= $build->getRemoteBranchLink(); ?>">
|
||||||
|
<i class="fa fa-code-fork"></i>
|
||||||
|
<?= $build->getRemoteBranch(); ?> :
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<a href="<?= $build->getBranchLink(); ?>">
|
||||||
|
<i class="fa fa-code-fork"></i>
|
||||||
|
<?= $build->getBranch(); ?>
|
||||||
|
</a>
|
||||||
|
<?php if ($tag = $build->getTag()): ?> /
|
||||||
|
<a href="<?= $build->getTagLink(); ?>">
|
||||||
|
<i class="fa fa-tag"></i> <?= $tag; ?>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('environment'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<?php
|
||||||
|
$environment = $build->getEnvironment();
|
||||||
|
echo !empty($environment) ? ('<i class="fa fa-gear"> ' . $environment) : '—' ;
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('merged_branches'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<a href="<?= $build->getBranchLink(); ?>">
|
||||||
|
<i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?>
|
||||||
|
</a>
|
||||||
|
+ <?php
|
||||||
|
$branches = $build->getExtra('branches');
|
||||||
|
if (!empty($branches)) {
|
||||||
|
foreach($branches as $branch) {
|
||||||
|
?><i class="fa fa-code-fork"></i> <?= $branch ?><?php
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
?>—<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title">
|
||||||
|
<?= Lang::get('commit_details'); ?>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box-body no-padding">
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('build_source'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<?= Lang::get($build->getSourceHumanize()); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('commit'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<a href="<?= $build->getCommitLink(); ?>">
|
||||||
|
<?= substr($build->getCommitId(), 0, 7); ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('committer'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<?= $build->getCommitterEmail(); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('commit_message'); ?></th>
|
||||||
|
<td style="text-align: right">
|
||||||
|
<?= htmlspecialchars($build->getCommitMessage()); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header">
|
||||||
|
<h3 class="box-title">
|
||||||
|
<?= Lang::get('timing'); ?>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="box-body no-padding">
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('created'); ?></th>
|
||||||
|
<td style="text-align: right" class="build-created datetime">
|
||||||
|
<?= ($build->getCreateDate() ? $build->getCreateDate()->format('Y-m-d H:i:s') : ''); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('started'); ?></th>
|
||||||
|
<td style="text-align: right" class="build-started datetime">
|
||||||
|
<?= ($build->getStartDate() ? $build->getStartDate()->format('Y-m-d H:i:s') : ''); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('finished'); ?></th>
|
||||||
|
<td style="text-align: right" class="build-finished datetime">
|
||||||
|
<?= ($build->getFinishDate() ? $build->getFinishDate()->format('Y-m-d H:i:s') : ''); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><?= Lang::get('duration'); ?></th>
|
||||||
|
<td style="text-align: right" class="build-duration duration">
|
||||||
|
<?= $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nav-tabs-custom">
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li class="active">
|
||||||
|
<a href="#">
|
||||||
|
<i class="fa fa-cogs"></i> <?= Lang::get('build_log'); ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="">
|
||||||
|
<a href="<?= APP_URL . 'build/viewErrors/' . $build->getProjectId(); ?>">
|
||||||
|
<i class="fa fa-exclamation-triangle"></i> <?= Lang::get('errors'); ?>
|
||||||
|
<?php if (!$totalErrors): ?>
|
||||||
|
<span class="errors-label label label-danger" style="display: none">0</span>
|
||||||
|
<?php else: ?>
|
||||||
|
<span class="errors-label label label-danger"><?= $totalErrors; ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="">
|
||||||
|
<a href="<?= APP_URL . 'build/viewInformation/' . $build->getProjectId(); ?>">
|
||||||
|
<i class="fa fa-info-circle"></i> <?= Lang::get('information'); ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane active">
|
||||||
|
<pre style="overflow-y: visible; white-space: pre-wrap"><?= AnsiConverter::convert($build->getLog()); ?></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
use PHPCensor\Helper\Lang;
|
use PHPCensor\Helper\Lang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $projects
|
||||||
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
|
|
Loading…
Reference in a new issue