Fixed job_host_summaries and job_events page links and browser refersh issue.

This commit is contained in:
Chris Houseknecht
2014-04-05 02:52:21 -04:00
parent 221db9b296
commit 9af0d424b6
12 changed files with 101 additions and 91 deletions

View File

@@ -112,18 +112,13 @@ angular.module('ansible', [
templateUrl: urlPrefix + 'partials/jobs.html', templateUrl: urlPrefix + 'partials/jobs.html',
controller: 'JobsListController' controller: 'JobsListController'
}). }).
/* when('/jobs/:id', { when('/job_events/:id', {
templateUrl: urlPrefix + 'partials/jobs.html',
controller: 'JobsEdit'
}). */
when('/jobs/:id/job_events', {
templateUrl: urlPrefix + 'partials/job_events.html', templateUrl: urlPrefix + 'partials/job_events.html',
controller: 'JobEventsList' controller: 'JobEventsList'
}). }).
when('/jobs/:id/job_host_summaries', { when('/job_host_summaries/:id', {
templateUrl: urlPrefix + 'partials/job_host_summaries.html', templateUrl: urlPrefix + 'partials/job_host_summaries.html',
controller: 'JobHostSummaryList' controller: 'JobHostSummaryList'
}). }).
@@ -445,6 +440,7 @@ angular.module('ansible', [
base = 'home'; base = 'home';
} else { } else {
base.replace(/\_/g, ' '); base.replace(/\_/g, ' ');
base = (base === 'job_events' || base === 'job_host_summaries') ? 'jobs' : base;
} }
$('.nav-tabs a[href="#' + base + '"]').tab('show'); $('.nav-tabs a[href="#' + base + '"]').tab('show');
}); });
@@ -466,6 +462,9 @@ angular.module('ansible', [
$location.path('/home'); $location.path('/home');
} else { } else {
base.replace(/\_/g, ' '); base.replace(/\_/g, ' ');
if (base === 'jobevents' || base === 'jobhostsummaries') {
base = 'jobs';
}
} }
$('.nav-tabs a[href="#' + base + '"]').tab('show'); $('.nav-tabs a[href="#' + base + '"]').tab('show');

View File

@@ -373,8 +373,8 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
". Click for details\" aw-tip-placement=\"top\"><i class=\"fa icon-job-" + ". Click for details\" aw-tip-placement=\"top\"><i class=\"fa icon-job-" +
row.status + "\"></i></a></td>\n"; row.status + "\"></i></a></td>\n";
//html += "<td>" + ($filter('date')(row.finished,'MM/dd HH:mm:ss')).replace(/ /,'<br />') + "</td>"; //html += "<td>" + ($filter('date')(row.finished,'MM/dd HH:mm:ss')).replace(/ /,'<br />') + "</td>";
html += "<td><a href=\"/#/jobs/" + row.id + "/job_events\">Events</a><br />" + html += "<td><a href=\"/#/job_events/" + row.id + "\">Events</a><br />" +
"<a href=\"/#/jobs/" + row.id + "/job_host_summaries\">Hosts</a></td>"; "<a href=\"/#/job_host_summaries/" + row.id + "\">Hosts</a></td>";
html += "<td><a href=\"\" ng-click=\"viewJob('" + url + row.id + "/')\" >" + ellipsis(row.name) + "</a></td>"; html += "<td><a href=\"\" ng-click=\"viewJob('" + url + row.id + "/')\" >" + ellipsis(row.name) + "</a></td>";
html += "</tr>\n"; html += "</tr>\n";
}); });

View File

