Refactored project structure.
This commit is contained in:
parent
cfe93434ad
commit
c015d8c58b
308 changed files with 39 additions and 47 deletions
125
src/View/Project/ajax-builds.phtml
Normal file
125
src/View/Project/ajax-builds.phtml
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @var \PHPCensor\Model\Build[] $builds
|
||||
*/
|
||||
|
||||
use PHPCensor\Helper\Lang;
|
||||
use PHPCensor\Model\Build;
|
||||
|
||||
?>
|
||||
|
||||
<?php if(empty($builds) || !count($builds)): ?>
|
||||
<tr class="">
|
||||
<td colspan="6"><?php Lang::out('no_builds_yet'); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach($builds as $build): ?>
|
||||
|
||||
<?php
|
||||
switch($build->getStatus())
|
||||
{
|
||||
case 0:
|
||||
$cls = 'active';
|
||||
$subcls = 'info';
|
||||
$status = Lang::get('pending');
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$cls = 'warning';
|
||||
$subcls = 'warning';
|
||||
$status = Lang::get('running');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$cls = 'success';
|
||||
$subcls = 'success';
|
||||
$status = Lang::get('success');
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$cls = 'danger';
|
||||
$subcls = 'danger';
|
||||
$status = Lang::get('failed');
|
||||
break;
|
||||
}
|
||||
|
||||
$branches = $build->getExtra('branches');
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?= APP_URL ?>build/view/<?= $build->getId(); ?>">#<?= str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
|
||||
<td><span class='label label-<?= $subcls ?>'><?= $status ?></span></td>
|
||||
<td><?= $build->getCreateDate()->format('Y-m-d H:i:s'); ?></td>
|
||||
<td><?php Lang::out($build->getSourceHumanize()); ?></td>
|
||||
<td class="hidden-md hidden-sm hidden-xs">
|
||||
<?php
|
||||
if (!empty($build->getCommitId())) {
|
||||
print sprintf(
|
||||
'<a href="%s">%s %s</a>',
|
||||
$build->getCommitLink(),
|
||||
substr($build->getCommitId(), 0, 7),
|
||||
$build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
|
||||
);
|
||||
} else {
|
||||
print '—';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?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>
|
||||
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
|
||||
<?php if ($tag = $build->getTag()): ?> /
|
||||
<a href="<?= $build->getTagLink(); ?>">
|
||||
<i class="fa fa-tag"></i>
|
||||
<?= $tag; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$environment = $build->getEnvironment();
|
||||
echo !empty($environment) ? $environment : '—' ;
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $build->getNewErrorsCount(); ?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-right">
|
||||
<a class="btn btn-default btn-sm" href="<?php echo APP_URL ?>build/view/<?php print $build->getId(); ?>"><?php Lang::out('view'); ?></a>
|
||||
<?php if($this->getUser()->getIsAdmin()): ?>
|
||||
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo APP_URL ?>build/delete/<?php print $build->getId(); ?>" class="delete-build"><?php Lang::out('delete_build'); ?></a></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.delete-build').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete(e.target.href)
|
||||
.onCloseConfirmed = function () {window.location = window.location.href};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
47
src/View/Project/edit.phtml
Normal file
47
src/View/Project/edit.phtml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<script src="<?= APP_URL; ?>assets/vendor/codemirror/lib/codemirror.js"></script>
|
||||
<script src="<?= APP_URL; ?>assets/vendor/codemirror/mode/yaml/yaml.js"></script>
|
||||
<link href="<?= APP_URL; ?>assets/vendor/codemirror/lib/codemirror.css" rel="stylesheet" type="text/css" />
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
CodeMirror.fromTextArea(document.getElementById('element-build_config'), {
|
||||
mode: "yaml",
|
||||
lineWrapping: true,
|
||||
lineNumbers: true
|
||||
});
|
||||
CodeMirror.fromTextArea(document.getElementById('element-environments'), {
|
||||
mode: "yaml",
|
||||
lineWrapping: true,
|
||||
lineNumbers: true
|
||||
});
|
||||
|
||||
setupProjectForm();
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php use PHPCensor\Helper\Lang; ?>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="box ">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php Lang::out('project_details'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<?php print $form; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(!is_null($key)): ?>
|
||||
<div class="col-sm-4">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<p><?php Lang::out('public_key_help'); ?></p>
|
||||
<textarea style="width: 90%; height: 150px;"><?php print $key ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
223
src/View/Project/view.phtml
Normal file
223
src/View/Project/view.phtml
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @var \JasonGrimes\Paginator $paginator
|
||||
*/
|
||||
|
||||
use PHPCensor\Helper\Lang;
|
||||
|
||||
?>
|
||||
<script>
|
||||
var PROJECT_ID = <?= $project->getId(); ?>;
|
||||
var PROJECT_ENVIRONMENT = '<?= $environment; ?>';
|
||||
var PROJECT_BRANCH = '<?= $branch; ?>';
|
||||
var PER_PAGE = <?= $perPage; ?>;
|
||||
var PAGE = <?= $page; ?>;
|
||||
</script>
|
||||
|
||||
<div class="clearfix" style="margin-bottom: 20px;">
|
||||
<a class="btn btn-default" href="<?= APP_URL . 'project/edit/' . $project->getId(); ?>">
|
||||
<?php Lang::out('edit_project'); ?>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-danger" id="delete-project">
|
||||
<?php Lang::out('delete_project'); ?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
$build_url = APP_URL . 'project/build/' . $project->getId();
|
||||
?>
|
||||
<div class="pull-right btn-group">
|
||||
<?php if (!$project->getArchived()): ?>
|
||||
<?php if ($this->getUser()->getIsAdmin()): ?>
|
||||
<?php if (!empty($environment)): ?>
|
||||
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment, 'debug' => 1]); ?>">
|
||||
<?php Lang::out('build_now_debug'); ?>
|
||||
</a>
|
||||
<?php elseif (!empty($branch)): ?>
|
||||
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch, 'debug' => 1]); ?>">
|
||||
<?php Lang::out('build_now_debug'); ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['debug' => 1]); ?>">
|
||||
<?php Lang::out('build_now_debug'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($environment)): ?>
|
||||
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment]); ?>">
|
||||
<?php Lang::out('build_now'); ?>
|
||||
</a>
|
||||
<?php elseif (!empty($branch)): ?>
|
||||
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch]); ?>">
|
||||
<?php Lang::out('build_now'); ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="btn btn-success" href="<?= $build_url; ?>">
|
||||
<?php Lang::out('build_now'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="btn-group branch-btn pull-right">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<?php if (!empty($environment)) {
|
||||
Lang::out('environment_x', $environment);
|
||||
} elseif (!empty($branch)) {
|
||||
Lang::out('branch_x', $branch);
|
||||
} else {
|
||||
Lang::out('all');
|
||||
} ?> <span class="caret"></span>
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>"><?php Lang::out('all'); ?></a></li>
|
||||
<li class="divider"></li>
|
||||
|
||||
<?php if(!empty($environments)): ?>
|
||||
<?php foreach ($environments as $currentEnvironment) : ?>
|
||||
<li <?= ($currentEnvironment == $environment) ? 'class="active"' : ''; ?>>
|
||||
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>?environment=<?= urlencode($currentEnvironment); ?>">
|
||||
<i class="fa fa-cog"></i><?= $currentEnvironment; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<li class="divider"></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($branches as $currentBranch) : ?>
|
||||
<li <?= ($currentBranch == $branch) ? 'class="active"' : ''; ?>>
|
||||
<a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>?branch=<?= urlencode($currentBranch); ?>">
|
||||
<i class="fa fa-code-fork"></i><?= $currentBranch; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-9 col-md-8 col-sm-8">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php Lang::out('builds'); ?> (<?= $total; ?>)</h3>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php Lang::out('id'); ?></th>
|
||||
<th><?php Lang::out('status'); ?></th>
|
||||
<th><?php Lang::out('date'); ?></th>
|
||||
<th><?php Lang::out('build_source'); ?></th>
|
||||
<th class="hidden-md hidden-sm hidden-xs"><?php Lang::out('commit'); ?></th>
|
||||
<th><?php Lang::out('branch'); ?></th>
|
||||
<th><?php Lang::out('environment'); ?></th>
|
||||
<th><?php Lang::out('duration'); ?></th>
|
||||
<th><?php Lang::out('new_errors'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="latest-builds">
|
||||
<?= $builds; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="paginator">
|
||||
<?= $paginator; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3 col-md-4 col-sm-4">
|
||||
|
||||
<?php if ($project->getAllowPublicStatus()): ?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h4 class="box-title"><?= Lang::get('public_status_title'); ?></h4>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<span style="word-wrap: break-word;">
|
||||
<a href="<?= APP_URL . 'build-status/view/' . $project->getId() . '?branch=master'; ?>">
|
||||
<img src="<?= APP_URL . 'build-status/image/' . $project->getId() . '?branch=master&label=PHPCensor&style=flat-square'; ?>" />
|
||||
</a>
|
||||
|
||||
<br /><br />
|
||||
<?= Lang::get('public_status_image'); ?>:<br /><strong><?= APP_URL . 'build-status/image/' . $project->getId() . '?branch=master&label=PHPCensor&style=flat-square'; ?></strong>
|
||||
|
||||
<br /><br />
|
||||
<?= Lang::get('public_status_page'); ?>:<br /><strong><?= APP_URL . 'build-status/view/' . $project->getId() . '?branch=master'; ?></strong>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (in_array($project->getType(), ['github', 'gitlab', 'bitbucket'])): ?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h4 class="box-title"><?php Lang::out('webhooks'); ?></h4>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<?php
|
||||
switch($project->getType())
|
||||
{
|
||||
case 'github':
|
||||
$url = APP_URL . 'webhook/github/' . $project->getId();
|
||||
Lang::out('webhooks_help_github', $project->getReference());
|
||||
break;
|
||||
|
||||
case 'gitlab':
|
||||
$url = APP_URL. 'webhook/gitlab/' . $project->getId();
|
||||
Lang::out('webhooks_help_gitlab');
|
||||
break;
|
||||
|
||||
case 'bitbucket':
|
||||
case 'bitbucket-hg':
|
||||
$url = APP_URL . 'webhook/bitbucket/' . $project->getId();
|
||||
Lang::out('webhooks_help_bitbucket', $project->getReference());
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<br><br><strong style="word-wrap: break-word;"><?= $url; ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($project->getSshPublicKey()): ?>
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php Lang::out('public_key'); ?></h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
|
||||
<i class="fa fa-minus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body" style="word-break: break-all;"><?= $project->getSshPublicKey(); ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#delete-project').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete("<?= APP_URL; ?>project/delete/<?= $project->getId(); ?>")
|
||||
.onCloseConfirmed = function () {window.location = '/'};
|
||||
});
|
||||
})
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue