AC-386 All Jobs and All Host Summaries links now work from Inventories-> Hosts page.

This commit is contained in:
chouseknecht
2013-09-03 17:38:28 -04:00
parent 78de6b360f
commit eae151ba31
6 changed files with 62 additions and 25 deletions

View File

@@ -89,9 +89,10 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
$location.url('/jobs/?job_host_summaries__host=' + id); $location.url('/jobs/?job_host_summaries__host=' + id);
} }
scope.allHostSummaries = function(id, name) { scope.allHostSummaries = function(id, name, inventory_id) {
LoadBreadCrumbs({ path: '/inventories/' + scope.inventory_id + '/hosts', title: name }); LoadBreadCrumbs({ path: '/hosts/' + id, title: name, altPath: '/inventories/' + inventory_id + '/hosts',
$location.url('/hosts/' + id + '/job_host_summaries'); inventory_id: inventory_id });
$location.url('/hosts/' + id + '/job_host_summaries/?inventory=' + inventory_id);
} }
scope.viewLastEvents = function(host_id, last_job, host_name, last_job_name) { scope.viewLastEvents = function(host_id, last_job, host_name, last_job_name) {

View File

@@ -22,6 +22,16 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
var scope = view.inject(list, { mode: 'edit' }); var scope = view.inject(list, { mode: 'edit' });
scope.selected = []; scope.selected = [];
// control enable/disable/show of job specific view elements
if (base == 'hosts') {
scope.job_id = null;
scope.host_id = $routeParams.id;
}
else {
scope.job_id = $routeParams.id;
scope.host_id = null;
}
// After a refresh, populate any needed summary field values on each row // After a refresh, populate any needed summary field values on each row
if (scope.PostRefreshRemove) { if (scope.PostRefreshRemove) {
scope.PostRefreshRemove(); scope.PostRefreshRemove();
@@ -48,30 +58,34 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
LoadBreadCrumbs(); LoadBreadCrumbs();
scope.showEvents = function(host_name, last_job) { scope.showEvents = function(host_name, last_job) {
// When click on !Failed Events link, redirect to latest job/job_events for the host // When click on !Failed Events link, redirect to latest job/job_events for the host
Rest.setUrl(last_job); Rest.setUrl(last_job);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.name }); LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.name });
$location.url('/jobs/' + data.id + '/job_events/?host=' + escape(host_name)); $location.url('/jobs/' + data.id + '/job_events/?host=' + escape(host_name));
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form, ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status }); { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status });
}); });
} }
scope.showJob = function(id) {
$location.path('/jobs/' + id);
}
scope.refresh = function() { scope.refresh = function() {
scope.search(list.iterator); scope.search(list.iterator);
} }
scope.jobDetails = function() { scope.jobDetails = function() {
$location.path('/jobs/' + $routeParams.id); $location.path('/jobs/' + $routeParams.id);
}; };
scope.jobEvents = function() { scope.jobEvents = function() {
$location.path('/jobs/' + $routeParams.id + '/job_events'); $location.path('/jobs/' + $routeParams.id + '/job_events');
}; };
} }

View File

@@ -40,7 +40,8 @@ angular.module('InventoryHostsFormDefinition', [])
//ngDisabled: 'host.last_job == null', //ngDisabled: 'host.last_job == null',
options: [ options: [
{ ngClick: "allJobs(\{\{ host.id \}\})", label: 'All jobs', ngShow: 'host.last_job' }, { ngClick: "allJobs(\{\{ host.id \}\})", label: 'All jobs', ngShow: 'host.last_job' },
{ ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}')", label: 'All host summaries', ngShow: 'host.last_job' }, { ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}', \{\{ inventory_id \}\})", label: 'All host summaries',
ngShow: 'host.last_job' },
{ ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' }, { ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' },
{ ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + { ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " +
"'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events', ngShow: 'host.last_job' }, "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events', ngShow: 'host.last_job' },

View File

@@ -17,6 +17,13 @@ angular.module('JobHostDefinition', [])
hover: true, hover: true,
fields: { fields: {
job: {
label: 'Job ID',
ngClick: "showJob(\{\{ jobhost.job \}\})",
columnShow: 'host_id !== null',
key: true,
desc: true
},
host: { host: {
label: 'Host', label: 'Host',
key: true, key: true,
@@ -68,6 +75,7 @@ angular.module('JobHostDefinition', [])
label: 'Details', label: 'Details',
icon: 'icon-edit', icon: 'icon-edit',
ngClick: "jobDetails()", ngClick: "jobDetails()",
ngShow: 'job_id !== null',
"class": 'btn btn-default btn-sm', "class": 'btn btn-default btn-sm',
awToolTip: 'Edit job details', awToolTip: 'Edit job details',
mode: 'all' mode: 'all'
@@ -76,6 +84,7 @@ angular.module('JobHostDefinition', [])
label: 'Events', label: 'Events',
icon: 'icon-list-ul', icon: 'icon-list-ul',
ngClick: "jobEvents()", ngClick: "jobEvents()",
ngShow: 'job_id !== null',
"class": 'btn btn-default btn-sm', "class": 'btn btn-default btn-sm',
awToolTip: 'View job events', awToolTip: 'View job events',
mode: 'all' mode: 'all'

View File

@@ -213,6 +213,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
html += "\" id=\""; html += "\" id=\"";
html += (list.fields[fld].id) ? list.fields[fld].id : fld + "-header"; html += (list.fields[fld].id) ? list.fields[fld].id : fld + "-header";
html += "\""; html += "\"";
html += (list.fields[fld].columnShow) ? " ng-show=\"" + list.fields[fld].columnShow + "\" " : "";
html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? "ng-click=\"sort('" + fld + "')\"" : ""; html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? "ng-click=\"sort('" + fld + "')\"" : "";
html += ">"; html += ">";
html += list.fields[fld].label; html += list.fields[fld].label;

View File

@@ -171,10 +171,21 @@ angular.module('Utilities',[])
break; break;
} }
} }
$rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); if ($rootScope.crumbCache[j].altPath) {
$rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath });
}
else {
$rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] });
}
} }
else { else {
$rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] }); if (paths[i] == 'hosts') {
$rootScope.breadcrumbs.push({ title: paths[i], path: '/inventories/' + $routeParams.inventory +
'/hosts' });
}
else {
$rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] });
}
} }
ppath += '/' + paths[i]; ppath += '/' + paths[i];
} }