mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Improved how LogViewer determines status icon.
This commit is contained in:
parent
54599578a0
commit
8fc0450dd9
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList, GenerateList, LoadBreadCrumbs,
|
function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, ProjectList, GenerateList, LoadBreadCrumbs,
|
||||||
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate,
|
Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate,
|
||||||
ProjectStatus, FormatDate, Refresh, Wait, Stream, GetChoices, Empty, Find, LogViewer) {
|
Refresh, Wait, Stream, GetChoices, Empty, Find, LogViewer, GetProjectIcon, GetProjectToolTip) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@ -48,30 +48,9 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
if ($scope.projects) {
|
if ($scope.projects) {
|
||||||
$scope.projects.forEach(function(project, i) {
|
$scope.projects.forEach(function(project, i) {
|
||||||
if (project.status === 'ok') {
|
|
||||||
$scope.projects[i].status = 'n/a';
|
$scope.projects[i].statusIcon = GetProjectIcon(project.status);
|
||||||
}
|
$scope.projects[i].statusTip = GetProjectToolTip(project.status);
|
||||||
switch (project.status) {
|
|
||||||
case 'n/a':
|
|
||||||
case 'never updated':
|
|
||||||
$scope.projects[i].statusIcon = 'none';
|
|
||||||
$scope.projects[i].statusTip = 'No SCM updates have run for this project';
|
|
||||||
break;
|
|
||||||
case 'updating':
|
|
||||||
case 'running':
|
|
||||||
$scope.projects[i].statusIcon = 'running pulsate';
|
|
||||||
$scope.projects[i].statusTip = 'Running! Click for details';
|
|
||||||
break;
|
|
||||||
case 'successful':
|
|
||||||
$scope.projects[i].statusIcon = 'success';
|
|
||||||
$scope.projects[i].statusTip = 'Success! Click for details';
|
|
||||||
break;
|
|
||||||
case 'failed':
|
|
||||||
case 'missing':
|
|
||||||
$scope.projects[i].statusTip = 'Failed. Click for details';
|
|
||||||
$scope.projects[i].statusIcon = 'error';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (project.status === 'failed' && project.summary_fields.last_update && project.summary_fields.last_update.status === 'canceled') {
|
if (project.status === 'failed' && project.summary_fields.last_update && project.summary_fields.last_update.status === 'canceled') {
|
||||||
$scope.projects[i].statusTip = 'Canceled. Click for details';
|
$scope.projects[i].statusTip = 'Canceled. Click for details';
|
||||||
@ -201,22 +180,18 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
} else {
|
} else {
|
||||||
if (project.related.current_update) {
|
if (project.related.current_update) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
ProjectStatus({
|
LogViewer({
|
||||||
project_id: id,
|
scope: $scope,
|
||||||
last_update: project.related.current_update
|
url: project.related.current_update,
|
||||||
|
getIcon: GetProjectIcon
|
||||||
});
|
});
|
||||||
} else if (project.related.last_update) {
|
} else if (project.related.last_update) {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
LogViewer({
|
LogViewer({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: project.related.last_update,
|
url: project.related.last_update,
|
||||||
status_icon: 'icon-job-' + project.statusIcon
|
getIcon: GetProjectIcon
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
ProjectStatus({
|
|
||||||
project_id: id,
|
|
||||||
last_update: project.related.last_update
|
|
||||||
});*/
|
|
||||||
} else {
|
} else {
|
||||||
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
||||||
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
||||||
@ -361,8 +336,8 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
|
|
||||||
ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'ProjectList', 'GenerateList',
|
ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'ProjectList', 'GenerateList',
|
||||||
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath',
|
'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath',
|
||||||
'SelectionInit', 'ProjectUpdate', 'ProjectStatus', 'FormatDate', 'Refresh', 'Wait', 'Stream', 'GetChoices', 'Empty', 'Find',
|
'SelectionInit', 'ProjectUpdate', 'Refresh', 'Wait', 'Stream', 'GetChoices', 'Empty', 'Find',
|
||||||
'LogViewer'
|
'LogViewer', 'GetProjectIcon', 'GetProjectToolTip'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
return function(params) {
|
return function(params) {
|
||||||
var parent_scope = params.scope,
|
var parent_scope = params.scope,
|
||||||
url = params.url,
|
url = params.url,
|
||||||
status_icon = params.status_icon,
|
getIcon = params.getIcon,
|
||||||
scope = parent_scope.$new();
|
scope = parent_scope.$new();
|
||||||
|
|
||||||
if (scope.removeModalReady) {
|
if (scope.removeModalReady) {
|
||||||
@ -37,8 +37,8 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
scope[key] = data[key];
|
scope[key] = data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTable({ scope: scope, form: LogViewerStatusForm, id: 'status-form-container', status_icon: status_icon });
|
AddTable({ scope: scope, form: LogViewerStatusForm, id: 'status-form-container', getIcon: getIcon });
|
||||||
AddTable({ scope: scope, form: LogViewerOptionsForm, id: 'options-form-container', status_icon: status_icon });
|
AddTable({ scope: scope, form: LogViewerOptionsForm, id: 'options-form-container', getIcon: getIcon });
|
||||||
|
|
||||||
if (data.result_stdout) {
|
if (data.result_stdout) {
|
||||||
AddPreFormattedText({
|
AddPreFormattedText({
|
||||||
@ -212,7 +212,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
var form = params.form,
|
var form = params.form,
|
||||||
id = params.id,
|
id = params.id,
|
||||||
scope = params.scope,
|
scope = params.scope,
|
||||||
status_icon = params.status_icon,
|
getIcon = params.getIcon,
|
||||||
fld, html, url,
|
fld, html, url,
|
||||||
urls = [
|
urls = [
|
||||||
{ "variable": "credential", "url": "/#/credentials/" },
|
{ "variable": "credential", "url": "/#/credentials/" },
|
||||||
@ -236,8 +236,9 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
else if (fld === 'elapsed') {
|
else if (fld === 'elapsed') {
|
||||||
html += scope[fld] + " <span class=\"small-text\">seconds</span>";
|
html += scope[fld] + " <span class=\"small-text\">seconds</span>";
|
||||||
}
|
}
|
||||||
else if (status_icon && fld === 'status') {
|
else if (getIcon && fld === 'status') {
|
||||||
html += "<i class=\"fa " + status_icon + "\"></i> " + scope[fld];
|
html += "<i class=\"fa icon-job-" + getIcon(scope[fld]) + "\"></i> " + scope[fld];
|
||||||
|
//html += "<i class=\"fa " + status_icon + scope[fld] + "\"></i> " + scope[fld];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
html += scope[fld];
|
html += scope[fld];
|
||||||
|
@ -13,123 +13,60 @@
|
|||||||
|
|
||||||
angular.module('ProjectsHelper', ['RestServices', 'Utilities', 'ProjectStatusDefinition', 'ProjectFormDefinition'])
|
angular.module('ProjectsHelper', ['RestServices', 'Utilities', 'ProjectStatusDefinition', 'ProjectFormDefinition'])
|
||||||
|
|
||||||
.factory('ProjectStatus', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GenerateForm',
|
.factory('GetProjectIcon', [ function() {
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'ProjectStatusForm', 'Wait',
|
return function(status) {
|
||||||
function ($rootScope, $location, $log, $routeParams, Rest, Alert, GenerateForm, Prompt, ProcessErrors, GetBasePath,
|
var result = '';
|
||||||
FormatDate, ProjectStatusForm, Wait) {
|
switch (status) {
|
||||||
return function (params) {
|
case 'n/a':
|
||||||
|
case 'ok':
|
||||||
var project_id = params.project_id,
|
case 'never updated':
|
||||||
last_update = params.last_update,
|
result = 'none';
|
||||||
generator = GenerateForm,
|
break;
|
||||||
form = ProjectStatusForm,
|
case 'pending':
|
||||||
html, scope, ww, wh, x, y, maxrows;
|
case 'waiting':
|
||||||
|
case 'new':
|
||||||
Wait('start');
|
result = 'none';
|
||||||
|
break;
|
||||||
html = "<div id=\"status-modal-dialog\"><div id=\"form-container\" style=\"width: 100%;\"></div></div>\n";
|
case 'updating':
|
||||||
$('#projects-modal-container').empty().append(html);
|
case 'running':
|
||||||
|
result = 'running pulsate';
|
||||||
scope = generator.inject(form, { mode: 'edit', id: 'form-container', related: false, breadCrumbs: false });
|
break;
|
||||||
generator.reset();
|
case 'successful':
|
||||||
|
result = 'success';
|
||||||
// Set modal dimensions based on viewport width
|
break;
|
||||||
ww = $(document).width();
|
case 'failed':
|
||||||
wh = $('body').height();
|
case 'missing':
|
||||||
if (ww > 1199) {
|
result = 'error';
|
||||||
// desktop
|
|
||||||
x = 675;
|
|
||||||
y = (750 > wh) ? wh - 20 : 750;
|
|
||||||
maxrows = 20;
|
|
||||||
} else if (ww <= 1199 && ww >= 768) {
|
|
||||||
x = 550;
|
|
||||||
y = (620 > wh) ? wh - 15 : 620;
|
|
||||||
maxrows = 15;
|
|
||||||
} else {
|
|
||||||
x = (ww - 20);
|
|
||||||
y = (500 > wh) ? wh : 500;
|
|
||||||
maxrows = 10;
|
|
||||||
}
|
}
|
||||||
// Create the modal
|
return result;
|
||||||
$('#status-modal-dialog').dialog({
|
|
||||||
buttons: {
|
|
||||||
"OK": function () {
|
|
||||||
$(this).dialog("close");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modal: true,
|
|
||||||
width: x,
|
|
||||||
height: y,
|
|
||||||
autoOpen: false,
|
|
||||||
create: function () {
|
|
||||||
// fix the close button
|
|
||||||
$('.ui-dialog[aria-describedby="status-modal-dialog"]').find('.ui-dialog-titlebar button').empty().attr({
|
|
||||||
'class': 'close'
|
|
||||||
}).text('x');
|
|
||||||
// fix the OK button
|
|
||||||
$('.ui-dialog[aria-describedby="status-modal-dialog"]').find('.ui-dialog-buttonset button:first')
|
|
||||||
.attr({
|
|
||||||
'class': 'btn btn-primary'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
resizeStop: function () {
|
|
||||||
var dialog = $('.ui-dialog[aria-describedby="status-modal-dialog"]'),
|
|
||||||
titleHeight = dialog.find('.ui-dialog-titlebar').outerHeight(),
|
|
||||||
buttonHeight = dialog.find('.ui-dialog-buttonpane').outerHeight(),
|
|
||||||
content = dialog.find('#status-modal-dialog');
|
|
||||||
content.width(dialog.width() - 28);
|
|
||||||
content.css({ height: (dialog.height() - titleHeight - buttonHeight - 10) });
|
|
||||||
|
|
||||||
},
|
|
||||||
close: function () {
|
|
||||||
// Destroy on close
|
|
||||||
// Destroy on close
|
|
||||||
$('.tooltip').each(function () {
|
|
||||||
// Remove any lingering tooltip <div> elements
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
$('.popover').each(function () {
|
|
||||||
// remove lingering popover <div> elements
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
$('#status-modal-dialog').dialog('destroy');
|
|
||||||
$('#projects-modal-container').empty();
|
|
||||||
},
|
|
||||||
open: function () {
|
|
||||||
Wait('stop');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
|
||||||
Rest.setUrl(last_update);
|
|
||||||
Rest.get()
|
|
||||||
.success(function (data) {
|
|
||||||
var results = data, fld;
|
|
||||||
for (fld in form.fields) {
|
|
||||||
if (results[fld]) {
|
|
||||||
if (fld === 'created') {
|
|
||||||
scope[fld] = FormatDate(new Date(results[fld]));
|
|
||||||
} else {
|
|
||||||
scope[fld] = results[fld];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (results.summary_fields.project[fld]) {
|
|
||||||
scope[fld] = results.summary_fields.project[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#status-modal-dialog')
|
|
||||||
.dialog({
|
|
||||||
title: results.summary_fields.project.name + ' Status'
|
|
||||||
})
|
|
||||||
.dialog('open');
|
|
||||||
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors(scope, data, status, form, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to retrieve project: ' + project_id + '. GET returned: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}])
|
||||||
]);
|
|
||||||
|
.factory('GetProjectToolTip', [ function() {
|
||||||
|
return function(status) {
|
||||||
|
var result = '';
|
||||||
|
switch (status) {
|
||||||
|
case 'n/a':
|
||||||
|
case 'ok':
|
||||||
|
case 'never updated':
|
||||||
|
result = 'No SCM updates have run for this project';
|
||||||
|
break;
|
||||||
|
case 'pending':
|
||||||
|
case 'waiting':
|
||||||
|
case 'new':
|
||||||
|
result = 'Queued. Click for details';
|
||||||
|
break;
|
||||||
|
case 'updating':
|
||||||
|
case 'running':
|
||||||
|
result = 'Running! Click for details';
|
||||||
|
break;
|
||||||
|
case 'successful':
|
||||||
|
result = 'Success! Click for details';
|
||||||
|
break;
|
||||||
|
case 'failed':
|
||||||
|
case 'missing':
|
||||||
|
result = 'Failed. Click for details';
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}]);
|
@ -60,7 +60,7 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
ngClick: 'addProject()',
|
ngClick: 'addProject()',
|
||||||
awToolTip: 'Create a new project'
|
awToolTip: 'Create a new project'
|
||||||
},
|
},
|
||||||
help: {
|
/*help: {
|
||||||
awPopOver: "<dl>\n<dt>Updating</dt><dd>A source control update is in progress.</dd>\n" +
|
awPopOver: "<dl>\n<dt>Updating</dt><dd>A source control update is in progress.</dd>\n" +
|
||||||
"<dt>Never Updated</dt><dd>This project has not yet been updated from source control.</dd>\n" +
|
"<dt>Never Updated</dt><dd>This project has not yet been updated from source control.</dd>\n" +
|
||||||
"<dt>Failed</dt><dd>An error occurred during the most recent source control update, click the status " +
|
"<dt>Failed</dt><dd>An error occurred during the most recent source control update, click the status " +
|
||||||
@ -74,7 +74,7 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
mode: 'edit',
|
mode: 'edit',
|
||||||
awToolTip: 'Click for help',
|
awToolTip: 'Click for help',
|
||||||
awTipPlacement: 'top'
|
awTipPlacement: 'top'
|
||||||
},
|
},*/
|
||||||
refresh: {
|
refresh: {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
awToolTip: "Refresh the page",
|
awToolTip: "Refresh the page",
|
||||||
|
Loading…
Reference in New Issue
Block a user