Merge pull request #4403 from mabashian/3654-inv-status-popover

Fix summary popover on inventory list

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-08-03 16:11:21 +00:00
committed by GitHub
5 changed files with 54 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
export default [ '$scope', 'Empty', 'Wait', 'GetBasePath', 'Rest', 'ProcessErrors', '$state', export default [ '$scope', 'Empty', 'Wait', 'GetBasePath', 'Rest', 'ProcessErrors',
function($scope, Empty, Wait, GetBasePath, Rest, ProcessErrors, $state) { function($scope, Empty, Wait, GetBasePath, Rest, ProcessErrors) {
$scope.gatherRecentJobs = function(event) { $scope.gatherRecentJobs = function(event) {
if (!Empty($scope.inventory.id)) { if (!Empty($scope.inventory.id)) {
@@ -25,16 +25,5 @@ export default [ '$scope', 'Empty', 'Wait', 'GetBasePath', 'Rest', 'ProcessError
} }
} }
}; };
$scope.viewJob = function(jobId, type) {
let outputType = 'playbook';
if (type === 'workflow_job') {
$state.go('workflowResults', { id: jobId}, { reload: true });
} else {
$state.go('output', { id: jobId, type: outputType });
}
};
} }
]; ];

View File

@@ -1,5 +1,5 @@
export default ['templateUrl', 'Wait', '$filter', '$compile', 'i18n', export default ['templateUrl', 'Wait', '$filter', '$compile', 'i18n', '$log',
function(templateUrl, Wait, $filter, $compile, i18n) { function(templateUrl, Wait, $filter, $compile, i18n, $log) {
return { return {
restrict: 'E', restrict: 'E',
replace: false, replace: false,
@@ -19,19 +19,20 @@ export default ['templateUrl', 'Wait', '$filter', '$compile', 'i18n',
function attachElem(event, html, title) { function attachElem(event, html, title) {
var elem = $(event.target).parent(); var elem = $(event.target).parent();
try { try {
elem.tooltip('hide'); elem.tooltip('hide');
elem.popover('destroy'); elem.popover('dispose');
} }
catch(err) { catch(err) {
//ignore $log.debug(err);
} }
$('.popover').each(function() { $('.popover').each(function() {
// remove lingering popover <div>. Seems to be a bug in TB3 RC1 // remove lingering popover <div>. Seems to be a bug in TB3 RC1
$(this).remove(); $(this).remove();
}); });
$('.tooltip').each( function() { $('.tooltip').each( function() {
// close any lingering tool tipss // close any lingering tooltips
$(this).hide(); $(this).hide();
}); });
elem.attr({ elem.attr({
@@ -44,36 +45,59 @@ export default ['templateUrl', 'Wait', '$filter', '$compile', 'i18n',
} }
scope.generateTable = function(data, event){ scope.generateTable = function(data, event){
var html, title = (scope.inventory.has_active_failures) ? "Recent Failed Jobs" : "Recent Successful Jobs"; var html, title = (scope.inventory.has_active_failures) ? i18n._("Recent Failed Jobs") : i18n._("Recent Successful Jobs");
Wait('stop'); Wait('stop');
if (data.count > 0) { if (data.count > 0) {
html = "<table class=\"table table-condensed flyout\" style=\"width: 100%\">\n"; html = `
html += "<thead>\n"; <table class="table table-condensed flyout" style="width: 100%">
html += "<tr>"; <thead>
html += "<th>" + i18n._("Status") + "</th>"; <tr>
html += "<th>" + i18n._("Finished") + "</th>"; <th>${i18n._("Status")}</th>
html += "<th>" + i18n._("Name") + "</th>"; <th>${i18n._("Finished")}</th>
html += "</tr>\n"; <th>${i18n._("Name")}</th>
html += "</thead>\n"; </tr>
html += "<tbody>\n"; </thead>
<tbody>
`;
data.results.forEach(function(row) { data.results.forEach(function(row) {
let href = '';
switch (row.type) {
case 'job':
case 'ad_hoc_command':
case 'system_job':
case 'project_update':
case 'inventory_update':
href = `#/jobs/${row.id}`;
break;
case 'workflow_job':
href = `#/workflows/${row.id}`;
break;
default:
break;
}
if ((scope.inventory.has_active_failures && row.status === 'failed') || (!scope.inventory.has_active_failures && row.status === 'successful')) { if ((scope.inventory.has_active_failures && row.status === 'failed') || (!scope.inventory.has_active_failures && row.status === 'successful')) {
html += "<tr>\n"; html += `
html += "<td><a href=\"\" ng-click=\"viewJob(" + row.id + "," + "'" + row.type + "'" + ")\" " + "aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) + <tr>
". Click for details\" aw-tip-placement=\"top\" data-tooltip-outer-class=\"Tooltip-secondary\"><i class=\"fa SmartStatus-tooltip--" + row.status + " icon-job-" + row.status + "\"></i></a></td>\n"; <td>
html += "<td>" + ($filter('longDate')(row.finished)) + "</td>"; <a href="${href}">
html += "<td><a href=\"\" ng-click=\"viewJob(" + row.id + "," + "'" + row.type + "'" + ")\" " + "aw-tool-tip=\"" + row.status.charAt(0).toUpperCase() + row.status.slice(1) + <i class="fa SmartStatus-tooltip--${row.status} icon-job-${row.status}"></i>
". Click for details\" aw-tip-placement=\"top\" data-tooltip-outer-class=\"Tooltip-secondary\">" + $filter('sanitize')(ellipsis(row.name)) + "</a></td>"; </a>
html += "</tr>\n"; </td>
<td>${($filter('longDate')(row.finished))}</td>
<td>
<a href="${href}">${$filter('sanitize')(ellipsis(row.name))}</a>
</td>
</tr>
`;
} }
}); });
html += "</tbody>\n"; html += `</tbody></table>`;
html += "</table>\n";
} }
else { else {
html = "<p>" + i18n._("No recent job data available for this inventory.") + "</p>\n"; html = `<p>${i18n._("No recent job data available for this inventory.")}</p>`;
} }
attachElem(event, html, title); attachElem(event, html, title);
}; };

View File

@@ -21,7 +21,7 @@ export default ['templateUrl', '$compile', 'Wait', '$filter', 'i18n',
var elem = $(event.target).parent(); var elem = $(event.target).parent();
try { try {
elem.tooltip('hide'); elem.tooltip('hide');
elem.popover('destroy'); elem.popover('dispose');
} }
catch(err) { catch(err) {
//ignore //ignore

View File

@@ -84,7 +84,7 @@ export default ['$scope', '$rootScope', '$location',
var elem = $(event.target).parent(); var elem = $(event.target).parent();
try { try {
elem.tooltip('hide'); elem.tooltip('hide');
elem.popover('destroy'); elem.popover('dispose');
} catch (err) { } catch (err) {
//ignore //ignore
} }

View File

@@ -33,6 +33,7 @@ $.fn.btn = btn;
// Whitelist table elements so they can be used in popovers // Whitelist table elements so they can be used in popovers
$.fn.popover.Constructor.Default.whiteList.table = []; $.fn.popover.Constructor.Default.whiteList.table = [];
$.fn.popover.Constructor.Default.whiteList.th = [];
$.fn.popover.Constructor.Default.whiteList.tr = []; $.fn.popover.Constructor.Default.whiteList.tr = [];
$.fn.popover.Constructor.Default.whiteList.td = []; $.fn.popover.Constructor.Default.whiteList.td = [];
$.fn.popover.Constructor.Default.whiteList.tbody = []; $.fn.popover.Constructor.Default.whiteList.tbody = [];