@@ -20,9 +20,7 @@ function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParam
defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/', //?parent__isnull=1'; defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/', //?parent__isnull=1';
generator = GenerateList, generator = GenerateList,
page; page;
generator.inject(list, { mode: 'edit', scope: $scope });
list.base = $location.path(); list.base = $location.path();
$scope.job_id = $routeParams.id; $scope.job_id = $routeParams.id;
$rootScope.flashMessage = null; $rootScope.flashMessage = null;
@@ -125,6 +123,7 @@ function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParam
} }
$scope.removePostRefresh = $scope.$on('PostRefresh', function () { $scope.removePostRefresh = $scope.$on('PostRefresh', function () {
// Initialize the parent levels // Initialize the parent levels
generator.inject(list, { mode: 'edit', scope: $scope });
var set = $scope[list.name], i; var set = $scope[list.name], i;
for (i = 0; i < set.length; i++) { for (i = 0; i < set.length; i++) {
set[i].event_display = set[i].event_display.replace(/^\u00a0*/g, ''); set[i].event_display = set[i].event_display.replace(/^\u00a0*/g, '');
@@ -179,9 +178,14 @@ function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParam
$scope.job_status = data.status; $scope.job_status = data.status;
$scope.job_name = data.summary_fields.job_template.name; $scope.job_name = data.summary_fields.job_template.name;
LoadBreadCrumbs({ LoadBreadCrumbs({
path: '/jobs/' + $scope.job_id, path: '/job_events/' + $scope.job_id,
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
altPath: '/jobs'
}); });
$rootScope.breadcrumbs = [{
path: '/jobs',
title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
}];
$scope.$emit('SetHostLinks', data.inventory); $scope.$emit('SetHostLinks', data.inventory);
}) })
.error(function (data, status) { .error(function (data, status) {
@@ -199,6 +203,7 @@ function JobEventsList($filter, $scope, $rootScope, $location, $log, $routeParam
}); });
page = ($routeParams.page) ? parseInt($routeParams.page,10) - 1 : null; page = ($routeParams.page) ? parseInt($routeParams.page,10) - 1 : null;
PaginateInit({ PaginateInit({
scope: $scope, scope: $scope,
list: list, list: list,

View File

@@ -17,28 +17,27 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
ClearScope(); ClearScope();
var list = JobHostList, var list = JobHostList,
base = $location.path().replace(/^\//, '').split('/')[0], defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_host_summaries/',
defaultUrl = GetBasePath(base) + $routeParams.id + '/job_host_summaries/', view = GenerateList;
view = GenerateList,
scope = view.inject(list, { mode: 'edit' });
// When viewing all summaries for a particular host, show job ID, otherwise row ID. // When viewing all summaries for a particular host, show job ID, otherwise row ID.
if (base === 'hosts') { //if (base === 'hosts') {
list.index = false; // list.index = false;
} else { //} else {
list.index = true; // list.index = true;
} //}
$scope.selected = []; $scope.selected = [];
// control enable/disable/show of job specific view elements // control enable/disable/show of job specific view elements
if (base === 'hosts') { //if (base === 'hosts') {
$scope.job_id = null; //$scope.job_id = null;
$scope.host_id = $routeParams.id; //$scope.host_id = $routeParams.id;
} else { //} else {
$scope.job_id = $routeParams.id; //}
$scope.host_id = null;
} $scope.job_id = $routeParams.id;
$scope.host_id = null;
if ($scope.RemoveSetHostLink) { if ($scope.RemoveSetHostLink) {
$scope.RemoveSetHostLink(); $scope.RemoveSetHostLink();
@@ -56,6 +55,8 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
} }
$scope.removePostRefresh = $scope.$on('PostRefresh', function () { $scope.removePostRefresh = $scope.$on('PostRefresh', function () {
view.inject(list, { mode: 'edit', scope: $scope });
// Set status, tooltips, badges icons, etc. // Set status, tooltips, badges icons, etc.
$scope.jobhosts.forEach(function(element, i) { $scope.jobhosts.forEach(function(element, i) {
$scope.jobhosts[i].host_name = ($scope.jobhosts[i].summary_fields.host) ? $scope.jobhosts[i].summary_fields.host.name : ''; $scope.jobhosts[i].host_name = ($scope.jobhosts[i].summary_fields.host) ? $scope.jobhosts[i].summary_fields.host.name : '';
@@ -63,67 +64,71 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
$scope.jobhosts[i].statusBadgeToolTip = JobStatusToolTip($scope.jobhosts[i].status) + $scope.jobhosts[i].statusBadgeToolTip = JobStatusToolTip($scope.jobhosts[i].status) +
" Click to view details."; " Click to view details.";
if ($scope.jobhosts[i].summary_fields.host) { if ($scope.jobhosts[i].summary_fields.host) {
$scope.jobhosts[i].statusLinkTo = '/#/jobs/' + $scope.jobhosts[i].job + '/job_events/?host=' + $scope.jobhosts[i].statusLinkTo = '/#/job_events/' + $scope.jobhosts[i].job + '/?host=' +
encodeURI($scope.jobhosts[i].summary_fields.host.name); encodeURI($scope.jobhosts[i].summary_fields.host.name);
} }
else { else {
$scope.jobhosts[i].statusLinkTo = '/#/jobs/' + $scope.jobhosts[i].job + '/job_events'; $scope.jobhosts[i].statusLinkTo = '/#/job_events/' + $scope.jobhosts[i].job;
} }
}); });
if ($scope.job_id !== null && $scope.job_id !== undefined && $scope.job_id !== '') { //if ($scope.job_id !== null && $scope.job_id !== undefined && $scope.job_id !== '') {
// need job_status so we can show/hide refresh button // need job_status so we can show/hide refresh button
Rest.setUrl(GetBasePath('jobs') + $scope.job_id); Rest.setUrl(GetBasePath('jobs') + $scope.job_id + '/');
Rest.get() Rest.get()
.success(function (data) { .success(function (data) {
LoadBreadCrumbs({ LoadBreadCrumbs({
path: '/jobs/' + data.id, path: '/job_host_summaries/' + $scope.job_id,
title: data.id + ' - ' + title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
data.summary_fields.job_template.name altPath: '/jobs'
}); });
$scope.job_status = data.status; $rootScope.breadcrumbs = [{
if (!(data.status === 'pending' || data.status === 'waiting' || data.status === 'running')) { path: '/jobs',
if ($rootScope.timer) { title: $scope.job_id + ' - ' + data.summary_fields.job_template.name,
clearInterval($rootScope.timer); }];
} $scope.job_status = data.status;
} if (!(data.status === 'pending' || data.status === 'waiting' || data.status === 'running')) {
$scope.$emit('setHostLink', data.inventory); if ($rootScope.timer) {
}) clearInterval($rootScope.timer);
.error(function (data, status) { }
ProcessErrors(scope, data, status, null, { }
hdr: 'Error!', $scope.$emit('setHostLink', data.inventory);
msg: 'Failed to get job status for job: ' + $scope.job_id + '. GET status: ' + status })
}); .error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Failed to get job status for job: ' + $scope.job_id + '. GET status: ' + status
}); });
} else {
// Make the host name appear in breadcrumbs
LoadBreadCrumbs({
path: '/hosts/' + $scope.host_id,
title: (($scope.jobhosts.length > 0) ? $scope.jobhosts[0].summary_fields.host.name : 'Host')
}); });
if ($routeParams.inventory) { //} else {
$scope.$emit('setHostLink', $routeParams.inventory); // Make the host name appear in breadcrumbs
} // LoadBreadCrumbs({
} // path: '/hosts/' + $scope.host_id,
// title: (($scope.jobhosts.length > 0) ? $scope.jobhosts[0].summary_fields.host.name : 'Host')
// });
// if ($routeParams.inventory) {
// $scope.$emit('setHostLink', $routeParams.inventory);
// }
//}
}); });
SearchInit({ SearchInit({
scope: scope, scope: $scope,
set: 'jobhosts', set: 'jobhosts',
list: list, list: list,
url: defaultUrl url: defaultUrl
}); });
PaginateInit({ PaginateInit({
scope: scope, scope: $scope,
list: list, list: list,
url: defaultUrl url: defaultUrl
}); });
// Called from Inventories tab, host failed events link: // Called from Inventories tab, host failed events link:
if ($routeParams.host_name) { if ($routeParams.host_name) {
scope[list.iterator + 'SearchField'] = 'host'; $scope[list.iterator + 'SearchField'] = 'host';
scope[list.iterator + 'SearchValue'] = $routeParams.host_name; $scope[list.iterator + 'SearchValue'] = $routeParams.host_name;
scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label; $scope[list.iterator + 'SearchFieldLabel'] = list.fields.host.label;
} }
$scope.search(list.iterator); $scope.search(list.iterator);
@@ -141,7 +146,7 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
$location.url('/jobs/' + data.id + '/job_events/?host=' + encodeURI(host_name)); $location.url('/jobs/' + data.id + '/job_events/?host=' + encodeURI(host_name));
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job +
'. GET status: ' + status }); '. GET status: ' + status });
}); });
}; };
@@ -156,7 +161,7 @@ function JobHostSummaryList($scope, $rootScope, $location, $log, $routeParams, R
$scope.jobLoading = true; $scope.jobLoading = true;
Wait('start'); Wait('start');
Refresh({ Refresh({
scope: scope, scope: $scope,
set: 'jobhosts', set: 'jobhosts',
iterator: 'jobhost', iterator: 'jobhost',
url: $scope.current_url url: $scope.current_url

View File

@@ -111,8 +111,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
"aw-tool-tip=\"" + job.status.charAt(0).toUpperCase() + job.status.slice(1) + "aw-tool-tip=\"" + job.status.charAt(0).toUpperCase() + job.status.slice(1) +
". Click for details\" data-placement=\"top\"><i class=\"fa icon-job-" + ". Click for details\" data-placement=\"top\"><i class=\"fa icon-job-" +
job.status + "\"></i></a></td>\n"; job.status + "\"></i></a></td>\n";
html += "<td><a href=\"/#/jobs/" + job.id + "/job_events/?host=" + encodeURI(host.name) + "\">Events</a><br />" + html += "<td><a href=\"/#/job_events/" + job.id + "/?host=" + encodeURI(host.name) + "\">Events</a><br />" +
"<a href=\"/#/jobs/" + job.id + "/job_host_summaries/?host_name=" + encodeURI(host.name) + "\">Hosts</a></td>\n"; "<a href=\"/#/job_host_summaries/" + job.id + "/?host_name=" + encodeURI(host.name) + "\">Hosts</a></td>\n";
html += "<td class=\"break\">" + ellipsis(job.name) + "</td>\n"; html += "<td class=\"break\">" + ellipsis(job.name) + "</td>\n";
html += "</tr>\n"; html += "</tr>\n";
} }

View File

@@ -108,8 +108,8 @@ angular.module('CompletedJobsDefinition', [])
'class': 'btn-default btn-xs', 'class': 'btn-default btn-xs',
options: [ options: [
//{ ngHref: '/#/jobs/{{ completed_job.id }}', label: 'Status' }, //{ ngHref: '/#/jobs/{{ completed_job.id }}', label: 'Status' },
{ ngHref: '/#/jobs/{{ completed_job.id }}/job_events', label: 'Events', ngHide: "completed_job.status == 'new'" }, { ngHref: '/#/job_events/{{ completed_job.id }}', label: 'Events', ngHide: "completed_job.status == 'new'" },
{ ngHref: '/#/jobs/{{ completed_job.id }}/job_host_summaries', label: 'Host Summary' } { ngHref: '/#/job_host_summaries/{{ completed_job.id }}', label: 'Host Summary' }
] ]
} }
} }

