mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 19:07:39 -02: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:
@@ -49,7 +49,8 @@ angular.module('ansible', [
|
|||||||
'JobsListDefinition',
|
'JobsListDefinition',
|
||||||
'JobFormDefinition',
|
'JobFormDefinition',
|
||||||
'JobEventsListDefinition',
|
'JobEventsListDefinition',
|
||||||
'JobEventFormDefinition'
|
'JobEventFormDefinition',
|
||||||
|
'JobHostDefinition'
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
@@ -61,6 +62,9 @@ angular.module('ansible', [
|
|||||||
|
|
||||||
when('/jobs/:id/job_events',
|
when('/jobs/:id/job_events',
|
||||||
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEventsList }).
|
{ 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',
|
when('/jobs/:job_id/job_events/:event_id',
|
||||||
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEventsEdit }).
|
{ templateUrl: urlPrefix + 'partials/jobs.html', controller: JobEventsEdit }).
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
}
|
}
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
ReturnToCaller();
|
$location.path('/inventories/' + data.id);
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
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()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
// Create a job record
|
// Create a job record
|
||||||
|
scope.credential = '';
|
||||||
if (data.credential == '' || data.credential == null) {
|
if (data.credential == '' || data.credential == null) {
|
||||||
// Template does not have credential, prompt for one
|
// Template does not have credential, prompt for one
|
||||||
if (scope.credentialWatchRemove) {
|
if (scope.credentialWatchRemove) {
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
$location.path($location.path() + '/' + id + '/job_events');
|
$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) {
|
scope.deleteJob = function(id, name) {
|
||||||
Rest.setUrl(defaultUrl + id + '/');
|
Rest.setUrl(defaultUrl + id + '/');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
var id = $routeParams.id;
|
var id = $routeParams.id;
|
||||||
var relatedSets = {};
|
var relatedSets = {};
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the project is loaded, retrieve each related set
|
||||||
if (scope.projectLoadedRemove) {
|
if (scope.projectLoadedRemove) {
|
||||||
scope.projectLoadedRemove();
|
scope.projectLoadedRemove();
|
||||||
}
|
}
|
||||||
@@ -257,8 +257,8 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
ReturnToCaller();
|
ReturnToCaller();
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, OrganizationForm,
|
ProcessErrors(scope, data, status, form,
|
||||||
{ hdr: 'Error!', msg: 'Failed to update project: ' + id + '. PUT status: ' + status });
|
{ 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 });
|
//SetTeamListeners({ scope: scope, set: 'teams', iterator: list.iterator });
|
||||||
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, 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.');
|
'and then click the Select button.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('found!');
|
|
||||||
if (postAction) {
|
if (postAction) {
|
||||||
postAction();
|
postAction();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ angular.module('PaginateHelper', ['RefreshHelper'])
|
|||||||
scope.changePageSize = function(set, iterator) {
|
scope.changePageSize = function(set, iterator) {
|
||||||
// Called when a new page size is selected
|
// Called when a new page size is selected
|
||||||
scope[iterator + 'Page'] = 0;
|
scope[iterator + 'Page'] = 0;
|
||||||
console.log(url);
|
|
||||||
url = url.replace(/\/\?.*$/,'/');
|
url = url.replace(/\/\?.*$/,'/');
|
||||||
console.log(url);
|
|
||||||
url += (scope[iterator + 'SearchParams']) ? scope[iterator + 'SearchParams'] + '&page_size=' + scope[iterator + 'PageSize' ] :
|
url += (scope[iterator + 'SearchParams']) ? scope[iterator + 'SearchParams'] + '&page_size=' + scope[iterator + 'PageSize' ] :
|
||||||
'?page_size=' + scope[iterator + 'PageSize' ];
|
'?page_size=' + scope[iterator + 'PageSize' ];
|
||||||
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
||||||
|
|||||||
@@ -30,7 +30,13 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
// Set default values
|
// Set default values
|
||||||
for (fld in list.fields) {
|
for (fld in list.fields) {
|
||||||
if (list.fields[fld].key) {
|
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 + 'SearchField'] = fld
|
||||||
scope[iterator + 'SearchFieldLabel'] = list.fields[fld].label;
|
scope[iterator + 'SearchFieldLabel'] = list.fields[fld].label;
|
||||||
break;
|
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=
|
// need to be able to search by related set. Ex: /api/v1/inventories/?organization__name__icontains=
|
||||||
//
|
//
|
||||||
scope[iterator + 'SearchSpin'] = true;
|
scope[iterator + 'SearchSpin'] = true;
|
||||||
|
scope[iterator + 'SearchParms'] = '';
|
||||||
var url = defaultUrl;
|
var url = defaultUrl;
|
||||||
if ( (scope[iterator + 'SelectShow'] == false && scope[iterator + 'SearchValue'] != '' && scope[iterator + 'SearchValue'] != undefined) ||
|
if ( (scope[iterator + 'SelectShow'] == false && scope[iterator + 'SearchValue'] != '' && scope[iterator + 'SearchValue'] != undefined) ||
|
||||||
(scope[iterator + 'SelectShow'] && scope[iterator + 'SearchSelectValue']) ) {
|
(scope[iterator + 'SelectShow'] && scope[iterator + 'SearchSelectValue']) ) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ angular.module('CredentialsListDefinition', [])
|
|||||||
selectTitle: 'Add Credentials',
|
selectTitle: 'Add Credentials',
|
||||||
editTitle: '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.',
|
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,
|
||||||
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: {
|
summary: {
|
||||||
title: 'Summary',
|
title: 'Summary',
|
||||||
icon: 'icon-filter',
|
icon: 'icon-filter',
|
||||||
ngClick: 'viewSummary(\{{ job.id \}\})',
|
ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.name \}\}')",
|
||||||
class: 'btn-success btn-mini',
|
class: 'btn-success btn-mini',
|
||||||
awToolTip: 'View host summary',
|
awToolTip: 'View host summary',
|
||||||
ngDisabled: "job.status == 'new'"
|
ngDisabled: "job.status == 'new'"
|
||||||
@@ -88,7 +88,7 @@ angular.module('JobsListDefinition', [])
|
|||||||
ngClick: 'deleteJob(\{\{ job.id \}\})',
|
ngClick: 'deleteJob(\{\{ job.id \}\})',
|
||||||
class: 'btn-danger btn-mini',
|
class: 'btn-danger btn-mini',
|
||||||
awToolTip: 'Cancel job',
|
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 += "\" ";
|
||||||
html += (list.fields[fld].ngClass) ? this.attr(list.fields[fld], 'ngClass') : "";
|
html += (list.fields[fld].ngClass) ? this.attr(list.fields[fld], 'ngClass') : "";
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
if ((list.fields[fld].key || list.fields[fld].link) && options.mode != 'lookup' && options.mode != 'select') {
|
if ((list.fields[fld].key || list.fields[fld].link || list.fields[fld].linkTo || list.fields[fld].ngClick )
|
||||||
html += "<a href=\"#/" + base + "/{{" + list.iterator + ".id }}\">";
|
&& 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) : "";
|
html += (list.fields[fld].icon) ? this.icon(list.fields[fld].icon) : "";
|
||||||
if (list.fields[fld].ngBind) {
|
if (list.fields[fld].ngBind) {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/controllers/Projects.js"></script>
|
<script src="{{ STATIC_URL }}js/controllers/Projects.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/controllers/Jobs.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/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/Users.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/forms/Organizations.js"></script>
|
<script src="{{ STATIC_URL }}js/forms/Organizations.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/forms/Inventories.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/Projects.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/lists/Jobs.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/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/refresh-related.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-paginate.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/related-search.js"></script>
|
||||||
@@ -208,7 +210,6 @@
|
|||||||
|
|
||||||
var loc = window.location.toString();
|
var loc = window.location.toString();
|
||||||
if (! regx.test(loc)) {
|
if (! regx.test(loc)) {
|
||||||
console.log('change! ' + window.location.toString());
|
|
||||||
window.location = '#/' + url.toLowerCase().replace(/ /g,'_');
|
window.location = '#/' + url.toLowerCase().replace(/ /g,'_');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user