var jobName = $('#job-name').val();
var kernelName = $('#kernel-name').val();
var defconfigFull = $('#defconfig-full').val();
var pageLen = $('#page-len').val();
var searchFilter = $('#search-filter').val();
var fileServer = $('#file-server').val();
function populateBootsTable(data) {
'use strict';
var localData = data.result,
dataLen = localData.length,
table = null;
if (dataLen > 0) {
table = $('#boots-table').dataTable({
'dom': '<"row"<"col-xs-12 col-sm-12 col-md-6 col-lg-6"' +
'<"length-menu"l>>' +
'<"col-xs-12 col-sm-12 col-md-4 col-lg-4 col-lg-offset-2"f>r' +
'<"col-xs-12 col-sm-12 col-md-12 col-lg-12"t>>' +
'<"row"<"col-xs-12 col-sm-12 col-md-6 col-lg-6"i>' +
'<"col-xs-12 col-sm-12 col-md-6 col-lg-6"p>>',
'language': {
'lengthMenu': '_MENU_ boot reports ' +
'per page',
'zeroRecords': '
No boot reports to display.
',
'search': '' +
'' +
'_INPUT_
'
},
'initComplete': function(settings, data) {
$('#table-loading').remove();
$('#table-div').fadeIn('slow', 'linear');
var api = this.api();
if (pageLen !== undefined && pageLen !== null) {
if (pageLen.length > 0) {
pageLen = Number(pageLen);
if (isNaN(pageLen)) {
pageLen = 25;
}
api.page.len(pageLen).draw();
}
}
if (searchFilter !== null && searchFilter !== undefined) {
if (searchFilter.length > 0) {
api.search(searchFilter, true).draw();
}
}
},
'lengthMenu': [25, 50, 75, 100],
'deferRender': true,
'ordering': true,
'processing': true,
'stateDuration': -1,
'stateSave': true,
'order': [5, 'desc'],
'search': {
'regex': true,
'smart': true
},
'data': localData,
'columns': [
{
'data': '_id',
'visible': false,
'searchable': false,
'orderable': false
},
{
'data': 'board',
'title': 'Board Model',
'render': function(data, type, object) {
return '' + data + '';
}
},
{
'data': 'lab_name',
'title': 'Lab Name',
'render': function(data, type, object) {
return '' + data + '';
}
},
{
'data': 'boot_result_description',
'title': 'Failure Reason',
'type': 'string',
'render': function(data, type, object) {
var display = '',
status = object.status;
if (data !== null && status !== 'PASS') {
if (data.length > 45) {
display = '' +
data.slice(0, 46) + '…';
} else {
display = data;
}
}
return display;
}
},
{
'data': 'boot_log',
'title': 'Boot Log',
'type': 'string',
'render': function(data, type, object) {
var arch = object.arch,
fileServerUrl = object.file_server_url,
fileServerResource = object.file_server_resource,
defconfigFull = object.defconfig_full,
labName = object.lab_name,
logPath = null,
fileServerUri = null,
pathUrl = null,
uriPath = null,
bootLog = data,
bootLogHtml = object.boot_log_html,
display = '';
if (fileServerUrl !== null &&
fileServerUrl !== undefined) {
fileServer = fileServerUrl;
}
if (fileServerResource !== null &&
fileServerResource !== undefined) {
pathUrl = fileServerResource;
} else {
pathUrl = jobName + '/' + kernelName + '/' +
arch + '-' + defconfigFull + '/';
}
fileServerUri = new URI(fileServer);
uriPath = fileServerUri.path() + '/' + pathUrl;
if (bootLog !== null) {
if (bootLog.search(labName) === -1) {
logPath = uriPath + '/' + labName + '/' +
bootLog;
} else {
logPath = uriPath + '/' + bootLog;
}
display += 'txt' +
' ' +
'';
}
if (bootLogHtml !== null) {
if (bootLog !== null) {
display += ' — ';
}
if (bootLogHtml.search(labName) === -1) {
logPath = uriPath + '/' + labName + '/' +
bootLogHtml;
} else {
logPath = uriPath + '/' + bootLogHtml;
}
display += 'html ' +
'';
}
return display;
}
},
{
'data': 'created_on',
'title': 'Date',
'type': 'date',
'className': 'pull-center',
'render': function(data) {
var created = new Date(data.$date);
return created.getCustomISODate();
}
},
{
'data': 'status',
'title': 'Status',
'type': 'string',
'className': 'pull-center',
'render': function(data) {
var displ;
switch (data) {
case 'PASS':
displ = '' +
'' +
'' +
'';
break;
case 'FAIL':
displ = '' +
'' +
'' +
'';
break;
case 'OFFLINE':
displ = '' +
'' +
'';
break;
default:
displ = '' +
'' +
'' +
'';
break;
}
return displ;
}
},
{
'data': 'board',
'title': '',
'orderable': false,
'searchable': false,
'className': 'pull-center',
'render': function(data, type, object) {
var lab = object.lab_name;
return '' +
'';
}
}
]
});
$(document).on('click', '#labtable tbody tr', function() {
var localTable = table.fnGetData(this),
location = '#';
if (localTable) {
location = '/boot/' + localTable.board + '/job/' +
localTable.job + '/kernel/' + localTable.kernel +
'/defconfig/' + localTable.defconfig_full + '/lab/' +
localTable.lab_name + '/';
if (localTable._id !== null) {
location += '?_id=' + localTable._id.$oid;
}
window.location = location;
}
});
$('#search-area > .input-sm').attr('placeholder', 'Filter the results');
$('.input-sm').keyup(function(key) {
// Remove focus from input when Esc is pressed.
if (key.keyCode === 27) {
$(this).blur();
}
});
} else {
$('#table-loading').remove();
JSBase.replaceContentByID(
'#table-div',
'No boot reports found.');
}
}
function ajaxDeferredFailed() {
'use strict';
$('#table-loading').remove();
JSBase.replaceContentByID(
'#table-div',
'Error loading data.');
}
$(document).ready(function() {
'use strict';
$('#li-boot').addClass('active');
$('#table-div').hide();
var ajaxDeferredCall = null,
ajaxData = null,
errorReason = 'Error loading boot reports data';
JSBase.replaceContentByID(
'#dd-tree',
'' +
'' + jobName +
'' +
' — ' +
''
);
JSBase.replaceContentByID(
'#dd-git-describe',
'' + kernelName +
'' +
' — ' +
''
);
JSBase.replaceContentByID(
'#dd-defconfig',
defconfigFull + ' — ' +
'' +
''
);
ajaxData = {
'job': jobName,
'kernel': kernelName,
'defconfig_full': defconfigFull
};
ajaxDeferredCall = JSBase.createDeferredCall(
'/_ajax/boot',
'GET',
ajaxData,
null,
ajaxDeferredFailed,
errorReason
);
$.when(ajaxDeferredCall).done(populateBootsTable);
});