var nonAvail = ''; var kernelName = $('#kernel-name').val(); var jobName = $('#job-name').val(); var searchFilter = $('#search-filter').val(); function createHideShowButton(element, action) { 'use strict'; var faClass = 'fa fa-eye', tooltipTitle = 'Show content for lab «' + element + '»"'; if (action === 'hide') { faClass = 'fa fa-eye-slash'; tooltipTitle = 'Hide content for lab «' + element + '»"'; } return ''; } function showHideLab(element) { 'use strict'; var tElement = $(element), dataId = tElement.data('id'), dataAction = tElement.data('action'); if (dataAction === 'hide') { $('#accordion' + dataId).hide(); $('#view-eye-' + dataId).empty().append( createHideShowButton(dataId, 'show') ); $('#view-' + dataId).empty().append( 'Content for lab «' + dataId + '» ' + 'hidden. Use the ' + 'button to show it again.' ); } else { $('#accordion' + dataId).show(); $('#view-' + dataId).empty(); $('#view-eye-' + dataId).empty().append( createHideShowButton(dataId, 'hide') ); } } function showHideBoots(element) { 'use strict'; switch (element.id) { case 'success-cell': if ($('#success-btn').attr('disabled') !== 'disabled') { $('.df-failed').hide(); $('.df-success').show(); $('.df-unknown').hide(); $('#success-btn').addClass('active').siblings() .removeClass('active'); } break; case 'success-btn': $('.df-failed').hide(); $('.df-success').show(); $('.df-unknown').hide(); break; case 'fail-cell': if ($('#fail-btn').attr('disabled') !== 'disabled') { $('.df-failed').show(); $('.df-success').hide(); $('.df-unknown').hide(); $('#fail-btn').addClass('active').siblings() .removeClass('active'); } break; case 'fail-btn': $('.df-failed').show(); $('.df-success').hide(); $('.df-unknown').hide(); break; case 'unknown-cell': if ($('#unknown-btn').attr('disabled') !== 'disabled') { $('.df-failed').hide(); $('.df-success').hide(); $('.df-unknown').show(); $('#unknown-btn').addClass('active').siblings() .removeClass('active'); } break; case 'unknown-btn': $('.df-failed').hide(); $('.df-success').hide(); $('.df-unknown').show(); break; default: $('.df-failed').show(); $('.df-success').show(); $('.df-unknown').show(); $('#all-btn').addClass('active').siblings() .removeClass('active'); break; } } function countUniqueData(data) { 'use strict'; var dData = null, board, arch, soc, defconfig, localData = data.result, localLen = localData.length, uniqueArchs = {}, uniqueBoards = {}, uniqueDefcons = {}, uniqueSocs = {}, uniq = {}, i = 0; if (localLen > 0) { for (i; i < localLen; i = i + 1) { dData = localData[i]; arch = dData.arch; board = dData.board; defconfig = dData.defconfig_full; soc = dData.mach; if (arch !== null) { uniqueArchs[arch] = (uniqueArchs[arch] || 0) + 1; } if (board !== null) { uniqueBoards[board] = (uniqueArchs[board] || 0) + 1; } if (defconfig !== null) { uniqueDefcons[defconfig] = (uniqueDefcons[defconfig] || 0) + 1; } if (soc !== null) { uniqueSocs[soc] = (uniqueSocs[soc] || 0) + 1; } } uniq = { arch: Object.keys(uniqueArchs), board: Object.keys(uniqueBoards), defconfig: Object.keys(uniqueDefcons), soc: Object.keys(uniqueSocs) }; } return uniq; } function populateUniqueCounts(data) { 'use strict'; var uniq = countUniqueData(data), ajaxData = null, ajaxDeferredCall = null, totalDefconfig = 0, boardText = '', socText = '', defconfigText = '', innerDefconfText = ''; boardText = '%d'; socText = '%d'; defconfigText = '%s'; if (Object.getOwnPropertyNames(uniq).length > 0) { if (uniq.board.length > 0) { JSBase.replaceContentByID( '#unique-boards', sprintf(boardText, uniq.board.length)); } else { JSBase.replaceContentByID('#unique-boards', nonAvail); } if (uniq.soc.length > 0) { JSBase.replaceContentByID( '#unique-socs', sprintf(socText, uniq.soc.length)); } else { JSBase.replaceContentByID('#unique-socs', nonAvail); } if (uniq.defconfig.length > 0) { ajaxData = {'job_id': data.result[0].job_id.$oid}; ajaxDeferredCall = JSBase.createDeferredCall( '/_ajax/count/defconfig', 'GET', ajaxData, null, null, null, null, null); $.when(ajaxDeferredCall).always(function(res, textStatus) { if (textStatus === 'success') { if (res.code === 200) { totalDefconfig = res.result[0].count; innerDefconfText = sprintf( '%d out of %d', uniq.defconfig.length, totalDefconfig); JSBase.replaceContentByID( '#unique-defconfigs', sprintf(defconfigText, innerDefconfText)); } else { JSBase.replaceContentByID( '#unique-defconfigs', sprintf(defconfigText, uniq.defconfig.length)); } } else { JSBase.replaceContentByID( '#unique-defconfigs', sprintf(defconfigText, uniq.defconfig.length)); } }); } else { JSBase.replaceContentByID('#unique-defconfigs', nonAvail); } } else { JSBase.replaceContentByClass('.unique-values', nonAvail); } } function createPieChart(data) { 'use strict'; var localData = data.result, len = localData.length, success = 0, fail = 0, unknown = 0, i = 0, width = 200, height = 200, radius = Math.min(width, height) / 2, dataset = null, svg = null, // success, fail and unknown status colors. color = ['#5cb85c', '#d9534f', '#f0ad4e'], pie = d3.layout.pie().sort(null), arc = d3.svg.arc().innerRadius(radius - 30).outerRadius(radius - 50); if (len > 0) { for (i; i < len; i = i + 1) { switch (localData[i].status) { case 'FAIL': fail = fail + 1; break; case 'PASS': success = success + 1; break; default: unknown = unknown + 1; break; } } dataset = [success, fail, unknown]; svg = d3.select('#pie-chart').append('svg') .attr('width', width) .attr('height', height) .append('g') .attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')' ); svg.selectAll('path') .data(pie(dataset)) .enter().append('path') .attr('fill', function(d, i) { return color[i]; }) .attr('d', arc); svg.append('text') .attr('dy', '0em') .style('text-anchor', 'middle') .attr('class', 'pie-chart-inside') .text(function(d) { return len; }); svg.append('text') .attr('dy', '1.5em') .style('text-anchor', 'middle') .attr('class', 'pie-chart-data') .text(function(d) { return 'total boots'; }); } $('#success-cell') .empty() .append( '' + success + '' ).css('border-bottom-color', color[0]); $('#fail-cell') .empty() .append( '' + fail + '' ).css('border-bottom-color', color[1]); $('#unknown-cell') .empty() .append( '' + unknown + '' ).css('border-bottom-color', color[2]); } function populateBootsPage(data) { 'use strict'; var localData = data.result, len = localData.length, fileServer = $('#file-server').val(), panel = '', cls, defconfigFull, job, kernel, board, label, arch, i = 0, bootObj = null, bootObjId, hasFailed = false, hasSuccess = false, hasUnknown = false, bootTime = null, labName, allLabs = {}, lab, fileServerUrl = null, fileServerResource = null, fileServerUri = null, uriPath = null, pathUrl = null, logPath = null, bootLog, bootLogHtml, failLabel = '' + '', successLabel = '' + '', unknownLabel = '' + '', toAppend = '', archLabel = ''; if (len > 0) { for (i; i < len; i = i + 1) { bootObj = localData[i]; defconfigFull = bootObj.defconfig_full; arch = bootObj.arch; job = bootObj.job; kernel = bootObj.kernel; board = bootObj.board; labName = bootObj.lab_name; bootObjId = bootObj._id; arch = bootObj.arch; fileServerUrl = bootObj.file_server_url; fileServerResource = bootObj.file_server_resource; bootLog = bootObj.boot_log; bootLogHtml = bootObj.boot_log_html; if (fileServerUrl !== null && fileServerUrl !== undefined) { fileServer = fileServerUrl; } if (fileServerResource !== null && fileServerResource !== undefined) { pathUrl = fileServerResource; } else { pathUrl = job + '/' + kernel + '/' + arch + '-' + defconfigFull + '/'; fileServerResource = null; } fileServerUri = new URI(fileServer); uriPath = fileServerUri.path() + '/' + pathUrl; switch (bootObj.status) { case 'FAIL': hasFailed = true; label = failLabel; cls = 'df-failed'; break; case 'PASS': hasSuccess = true; label = successLabel; cls = 'df-success'; break; default: hasUnknown = true; label = unknownLabel; cls = 'df-unknown'; break; } if (arch !== null) { archLabel = '' + '' + arch + ''; } panel = '