From a450dbb42a71d767b4772eb6dd9f498849f321ff Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Tue, 9 Feb 2016 15:49:03 -0500 Subject: [PATCH] Added activity stream navigation dropdown --- awx/ui/client/legacy-styles/lists.less | 6 +++ awx/ui/client/src/activity-stream/main.js | 3 ++ .../stream-dropdown-nav.directive.js | 46 +++++++++++++++++++ awx/ui/client/src/lists/Streams.js | 1 + .../list-generator/list-generator.factory.js | 5 ++ 5 files changed, 61 insertions(+) create mode 100644 awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js diff --git a/awx/ui/client/legacy-styles/lists.less b/awx/ui/client/legacy-styles/lists.less index 0dd92dbdff..38d1945e9b 100644 --- a/awx/ui/client/legacy-styles/lists.less +++ b/awx/ui/client/legacy-styles/lists.less @@ -173,6 +173,12 @@ table, tbody { justify-content: flex-end; display: flex; margin-top: -10px; + margin-left: 10px; +} + +.List-auxAction { + justify-content: flex-end; + display: flex; } .List-buttonSubmit { diff --git a/awx/ui/client/src/activity-stream/main.js b/awx/ui/client/src/activity-stream/main.js index 80e0ed1e53..381c421c87 100644 --- a/awx/ui/client/src/activity-stream/main.js +++ b/awx/ui/client/src/activity-stream/main.js @@ -7,10 +7,13 @@ import activityStreamRoute from './activitystream.route'; import activityStreamController from './activitystream.controller'; +import streamDropdownNav from './streamDropdownNav/stream-dropdown-nav.directive'; + import streamDetailModal from './streamDetailModal/main'; export default angular.module('activityStream', [streamDetailModal.name]) .controller('activityStreamController', activityStreamController) + .directive('streamDropdownNav', streamDropdownNav) .run(['$stateExtender', function($stateExtender) { $stateExtender.addState(activityStreamRoute); }]); diff --git a/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js b/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js new file mode 100644 index 0000000000..1652ab6e64 --- /dev/null +++ b/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js @@ -0,0 +1,46 @@ +/************************************************* + * Copyright (c) 2016 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +export default [function() { + return { + restrict: 'E', + scope: true, + replace: true, + template: '', + controller: ['$scope', '$state', function($scope, $state) { + + $scope.streamTarget = ($state.params && $state.params.target) ? $state.params.target : 'dashboard'; + + $scope.options = [ + {label: 'Credentials', value: 'credential'}, + {label: 'Dashboard', value: 'dashboard'}, + {label: 'Hosts', value: 'host'}, + {label: 'Inventories', value: 'inventory'}, + {label: 'Inventory Scripts', value: 'inventory_script'}, + {label: 'Job Templates', value: 'job_template'}, + {label: 'Management Jobs', value: 'management_job'}, + {label: 'Organizations', value: 'organization'}, + {label: 'Projects', value: 'project'}, + {label: 'Schedules', value: 'schedule'}, + {label: 'Teams', value: 'team'}, + {label: 'Users', value: 'user'} + ]; + + $scope.changeStreamTarget = function(){ + + if($scope.streamTarget && $scope.streamTarget == 'dashboard') { + // Just navigate to the base activity stream + $state.go('activityStream', {}, {inherit: false, reload: true}); + } + else { + // Attach the taget to the query parameters + $state.go('activityStream', {target: $scope.streamTarget}); + } + + } + }], + }; +}]; diff --git a/awx/ui/client/src/lists/Streams.js b/awx/ui/client/src/lists/Streams.js index 1cc99c4d7c..b3dc97af84 100644 --- a/awx/ui/client/src/lists/Streams.js +++ b/awx/ui/client/src/lists/Streams.js @@ -19,6 +19,7 @@ export default hover: true, "class": "table-condensed", searchWidgets: 3, + toolbarAuxAction: "", fields: { timestamp: { diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js index aed7d93652..54b40b74c3 100644 --- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js +++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js @@ -315,6 +315,11 @@ export default ['$location', '$compile', '$rootScope', 'SearchWidget', 'Paginate } html += ""; + if(list.toolbarAuxAction) { + html += "
"; + html += list.toolbarAuxAction; + html += "
"; + } html += "
"; html += "