View File

@@ -28,13 +28,13 @@ angular.module('JobEventsListDefinition', [])
// ngShow: 'job_id !== null' // ngShow: 'job_id !== null'
//}, //},
events: { events: {
href: '/#/jobs/{{ job_id }}/job_events', href: '/#/job_events/{{ job_id }}',
label: 'Events', label: 'Events',
active: true, active: true,
icon: 'icon-list-ul' icon: 'icon-list-ul'
}, },
hosts: { hosts: {
href: '/#/jobs/{{ job_id }}/job_host_summaries', href: '/#/job_host_summaries/{{ job_id }}',
label: 'Host Summary', label: 'Host Summary',
icon: 'icon-laptop' icon: 'icon-laptop'
} }
@@ -47,7 +47,7 @@ angular.module('JobEventsListDefinition', [])
key: true, key: true,
nosort: true, nosort: true,
searchable: false, searchable: false,
link: false noLink: true
}, },
status: { status: {
label: 'Status', label: 'Status',

View File

@@ -27,12 +27,12 @@ angular.module('JobHostDefinition', [])
// ngShow: "job_id !== null" // ngShow: "job_id !== null"
//}, //},
events: { events: {
href: "/#/jobs/{{ job_id }}/job_events", href: "/#/job_events/{{ job_id }}",
label: 'Events', label: 'Events',
icon: 'icon-list-ul' icon: 'icon-list-ul'
}, },
hosts: { hosts: {
href: "/#/jobs/{{ job_id }}/job_host_summaries", href: "/#/job_host_summariess/{{ job_id }}",
label: 'Host Summary', label: 'Host Summary',
active: true, active: true,
icon: 'icon-laptop' icon: 'icon-laptop'
@@ -67,6 +67,7 @@ angular.module('JobHostDefinition', [])
dataPlacement: 'top', dataPlacement: 'top',
searchField: 'failed', searchField: 'failed',
searchType: 'boolean', searchType: 'boolean',
showValue: false,
searchOptions: [{ searchOptions: [{
name: "success", name: "success",
value: 0 value: 0
@@ -132,8 +133,8 @@ angular.module('JobHostDefinition', [])
ngClick: "refresh()", ngClick: "refresh()",
ngShow: "host_id == null" //don't show when viewing from inventory->hosts ngShow: "host_id == null" //don't show when viewing from inventory->hosts
} }
}, }
fieldActions: {} //fieldActions: {}
}); });

