diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index df022e8973..22284fb3db 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -303,7 +303,8 @@ InventoriesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateList, ClearScope, InventoryGroups, InventoryHosts, BuildTree, Wait, GetSyncStatusMsg, InjectHosts, HostsReload, GroupsAdd, GroupsEdit, GroupsDelete, Breadcrumbs, LoadBreadCrumbs, Empty, Rest, ProcessErrors, InventoryUpdate, Alert, ToggleChildren, ViewUpdateStatus, GroupsCancelUpdate, Find, - HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost) + HostsCreate, EditInventoryProperties, HostsEdit, HostsDelete, ToggleHostEnabled, CopyMoveGroup, CopyMoveHost, + Stream, GetBasePath) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -502,6 +503,16 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis $scope.toggleHostEnabled = function(host_id, external_source) { ToggleHostEnabled({ scope: $scope, host_id: host_id, external_source: external_source }); } + + $scope.showHostActivity = function() { + var url = GetBasePath('activity_stream') + '?host__inventory__id=' + $scope.inventory_id; + Stream({ inventory_name: $scope.inventory_name, url: url }); + } + + $scope.showGroupActivity = function() { + var url = GetBasePath('activity_stream') + '?group__inventory__id=' + $scope.inventory_id; + Stream({ inventory_name: $scope.inventory_name, url: url }); + } //Load tree data for the first time BuildTree({ scope: $scope, inventory_id: $scope.inventory_id, refresh: false }); @@ -512,6 +523,6 @@ InventoriesEdit.$inject = [ '$scope', '$location', '$routeParams', '$compile', ' 'BuildTree', 'Wait', 'GetSyncStatusMsg', 'InjectHosts', 'HostsReload', 'GroupsAdd', 'GroupsEdit', 'GroupsDelete', 'Breadcrumbs', 'LoadBreadCrumbs', 'Empty', 'Rest', 'ProcessErrors', 'InventoryUpdate', 'Alert', 'ToggleChildren', 'ViewUpdateStatus', 'GroupsCancelUpdate', 'Find', 'HostsCreate', 'EditInventoryProperties', 'HostsEdit', - 'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost' + 'HostsDelete', 'ToggleHostEnabled', 'CopyMoveGroup', 'CopyMoveHost', 'Stream', 'GetBasePath' ]; diff --git a/awx/ui/static/js/helpers/search.js b/awx/ui/static/js/helpers/search.js index e61e1632ba..a760cd2ce9 100644 --- a/awx/ui/static/js/helpers/search.js +++ b/awx/ui/static/js/helpers/search.js @@ -546,10 +546,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) // Call after modal dialogs to remove any lingering callbacks scope.searchCleanup = function() { - console.log('search cleanup!'); scope.removeDoSearch(); - //scope.removeFoundObject(); - //scope.removeResultWarning(); scope.removePrepareSearch(); scope.removePrepareSearch2(); } diff --git a/awx/ui/static/js/lists/InventoryGroups.js b/awx/ui/static/js/lists/InventoryGroups.js index 7f54d92ba3..f712e10b79 100644 --- a/awx/ui/static/js/lists/InventoryGroups.js +++ b/awx/ui/static/js/lists/InventoryGroups.js @@ -59,7 +59,7 @@ angular.module('InventoryGroupsDefinition', []) ngClick: "refreshGroups()" }, stream: { - ngClick: "showActivity()", + ngClick: "showGroupActivity()", awToolTip: "View Activity Stream", mode: 'all', ngShow: "user_is_superuser" diff --git a/awx/ui/static/js/lists/InventoryHosts.js b/awx/ui/static/js/lists/InventoryHosts.js index dc48c886bc..7d2406d556 100644 --- a/awx/ui/static/js/lists/InventoryHosts.js +++ b/awx/ui/static/js/lists/InventoryHosts.js @@ -66,7 +66,7 @@ angular.module('InventoryHostsDefinition', []) fieldActions: { enabled_flag: { //label: 'Enabled', - iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}", + iconClass: "\{\{ 'fa icon-enabled-' + host.enabled \}\}", dataPlacement: 'top', awToolTip: "\{\{ host.enabledToolTip \}\}", dataTipWatch: "host.enabledToolTip", @@ -83,7 +83,6 @@ angular.module('InventoryHostsDefinition', []) //label: 'Edit', ngClick: "editHost(\{\{ host.id \}\})", icon: 'icon-edit', - "class": 'btn-xs btn-primary', awToolTip: 'Edit host', dataPlacement: 'top' }, @@ -91,7 +90,6 @@ angular.module('InventoryHostsDefinition', []) //label: 'Delete', ngClick: "deleteHost(\{\{ host.id \}\},'\{\{ host.name \}\}')", icon: 'icon-trash', - "class": 'btn-xs btn-primary', awToolTip: 'Delete host', dataPlacement: 'top' } @@ -106,7 +104,7 @@ angular.module('InventoryHostsDefinition', []) }, stream: { mode: 'all', - ngClick: "showActivity()", + ngClick: "showHostActivity()", awToolTip: "View Activity Stream", ngShow: "user_is_superuser" }, diff --git a/awx/ui/static/js/widgets/Stream.js b/awx/ui/static/js/widgets/Stream.js index 7a911bce5f..4a41979f5a 100644 --- a/awx/ui/static/js/widgets/Stream.js +++ b/awx/ui/static/js/widgets/Stream.js @@ -51,7 +51,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti stream.hide('slide', {'direction': 'left'}, {'duration': 500, 'queue': false }); // Completely destroy the container so we don't experience random flashes of it later. - // There was some sort weirdness with the tab 'show' causing the stream to slide in when + // There was some sort of weirdness with the tab 'show' causing the stream to slide in when // a tab was clicked, after the stream had been hidden. Seemed like timing- wait long enough // before clicking a tab, and it would not happen. setTimeout( function() { @@ -67,7 +67,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti .factory('StreamBreadCrumbs', ['$rootScope', '$location', function($rootScope, $location) { return function() { - // Load the breadcrumbs array. We have to do things a bit different than our standing Utilities.LoadBreadcrumbs. + // Load the breadcrumbs array. We have to do things a bit different than Utilities.LoadBreadcrumbs. // Rather than botch that all up, we'll do our own thing here. $rootScope.breadcrumbs = []; var paths = $location.path().split('/'); @@ -82,8 +82,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti } for (j=0; j < $rootScope.crumbCache.length; j++) { if ($rootScope.crumbCache[j].path == path) { - title = $rootScope.crumbCache[j].title; - break; + title = $rootScope.crumbCache[j].title; + break; } } if (!title) { @@ -221,61 +221,82 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti .factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit', 'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'BuildUrl', - 'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight', + 'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight', 'Find', function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList, - FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight) { + FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight, + Find) { return function(params) { var list = StreamList; var defaultUrl = GetBasePath('activity_stream'); var view = GenerateList; var base = $location.path().replace(/^\//,'').split('/')[0]; + + // pass in an inventory name to fix breadcrumb display + var inventory_name = (params) ? params.inventory_name : null; + + // url will override the attempt to compute an activity_stream query + var url = (params) ? params.url : null; $rootScope.flashMessage = null; - - if ($location.path() !== '/home') { - // Restrict what we're looking at based on the path - var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,''); - var paths = $location.path().split('/'); - paths.splice(0,1); - if (paths.length > 1 && /^\d+/.test(paths[paths.length - 1])) { - type = paths[paths.length - 2]; - type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,''); - //defaultUrl += '?object1=' + type + '&object1__id=' + - defaultUrl += '?' + type + '__id=' + paths[paths.length - 1]; - } - else if (paths.length > 1) { - type = paths[paths.length - 1]; - type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,''); - defaultUrl += '?or__object1=' + type + '&or__object2=' + type; - } - else { - defaultUrl += '?or__object1=' + type + '&or__object2=' + type; - } + + if (url) { + defaultUrl = url; } - + else { + if ($location.path() !== '/home') { + // Restrict what we're looking at based on the path + var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,''); + var paths = $location.path().split('/'); + paths.splice(0,1); + if (paths.length > 1 && /^\d+/.test(paths[paths.length - 1])) { + type = paths[paths.length - 2]; + type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,''); + //defaultUrl += '?object1=' + type + '&object1__id=' + + defaultUrl += '?' + type + '__id=' + paths[paths.length - 1]; + } + else if (paths.length > 1) { + type = paths[paths.length - 1]; + type = (type == 'inventories') ? 'inventory' : type.replace(/s$/,''); + defaultUrl += '?or__object1=' + type + '&or__object2=' + type; + } + else { + defaultUrl += '?or__object1=' + type + '&or__object2=' + type; + } + } + } + // Add a container for the stream widget $('#tab-content-container').append('
'); StreamBreadCrumbs(); + + // Fix inventory name. The way we're doing breadcrumbs doesn't support bind variables. + if (inventory_name) { + var itm = Find({ list: $rootScope.breadcrumbs, key: 'title', val: '{{ inventory_name }}' }); + if (itm) { + itm.title = inventory_name; + } + } + ShowStream(); // Generate the list var scope = view.inject(list, { mode: 'edit', id: 'stream-content', - breadCrumbs: true, searchSize: 'col-lg-3', secondWidget: true, activityStream: true }); - + scope.closeStream = function(inUrl) { HideStream(); - if (inUrl) { - $location.path(inUrl); + if (scope.searchCleanup) + scope.searchCleanup(); + if (inUrl) + $location.path(inUrl); } - } scope.refreshStream = function() { scope.search(list.iterator); diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 0060e39b74..e5d5b3f54f 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -921,6 +921,7 @@ input[type="checkbox"].checkbox-no-label { .icon-enabled-true { color: @green; + width: 14px; } .icon-enabled-false:before { @@ -929,6 +930,7 @@ input[type="checkbox"].checkbox-no-label { .icon-enabled-false{ color: @red; + width: 14px; } /* Inventory cloud sourced? indicator */ diff --git a/awx/ui/static/lib/ansible/generator-helpers.js b/awx/ui/static/lib/ansible/generator-helpers.js index 9ececaf76f..5b347ca3dc 100644 --- a/awx/ui/static/lib/ansible/generator-helpers.js +++ b/awx/ui/static/lib/ansible/generator-helpers.js @@ -378,14 +378,14 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers']) .factory('Breadcrumbs', ['Attr', function(Attr) { return function(params) { - // Generats breadcrumbs using the list-generator.js method. + // Generate breadcrumbs using the list-generator.js method. var list = params.list; var mode = params.mode; var html = ''; html += "
\n"; - html += "