php-censor/src/View/Project/view.phtml
Dmitry Khomutov 8c69129c76
Small fixes.
2018-04-06 23:55:44 +07:00

221 lines
9.5 KiB
PHTML

<?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');
} ?>&nbsp;&nbsp;<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>