diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index d9bc0c9a53..d0f817b262 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -277,6 +277,12 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe scope[list.iterator + 'SearchFieldLabel'] = list.fields.has_external_source.label; } + if ($routeParams.inventory_source__id) { + scope[list.iterator + 'SearchField'] = 'inventory_source'; + scope[list.iterator + 'SearchValue'] = $routeParams.inventory_source__id; + scope[list.iterator + 'SearchFieldLabel'] = 'Source ID'; + } + scope.search(list.iterator); LoadBreadCrumbs(); diff --git a/awx/ui/static/js/helpers/Schedules.js b/awx/ui/static/js/helpers/Schedules.js index 29859e6213..788aef629c 100644 --- a/awx/ui/static/js/helpers/Schedules.js +++ b/awx/ui/static/js/helpers/Schedules.js @@ -536,8 +536,8 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe * Called from a controller to setup the scope for a schedules list * */ - .factory('LoadSchedulesScope', ['SearchInit', 'PaginateInit', 'GenerateList', 'SchedulesControllerInit', 'SchedulesListInit', - function(SearchInit, PaginateInit, GenerateList, SchedulesControllerInit, SchedulesListInit) { + .factory('LoadSchedulesScope', ['$routeParams','SearchInit', 'PaginateInit', 'GenerateList', 'SchedulesControllerInit', 'SchedulesListInit', + function($routeParams, SearchInit, PaginateInit, GenerateList, SchedulesControllerInit, SchedulesListInit) { return function(params) { var parent_scope = params.parent_scope, scope = params.scope, @@ -587,72 +587,13 @@ angular.module('SchedulesHelper', [ 'Utilities', 'RestServices', 'SchedulesHelpe }); parent_scope.$emit('listLoaded'); }); + + if ($routeParams.id__int) { + scope[list.iterator + 'SearchField'] = 'id'; + scope[list.iterator + 'SearchValue'] = $routeParams.id__int; + scope[list.iterator + 'SearchFieldLabel'] = 'ID'; + } + scope.search(list.iterator); }; - }]); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + }]); \ No newline at end of file diff --git a/awx/ui/static/js/lists/HomeGroups.js b/awx/ui/static/js/lists/HomeGroups.js index d7f0060170..bcaf22fcac 100644 --- a/awx/ui/static/js/lists/HomeGroups.js +++ b/awx/ui/static/js/lists/HomeGroups.js @@ -100,6 +100,11 @@ angular.module('HomeGroupListDefinition', []) id: { label: 'ID', searchOnly: true + }, + inventory_source: { + label: 'Source ID', + searchType: 'int', + searchOnly: true } }, diff --git a/awx/ui/static/js/lists/Schedules.js b/awx/ui/static/js/lists/Schedules.js index b37fed1909..163fc74b0a 100644 --- a/awx/ui/static/js/lists/Schedules.js +++ b/awx/ui/static/js/lists/Schedules.js @@ -43,6 +43,12 @@ angular.module('SchedulesListDefinition', []) filter: "date:'MM/dd/yy HH:mm:ss'", searchable: false, columnClass: "col-md-2 col-sm-3 hidden-xs" + }, + id: { + label: 'ID', + key: true, + desc: true, + searchType: 'int' } }, diff --git a/awx/ui/static/js/widgets/Stream.js b/awx/ui/static/js/widgets/Stream.js index 7247e8aab5..5034a936ca 100644 --- a/awx/ui/static/js/widgets/Stream.js +++ b/awx/ui/static/js/widgets/Stream.js @@ -150,18 +150,21 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti return function (obj) { var url = '/#/'; switch (obj.base) { - case 'group': - case 'host': - url += 'home/' + obj.base + 's/?id=' + obj.id; - break; - case 'job': - url += 'jobs/?id__int=' + obj.id; - break; - case 'inventory': - url += 'inventories/' + obj.id + '/'; - break; - default: - url += obj.base + 's/' + obj.id + '/'; + case 'group': + case 'host': + url += 'home/' + obj.base + 's/?id=' + obj.id; + break; + case 'job': + url += 'jobs/?id__int=' + obj.id; + break; + case 'inventory': + url += 'inventories/' + obj.id + '/'; + break; + case 'schedule': + url = (obj.url) ? '/#' + obj.url : ''; + break; + default: + url += obj.base + 's/' + obj.id + '/'; } return url; }; @@ -185,7 +188,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti // labels obj1 = activity.object1; obj2 = activity.object2; - + // objects obj1_obj = (activity.summary_fields[obj1]) ? activity.summary_fields[obj1][0] : null; if (obj1 === obj2) { @@ -417,14 +420,13 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti scope.removeStreamPostRefresh(); } scope.removeStreamPostRefresh = scope.$on('PostRefresh', function () { - var i, href, deleted, obj1, obj2; - for (i = 0; i < scope.activities.length; i++) { - // Convert event_time date to local time zone - //cDate = new Date(scope.activities[i].timestamp); - //scope.activities[i].timestamp = FormatDate(cDate); - + var href, deleted, obj1, obj2; + scope.activities.forEach(function(activity, i) { + var row = scope.activities[i], + type, url; + if (scope.activities[i].summary_fields.actor) { - scope.activities[i].user = "" + + scope.activities[i].user = "" + scope.activities[i].summary_fields.actor.username + ""; } else { scope.activities[i].user = 'system'; @@ -434,9 +436,37 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti deleted = /^\_delete/; obj1 = scope.activities[i].object1; obj2 = scope.activities[i].object2; + + if ((obj1 === "schedule" || obj2 === "schedule") && activity.summary_fields.schedule) { + if (activity.summary_fields.inventory_source) { + type = 'inventory_source'; + url = '/home/groups/?inventory_source__id=' + row.summary_fields.inventory_source.id; + } + else if (activity.summary_fields.project) { + type = 'project'; + url = '/projects/' + activity.summary_fields[type].id + '/schedules/?id__int='; + } + else if (activity.summary_fields.job_template) { + type = 'job_template'; + url = '/job_templates/' + activity.summary_fields[type].id + '/schedules/?id__int='; + } + if (obj1 === 'schedule') { + row.summary_fields.schedule[0].url = url + ((type === 'inventory_source') ? '' : row.summary_fields.schedule[0].id); + row.summary_fields.schedule[0].type = type; + row.summary_fields.schedule[0].type_id = activity.summary_fields[type].id; + row.summary_fields.schedule[0].base = 'schedule'; + } + if (obj2 === 'schedule') { + row.summary_fields.schedule[1].url = url + ((type === 'inventory_source') ? '' : row.summary_fields.schedule[1].id); + row.summary_fields.schedule[1].type = type; + row.summary_fields.schedule[1].type_id = activity.summary_fields[type].id; + row.summary_fields.schedule[1].base = 'schedule'; + } + } + if (obj1 && scope.activities[i].summary_fields[obj1] && scope.activities[i].summary_fields[obj1].name) { if (!deleted.test(scope.activities[i].summary_fields[obj1].name)) { - href = BuildUrl(scope.activities[i].summary_fields.object1); + href = BuildUrl(scope.activities[i].summary_fields[obj1]); scope.activities[i].objects = "" + scope.activities[i].summary_fields[obj1].name + ""; } else { scope.activities[i].objects = scope.activities[i].summary_fields[obj1].name; @@ -445,8 +475,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti scope.activities[i].objects = scope.activities[i].object1; } if (obj2 && scope.activities[i].summary_fields[obj2] && scope.activities[i].summary_fields[obj2].name) { - if (!deleted.test(scope.activities[i].summary_fields.object2.name)) { - href = BuildUrl(scope.activities[i].summary_fields.object2); + if (!deleted.test(scope.activities[i].summary_fields[obj2].name)) { + href = BuildUrl(scope.activities[i].summary_fields[obj2]); scope.activities[i].objects += ", " + scope.activities[i].summary_fields[obj2].name + ""; } else { scope.activities[i].objects += "," + scope.activities[i].summary_fields[obj2].name; @@ -457,7 +487,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti BuildDescription(scope.activities[i]); - } + }); // Give ng-repeate a chance to show the data before adjusting the page size. setTimeout(function () { setStreamHeight();