View build

This commit is contained in:
Dan Cryer 2014-12-04 13:08:48 +00:00
parent 54765bf823
commit 4a03e01c3f
16 changed files with 115 additions and 61 deletions

View file

@ -12,6 +12,7 @@ namespace PHPCI\Controller;
use b8;
use b8\Exception\HttpException\NotFoundException;
use PHPCI\BuildFactory;
use PHPCI\Helper\Lang;
use PHPCI\Model\Build;
use PHPCI\Model\Project;
use PHPCI\Service\BuildService;
@ -52,26 +53,26 @@ class BuildController extends \PHPCI\Controller
}
if (empty($build)) {
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
}
$this->view->plugins = $this->getUiPlugins();
$this->view->build = $build;
$this->view->data = $this->getBuildData($build);
$this->layout->title = 'Build #' . $build->getId();
$this->layout->title = Lang::get('build_n', $buildId);
$this->layout->subtitle = $build->getProjectTitle();
$nav = array(
'title' => 'Build '.$build->getId(),
'title' => Lang::get('build_n', $buildId),
'icon' => 'cog',
'links' => array(
'build/rebuild/' . $build->getId() => 'Rebuild Now',
'build/rebuild/' . $build->getId() => Lang::get('rebuild_now'),
),
);
if ($this->currentUserIsAdmin()) {
$nav['links']['build/delete/' . $build->getId()] = 'Delete Build';
$nav['links']['build/delete/' . $build->getId()] = Lang::get('delete_build');
}
$this->layout->nav = $nav;
@ -142,7 +143,7 @@ class BuildController extends \PHPCI\Controller
$copy = BuildFactory::getBuildById($buildId);
if (empty($copy)) {
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
}
$build = $this->buildService->createDuplicateBuild($copy);
@ -161,7 +162,7 @@ class BuildController extends \PHPCI\Controller
$build = BuildFactory::getBuildById($buildId);
if (empty($build)) {
throw new NotFoundException('Build with ID: ' . $buildId . ' does not exist.');
throw new NotFoundException(Lang::get('build_x_not_found', $buildId));
}
$this->buildService->deleteBuild($build);

View file

@ -87,4 +87,4 @@ class Lang
return $strings;
}
}
}

View file

@ -115,5 +115,55 @@ $strings = array(
<a href="https://bitbucket.org/%s/admin/services">
Services</a> section of your Bitbucket repository.',
// View Build
'build_x_not_found' => 'Build with ID %d does not exist.',
'build_n' => 'Build %d',
'rebuild_now' => 'Rebuild Now',
);
'committed_by_x' => 'Committed by %s',
'commit_id_x' => 'Commit: %s',
'chart_display' => 'This chart will display once the build has completed.',
'build' => 'Build',
'lines' => 'Lines',
'comment_lines' => 'Comment Lines',
'noncomment_lines' => 'Non-Comment Lines',
'logical_lines' => 'Logical Lines',
'lines_of_code' => 'Lines of Code',
'build_log' => 'Build Log',
'quality_trend' => 'Quality Trend',
'phpmd_warnings' => 'PHPMD Warnings',
'phpcs_warnings' => 'PHPCS Warnings',
'phpcs_errors' => 'PHPCS Errors',
'phplint_errors' => 'Lint Errors',
'phpunit_errors' => 'PHPUnit Errors',
'phpdoccheck_warnings' => 'Missing Docblocks',
'issues' => 'Issues',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',
'phpmd' => 'PHP Mess Detector',
'phpspec' => 'PHP Spec',
'phpunit' => 'PHP Unit',
'file' => 'File',
'line' => 'Line',
'class' => 'Class',
'method' => 'Method',
'message' => 'Message',
'start' => 'Start',
'end' => 'End',
'from' => 'From',
'to' => 'To',
'suite' => 'Suite',
'test' => 'Test',
'result' => 'Result',
'ok' => 'OK',
'took_n_seconds' => 'Took %d seconds',
'build_created' => 'Build Created',
'build_started' => 'Build Started',
'build_finished' => 'Build Finished',
);

View file

@ -9,4 +9,6 @@
require_once(dirname(__FILE__) . '/lang.en-gb.php');
if (!isset($strings)) $strings = array('test' => 'test');
if (!isset($strings)) {
$strings = array('test' => 'test');
}

View file

@ -1,8 +1,9 @@
<?php use PHPCI\Helper\Lang; ?>
<div class="build-info-panel box box-solid">
<div class="box-header">
<h1 class="box-title">
Committed by <?php print $build->getCommitterEmail(); ?>
<?php Lang::out('committed_by_x', $build->getCommitterEmail()); ?>
<label class="pull-right label"></label>
</h1>
</div>
@ -17,10 +18,10 @@
</div>
<?php endif; ?>
<strong>Branch: </strong> <?php print $build->getBranch(); ?>
<?php Lang::out('branch_x', $build->getBranch()); ?>
<?php if ($build->getCommitId() != 'Manual'): ?>
<br><strong>Commit ID: </strong> <?php print $build->getCommitId(); ?><br>
<br><?php Lang::out('commit_id_x', $build->getCommitId()); ?>
<?php endif; ?>
</div>
</div>

