mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
First pass at Job Hosts Summary page. Added link to host detail page. Need to add link to job->host->events.
This commit is contained in:
parent
45a4ba7743
commit
34994a6736
@ -49,7 +49,8 @@ angular.module('ansible', [
|
||||
'JobsListDefinition',
|
||||
'JobFormDefinition',
|
||||
'JobEventsListDefinition',
|
||||
'JobEventFormDefinition'
|
||||
'JobEventFormDefinition',
|
||||
'JobHostDefinition'
|
||||
])
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.
|
||||
@ -61,6 +62,9 @@ angular.module('ansible', [
|
||||
|
||||
when('/jobs/:id/job_events',
|
||||
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEventsList }).
|
||||
|
||||
when('/jobs/:id/job_host_summaries',
|
||||
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobHostSummaryList }).
|
||||
|
||||
when('/jobs/:job_id/job_events/:event_id',
|
||||
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEventsEdit }).
|
||||
|
||||
@ -179,7 +179,7 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
||||
}
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
ReturnToCaller();
|
||||
$location.path('/inventories/' + data.id);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
|
||||
59
ansibleworks/ui/static/js/controllers/JobHosts.js
Normal file
59
ansibleworks/ui/static/js/controllers/JobHosts.js
Normal file
@ -0,0 +1,59 @@
|
||||
/************************************
|
||||
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||
*
|
||||
*
|
||||
* JobHosts.js
|
||||
*
|
||||
* Controller functions for the Job Hosts Summary model.
|
||||
*
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath)
|
||||
{
|
||||
ClearScope('htmlTemplate');
|
||||
var list = JobHostList;
|
||||
var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_host_summaries/';
|
||||
var view = GenerateList;
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
var scope = view.inject(list, { mode: 'edit' });
|
||||
scope.selected = [];
|
||||
|
||||
// After a refresh, populate any needed summary field values on each row
|
||||
if (scope.PostRefreshRemove) {
|
||||
scope.PostRefreshRemove();
|
||||
}
|
||||
scope.PostRefershRemove = scope.$on('PostRefresh', function() {
|
||||
for( var i=0; i < scope.jobhosts.length; i++) {
|
||||
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
||||
}
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'jobhosts', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
scope.search(list.iterator);
|
||||
|
||||
LoadBreadCrumbs();
|
||||
|
||||
scope.viewHost = function(id) {
|
||||
Rest.setUrl(GetBasePath('jobs') + $routeParams.id + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
LoadBreadCrumbs({ path: '/inventories/' + data.inventory, title: data.summary_fields.inventory.name });
|
||||
$location.path('/inventories/' + data.inventory + /hosts/ + id);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to lookup job record for job ' + $routeParams.id + ' GET returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
JobHostSummaryList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobHostList',
|
||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'ProcessErrors','GetBasePath'
|
||||
];
|
||||
@ -185,6 +185,7 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
// Create a job record
|
||||
scope.credential = '';
|
||||
if (data.credential == '' || data.credential == null) {
|
||||
// Template does not have credential, prompt for one
|
||||
if (scope.credentialWatchRemove) {
|
||||
|
||||
@ -41,6 +41,11 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
$location.path($location.path() + '/' + id + '/job_events');
|
||||
}
|
||||
|
||||
scope.viewSummary = function(id, name) {
|
||||
LoadBreadCrumbs({ path: '/jobs/' + id, title: name });
|
||||
$location.path($location.path() + '/' + id + '/job_host_summaries');
|
||||
}
|
||||
|
||||
scope.deleteJob = function(id, name) {
|
||||
Rest.setUrl(defaultUrl + id + '/');
|
||||
Rest.get()
|
||||
|
||||
@ -207,7 +207,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
||||
var id = $routeParams.id;
|
||||
var relatedSets = {};
|
||||
|
||||
// After the Organization is loaded, retrieve each related set
|
||||
// After the project is loaded, retrieve each related set
|
||||
if (scope.projectLoadedRemove) {
|
||||
scope.projectLoadedRemove();
|
||||
}
|
||||
@ -257,8 +257,8 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
||||
ReturnToCaller();
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, OrganizationForm,
|
||||
{ hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@ function TeamsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//SetTeamListeners({ scope: scope, set: 'teams', iterator: list.iterator });
|
||||
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||
|
||||
@ -66,7 +66,6 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
'and then click the Select button.');
|
||||
}
|
||||
else {
|
||||
console.log('found!');
|
||||
if (postAction) {
|
||||
postAction();
|
||||
}
|
||||
|
||||
@ -53,9 +53,7 @@ angular.module('PaginateHelper', ['RefreshHelper'])
|
||||
scope.changePageSize = function(set, iterator) {
|
||||
// Called when a new page size is selected
|
||||
scope[iterator + 'Page'] = 0;
|
||||
console.log(url);
|
||||
url = url.replace(/\/\?.*$/,'/');
|
||||
console.log(url);
|
||||
url += (scope[iterator + 'SearchParams']) ? scope[iterator + 'SearchParams'] + '&page_size=' + scope[iterator + 'PageSize' ] :
|
||||
'?page_size=' + scope[iterator + 'PageSize' ];
|
||||
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
||||
|
||||
@ -30,7 +30,13 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
// Set default values
|
||||
for (fld in list.fields) {
|
||||
if (list.fields[fld].key) {
|
||||
default_order = (list.fields[fld].desc) ? '-' + fld : fld;
|
||||
if (list.fields[fld].sourceModel) {
|
||||
var fka = list.fields[fld].sourceModel + '__' + list.fields[fld].sourceField;
|
||||
default_order = (list.fields[fld].desc) ? '-' + fka : fka;
|
||||
}
|
||||
else {
|
||||
default_order = (list.fields[fld].desc) ? '-' + fld : fld;
|
||||
}
|
||||
scope[iterator + 'SearchField'] = fld
|
||||
scope[iterator + 'SearchFieldLabel'] = list.fields[fld].label;
|
||||
break;
|
||||
@ -84,6 +90,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
// need to be able to search by related set. Ex: /api/v1/inventories/?organization__name__icontains=
|
||||
//
|
||||
scope[iterator + 'SearchSpin'] = true;
|
||||
scope[iterator + 'SearchParms'] = '';
|
||||
var url = defaultUrl;
|
||||
if ( (scope[iterator + 'SelectShow'] == false && scope[iterator + 'SearchValue'] != '' && scope[iterator + 'SearchValue'] != undefined) ||
|
||||
(scope[iterator + 'SelectShow'] && scope[iterator + 'SearchSelectValue']) ) {
|
||||
|
||||
@ -15,7 +15,7 @@ angular.module('CredentialsListDefinition', [])
|
||||
selectTitle: 'Add Credentials',
|
||||
editTitle: 'Credentials',
|
||||
selectInstructions: 'Check the Select checkbox next to each credential to be added, and click Finished when done. Use the green <i class=\"icon-plus\"></i> button to create a new user.',
|
||||
editInstructions: 'Add a new credential record from either the Teams tab or the Users tab. Teams and Users each have an associated set of Credentials.',
|
||||
editInstructions: 'Create a new credential from either the Teams tab or the Users tab. Teams and Users each have an associated set of Credentials.',
|
||||
index: true,
|
||||
index: true,
|
||||
|
||||
|
||||
62
ansibleworks/ui/static/js/lists/JobHosts.js
Normal file
62
ansibleworks/ui/static/js/lists/JobHosts.js
Normal file
@ -0,0 +1,62 @@
|
||||
/*********************************************
|
||||
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||
*
|
||||
* JobHosts.js
|
||||
* List view object for Job Host Summary data model.
|
||||
*
|
||||
*
|
||||
*/
|
||||
angular.module('JobHostDefinition', [])
|
||||
.value(
|
||||
'JobHostList', {
|
||||
|
||||
name: 'jobhosts',
|
||||
iterator: 'jobhost',
|
||||
editTitle: 'Job Host Summary',
|
||||
index: true,
|
||||
hover: true,
|
||||
|
||||
fields: {
|
||||
host: {
|
||||
label: 'Host',
|
||||
key: true,
|
||||
sourceModel: 'host',
|
||||
sourceField: 'name',
|
||||
ngBind: 'jobhost.host_name',
|
||||
//linkTo: '/hosts/\{\{ jobhost.host \}\}'
|
||||
ngClick:"viewHost(\{\{ jobhost.host \}\})"
|
||||
},
|
||||
changed: {
|
||||
label: 'Changed',
|
||||
searchType: 'math'
|
||||
},
|
||||
dark: {
|
||||
label: 'Dark',
|
||||
searchType: 'math'
|
||||
},
|
||||
failures: {
|
||||
label: 'Failures',
|
||||
searchType: 'math'
|
||||
},
|
||||
ok: {
|
||||
label: 'OK',
|
||||
searchType: 'math'
|
||||
},
|
||||
processed: {
|
||||
label: 'Processed',
|
||||
searchType: 'math'
|
||||
},
|
||||
skipped: {
|
||||
label: 'Skipped',
|
||||
searchType: 'math'
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
}
|
||||
|
||||
});
|
||||
@ -67,7 +67,7 @@ angular.module('JobsListDefinition', [])
|
||||
summary: {
|
||||
title: 'Summary',
|
||||
icon: 'icon-filter',
|
||||
ngClick: 'viewSummary(\{{ job.id \}\})',
|
||||
ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.name \}\}')",
|
||||
class: 'btn-success btn-mini',
|
||||
awToolTip: 'View host summary',
|
||||
ngDisabled: "job.status == 'new'"
|
||||
@ -88,7 +88,7 @@ angular.module('JobsListDefinition', [])
|
||||
ngClick: 'deleteJob(\{\{ job.id \}\})',
|
||||
class: 'btn-danger btn-mini',
|
||||
awToolTip: 'Cancel job',
|
||||
ngDisabled: "job.status == 'error' || job.status == 'failed' || job.status == 'success'"
|
||||
ngDisabled: "job.status != 'new' && job.status != 'pending'"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -200,8 +200,17 @@ angular.module('ListGenerator', ['GeneratorHelpers',])
|
||||
html += "\" ";
|
||||
html += (list.fields[fld].ngClass) ? this.attr(list.fields[fld], 'ngClass') : "";
|
||||
html += ">\n";
|
||||
if ((list.fields[fld].key || list.fields[fld].link) && options.mode != 'lookup' && options.mode != 'select') {
|
||||
html += "<a href=\"#/" + base + "/{{" + list.iterator + ".id }}\">";
|
||||
if ((list.fields[fld].key || list.fields[fld].link || list.fields[fld].linkTo || list.fields[fld].ngClick )
|
||||
&& options.mode != 'lookup' && options.mode != 'select') {
|
||||
if (list.fields[fld].linkTo) {
|
||||
html += "<a href=\"#" + list.fields[fld].linkTo + "\">";
|
||||
}
|
||||
else if (list.fields[fld].ngClick) {
|
||||
html += "<a href=\"\"" + this.attr(list.fields[fld], 'ngClick') + "\">";
|
||||
}
|
||||
else {
|
||||
html += "<a href=\"#/" + base + "/{{" + list.iterator + ".id }}\">";
|
||||
}
|
||||
}
|
||||
html += (list.fields[fld].icon) ? this.icon(list.fields[fld].icon) : "";
|
||||
if (list.fields[fld].ngBind) {
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
<script src="{{ STATIC_URL }}js/controllers/Projects.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/controllers/Jobs.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/controllers/JobEvents.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/controllers/JobHosts.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Users.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Organizations.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/forms/Inventories.js"></script>
|
||||
@ -60,6 +61,7 @@
|
||||
<script src="{{ STATIC_URL }}js/lists/Projects.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/Jobs.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/JobEvents.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/lists/JobHosts.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/refresh-related.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||
@ -208,7 +210,6 @@
|
||||
|
||||
var loc = window.location.toString();
|
||||
if (! regx.test(loc)) {
|
||||
console.log('change! ' + window.location.toString());
|
||||
window.location = '#/' + url.toLowerCase().replace(/ /g,'_');
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user