mirror of
https://github.com/ansible/awx.git
synced 2026-06-27 17:38:02 -02:30
AC-414 Making red/green bubbles consistent throughout the application. Changes made to Inventory and jobs pages. Tooltip text now dynamic. Improved deep linking, especially on status fields.
This commit is contained in:
@@ -43,15 +43,15 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
|
||||
LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] });
|
||||
|
||||
// Add the selected flag to the hosts set.
|
||||
if (scope.relatedHostsRemove) {
|
||||
scope.relatedHostsRemove();
|
||||
}
|
||||
scope.relatedHostsRemove = scope.$on('relatedhosts', function() {
|
||||
scope.toggleAllFlag = false;
|
||||
for (var i=0; i < scope.hosts.length; i++) {
|
||||
scope.hosts[i].selected = 0;
|
||||
}
|
||||
});
|
||||
//if (scope.relatedHostsRemove) {
|
||||
// scope.relatedHostsRemove();
|
||||
//}
|
||||
//scope.relatedHostsRemove = scope.$on('relatedhosts', function() {
|
||||
// scope.toggleAllFlag = false;
|
||||
// for (var i=0; i < scope.hosts.length; i++) {
|
||||
// scope.hosts[i].selected = 0;
|
||||
// }
|
||||
// });
|
||||
|
||||
scope.filterHosts = function() {
|
||||
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
|
||||
|
||||
@@ -30,65 +30,79 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res
|
||||
scope.search(list.iterator);
|
||||
|
||||
LoadBreadCrumbs();
|
||||
|
||||
|
||||
if (scope.projectsPostRefresh) {
|
||||
scope.projectsPostRefresh();
|
||||
}
|
||||
scope.projectsPostRefresh = scope.$on('PostRefresh', function() {
|
||||
for (var i=0; i < scope.inventories.length; i++) {
|
||||
if (scope.inventories[i].hosts_with_active_failures > 0) {
|
||||
scope.inventories[i].active_failures_params = "/?has_active_failures=true";
|
||||
}
|
||||
//if (scope.inventories[i].hosts_with_active_failures < 99) {
|
||||
// scope.inventories[i].hosts_with_active_failures = ('00' + scope.inventories[i].hosts_with_active_failures).substr(-2);
|
||||
//}
|
||||
}
|
||||
});
|
||||
|
||||
scope.addInventory = function() {
|
||||
$location.path($location.path() + '/add');
|
||||
}
|
||||
$location.path($location.path() + '/add');
|
||||
}
|
||||
|
||||
scope.editInventory = function(id) {
|
||||
$location.path($location.path() + '/' + id);
|
||||
}
|
||||
$location.path($location.path() + '/' + id);
|
||||
}
|
||||
|
||||
scope.deleteInventory = function(id, name) {
|
||||
|
||||
var action = function() {
|
||||
var url = defaultUrl + id + '/';
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.search(list.iterator);
|
||||
Wait('stop');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
var action = function() {
|
||||
var url = defaultUrl + id + '/';
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.destroy()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.search(list.iterator);
|
||||
Wait('stop');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
Prompt({ hdr: 'Delete',
|
||||
body: 'Are you sure you want to delete ' + name + '?',
|
||||
action: action
|
||||
});
|
||||
}
|
||||
Prompt({ hdr: 'Delete',
|
||||
body: 'Are you sure you want to delete ' + name + '?',
|
||||
action: action
|
||||
});
|
||||
}
|
||||
|
||||
scope.lookupOrganization = function(organization_id) {
|
||||
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
return data.name;
|
||||
});
|
||||
}
|
||||
scope.lookupOrganization = function(organization_id) {
|
||||
Rest.setUrl(GetBasePath('organizations') + organization_id + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
return data.name;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
|
||||
scope.viewJobs = function(id) {
|
||||
$location.url('/jobs/?inventory__int=' + id);
|
||||
}
|
||||
// Failed jobs link. Go to the jobs tabs, find all jobs for the inventory and sort by status
|
||||
scope.viewJobs = function(id) {
|
||||
$location.url('/jobs/?inventory__int=' + id);
|
||||
}
|
||||
|
||||
scope.viewFailedJobs = function(id) {
|
||||
$location.url('/jobs/?inventory__int=' + id + '&status=failed');
|
||||
}
|
||||
scope.viewFailedJobs = function(id) {
|
||||
$location.url('/jobs/?inventory__int=' + id + '&status=failed');
|
||||
}
|
||||
|
||||
scope.editHosts = function(id) {
|
||||
$location.url('/inventories/' + id + '/hosts');
|
||||
}
|
||||
scope.editHosts = function(id) {
|
||||
$location.url('/inventories/' + id + '/hosts');
|
||||
}
|
||||
|
||||
scope.editGroups = function(id) {
|
||||
$location.url('/inventories/' + id + '/groups');
|
||||
}
|
||||
scope.editGroups = function(id) {
|
||||
$location.url('/inventories/' + id + '/groups');
|
||||
}
|
||||
}
|
||||
|
||||
InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList',
|
||||
|
||||
@@ -131,12 +131,39 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
set[i]['spaces'] = set[i].event_level * 24;
|
||||
if (scope.jobevents[i].failed) {
|
||||
scope.jobevents[i].status = 'error';
|
||||
if (i == set.length - 1) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred durring one or more playbook tasks.";
|
||||
}
|
||||
else if (set[i].event_level < 3) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred within the children of this event.";
|
||||
}
|
||||
else {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A failure occurred. Click to view details";
|
||||
}
|
||||
}
|
||||
else if (scope.jobevents[i].changed) {
|
||||
scope.jobevents[i].status = 'changed';
|
||||
if (i == set.length - 1) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed durring one or more playbook tasks.";
|
||||
}
|
||||
else if (set[i].event_level < 3) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed by one or more children of this event.";
|
||||
}
|
||||
else {
|
||||
scope.jobevents[i].statusBadgeToolTip = "A change was completed. Click to view details";
|
||||
}
|
||||
}
|
||||
else {
|
||||
scope.jobevents[i].status = 'success';
|
||||
if (i == set.length - 1) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "All playbook tasks completed successfully.";
|
||||
}
|
||||
else if (set[i].event_level < 3) {
|
||||
scope.jobevents[i].statusBadgeToolTip = "All the children of this event completed successfully.";
|
||||
}
|
||||
else {
|
||||
scope.jobevents[i].statusBadgeToolTip = "No errors occurred. Click to view details";
|
||||
}
|
||||
}
|
||||
cDate = new Date(set[i].created);
|
||||
set[i].created = FormatDate(cDate);
|
||||
@@ -147,6 +174,8 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.job_status = data.status;
|
||||
scope.job_name = data.summary_fields.job_template.name;
|
||||
LoadBreadCrumbs({ path: '/jobs/' + scope.job_id, title: scope.job_name });
|
||||
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
||||
if ($rootScope.timer) {
|
||||
clearInterval($rootScope.timer);
|
||||
@@ -181,8 +210,6 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
|
||||
LoadBreadCrumbs();
|
||||
|
||||
scope.viewJobEvent = function(id) {
|
||||
EventView({ event_id: id });
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
|
||||
function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath, Refresh)
|
||||
ClearScope, ProcessErrors, GetBasePath, Refresh, JobStatusToolTip)
|
||||
{
|
||||
ClearScope('htmlTemplate');
|
||||
var list = JobHostList;
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
var defaultUrl = GetBasePath(base) + $routeParams.id + '/job_host_summaries/';
|
||||
|
||||
var inventory_id;
|
||||
|
||||
// When viewing all summaries for a particular host, show job ID, otherwise row ID.
|
||||
if (base == 'hosts') {
|
||||
list.index = false;
|
||||
@@ -42,46 +43,71 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
||||
scope.host_id = null;
|
||||
}
|
||||
|
||||
if (scope.RemoveSetHostLink) {
|
||||
scope.RemoveSetHostLink();
|
||||
}
|
||||
scope.RemoveSetHostLink = scope.$on('setHostLink', function(e, inventory_id) {
|
||||
for (var i=0; i < scope.jobhosts.length; i++) {
|
||||
scope.jobhosts[i].hostLinkTo = '/#/inventories/' + inventory_id + '/hosts/?name=' +
|
||||
escape(scope.jobhosts[i].summary_fields.host.name);
|
||||
}
|
||||
});
|
||||
|
||||
// After a refresh, populate any needed summary field values on each row
|
||||
if (scope.PostRefreshRemove) {
|
||||
scope.PostRefreshRemove();
|
||||
}
|
||||
scope.PostRefershRemove = scope.$on('PostRefresh', function() {
|
||||
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||
|
||||
// Set status, tooltips, badget icons, etc.
|
||||
for( var i=0; i < scope.jobhosts.length; i++) {
|
||||
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
||||
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'error' : 'success';
|
||||
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'failed' : 'success';
|
||||
scope.jobhosts[i].statusBadgeToolTip = JobStatusToolTip(scope.jobhosts[i].status) +
|
||||
" Click to view details.";
|
||||
scope.jobhosts[i].statusLinkTo = '/#/jobs/' + scope.jobhosts[i].job + '/job_events/?host=' +
|
||||
escape(scope.jobhosts[i].summary_fields.host.name);
|
||||
}
|
||||
|
||||
if (scope.job_id !== null && scope.job_id !== undefined && scope.job_id !== '') {
|
||||
// need job_status so we can show/hide refresh button
|
||||
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.job_status = data.status;
|
||||
scope.$emit('setHostLink', data.inventory);
|
||||
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
||||
if ($rootScope.timer) {
|
||||
clearInterval($rootScope.timer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
||||
});
|
||||
}
|
||||
if (base == 'hosts' && $routeParams['host_name']) {
|
||||
// Make the host name appear in breadcrumbs
|
||||
LoadBreadCrumbs({ path: '/hosts/' + scope['host_id'], title: $routeParams['host_name'] });
|
||||
}
|
||||
else {
|
||||
LoadBreadCrumbs();
|
||||
}
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'jobhosts', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
|
||||
// Called from Inventories tab, host failed events link:
|
||||
if ($routeParams.host) {
|
||||
if ($routeParams['host_name']) {
|
||||
scope[list.iterator + 'SearchField'] = 'host';
|
||||
scope[list.iterator + 'SearchValue'] = $routeParams.host;
|
||||
scope[list.iterator + 'SearchValue'] = $routeParams['host_name'];
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['host'].label;
|
||||
}
|
||||
|
||||
scope.search(list.iterator);
|
||||
LoadBreadCrumbs();
|
||||
|
||||
|
||||
scope.showEvents = function(host_name, last_job) {
|
||||
// When click on !Failed Events link, redirect to latest job/job_events for the host
|
||||
@@ -113,5 +139,5 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
||||
|
||||
JobHostSummaryList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobHostList',
|
||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'ProcessErrors', 'GetBasePath', 'Refresh'
|
||||
'ProcessErrors', 'GetBasePath', 'Refresh', 'JobStatusToolTip'
|
||||
];
|
||||
|
||||
@@ -27,6 +27,14 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re
|
||||
|
||||
SearchInit({ scope: scope, set: 'job_templates', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
|
||||
// Called from Inventories tab, host failed events link:
|
||||
if ($routeParams['name']) {
|
||||
scope[list.iterator + 'SearchField'] = 'name';
|
||||
scope[list.iterator + 'SearchValue'] = $routeParams['name'];
|
||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
||||
}
|
||||
|
||||
scope.search(list.iterator);
|
||||
|
||||
LoadBreadCrumbs();
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath, LookUpInit, SubmitJob, FormatDate, Refresh)
|
||||
ClearScope, ProcessErrors, GetBasePath, LookUpInit, SubmitJob, FormatDate, Refresh,
|
||||
JobStatusToolTip)
|
||||
{
|
||||
ClearScope('htmlTemplate');
|
||||
var list = JobList;
|
||||
@@ -41,6 +42,13 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
scope[list.name][i].created = FormatDate(cDate);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i < scope.jobs.length; i++) {
|
||||
scope.jobs[i].statusBadgeToolTip = JobStatusToolTip(scope.jobs[i].status) +
|
||||
" Click to view status details.";
|
||||
scope.jobs[i].statusLinkTo = '/#/jobs/' + scope.jobs[i].id;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -157,14 +165,14 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
|
||||
JobsListCtrl.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobList',
|
||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'ProcessErrors','GetBasePath', 'LookUpInit', 'SubmitJob', 'FormatDate', 'Refresh'
|
||||
'ProcessErrors','GetBasePath', 'LookUpInit', 'SubmitJob', 'FormatDate', 'Refresh', 'JobStatusToolTip'
|
||||
];
|
||||
|
||||
|
||||
function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||
RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList,
|
||||
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, FormatDate)
|
||||
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, FormatDate, JobStatusToolTip)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@@ -334,7 +342,9 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scope.statusToolTip = JobStatusToolTip(data.status);
|
||||
|
||||
$('form[name="jobs_form"] input[type="text"], form[name="jobs_form"] jobs_form textarea').attr('readonly','readonly');
|
||||
$('form[name="jobs_form"] select').prop('disabled', 'disabled');
|
||||
$('form[name="jobs_form"] .lookup-btn').prop('disabled', 'disabled');
|
||||
@@ -503,5 +513,6 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
JobsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobForm',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList',
|
||||
'ProjectList', 'LookUpInit', 'PromptPasswords', 'GetBasePath', 'md5Setup', 'FormatDate'
|
||||
'ProjectList', 'LookUpInit', 'PromptPasswords', 'GetBasePath', 'md5Setup', 'FormatDate',
|
||||
'JobStatusToolTip'
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user