View File

@@ -91,8 +91,8 @@ angular.module('RunningJobsDefinition', [])
'class': 'btn-default btn-xs', 'class': 'btn-default btn-xs',
options: [ options: [
//{ ngHref: '/#/jobs/{{ running_job.id }}', label: 'Status' }, //{ ngHref: '/#/jobs/{{ running_job.id }}', label: 'Status' },
{ ngHref: '/#/jobs/{{ running_job.id }}/job_events', label: 'Events' }, { ngHref: '/#/job_events/{{ running_job.id }}', label: 'Events' },
{ ngHref: '/#/jobs/{{ running_job.id }}/job_host_summaries', label: 'Host Summary' } { ngHref: '/#/job_host_summaries/{{ running_job.id }}', label: 'Host Summary' }
] ]
} }
} }

View File

@@ -246,7 +246,6 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
$rootScope.crumbCache.push(crumb); $rootScope.crumbCache.push(crumb);
} }
} }
paths = $location.path().replace(/^\//, '').split('/'); paths = $location.path().replace(/^\//, '').split('/');
ppath = ''; ppath = '';
$rootScope.breadcrumbs = []; $rootScope.breadcrumbs = [];

View File

@@ -372,8 +372,8 @@ angular.module('GeneratorHelpers', [])
} }
]) ])
.factory('Breadcrumbs', ['Attr', .factory('Breadcrumbs', ['$rootScope', 'Attr',
function (Attr) { function ($rootScope, Attr) {
return function (params) { return function (params) {
// Generate breadcrumbs using the list-generator.js method. // Generate breadcrumbs using the list-generator.js method.

View File

@@ -409,9 +409,10 @@
<script> <script>
// When user clicks on main tab, fire the matching Angular route // When user clicks on main tab, fire the matching Angular route
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) { $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
var url = $(e.target).text(); var url, regx, loc;
var regx = new RegExp('/\#\/' + url.toLowerCase().replace(/ /g,'_') + '/'); url = ($(e.target).text() === 'Jobs') ? 'job' : $(e.target).text().toLowerCase().replace(/ /g,'_');
var loc = window.location.toString(); regx = new RegExp('/\#\/' + url);
loc = window.location.toString();
if (! regx.test(loc)) { if (! regx.test(loc)) {
window.location = '#/' + url.toLowerCase().replace(/ /g,'_'); window.location = '#/' + url.toLowerCase().replace(/ /g,'_');
} }