diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 07b820d8..d2bde2c3 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -38,7 +38,7 @@ var PHPCensor = { getProjectBuilds: function () { $.ajax({ - url: APP_URL + 'project/ajax-builds/' + PROJECT_ID + '?branch=' + PROJECT_BRANCH + '&environment=' + PROJECT_ENVIRONMENT + '&per_page=' + PER_PAGE, + url: APP_URL + 'project/ajax-builds/' + PROJECT_ID + '?branch=' + PROJECT_BRANCH + '&environment=' + PROJECT_ENVIRONMENT + '&per_page=' + PER_PAGE + '&page=' + PAGE, success: function (data) { $('#latest-builds').html(data); diff --git a/src/PHPCensor/Controller/ProjectController.php b/src/PHPCensor/Controller/ProjectController.php index 604c63dd..f05ba7d6 100644 --- a/src/PHPCensor/Controller/ProjectController.php +++ b/src/PHPCensor/Controller/ProjectController.php @@ -52,6 +52,25 @@ class ProjectController extends PHPCensor\Controller $this->buildService = new BuildService($this->buildStore); } + /** + * @param int $projectId + * + * @return b8\Http\Response + */ + public function ajaxBuilds($projectId) + { + $branch = $this->getParam('branch', ''); + $environment = $this->getParam('environment', ''); + $page = (integer)$this->getParam('page', 1); + $perPage = (integer)$this->getParam('per_page', 10); + $builds = $this->getLatestBuildsHtml($projectId, $environment, $branch, (($page - 1) * $perPage), $perPage); + + $this->response->disableLayout(); + $this->response->setContent($builds[0]); + + return $this->response; + } + /** * View a specific project. * @@ -65,20 +84,21 @@ class ProjectController extends PHPCensor\Controller { $branch = $this->getParam('branch', ''); $environment = $this->getParam('environment', ''); + $page = (integer)$this->getParam('page', 1); $project = $this->projectStore->getById($projectId); if (empty($project)) { throw new NotFoundException(Lang::get('project_x_not_found', $projectId)); } - $perPage = $_SESSION['php-censor-user']->getFinalPerPage(); - $page = $this->getParam('p', 1); - $builds = $this->getLatestBuildsHtml($projectId, urldecode($environment), urlencode($branch), (($page - 1) * $perPage), $perPage); + $perPage = $_SESSION['php-censor-user']->getFinalPerPage(); + $builds = $this->getLatestBuildsHtml($projectId, $environment, $branch, (($page - 1) * $perPage), $perPage); $pages = $builds[1] == 0 ? 1 : ceil($builds[1] / $perPage); if ($page > $pages) { $response = new b8\Http\Response\RedirectResponse(); - $response->setHeader('Location', APP_URL.'project/view/'.$projectId); + $response->setHeader('Location', APP_URL . 'project/view/' . $projectId); + return $response; } @@ -109,16 +129,18 @@ class ProjectController extends PHPCensor\Controller * Create a new pending build for a project. * * @param integer $projectId - * @param string $type Build type: 'environment'|'branch' - * @param string $id Build type id: environment name or branch name * * @throws NotFoundException * * @return b8\Http\Response\RedirectResponse * */ - public function build($projectId, $type = null, $id = null) + public function build($projectId) { + $type = $this->getParam('type', 'branch'); + $id = $this->getParam('id', 'master'); + $debug = (boolean)$this->getParam('debug', false); + /* @var \PHPCensor\Model\Project $project */ $project = $this->projectStore->getById($projectId); $environment = null; @@ -141,7 +163,6 @@ class ProjectController extends PHPCensor\Controller $branch = $project->getBranch(); } - $debug = (boolean)$this->getParam('debug', false); $extra = null; if ($debug && $this->currentUserIsAdmin()) { @@ -155,7 +176,7 @@ class ProjectController extends PHPCensor\Controller $project, $environment, null, - urldecode($branch), + $branch, null, $email, null, @@ -524,24 +545,6 @@ class ProjectController extends PHPCensor\Controller }; } - /** - * @param int $projectId - * - * @return b8\Http\Response - */ - public function ajaxBuilds($projectId) - { - $branch = $this->getParam('branch', ''); - $environment = $this->getParam('environment', ''); - $perPage = (integer)$this->getParam('per_page', 10); - $builds = $this->getLatestBuildsHtml($projectId, urldecode($environment), urldecode($branch), 0, $perPage); - - $this->response->disableLayout(); - $this->response->setContent($builds[0]); - - return $this->response; - } - /** * @param int $projectId * diff --git a/src/PHPCensor/View/Build/view.phtml b/src/PHPCensor/View/Build/view.phtml index 9e972182..60ba7d30 100644 --- a/src/PHPCensor/View/Build/view.phtml +++ b/src/PHPCensor/View/Build/view.phtml @@ -14,9 +14,9 @@
- + = $message; ?>