diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 644d7974..c37723cd 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -498,3 +498,17 @@ var Lang = { 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; + }; + }); +}); diff --git a/src/Controller/BuildController.php b/src/Controller/BuildController.php index 3db8143b..7430449a 100644 --- a/src/Controller/BuildController.php +++ b/src/Controller/BuildController.php @@ -10,6 +10,7 @@ use PHPCensor\Helper\AnsiConverter; use PHPCensor\Helper\Lang; use PHPCensor\Http\Response\RedirectResponse; use PHPCensor\Model\Build; +use PHPCensor\Model\Project; use PHPCensor\Model\User; use PHPCensor\Service\BuildService; use PHPCensor\WebController; @@ -47,8 +48,6 @@ class BuildController extends WebController } /** - * View a specific build. - * * @param integer $buildId * * @throws NotFoundException @@ -143,6 +142,77 @@ class BuildController extends WebController $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( + '%s', + $rebuildLink, + $rebuildLabel + ); + } + + if ($this->currentUserIsAdmin()) { + $actions .= sprintf( + '%s', + $build->getId(), + $build->getProjectId(), + $deleteLink, + $deleteLabel + ); + } + + $this->layout->actions = $actions; + } + /** * Returns an array of the JS plugins to include. * @return array diff --git a/src/View/Build/errors.phtml b/src/View/Build/errors.phtml index c7b87be6..979f502d 100644 --- a/src/View/Build/errors.phtml +++ b/src/View/Build/errors.phtml @@ -21,7 +21,9 @@ foreach ($errors as $error): getIsNew()): ?> - + + + @@ -29,19 +31,25 @@ foreach ($errors as $error): getSeverityString()); ?> - getPlugin()); ?> - getFile(); ?> + + getPlugin()); ?> + - getLineStart() == $error->getLineEnd() || !$error->getLineEnd()) { - echo $error->getLineStart(); - } else { - echo ($error->getLineStart() . ' - ' . $error->getLineEnd()); - } - ?> + getFile(); ?> - getMessage())); ?> + + + getLineStart() == $error->getLineEnd() || !$error->getLineEnd()): ?> + getLineStart(); ?> + + getLineStart() . ' - ' . $error->getLineEnd()); ?> + + + + + getMessage())); ?> + diff --git a/src/View/Build/viewLog.phtml b/src/View/Build/viewLog.phtml new file mode 100644 index 00000000..a09bc27d --- /dev/null +++ b/src/View/Build/viewLog.phtml @@ -0,0 +1,205 @@ + + +
+
+
+
+

+ +

+
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + getProject()->getTitle(); ?> + +
+ getSource()): ?> + + + getRemoteBranch(); ?> : + + + + + getBranch(); ?> + + getTag()): ?> / + + + + +
+ getEnvironment(); + echo !empty($environment) ? (' ' . $environment) : '—' ; + ?> +
+ + getBranch(); ?> + + + getExtra('branches'); + if (!empty($branches)) { + foreach($branches as $branch) { + ?> +
+
+
+
+ +
+
+
+

+ +

+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ getSourceHumanize()); ?> +
+ + getCommitId(), 0, 7); ?> + +
+ getCommitterEmail(); ?> +
+ getCommitMessage()); ?> +
+
+
+
+ +
+
+
+

+ +

+
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ getCreateDate() ? $build->getCreateDate()->format('Y-m-d H:i:s') : ''); ?> +
+ getStartDate() ? $build->getStartDate()->format('Y-m-d H:i:s') : ''); ?> +
+ getFinishDate() ? $build->getFinishDate()->format('Y-m-d H:i:s') : ''); ?> +
+ getDuration(); ?> +
+
+
+
+ +
+ + diff --git a/src/View/WidgetBuildErrors/index.phtml b/src/View/WidgetBuildErrors/index.phtml index 363ae597..2d42181d 100644 --- a/src/View/WidgetBuildErrors/index.phtml +++ b/src/View/WidgetBuildErrors/index.phtml @@ -2,6 +2,10 @@ use PHPCensor\Helper\Lang; +/** + * @var string $projects + */ + ?>