View file

@ -1,7 +1,7 @@
var locPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-lines-chart',
css: 'col-lg-6 col-md-6 col-sm-12 col-xs-12',
title: 'Lines of Code',
title: Lang.get('lines_of_code'),
lastData: null,
displayOnUpdate: false,
rendered: false,
@ -24,7 +24,7 @@ var locPlugin = ActiveBuild.UiPlugin.extend({
},
render: function() {
return $('<div id="phploc-lines"></div>').text('This chart will display once the build has completed.');
return $('<div id="phploc-lines"></div>').text(Lang.get('chart_display'));
},
onUpdate: function(e) {
@ -44,7 +44,7 @@ var locPlugin = ActiveBuild.UiPlugin.extend({
$('#phploc-lines').empty().animate({height: '275px'});
var titles = ['Build', 'Lines', 'Comment Lines', 'Non-Comment Lines', 'Logical Lines'];
var titles = [Lang.get('build'), Lang.get('lines'), Lang.get('comment_lines'), Lang.get('noncomment_lines'), Lang.get('logical_lines')];
var data = [titles];
for (var i in builds) {
data.push(['#' + builds[i].build_id, parseInt(builds[i].meta_value.LOC), parseInt(builds[i].meta_value.CLOC), parseInt(builds[i].meta_value.NCLOC), parseInt(builds[i].meta_value.LLOC)]);
@ -52,8 +52,8 @@ var locPlugin = ActiveBuild.UiPlugin.extend({
var data = google.visualization.arrayToDataTable(data);
var options = {
hAxis: {title: 'Builds'},
vAxis: {title: 'Lines'},
hAxis: {title: Lang.get('builds')},
vAxis: {title: Lang.get('lines')},
backgroundColor: { fill: 'transparent' },
height: 275
};

View file

@ -1,7 +1,7 @@
var logPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-log',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'Build Log',
title: Lang.get('build_log'),
init: function(){
this._super();

View file

@ -1,7 +1,7 @@
var phpcpdPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpcpd',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'PHP Copy/Paste Detector',
title: Lang.get('phpcpd'),
lastData: null,
box: true,
rendered: false,
@ -26,9 +26,9 @@ var phpcpdPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table" id="phpcpd-data">' +
'<thead>' +
'<tr>' +
' <th>File</th>' +
' <th>Start</th>' +
' <th>End</th>' +
' <th>'+Lang.get('file')+'</th>' +
' <th>'+Lang.get('start')+'</th>' +
' <th>'+Lang.get('end')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
@ -64,10 +64,10 @@ var phpcpdPlugin = ActiveBuild.UiPlugin.extend({
file = '<a target="_blank" href="'+fileLink+'">' + file + '</a>';
}
var label = 'From';
var label = Lang.get('from');
if (i % 2 > 0) {
label = 'To';
label = Lang.get('to');
}
else {
rowClass = (rowClass == 'warning' ? 'danger' : 'warning');

View file

@ -1,7 +1,7 @@
var phpcsPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpcs',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'PHP Code Sniffer',
title: Lang.get('phpcs'),
lastData: null,
box: true,
rendered: false,
@ -25,9 +25,9 @@ var phpcsPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table" id="phpcs-data">' +
'<thead>' +
'<tr>' +
' <th>File</th>' +
' <th>Line</th>' +
' <th>Message</th>' +
' <th>'+Lang.get('file')+'</th>' +
' <th>'+Lang.get('line')+'</th>' +
' <th>'+Lang.get('message')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},

View file

@ -1,7 +1,7 @@
var phpdoccheckPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpdoccheck-warnings',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'PHP Docblock Checker',
title: Lang.get('phpdoccheck'),
lastData: null,
displayOnUpdate: false,
box: true,
@ -27,10 +27,10 @@ var phpdoccheckPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table" id="phpdoccheck-data">' +
'<thead>' +
'<tr>' +
' <th>File</th>' +
' <th>Line</th>' +
' <th>Class</th>' +
' <th>Method</th>' +
' <th>'+Lang.get('file')+'</th>' +
' <th>'+Lang.get('line')+'</th>' +
' <th>'+Lang.get('class')+'</th>' +
' <th>'+Lang.get('method')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},

View file

@ -1,7 +1,7 @@
var phpmdPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpmd-warnings',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'PHP Mess Detector',
title: Lang.get('phpmd'),
lastData: null,
displayOnUpdate: false,
box: true,
@ -28,10 +28,10 @@ var phpmdPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table" id="phpmd-data">' +
'<thead>' +
'<tr>' +
' <th>File</th>' +
' <th>Start</th>' +
' <th>End</th>' +
' <th>Message</th>' +
' <th>'+Lang.get('file')+'</th>' +
' <th>'+Lang.get('start')+'</th>' +
' <th>'+Lang.get('end')+'</th>' +
' <th>'+Lang.get('message')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},

View file

@ -1,7 +1,7 @@
var phpspecPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpspec-errors',
css: 'col-lg-12 col-md-12 col-sm-12 col-xs-12',
title: 'PHPSpec',
title: Lang.get('phpspec'),
lastData: null,
displayOnUpdate: false,
box: true,
@ -28,9 +28,9 @@ var phpspecPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table table-striped" id="phpspec-data">' +
'<thead>' +
'<tr>' +
' <th>Suite</th>' +
' <th>Test</th>' +
' <th>Result</th>' +
' <th>'+Lang.get('suite')+'</th>' +
' <th>'+Lang.get('test')+'</th>' +
' <th>'+Lang.get('result')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},
@ -57,8 +57,8 @@ var phpspecPlugin = ActiveBuild.UiPlugin.extend({
var row = $(
'<tr>'+
'<td>'+test_suite.name+'</td>'+
'<td title="Took '+test_case['time']+'Seconds">'+test_case.name+'</td>'+
'<td>'+(test_case.message?test_case.message:'OK')+'</td>'+
'<td title="'+Lang.get('took_n_seconds', test_case['time'])+'">'+test_case.name+'</td>'+
'<td>'+(test_case.message ? test_case.message : Lang.get('ok'))+'</td>'+
'</tr>'
);

View file

@ -1,7 +1,7 @@
var phpunitPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpunit-errors',
css: 'col-lg-6 col-md-12 col-sm-12 col-xs-12',
title: 'PHPUnit',
title: Lang.get('phpunit'),
lastData: null,
displayOnUpdate: false,
box: true,
@ -28,7 +28,7 @@ var phpunitPlugin = ActiveBuild.UiPlugin.extend({
return $('<table class="table" id="phpunit-data">' +
'<thead>' +
'<tr>' +
' <th>Test</th>' +
' <th>'+Lang.get('test')+'</th>' +
'</tr>' +
'</thead><tbody></tbody></table>');
},

View file

@ -28,9 +28,9 @@ var timePlugin = ActiveBuild.UiPlugin.extend({
return '<table class="table table-striped table-bordered">' +
'<thead>' +
'<tr>' +
'<th style="width: 33.3%">Build Created</th>' +
'<th style="width: 33.3%">Build Started</th>' +
'<th style="width: 33.3%">Build Finished</th>' +
'<th style="width: 33.3%">'+Lang.get('build_created')+'</th>' +
'<th style="width: 33.3%">'+Lang.get('build_started')+'</th>' +
'<th style="width: 33.3%">'+Lang.get('build_finished')+'</th>' +
'</tr>' +
'</thead>' +
'<tbody>' +

View file

@ -1,14 +1,14 @@
var warningsPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-warnings-chart',
css: 'col-lg-6 col-md-6 col-sm-12 col-xs-12',
title: 'Quality Trend',
title: Lang.get('quality_trend'),
keys: {
'phpmd-warnings': 'PHPMD Warnings',
'phpcs-warnings': 'PHPCS Warnings',
'phpcs-errors': 'PHPCS Errors',
'phplint-errors': 'PHPLint Errors',
'phpunit-errors': 'PHPUnit Errors',
'phpdoccheck-warnings': 'PHP Docblock Checker Warnings'
'phpmd-warnings': Lang.get('phpmd_warnings'),
'phpcs-warnings': Lang.get('phpcs_warnings'),
'phpcs-errors': Lang.get('phpcs_errors'),
'phplint-errors': Lang.get('phplint_errors'),
'phpunit-errors': Lang.get('phpunit_errors'),
'phpdoccheck-warnings': Lang.get('phpdoccheck')
},
data: {},
displayOnUpdate: false,
@ -39,7 +39,7 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
},
render: function() {
return $('<div id="build-warnings"></div>').text('This chart will display once the build has completed.');
return $('<div id="build-warnings"></div>').text(Lang.get('chart_display'));
},
onUpdate: function(e) {
@ -91,8 +91,8 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
var data = google.visualization.arrayToDataTable(data);
var options = {
hAxis: {title: 'Builds'},
vAxis: {title: 'Warnings / Errors'},
hAxis: {title: Lang.get('builds')},
vAxis: {title: Lang.get('issues')},
backgroundColor: { fill: 'transparent' },
height: 275,
pointSize: 3

View file

@ -484,6 +484,6 @@ var Lang = {
return sprintf.apply(sprintf[0], args);
}
return '';
return 'MISSING: ' + string;
}
};