From 4661a9e97a77d1d54792a69669262e196fc109fd Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Tue, 19 Nov 2013 18:52:26 +0000 Subject: [PATCH] Added AS to /inventories/hosts/N and /inventories/groups/N as well has /home/[groups, hosts]. Fixed CSS container sizing issue, so widget will not overlap footer. --- awx/ui/static/js/controllers/Groups.js | 6 ++- awx/ui/static/js/controllers/Home.js | 14 ++++--- awx/ui/static/js/controllers/Hosts.js | 6 ++- awx/ui/static/js/forms/InventoryHosts.js | 11 +++++- awx/ui/static/js/lists/HomeGroups.js | 10 ++++- awx/ui/static/js/lists/HomeHosts.js | 9 +++++ awx/ui/static/js/lists/InventorySummary.js | 9 +++++ awx/ui/static/js/widgets/Stream.js | 45 +++++++++++++++------- awx/ui/static/less/ansible-ui.less | 1 + 9 files changed, 85 insertions(+), 26 deletions(-) diff --git a/awx/ui/static/js/controllers/Groups.js b/awx/ui/static/js/controllers/Groups.js index 89194e68d5..0e29a7a8f5 100644 --- a/awx/ui/static/js/controllers/Groups.js +++ b/awx/ui/static/js/controllers/Groups.js @@ -10,7 +10,7 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryGroupsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, BuildTree, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory, - GroupsDelete, EditInventory, InventoryStatus) + GroupsDelete, EditInventory, InventoryStatus, Stream) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior @@ -108,6 +108,8 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP } }); + scope.showActivity = function() { Stream(); } + scope.addGroup = function() { GroupsList({ "inventory_id": id, group_id: scope.group_id }); } @@ -159,6 +161,6 @@ InventoryGroups.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryGroupsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'BuildTree', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory', - 'GroupsDelete', 'EditInventory', 'InventoryStatus' + 'GroupsDelete', 'EditInventory', 'InventoryStatus', 'Stream' ]; \ No newline at end of file diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index f3bb8ac9bc..03f6203f73 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -50,7 +50,7 @@ Home.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', 'Wait', 'Obj function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, - GetBasePath, SearchInit, PaginateInit, FormatDate, HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus) { + GetBasePath, SearchInit, PaginateInit, FormatDate, HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus, Stream) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -158,18 +158,19 @@ function HomeGroups ($location, $routeParams, HomeGroupList, GenerateList, Proce scope.search(list.iterator); LoadBreadCrumbs(); - + + scope.showActivity = function() { Stream(); } scope.viewUpdateStatus = function(id) { ViewUpdateStatus({ scope: scope, group_id: id }) }; } HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', - 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus' + 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus', 'Stream' ]; function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, - GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit) { + GetBasePath, SearchInit, PaginateInit, FormatDate, SetHostStatus, ToggleHostEnabled, HostsEdit, Stream) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -213,7 +214,8 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process scope.search(list.iterator); LoadBreadCrumbs(); - + + scope.showActivity = function() { Stream(); } scope.toggle_host_enabled = function(id, sources) { ToggleHostEnabled(id, sources, scope); } scope.editHost = function(host_id, host_name) { @@ -233,6 +235,6 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process HomeGroups.$inject = [ '$location', '$routeParams', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus', - 'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit' + 'SetHostStatus', 'ToggleHostEnabled', 'HostsEdit', 'Stream' ]; \ No newline at end of file diff --git a/awx/ui/static/js/controllers/Hosts.js b/awx/ui/static/js/controllers/Hosts.js index 3662dbefb8..0ffaf22be0 100644 --- a/awx/ui/static/js/controllers/Hosts.js +++ b/awx/ui/static/js/controllers/Hosts.js @@ -14,7 +14,7 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, HostsList, HostsAdd, HostsEdit, HostsDelete, HostsReload, BuildTree, EditHostGroups, InventoryHostsHelp, HelpDialog, Wait, - ToggleHostEnabled) + ToggleHostEnabled, Stream) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -40,6 +40,8 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa LoadBreadCrumbs({ path: '/inventories/' + id, title: inventory_name }); }); + scope.showActivity = function() { Stream(); } + scope.filterHosts = function() { HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] }); } @@ -164,6 +166,6 @@ InventoryHosts.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$lo 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'HostsReload', 'BuildTree', 'EditHostGroups', 'InventoryHostsHelp', 'HelpDialog', 'Wait', - 'ToggleHostEnabled' + 'ToggleHostEnabled', 'Stream' ]; diff --git a/awx/ui/static/js/forms/InventoryHosts.js b/awx/ui/static/js/forms/InventoryHosts.js index 8cf3da05c3..43ba98dc32 100644 --- a/awx/ui/static/js/forms/InventoryHosts.js +++ b/awx/ui/static/js/forms/InventoryHosts.js @@ -104,7 +104,16 @@ angular.module('InventoryHostsFormDefinition', []) iconSize: 'large', ngClick: "showHelp()", id: "hosts-page-help" - } + }, + stream: { + 'class': "btn-primary btn-xs activity-btn", + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + dataPlacement: "top", + icon: "icon-comments-alt", + mode: 'edit', + iconSize: 'large' + } }, fieldActions: { diff --git a/awx/ui/static/js/lists/HomeGroups.js b/awx/ui/static/js/lists/HomeGroups.js index e26a10e0e7..06af80dd7d 100644 --- a/awx/ui/static/js/lists/HomeGroups.js +++ b/awx/ui/static/js/lists/HomeGroups.js @@ -110,7 +110,15 @@ angular.module('HomeGroupListDefinition', []) }, actions: { - + stream: { + 'class': "btn-primary btn-xs activity-btn", + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + dataPlacement: "top", + icon: "icon-comments-alt", + mode: 'all', + iconSize: 'large' + } }, fieldActions: { diff --git a/awx/ui/static/js/lists/HomeHosts.js b/awx/ui/static/js/lists/HomeHosts.js index 9de38f5bf0..d2646db0cf 100644 --- a/awx/ui/static/js/lists/HomeHosts.js +++ b/awx/ui/static/js/lists/HomeHosts.js @@ -81,6 +81,15 @@ angular.module('HomeHostListDefinition', []) }, actions: { + stream: { + 'class': "btn-primary btn-xs activity-btn", + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + dataPlacement: "top", + icon: "icon-comments-alt", + mode: 'all', + iconSize: 'large' + } }, fieldActions: { diff --git a/awx/ui/static/js/lists/InventorySummary.js b/awx/ui/static/js/lists/InventorySummary.js index 8ae2f4f2a6..a5433885f9 100644 --- a/awx/ui/static/js/lists/InventorySummary.js +++ b/awx/ui/static/js/lists/InventorySummary.js @@ -135,6 +135,15 @@ angular.module('InventorySummaryDefinition', []) awToolTip: "Refresh the page", ngClick: "refresh()", iconSize: 'large' + }, + stream: { + 'class': "btn-primary btn-xs activity-btn", + ngClick: "showActivity()", + awToolTip: "View Activity Stream", + dataPlacement: "top", + icon: "icon-comments-alt", + mode: 'all', + iconSize: 'large' } }, diff --git a/awx/ui/static/js/widgets/Stream.js b/awx/ui/static/js/widgets/Stream.js index bfc15e8858..a41a9520f7 100644 --- a/awx/ui/static/js/widgets/Stream.js +++ b/awx/ui/static/js/widgets/Stream.js @@ -10,7 +10,17 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefinition', 'SearchHelper', 'PaginateHelper', 'RefreshHelper', 'ListGenerator', 'StreamWidget']) - .factory('ShowStream', [ function() { + .factory('setStreamHeight', [ function() { + return function() { + // Try not to overlap footer. Because stream is positioned absolute, the parent + // doesn't resize correctly when stream is loaded. + var stream = $('#stream-container'); + var height = stream.height() + 50; + $('#tab-content-container').css({ "min-height": height }); + } + }]) + + .factory('ShowStream', [ 'setStreamHeight', function(setStreamHeight) { return function() { // Slide in the Stream widget @@ -24,10 +34,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti 'min-height': '100%', 'background-color': '#FFF' }); - - // Try not to overlap footer. Because stream is positioned absolute, the parent - // doesn't resize correctly when stream is loaded. - $('#tab-content-container').css({ 'min-height': stream.height() + 50 }); + + setStreamHeight(); // Slide in stream stream.show('slide', {'direction': 'left'}, {'duration': 500, 'queue': false }); @@ -172,7 +180,6 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti .success( function(data, status, headers, config) { // load up the form var results = data; - $('#form-modal').on('show.bs.modal', function (e) { $('#form-modal-body').css({ width:'auto', //probably not needed @@ -230,9 +237,9 @@ 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', + 'ShowDetail', 'StreamBreadCrumbs', 'setStreamHeight', function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList, - FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs) { + FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail, StreamBreadCrumbs, setStreamHeight) { return function(params) { var list = StreamList; @@ -240,13 +247,20 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti var view = GenerateList; var base = $location.path().replace(/^\//,'').split('/')[0]; - if (base !== 'home') { + 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[1])) { - defaultUrl += '?object1=' + type + '&object1_id=' + paths[i]; + 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=' + 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; @@ -284,10 +298,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti ShowDetail(id); } - if (scope.removePostRefresh) { - scope.removePostRefresh(); + if (scope.removeStreamPostRefresh) { + scope.removeStreamPostRefresh(); } - scope.removePostRefresh = scope.$on('PostRefresh', function() { + scope.removeStreamPostRefresh = scope.$on('PostRefresh', function() { for (var i=0; i < scope['activities'].length; i++) { // Convert event_time date to local time zone cDate = new Date(scope['activities'][i].timestamp); @@ -332,7 +346,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti // Description scope['activities'][i].description = BuildDescription(scope['activities'][i]); + } + // Give ng-repeate a chance to show the data before adjusting the page size. + setTimeout(function() { setStreamHeight(); }, 500); }); // Initialize search and paginate pieces and load data diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 6533381c7f..16af6984ed 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -1378,6 +1378,7 @@ tr td button i { #stream-container { display: none; border-radius: 8px; + z-index: 20; /* has to be greater than tree selector */ } #stream-content {