Merge branch 'feature-fixes'

This commit is contained in:
Dmitry Khomutov 2017-09-17 20:09:41 +07:00
commit 00744c269b
13 changed files with 286 additions and 258 deletions

View file

@ -94,8 +94,11 @@ Type=simple
ExecStart=/your/path/bin/console php-censor:worker ExecStart=/your/path/bin/console php-censor:worker
Restart=always Restart=always
User=php-censor #Could be changed #Could be changed
Group=php-censor #Could be changed User=php-censor
#Could be changed
Group=php-censor
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,4 +1,3 @@
var PHPCensor = { var PHPCensor = {
intervals: {}, intervals: {},
@ -12,10 +11,10 @@ var PHPCensor = {
if (typeof PROJECT_ID != 'undefined') { if (typeof PROJECT_ID != 'undefined') {
PHPCensor.intervals.getProjectBuilds = setInterval(PHPCensor.getProjectBuilds, 10000); PHPCensor.intervals.getProjectBuilds = setInterval(PHPCensor.getProjectBuilds, 10000);
} }
if (typeof DASHBOARD != 'undefined') { if (typeof DASHBOARD != 'undefined') {
PHPCensor.intervals.getDashboard = setInterval(PHPCensor.getDashboard, 10000); PHPCensor.intervals.getDashboard = setInterval(PHPCensor.getDashboard, 10000);
PHPCensor.intervals.getTimeline = setInterval(PHPCensor.getTimeline, 10000); PHPCensor.intervals.getTimeline = setInterval(PHPCensor.getTimeline, 10000);
} }
}); });
@ -49,7 +48,7 @@ var PHPCensor = {
}, },
getDashboard: function () { getDashboard: function () {
$('.project-box').each(function(index) { $('.project-box').each(function (index) {
var projectId = this.id.substring(12); var projectId = this.id.substring(12);
$.ajax({ $.ajax({
@ -165,10 +164,10 @@ if (!Function.prototype.bind) {
function confirmDelete(url, reloadAfter) { function confirmDelete(url, reloadAfter) {
var dialog = new PHPCensorConfirmDialog({ var dialog = new PHPCensorConfirmDialog({
title: Lang.get('confirm_title'), title: Lang.get('confirm_title'),
message: Lang.get('confirm_message'), message: Lang.get('confirm_message'),
confirmBtnCaption: Lang.get('confirm_ok'), confirmBtnCaption: Lang.get('confirm_ok'),
cancelBtnCaption: Lang.get('confirm_cancel'), cancelBtnCaption: Lang.get('confirm_cancel'),
/* /*
confirm-btn click handler confirm-btn click handler
*/ */
@ -296,7 +295,9 @@ var PHPCensorConfirmDialog = Class.extend({
/* /*
Bind the close event of the dialog to the set of onClose* methods Bind the close event of the dialog to the set of onClose* methods
*/ */
this.$dialog.on('hidden.bs.modal', function () {this.onClose()}.bind(this)); this.$dialog.on('hidden.bs.modal', function () {
this.onClose()
}.bind(this));
this.$dialog.on('hidden.bs.modal', function () { this.$dialog.on('hidden.bs.modal', function () {
if (this.confirmed) { if (this.confirmed) {
this.onCloseConfirmed(); this.onCloseConfirmed();
@ -336,17 +337,20 @@ var PHPCensorConfirmDialog = Class.extend({
/** /**
* Called only when confirmed dialog was closed * Called only when confirmed dialog was closed
*/ */
onCloseConfirmed: function () {}, onCloseConfirmed: function () {
},
/** /**
* Called only when canceled dialog was closed * Called only when canceled dialog was closed
*/ */
onCloseCanceled: function () {}, onCloseCanceled: function () {
},
/** /**
* Called always when the dialog was closed * Called always when the dialog was closed
*/ */
onClose: function () {}, onClose: function () {
},
showStatusMessage: function (message, closeTimeout) { showStatusMessage: function (message, closeTimeout) {
this.$confirmBtn.hide(); this.$confirmBtn.hide();
@ -371,13 +375,11 @@ var PHPCensorConfirmDialog = Class.extend({
/** /**
* Used to initialise the project form: * Used to initialise the project form:
*/ */
function setupProjectForm() function setupProjectForm() {
{
$('.github-container').hide(); $('.github-container').hide();
$('#element-reference').change(function() $('#element-reference').change(function () {
{ var el = $(this);
var el = $(this);
var val = el.val(); var val = el.val();
var type = $('#element-type').val(); var type = $('#element-type').val();
var acceptable = { var acceptable = {
@ -394,16 +396,16 @@ function setupProjectForm()
}; };
if( acceptable[type] !== undefined ) { if (acceptable[type] !== undefined) {
for(var i in acceptable[type]) { for (var i in acceptable[type]) {
if(val.match(acceptable[type][i])) { if (val.match(acceptable[type][i])) {
el.val(val.replace(acceptable[type][i], '$1')); el.val(val.replace(acceptable[type][i], '$1'));
} }
} }
} }
}); });
$('#element-type').change(function() { $('#element-type').change(function () {
if ($(this).val() == 'github') { if ($(this).val() == 'github') {
$('#loading').show(); $('#loading').show();
@ -432,10 +434,10 @@ function setupProjectForm()
$('#element-reference').trigger('change'); $('#element-reference').trigger('change');
}); });
$('#element-github').change(function() { $('#element-github').change(function () {
var val = $('#element-github').val(); var val = $('#element-github').val();
if(val != 'choose') { if (val != 'choose') {
$('#element-type').val('github'); $('#element-type').val('github');
$('#element-reference').val(val); $('#element-reference').val(val);
@ -457,7 +459,8 @@ function setupProjectForm()
var Lang = { var Lang = {
get: function () { get: function () {
var args = Array.prototype.slice.call(arguments);; var args = Array.prototype.slice.call(arguments);
;
var string = args.shift(); var string = args.shift();
if (STRINGS[string]) { if (STRINGS[string]) {

View file

@ -1,44 +1,48 @@
var codeceptionPlugin = ActiveBuild.UiPlugin.extend({ var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-codeception-errors', id: 'build-codeception-errors',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('codeception'), title: Lang.get('codeception'),
lastData: null, lastData: null,
lastMeta: null, lastMeta: null,
displayOnUpdate: false, displayOnUpdate: false,
rendered: false, rendered: false,
register: function() { register: function () {
var self = this; var self = this;
var query_data = ActiveBuild.registerQuery('codeception-data', -1, {key: 'codeception-data'}); var query_data = ActiveBuild.registerQuery('codeception-data', -1, {key: 'codeception-data'});
var query_meta_data = ActiveBuild.registerQuery('codeception-meta', -1, {key: 'codeception-meta'}); var query_meta_data = ActiveBuild.registerQuery('codeception-meta', -1, {key: 'codeception-meta'});
$(window).on('codeception-data', function(data) { $(window).on('codeception-data', function (data) {
self.onUpdateData(data); self.onUpdateData(data);
}); });
$(window).on('codeception-meta', function(data) { $(window).on('codeception-meta', function (data) {
self.onUpdateMeta(data); self.onUpdateMeta(data);
}); });
$(window).on('build-updated', function() { $(window).on('build-updated', function () {
if (!self.rendered) { if (!self.rendered) {
self.displayOnUpdate = true; self.displayOnUpdate = true;
query_data(); query_data();
query_meta_data(); query_meta_data();
} }
}); });
}, },
render: function() { render: function () {
return $('<table class="table table-hover" id="codeception-data">' + return $('<table class="table table-hover" id="codeception-data">' +
'<thead>' + '<thead>' +
'<tr><th>'+Lang.get('codeception_suite')+'</th>' + '<tr><th>' + Lang.get('status') + '</th>' +
'<th>'+Lang.get('codeception_feature')+'</th>' + '<th>' + Lang.get('codeception_suite') + '</th>' +
'<th>'+Lang.get('codeception_time')+'</th></tr>' + '<th>' + Lang.get('codeception_feature') + '</th>' +
'<th>' + Lang.get('file') + '</th>' +
'<th>' + Lang.get('message') + '</th>' +
'<th>' + Lang.get('codeception_time') + '</th></tr>' +
'</thead><tbody></tbody><tfoot></tfoot></table>'); '</thead><tbody></tbody><tfoot></tfoot></table>');
}, },
onUpdateData: function(e) { onUpdateData: function (e) {
if (!e.queryData) { if (!e.queryData) {
$('#build-codeception-errors').hide(); $('#build-codeception-errors').hide();
return; return;
@ -49,6 +53,7 @@ var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
var tests = this.lastData[0].meta_value; var tests = this.lastData[0].meta_value;
var tbody = $('#codeception-data tbody'); var tbody = $('#codeception-data tbody');
tbody.empty(); tbody.empty();
if (tests.length == 0) { if (tests.length == 0) {
@ -57,35 +62,22 @@ var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
} }
for (var i in tests) { for (var i in tests) {
var rows = $('<tr>' +
var rows = $('<tr data-toggle="collapse" data-target="#collapse'+i+'">' + '<td>' + (tests[i].pass ? '<span class="label label-success">' + Lang.get('success') + '</span>' : '<span class="label label-danger">' + Lang.get('failed') + '</span>') + '</td>' +
'<td><strong>'+tests[i].suite+'</strong</td>' + '<td>' + tests[i].suite + '</td>' +
'<td>'+tests[i].feature+'</td>' + '<td>' + tests[i].feature + '</td>' +
'<td>'+tests[i].time+'</td>'+ '<td>' + tests[i].file + '</td>' +
'</tr>' + '<td>' + ((tests[i].message) ? tests[i].message : '') + '</td>' +
'<tr id="collapse'+i+'" class="collapse" >' + '<td>' + tests[i].time + '</td>' +
'<td></td><td colspan="2">' +
'<small><strong>'+Lang.get('name')+':</strong> '+tests[i].name+'</small><br />' +
'<small><strong>'+Lang.get('file')+':</strong> '+tests[i].file+'</small><br />' +
(tests[i].message
? '<small><strong>'+Lang.get('message')+':</strong> '+tests[i].message+'</small>'
: '') +
'</td>' +
'</tr>'); '</tr>');
if (!tests[i].pass) {
rows.first().addClass('danger');
} else {
rows.first().addClass('success');
}
tbody.append(rows); tbody.append(rows);
} }
$('#build-codeception-errors').show(); $('#build-codeception-errors').show();
}, },
onUpdateMeta: function(e) { onUpdateMeta: function (e) {
if (!e.queryData) { if (!e.queryData) {
return; return;
} }
@ -95,8 +87,9 @@ var codeceptionPlugin = ActiveBuild.UiPlugin.extend({
this.lastMeta = e.queryData; this.lastMeta = e.queryData;
var data = this.lastMeta[0].meta_value; var data = this.lastMeta[0].meta_value;
var tfoot = $('#codeception-data tfoot'); var tfoot = $('#codeception-data tfoot');
tfoot.empty(); tfoot.empty();
var row = $('<tr>' + var row = $('<tr>' +

View file

@ -1,30 +1,31 @@
var locPlugin = ActiveBuild.UiPlugin.extend({ var locPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-lines-chart', id: 'build-lines-chart',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('lines_of_code'), title: Lang.get('lines_of_code'),
lastData: null, lastData: null,
displayOnUpdate: false, displayOnUpdate: false,
rendered: false, rendered: false,
chartData: null, chartData: null,
register: function() { register: function () {
var self = this; var self = this;
var query = ActiveBuild.registerQuery('phploc-lines', -1, {num_builds: 10, key: 'phploc'}) var query = ActiveBuild.registerQuery('phploc-lines', -1, {num_builds: 10, key: 'phploc'})
$(window).on('phploc-lines', function(data) { $(window).on('phploc-lines', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function(data) { $(window).on('build-updated', function (data) {
if (data.queryData && data.queryData.status > 1 && !self.rendered) { if (data.queryData && data.queryData.status > 1 && !self.rendered) {
query(); query();
} }
}); });
}, },
render: function() { render: function () {
var self = this; var self = this;
var container = $('<div id="phploc-lines" style="width: 100%; height: 300px"></div>'); var container = $('<div id="phploc-lines" style="width: 100%; height: 300px"></div>');
container.append('<canvas id="phploc-lines-chart" style="width: 100%; height: 300px"></canvas>'); container.append('<canvas id="phploc-lines-chart" style="width: 100%; height: 300px"></canvas>');
$(document).on('shown.bs.tab', function () { $(document).on('shown.bs.tab', function () {
@ -35,42 +36,42 @@ var locPlugin = ActiveBuild.UiPlugin.extend({
return container; return container;
}, },
onUpdate: function(e) { onUpdate: function (e) {
this.lastData = e.queryData; this.lastData = e.queryData;
this.displayChart(); this.displayChart();
}, },
displayChart: function() { displayChart: function () {
var self = this; var self = this;
var builds = this.lastData; var builds = this.lastData;
self.rendered = true; self.rendered = true;
self.chartData = { self.chartData = {
labels: [], labels: [],
datasets: [ datasets: [
{ {
label: Lang.get('lines'), label: Lang.get('lines'),
strokeColor: "rgba(60,141,188,1)", strokeColor: "#555299",
pointColor: "rgba(60,141,188,1)", pointColor: "#555299",
data: [] data: []
}, },
{ {
label: Lang.get('logical_lines'), label: Lang.get('logical_lines'),
strokeColor: "rgba(245,105,84,1)", strokeColor: "#00A65A",
pointColor: "rgba(245,105,84,1)", pointColor: "#00A65A",
data: [] data: []
}, },
{ {
label: Lang.get('comment_lines'), label: Lang.get('comment_lines'),
strokeColor: "rgba(0,166,90,1)", strokeColor: "#8AA4AF",
pointColor: "rgba(0,166,90,1)", pointColor: "#8AA4AF",
data: [] data: []
}, },
{ {
label: Lang.get('noncomment_lines'), label: Lang.get('noncomment_lines'),
strokeColor: "rgba(0,192,239,1)", strokeColor: "#00A7D0",
pointColor: "rgba(0,192,239,1)", pointColor: "#00A7D0",
data: [] data: []
} }
] ]
}; };
@ -98,7 +99,7 @@ var locPlugin = ActiveBuild.UiPlugin.extend({
Chart.defaults.global.responsive = true; Chart.defaults.global.responsive = true;
phpLocChart.Line(self.chartData, { phpLocChart.Line(self.chartData, {
datasetFill: false, datasetFill: false,
multiTooltipTemplate: "<%=datasetLabel%>: <%= value %>" multiTooltipTemplate: "<%=datasetLabel%>: <%= value %>"
}); });
} }

View file

@ -1,40 +1,43 @@
var phpspecPlugin = ActiveBuild.UiPlugin.extend({ var phpspecPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpspec-errors', id: 'build-phpspec-errors',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('phpspec'), title: Lang.get('phpspec'),
lastData: null, lastData: null,
displayOnUpdate: false, displayOnUpdate: false,
rendered: false, rendered: false,
register: function() { register: function () {
var self = this; var self = this;
var query = ActiveBuild.registerQuery('phpspec', -1, {key: 'phpspec'}) var query = ActiveBuild.registerQuery('phpspec', -1, {key: 'phpspec'})
$(window).on('phpspec', function(data) { $(window).on('phpspec', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function() { $(window).on('build-updated', function () {
if (!self.rendered) { if (!self.rendered) {
self.displayOnUpdate = true; self.displayOnUpdate = true;
query(); query();
} }
}); });
}, },
render: function() { render: function () {
return $('<table class="table table-striped" id="phpspec-data">' + return $('<table class="table table-hover" id="phpspec-data">' +
'<thead>' + '<thead>' +
'<tr>' + '<tr>' +
' <th>'+Lang.get('suite')+'</th>' + ' <th>' + Lang.get('status') + '</th>' +
' <th>'+Lang.get('test')+'</th>' + ' <th>' + Lang.get('suite') + '</th>' +
' <th>'+Lang.get('result')+'</th>' + ' <th>' + Lang.get('test') + '</th>' +
' <th>' + Lang.get('test_message') + '</th>' +
' <th>' + Lang.get('codeception_time') + '</th>' +
'</tr>' + '</tr>' +
'</thead><tbody></tbody></table>'); '</thead><tbody></tbody></table>');
}, },
onUpdate: function(e) { onUpdate: function (e) {
if (!e.queryData) { if (!e.queryData) {
$('#build-phpspec-errors').hide(); $('#build-phpspec-errors').hide();
return; return;
@ -45,6 +48,7 @@ var phpspecPlugin = ActiveBuild.UiPlugin.extend({
var tests = this.lastData[0].meta_value; var tests = this.lastData[0].meta_value;
var tbody = $('#phpspec-data tbody'); var tbody = $('#phpspec-data tbody');
tbody.empty(); tbody.empty();
for (var i in tests.suites) { for (var i in tests.suites) {
@ -55,22 +59,18 @@ var phpspecPlugin = ActiveBuild.UiPlugin.extend({
var row = $( var row = $(
'<tr>' + '<tr>' +
'<td>' + ((test_case.status == 'passed') ? '<span class="label label-success">' + Lang.get('success') + '</span>' : '<span class="label label-danger">' + Lang.get('failed') + '</span>') + '</td>' +
'<td>' + test_suite.name + '</td>' + '<td>' + test_suite.name + '</td>' +
'<td title="' + Lang.get('took_n_seconds', test_case['time']) + '">' + test_case.name + '</td>' + '<td>' + test_case.name + '</td>' +
'<td>' + (test_case.message ? test_case.message : Lang.get('ok')) + '</td>' + '<td>' + (test_case.message ? test_case.message : '') + '</td>' +
'<td>' + test_case['time'] + '</td>' +
'</tr>' '</tr>'
); );
if (test_case.status != 'passed') {
row.addClass('danger');
} else {
row.addClass('success');
}
tbody.append(row); tbody.append(row);
} }
} }
// show plugin once preparation of grid is done // show plugin once preparation of grid is done
$('#build-phpspec-errors').show(); $('#build-phpspec-errors').show();
} }

View file

@ -1,26 +1,26 @@
var phptalPlugin = ActiveBuild.UiPlugin.extend({ var phptalPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phptal', id: 'build-phptal',
css: 'col-xs-12', css: 'col-xs-12',
title: 'PHPTAL Lint', title: 'PHPTAL Lint',
lastData: null, lastData: null,
rendered: false, rendered: false,
register: function() { register: function () {
var self = this; var self = this;
var query = ActiveBuild.registerQuery('phptallint-data', -1, {key: 'phptallint-data'}) var query = ActiveBuild.registerQuery('phptallint-data', -1, {key: 'phptallint-data'})
$(window).on('phptallint-data', function(data) { $(window).on('phptallint-data', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function() { $(window).on('build-updated', function () {
if (!self.rendered) { if (!self.rendered) {
query(); query();
} }
}); });
}, },
render: function() { render: function () {
return $('<table class="table table-hover" id="phptal-data">' + return $('<table class="table table-hover" id="phptal-data">' +
'<thead>' + '<thead>' +
'<tr>' + '<tr>' +
@ -31,7 +31,7 @@ var phptalPlugin = ActiveBuild.UiPlugin.extend({
'</thead><tbody></tbody></table>'); '</thead><tbody></tbody></table>');
}, },
onUpdate: function(e) { onUpdate: function (e) {
if (!e.queryData) { if (!e.queryData) {
$('#build-phptal').hide(); $('#build-phptal').hide();
return; return;
@ -41,7 +41,8 @@ var phptalPlugin = ActiveBuild.UiPlugin.extend({
this.lastData = e.queryData; this.lastData = e.queryData;
var errors = this.lastData[0].meta_value; var errors = this.lastData[0].meta_value;
var tbody = $('#phptal-data tbody'); var tbody = $('#phptal-data tbody');
tbody.empty(); tbody.empty();
if (errors.length == 0) { if (errors.length == 0) {
@ -54,15 +55,15 @@ var phptalPlugin = ActiveBuild.UiPlugin.extend({
if (ActiveBuild.fileLinkTemplate) { if (ActiveBuild.fileLinkTemplate) {
var fileLink = ActiveBuild.fileLinkTemplate.replace('{FILE}', file); var fileLink = ActiveBuild.fileLinkTemplate.replace('{FILE}', file);
fileLink = fileLink.replace('{LINE}', errors[i].line); fileLink = fileLink.replace('{LINE}', errors[i].line);
file = '<a target="_blank" href="'+fileLink+'">' + file + '</a>'; file = '<a target="_blank" href="' + fileLink + '">' + file + '</a>';
} }
var row = $('<tr>' + var row = $('<tr>' +
'<td>'+file+'</td>' + '<td>' + file + '</td>' +
'<td>'+errors[i].line+'</td>' + '<td>' + errors[i].line + '</td>' +
'<td>'+errors[i].message+'</td></tr>'); '<td>' + errors[i].message + '</td></tr>');
if (errors[i].type == 'error') { if (errors[i].type == 'error') {
row.addClass('danger'); row.addClass('danger');

View file

@ -1,27 +1,27 @@
var phpunitPlugin = ActiveBuild.UiPlugin.extend({ var phpunitPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-phpunit-errors', id: 'build-phpunit-errors',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('phpunit'), title: Lang.get('phpunit'),
lastData: null, lastData: null,
displayOnUpdate: false, displayOnUpdate: false,
rendered: false, rendered: false,
statusMap: { statusMap: {
success : 'ok', success: 'ok',
failed: 'remove', failed: 'remove',
error: 'warning-sign', error: 'warning-sign',
todo: 'info-sign', todo: 'info-sign',
skipped: 'exclamation-sign' skipped: 'exclamation-sign'
}, },
register: function() { register: function () {
var self = this; var self = this;
var query = ActiveBuild.registerQuery('phpunit-data', -1, {key: 'phpunit-data'}) var query = ActiveBuild.registerQuery('phpunit-data', -1, {key: 'phpunit-data'})
$(window).on('phpunit-data', function(data) { $(window).on('phpunit-data', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function() { $(window).on('build-updated', function () {
if (!self.rendered) { if (!self.rendered) {
self.displayOnUpdate = true; self.displayOnUpdate = true;
query(); query();
@ -29,19 +29,18 @@ var phpunitPlugin = ActiveBuild.UiPlugin.extend({
}); });
}, },
render: function() { render: function () {
return $('<table class="table table-hover" id="phpunit-data">' + return $('<table class="table table-hover" id="phpunit-data">' +
'<thead>' + '<thead>' +
'<tr>' + '<tr>' +
'<th>'+Lang.get('status')+'</th>' + '<th>' + Lang.get('status') + '</th>' +
'<th>'+Lang.get('test_message')+'</th>' + '<th>' + Lang.get('test_message') + '</th>' +
'<th>'+Lang.get('trace')+'</th>' + '<th>' + Lang.get('trace') + '</th>' +
'</tr>' + '</tr>' +
'</thead><tbody></tbody></table>'); '</thead><tbody></tbody></table>');
}, },
onUpdate: function(e) { onUpdate: function (e) {
if (!e.queryData) { if (!e.queryData) {
$('#build-phpunit-errors').hide(); $('#build-phpunit-errors').hide();
return; return;
@ -53,27 +52,29 @@ var phpunitPlugin = ActiveBuild.UiPlugin.extend({
var tests = this.lastData[0].meta_value; var tests = this.lastData[0].meta_value;
var thead = $('#phpunit-data thead tr'); var thead = $('#phpunit-data thead tr');
var tbody = $('#phpunit-data tbody'); var tbody = $('#phpunit-data tbody');
thead.empty().append('<th>'+Lang.get('status')+'</th><th>'+Lang.get('test_message')+'</th><th>'+Lang.get('trace')+'</th>');
thead.empty().append('<th>' + Lang.get('status') + '</th><th>' + Lang.get('test_message') + '</th><th>' + Lang.get('trace') + '</th>');
tbody.empty(); tbody.empty();
if (tests.length == 0) { if (tests.length == 0) {
$('#build-phpunit-errors').hide(); $('#build-phpunit-errors').hide();
return; return;
} }
var counts = { success: 0, failed: 0, error: 0, skipped: 0, todo: 0 }, total = 0; var counts = {success: 0, failed: 0, error: 0, skipped: 0, todo: 0}, total = 0;
for (var i in tests) { for (var i in tests) {
var severity = tests[i].severity || (tests[i].pass ? 'success' : 'failed'), var severity = tests[i].severity || (tests[i].pass ? 'success' : 'failed'),
label = ('success' == severity) ? 'success' : ( label = ('success' == severity) ? 'success' : (
('error' == severity) ? 'danger' : 'warning' ('error' == severity) ? 'danger' : 'warning'
); );
if ('fail' === severity) { if ('fail' === severity) {
severity = 'failed'; severity = 'failed';
} }
var status = $('<td><span class="label label-' + label + '">'+Lang.get(severity)+'</span></td>'), var status = $('<td><span class="label label-' + label + '">' + Lang.get(severity) + '</span></td>'),
content = $('<td></td>'), content = $('<td></td>'),
trace = $('<td></td>'), trace = $('<td></td>'),
message = $('<div class="visible-line-breaks"></div>').appendTo(content), message = $('<div class="visible-line-breaks"></div>').appendTo(content),
@ -104,44 +105,44 @@ var phpunitPlugin = ActiveBuild.UiPlugin.extend({
$('#build-phpunit-errors').show(); $('#build-phpunit-errors').show();
}, },
repr: function(data) repr: function (data) {
{ switch (typeof(data)) {
switch(typeof(data)) {
case 'boolean': case 'boolean':
return '<span class="boolean">' + (data ? 'true' : 'false') + '</span>'; return '<span class="boolean">' + (data ? 'true' : 'false') + '</span>';
case 'string': case 'string':
return '<span class="string">"' + data + '"</span>'; return '<span class="string">"' + data + '"</span>';
case 'undefined': case null: case 'undefined':
case null:
return '<span class="null">null</span>'; return '<span class="null">null</span>';
case 'object': case 'object':
var rows = []; var rows = [];
if(data instanceof Array) { if (data instanceof Array) {
for(var i in data) { for (var i in data) {
rows.push('<tr><td colspan="3">' + this.repr(data[i]) + ',</td></tr>'); rows.push('<tr><td colspan="3">' + this.repr(data[i]) + ',</td></tr>');
} }
} else { } else {
for(var key in data) { for (var key in data) {
rows.push( rows.push(
'<tr>' + '<tr>' +
'<td>' + this.repr(key) + '</td>' + '<td>' + this.repr(key) + '</td>' +
'<td>=&gt;</td>' + '<td>=&gt;</td>' +
'<td>' + this.repr(data[key]) + ',</td>' + '<td>' + this.repr(data[key]) + ',</td>' +
'</tr>'); '</tr>');
} }
} }
return '<table>' + return '<table>' +
'<tr><th colspan="3">array(</th></tr>' + '<tr><th colspan="3">array(</th></tr>' +
rows.join('') + rows.join('') +
'<tr><th colspan="3">)</th></tr>' + '<tr><th colspan="3">)</th></tr>' +
'</table>'; '</table>';
} }
return '???'; return '???';
}, },
buildTrace: function(trace){ buildTrace: function (trace) {
var list = '<ol reversed>'; var list = '<ol reversed>';
trace.forEach(function(line){ trace.forEach(function (line) {
list += '<li>' + line + '</li>'; list += '<li>' + line + '</li>';
}); });
list += '</ol>'; list += '</ol>';

View file

@ -1,36 +1,48 @@
var SummaryPlugin = ActiveBuild.UiPlugin.extend({ var SummaryPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-summary', id: 'build-summary',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('build-summary'), title: Lang.get('build-summary'),
statusLabels: [Lang.get('pending'), Lang.get('running'), Lang.get('success'), Lang.get('failed'), Lang.get('failed_allowed')], statusLabels: [
statusClasses: ['info', 'warning', 'success', 'danger', 'danger'], Lang.get('pending'),
Lang.get('running'),
Lang.get('success'),
Lang.get('failed'),
Lang.get('failed_allowed')
],
statusClasses: [
'info',
'warning',
'success',
'danger',
'danger'
],
register: function() { register: function () {
var self = this; var self = this;
var query = ActiveBuild.registerQuery('plugin-summary', 5, {key: 'plugin-summary'}) var query = ActiveBuild.registerQuery('plugin-summary', 5, {key: 'plugin-summary'})
$(window).on('plugin-summary', function(data) { $(window).on('plugin-summary', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function() { $(window).on('build-updated', function () {
query(); query();
}); });
}, },
render: function() { render: function () {
return $( return $(
'<table class="table table-hover" id="plugin-summary">' + '<table class="table table-hover" id="plugin-summary">' +
'<thead><tr>' + '<thead><tr>' +
'<th>'+Lang.get('stage')+'</th>' + '<th>' + Lang.get('stage') + '</th>' +
'<th>'+Lang.get('plugin')+'</th>' + '<th>' + Lang.get('plugin') + '</th>' +
'<th>'+Lang.get('status')+'</th>' + '<th>' + Lang.get('status') + '</th>' +
'<th class="text-right">' + Lang.get('duration') + ' (' + Lang.get('seconds') + ')</th>' + '<th class="text-right">' + Lang.get('duration') + ' (' + Lang.get('seconds') + ')</th>' +
'</tr></thead><tbody></tbody></table>' '</tr></thead><tbody></tbody></table>'
); );
}, },
onUpdate: function(e) { onUpdate: function (e) {
if (!e.queryData) { if (!e.queryData) {
$('#build-summary').hide(); $('#build-summary').hide();
return; return;
@ -38,20 +50,21 @@ var SummaryPlugin = ActiveBuild.UiPlugin.extend({
var tbody = $('#plugin-summary tbody'), var tbody = $('#plugin-summary tbody'),
summary = e.queryData[0].meta_value; summary = e.queryData[0].meta_value;
tbody.empty(); tbody.empty();
for(var stage in summary) { for (var stage in summary) {
for(var plugin in summary[stage]) { for (var plugin in summary[stage]) {
var data = summary[stage][plugin], var data = summary[stage][plugin],
duration = data.started ? ((data.ended || Math.floor(Date.now()/1000)) - data.started) : '-'; duration = data.started ? ((data.ended || Math.floor(Date.now() / 1000)) - data.started) : '-';
tbody.append( tbody.append(
'<tr>' + '<tr>' +
'<td>' + Lang.get('stage_' + stage) + '</td>' + '<td>' + Lang.get('stage_' + stage) + '</td>' +
'<td>' + Lang.get(plugin) + '</td>' + '<td>' + Lang.get(plugin) + '</td>' +
'<td><span class="label label-' + this.statusClasses[data.status] + '">' + '<td><span class="label label-' + this.statusClasses[data.status] + '">' +
this.statusLabels[data.status] + this.statusLabels[data.status] +
'</span></td>' + '</span></td>' +
'<td class="text-right">' + duration + '</td>' + '<td class="text-right">' + duration + '</td>' +
'</tr>' '</tr>'
); );
} }

View file

@ -1,49 +1,50 @@
var warningsPlugin = ActiveBuild.UiPlugin.extend({ var warningsPlugin = ActiveBuild.UiPlugin.extend({
id: 'build-warnings-chart', id: 'build-warnings-chart',
css: 'col-xs-12', css: 'col-xs-12',
title: Lang.get('quality_trend'), title: Lang.get('quality_trend'),
keys: { keys: {
'codeception-errors': Lang.get('codeception_errors'), 'codeception-errors': Lang.get('codeception_errors'),
'phplint-errors': Lang.get('phplint_errors'), 'phplint-errors': Lang.get('phplint_errors'),
'phpunit-errors': Lang.get('phpunit_errors'), 'phpunit-errors': Lang.get('phpunit_errors'),
'phptallint-errors': Lang.get('phptal_errors'), 'phptallint-errors': Lang.get('phptal_errors'),
'phptallint-warnings': Lang.get('phptal_warnings'), 'phptallint-warnings': Lang.get('phptal_warnings'),
'phpmd-warnings': Lang.get('phpmd_warnings'), 'phpmd-warnings': Lang.get('phpmd_warnings'),
'phpdoccheck-warnings': Lang.get('phpdoccheck_warnings'), 'phpdoccheck-warnings': Lang.get('phpdoccheck_warnings'),
'phpcpd-warnings': Lang.get('phpcpd_warnings'), 'phpcpd-warnings': Lang.get('phpcpd_warnings'),
'phpcs-warnings': Lang.get('phpcs_warnings'), 'phpcs-warnings': Lang.get('phpcs_warnings'),
'phpcs-errors': Lang.get('phpcs_errors') 'phpcs-errors': Lang.get('phpcs_errors')
}, },
data: {}, data: {},
displayOnUpdate: false, displayOnUpdate: false,
rendered: false, rendered: false,
chartData: null, chartData: null,
register: function() { register: function () {
var self = this; var self = this;
var queries = []; var queries = [];
for (var key in self.keys) { for (var key in self.keys) {
queries.push(ActiveBuild.registerQuery(key, -1, {num_builds: 10, key: key})); queries.push(ActiveBuild.registerQuery(key, -1, {num_builds: 10, key: key}));
} }
$(window).on('codeception-errors phptallint-warnings phptallint-errors phplint-errors phpunit-errors phpmd-warnings phpdoccheck-warnings phpcpd-warnings phpcs-warnings phpcs-errors', function(data) { $(window).on('codeception-errors phptallint-warnings phptallint-errors phplint-errors phpunit-errors phpmd-warnings phpdoccheck-warnings phpcpd-warnings phpcs-warnings phpcs-errors', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
$(window).on('build-updated', function(data) { $(window).on('build-updated', function (data) {
if (!self.rendered && data.queryData && data.queryData.status > 1) { if (!self.rendered && data.queryData && data.queryData.status > 1) {
self.displayOnUpdate = true; self.displayOnUpdate = true;
for (var query in queries) { for (var query in queries) {
queries[query](); queries[query]();
} }
} }
}); });
}, },
render: function() { render: function () {
var self = this; var self = this;
var container = $('<div id="build-warnings" style="width: 100%; height: 300px"></div>'); var container = $('<div id="build-warnings" style="width: 100%; height: 300px"></div>');
container.append('<canvas id="build-warnings-linechart" style="width: 100%; height: 300px"></canvas>'); container.append('<canvas id="build-warnings-linechart" style="width: 100%; height: 300px"></canvas>');
$(document).on('shown.bs.tab', function () { $(document).on('shown.bs.tab', function () {
@ -54,8 +55,8 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
return container; return container;
}, },
onUpdate: function(e) { onUpdate: function (e) {
var self = this; var self = this;
var builds = e.queryData; var builds = e.queryData;
if (!builds || !builds.length) { if (!builds || !builds.length) {
@ -79,14 +80,25 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
} }
}, },
displayChart: function() { displayChart: function () {
var self = this; var self = this;
self.rendered = true; self.rendered = true;
var colors = ['#4D4D4D', '#5DA5DA', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#F15854', '#4D4D4D']; var colors = [
'#FF0084',
'#D33724',
'#FF851B',
'#F7BE64',
'#B5BBC8',
'#555299',
'#7EDEDE',
'#00A7D0',
'#B5BBC8',
'#001F3F'
];
self.chartData = { self.chartData = {
labels: [], labels: [],
datasets: [] datasets: []
}; };
@ -94,10 +106,10 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
var color = colors.shift(); var color = colors.shift();
self.chartData.datasets.push({ self.chartData.datasets.push({
label: self.keys[key], label: self.keys[key],
strokeColor: color, strokeColor: color,
pointColor: color, pointColor: color,
data: [] data: []
}); });
} }
@ -121,7 +133,7 @@ var warningsPlugin = ActiveBuild.UiPlugin.extend({
if ($('#information').hasClass('active') && self.chartData) { if ($('#information').hasClass('active') && self.chartData) {
$('#build-warnings-chart').show(); $('#build-warnings-chart').show();
var ctx = $("#build-warnings-linechart").get(0).getContext("2d"); var ctx = $("#build-warnings-linechart").get(0).getContext("2d");
var buildWarningsChart = new Chart(ctx); var buildWarningsChart = new Chart(ctx);
Chart.defaults.global.responsive = true; Chart.defaults.global.responsive = true;

View file

@ -6,7 +6,7 @@ var Build = Class.extend({
queries: {}, queries: {},
updateInterval: null, updateInterval: null,
init: function(build) { init: function (build) {
var self = this; var self = this;
self.buildId = build; self.buildId = build;
}, },
@ -18,7 +18,7 @@ var Build = Class.extend({
self.registerQuery('build-updated', 5); self.registerQuery('build-updated', 5);
$(window).on('build-updated', function(data) { $(window).on('build-updated', function (data) {
self.buildData = data.queryData; self.buildData = data.queryData;
@ -68,12 +68,12 @@ var Build = Class.extend({
}); });
}, },
registerQuery: function(name, seconds, query) { registerQuery: function (name, seconds, query) {
var self = this; var self = this;
var uri = 'build/ajax-meta/' + self.buildId; var uri = 'build/ajax-meta/' + self.buildId;
var query = query || {}; var query = query || {};
var cb = function() { var cb = function () {
var fullUri = window.APP_URL + uri; var fullUri = window.APP_URL + uri;
if (name == 'build-updated') { if (name == 'build-updated') {
@ -84,7 +84,7 @@ var Build = Class.extend({
dataType: "json", dataType: "json",
url: fullUri, url: fullUri,
data: query, data: query,
success: function(data) { success: function (data) {
$(window).trigger({type: name, queryData: data}); $(window).trigger({type: name, queryData: data});
}, },
error: handleFailedAjax error: handleFailedAjax
@ -102,7 +102,7 @@ var Build = Class.extend({
clearInterval(this.queries[name]); clearInterval(this.queries[name]);
}, },
registerPlugin: function(plugin) { registerPlugin: function (plugin) {
this.plugins[plugin.id] = plugin; this.plugins[plugin.id] = plugin;
plugin.register(); plugin.register();
}, },
@ -110,14 +110,14 @@ var Build = Class.extend({
storePluginOrder: function () { storePluginOrder: function () {
var renderOrder = []; var renderOrder = [];
$('.ui-plugin > div').each(function() { $('.ui-plugin > div').each(function () {
renderOrder.push($(this).attr('id')); renderOrder.push($(this).attr('id'));
}); });
localStorage.setItem('app-plugin-order', JSON.stringify(renderOrder)); localStorage.setItem('app-plugin-order', JSON.stringify(renderOrder));
}, },
renderPlugins: function() { renderPlugins: function () {
var self = this; var self = this;
var rendered = []; var rendered = [];
var renderOrder = localStorage.getItem('app-plugin-order'); var renderOrder = localStorage.getItem('app-plugin-order');
@ -149,7 +149,7 @@ var Build = Class.extend({
$(window).trigger({type: 'build-updated', queryData: self.buildData}); $(window).trigger({type: 'build-updated', queryData: self.buildData});
}, },
renderPlugin: function(plugin) { renderPlugin: function (plugin) {
var output = plugin.render(); var output = plugin.render();
output = $('<div class="box-body"></div>').append(output); output = $('<div class="box-body"></div>').append(output);
@ -160,9 +160,9 @@ var Build = Class.extend({
if (plugin.title) { if (plugin.title) {
content.prepend( content.prepend(
'<div class="box-header"><h3 class="box-title">'+plugin.title+'</h3>'+ '<div class="box-header"><h3 class="box-title">' + plugin.title + '</h3>' +
'<div class="box-tools pull-right">'+ '<div class="box-tools pull-right">' +
'<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">'+ '<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>' '<i class="fa fa-minus"></i></button></div></div>'
); );
} }
@ -177,13 +177,13 @@ var Build = Class.extend({
css: 'col-xs-12', css: 'col-xs-12',
box: false, box: false,
init: function(){ init: function () {
}, },
register: function() { register: function () {
var self = this; var self = this;
$(window).on('build-updated', function(data) { $(window).on('build-updated', function (data) {
self.onUpdate(data); self.onUpdate(data);
}); });
}, },

View file

@ -3,14 +3,15 @@
* MIT Licensed. * MIT Licensed.
*/ */
// Inspired by base2 and Prototype // Inspired by base2 and Prototype
(function(){ (function () {
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; var initializing = false, fnTest = /xyz/.test(function () {xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing) // The base Class implementation (does nothing)
this.Class = function(){}; this.Class = function () {
};
// Create a new Class that inherits from this class // Create a new Class that inherits from this class
Class.extend = function(prop) { Class.extend = function (prop) {
var _super = this.prototype; var _super = this.prototype;
// Instantiate a base class (but only create the instance, // Instantiate a base class (but only create the instance,
@ -23,9 +24,9 @@
for (var name in prop) { for (var name in prop) {
// Check if we're overwriting an existing function // Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" && prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ? typeof _super[name] == "function" && fnTest.test(prop[name]) ?
(function(name, fn){ (function (name, fn) {
return function() { return function () {
var tmp = this._super; var tmp = this._super;
// Add a new ._super() method that is the same method // Add a new ._super() method that is the same method
@ -46,7 +47,7 @@
// The dummy class constructor // The dummy class constructor
function Class() { function Class() {
// All construction is actually done in the init method // All construction is actually done in the init method
if ( !initializing && this.init ) if (!initializing && this.init)
this.init.apply(this, arguments); this.init.apply(this, arguments);
} }
@ -61,4 +62,4 @@
return Class; return Class;
}; };
})(); })();

View file

@ -158,7 +158,7 @@ class BuildStatusController extends Controller
} }
} }
$cacheDir = RUNTIME_DIR . '/status_cache/'; $cacheDir = RUNTIME_DIR . 'status_cache/';
$cacheFile = $cacheDir . md5($imageUrl) . '.svg'; $cacheFile = $cacheDir . md5($imageUrl) . '.svg';
if (!is_file($cacheFile)) { if (!is_file($cacheFile)) {
$image = file_get_contents($imageUrl); $image = file_get_contents($imageUrl);

View file

@ -312,7 +312,7 @@ PHP Censor',
'seconds' => 'сек.', 'seconds' => 'сек.',
'plugin' => 'Плагин', 'plugin' => 'Плагин',
'stage_setup' => 'Установка', 'stage_setup' => 'Установка',
'stage_test' => 'тестирование', 'stage_test' => 'Тестирование',
'stage_complete' => 'Завершение', 'stage_complete' => 'Завершение',
'stage_success' => 'Успешное завершение', 'stage_success' => 'Успешное завершение',
'stage_failure' => 'Провал', 'stage_failure' => 'Провал',