mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 05:55:59 -03:30
Merge pull request #6467 from mabashian/6458-inventory-activity-stream
Fixed various activity stream bugs
This commit is contained in:
@@ -51,6 +51,9 @@ export default function ModelToBasePathKey() {
|
|||||||
case 'workflow_job_template':
|
case 'workflow_job_template':
|
||||||
basePathKey = 'workflow_job_templates';
|
basePathKey = 'workflow_job_templates';
|
||||||
break;
|
break;
|
||||||
|
case 'host':
|
||||||
|
basePathKey = 'hosts';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return basePathKey;
|
return basePathKey;
|
||||||
|
|||||||
@@ -8,12 +8,59 @@ export default
|
|||||||
|
|
||||||
var streamConfig = {}, originalRoute;
|
var streamConfig = {}, originalRoute;
|
||||||
|
|
||||||
function init() {
|
let init = function() {
|
||||||
|
|
||||||
scope.showActivityStreamButton = false;
|
scope.showActivityStreamButton = false;
|
||||||
scope.showRefreshButton = false;
|
scope.showRefreshButton = false;
|
||||||
scope.loadingLicense = true;
|
scope.loadingLicense = true;
|
||||||
|
|
||||||
|
scope.$on("$stateChangeSuccess", function updateActivityStreamButton(event, toState, toParams, fromState, fromParams) {
|
||||||
|
if(fromState && !Empty(fromState.name)) {
|
||||||
|
// Go ahead and attach the from params to the state object so that it can all be stored together
|
||||||
|
fromState.fromParams = fromParams ? fromParams : {};
|
||||||
|
|
||||||
|
// Store the state that we're coming from in local storage to be accessed when navigating away from the
|
||||||
|
// activity stream
|
||||||
|
//Store('previous_state', fromState);
|
||||||
|
}
|
||||||
|
|
||||||
|
streamConfig = (toState && toState.data) ? toState.data : {};
|
||||||
|
|
||||||
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
|
|
||||||
|
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
||||||
|
// after the resolve on the state declaration so features should be available at this
|
||||||
|
// point. We use the get() function call here just in case the features aren't available.
|
||||||
|
// The get() function will only fire off the server call if the features aren't already
|
||||||
|
// attached to the $rootScope.
|
||||||
|
var features = FeaturesService.get();
|
||||||
|
if(features){
|
||||||
|
scope.loadingLicense = false;
|
||||||
|
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
||||||
|
scope.activityStreamTooltip = (toState.name === 'activityStream') ? i18n._('Hide Activity Stream') : i18n._('View Activity Stream');
|
||||||
|
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name ==='activityStream') ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
scope.showActivityStreamButton = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.showRefreshButton = (streamConfig && streamConfig.refreshButton) ? true : false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// scope.$on('featuresLoaded', function(){
|
||||||
|
$rootScope.featuresConfigured.promise.then(function(features){
|
||||||
|
// var features = FeaturesService.get();
|
||||||
|
if(features){
|
||||||
|
scope.loadingLicense = false;
|
||||||
|
scope.activityStreamActive = ($state.current.name === 'activityStream') ? true : false;
|
||||||
|
scope.activityStreamTooltip = ($state.current.name === 'activityStream') ? 'Hide Activity Stream' : 'View Activity Stream';
|
||||||
|
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.current.name ==='activityStream') ? true : false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function onResize(){
|
function onResize(){
|
||||||
BreadCrumbService.truncateCrumbs();
|
BreadCrumbService.truncateCrumbs();
|
||||||
}
|
}
|
||||||
@@ -24,7 +71,7 @@ export default
|
|||||||
|
|
||||||
angular.element($window).on('resize', onResize);
|
angular.element($window).on('resize', onResize);
|
||||||
scope.$on('$destroy', cleanUp);
|
scope.$on('$destroy', cleanUp);
|
||||||
}
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -34,103 +81,56 @@ export default
|
|||||||
|
|
||||||
scope.toggleActivityStream = function() {
|
scope.toggleActivityStream = function() {
|
||||||
|
|
||||||
// If the user is not already on the activity stream then they want to navigate to it
|
// If the user is not already on the activity stream then they want to navigate to it
|
||||||
if(!scope.activityStreamActive) {
|
if(!scope.activityStreamActive) {
|
||||||
var stateGoParams = {};
|
var stateGoParams = {};
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
if(streamConfig.activityStreamTarget) {
|
if(streamConfig.activityStreamTarget) {
|
||||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||||
let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget);
|
let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget);
|
||||||
stateGoParams.activity_search = {
|
stateGoParams.activity_search = {
|
||||||
or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||||
or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||||
order_by: '-timestamp',
|
order_by: '-timestamp',
|
||||||
page_size: '20',
|
page_size: '20',
|
||||||
};
|
};
|
||||||
if (streamConfig.activityStreamTarget && streamConfig.activityStreamId) {
|
if (streamConfig.activityStreamTarget && streamConfig.activityStreamId) {
|
||||||
stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params[streamConfig.activityStreamId];
|
stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params[streamConfig.activityStreamId];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
stateGoParams.activity_search = {
|
|
||||||
order_by: '-timestamp',
|
|
||||||
page_size: '20',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if(streamConfig.activityStreamId) {
|
|
||||||
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
|
||||||
}
|
|
||||||
if(stateGoParams.target === "custom_inventory_script"){
|
|
||||||
stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params.inventory_script_id;
|
|
||||||
stateGoParams.id = $state.params.inventory_script_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
originalRoute = $state.current;
|
|
||||||
$state.go('activityStream', stateGoParams);
|
|
||||||
}
|
|
||||||
// The user is navigating away from the activity stream - take them back from whence they came
|
|
||||||
else {
|
|
||||||
if(originalRoute) {
|
|
||||||
$state.go(originalRoute.name, originalRoute.fromParams);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If for some reason something went wrong (like local storage was wiped, etc) take the
|
stateGoParams.activity_search = {
|
||||||
// user back to the dashboard
|
order_by: '-timestamp',
|
||||||
$state.go('dashboard');
|
page_size: '20',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if(streamConfig.activityStreamId) {
|
||||||
|
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
||||||
|
}
|
||||||
|
if(stateGoParams.target === "custom_inventory_script"){
|
||||||
|
stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params.inventory_script_id;
|
||||||
|
stateGoParams.id = $state.params.inventory_script_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
originalRoute = $state.current;
|
||||||
};
|
$state.go('activityStream', stateGoParams);
|
||||||
|
|
||||||
scope.$on("$stateChangeStart", function updateActivityStreamButton(event, toState, toParams, fromState, fromParams) {
|
|
||||||
if(fromState && !Empty(fromState.name)) {
|
|
||||||
// Go ahead and attach the from params to the state object so that it can all be stored together
|
|
||||||
fromState.fromParams = fromParams ? fromParams : {};
|
|
||||||
|
|
||||||
// Store the state that we're coming from in local storage to be accessed when navigating away from the
|
|
||||||
// activity stream
|
|
||||||
//Store('previous_state', fromState);
|
|
||||||
}
|
|
||||||
|
|
||||||
streamConfig = (toState && toState.data) ? toState.data : {};
|
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
|
||||||
|
|
||||||
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
|
||||||
// after the resolve on the state declaration so features should be available at this
|
|
||||||
// point. We use the get() function call here just in case the features aren't available.
|
|
||||||
// The get() function will only fire off the server call if the features aren't already
|
|
||||||
// attached to the $rootScope.
|
|
||||||
var features = FeaturesService.get();
|
|
||||||
if(features){
|
|
||||||
scope.loadingLicense = false;
|
|
||||||
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
|
||||||
scope.activityStreamTooltip = (toState.name === 'activityStream') ? i18n._('Hide Activity Stream') : i18n._('View Activity Stream');
|
|
||||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name ==='activityStream') ? true : false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// The user is navigating away from the activity stream - take them back from whence they came
|
||||||
else {
|
else {
|
||||||
|
if(originalRoute) {
|
||||||
scope.showActivityStreamButton = false;
|
$state.go(originalRoute.name, originalRoute.fromParams);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If for some reason something went wrong (like local storage was wiped, etc) take the
|
||||||
|
// user back to the dashboard
|
||||||
|
$state.go('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.showRefreshButton = (streamConfig && streamConfig.refreshButton) ? true : false;
|
};
|
||||||
});
|
|
||||||
|
|
||||||
// scope.$on('featuresLoaded', function(){
|
|
||||||
$rootScope.featuresConfigured.promise.then(function(features){
|
|
||||||
// var features = FeaturesService.get();
|
|
||||||
if(features){
|
|
||||||
scope.loadingLicense = false;
|
|
||||||
scope.activityStreamActive = ($state.current.name === 'activityStream') ? true : false;
|
|
||||||
scope.activityStreamTooltip = ($state.current.name === 'activityStream') ? 'Hide Activity Stream' : 'View Activity Stream';
|
|
||||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.current.name ==='activityStream') ? true : false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ export default {
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: N_('INVENTORIES')
|
label: N_('INVENTORIES')
|
||||||
},
|
},
|
||||||
|
data: {
|
||||||
|
activityStream: true,
|
||||||
|
activityStreamTarget: 'inventory'
|
||||||
|
},
|
||||||
views: {
|
views: {
|
||||||
'@': {
|
'@': {
|
||||||
templateUrl: templateUrl('inventories/inventories')
|
templateUrl: templateUrl('inventories/inventories')
|
||||||
|
|||||||
@@ -110,6 +110,10 @@ angular.module('inventory', [
|
|||||||
},
|
},
|
||||||
breadcrumbs: {
|
breadcrumbs: {
|
||||||
edit: '{{breadcrumb.inventory_name}}'
|
edit: '{{breadcrumb.inventory_name}}'
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
activityStream: true,
|
||||||
|
activityStreamTarget: 'inventory'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -146,6 +150,10 @@ angular.module('inventory', [
|
|||||||
},
|
},
|
||||||
breadcrumbs: {
|
breadcrumbs: {
|
||||||
edit: '{{breadcrumb.inventory_name}}'
|
edit: '{{breadcrumb.inventory_name}}'
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
activityStream: true,
|
||||||
|
activityStreamTarget: 'inventory'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -285,6 +293,10 @@ angular.module('inventory', [
|
|||||||
urls: {
|
urls: {
|
||||||
list: '/hosts'
|
list: '/hosts'
|
||||||
},
|
},
|
||||||
|
data: {
|
||||||
|
activityStream: true,
|
||||||
|
activityStreamTarget: 'host'
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
edit: {
|
edit: {
|
||||||
host: ['Rest', '$stateParams', 'GetBasePath',
|
host: ['Rest', '$stateParams', 'GetBasePath',
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ angular.module('Organizations', [
|
|||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'organizations',
|
name: 'organizations',
|
||||||
url: '/organizations',
|
url: '/organizations',
|
||||||
data: {
|
|
||||||
activityStream: true,
|
|
||||||
activityStreamTarget: 'organization'
|
|
||||||
},
|
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'organizations', // top-most node in the generated tree
|
parent: 'organizations', // top-most node in the generated tree
|
||||||
modes: ['add', 'edit'], // form nodes to generate
|
modes: ['add', 'edit'], // form nodes to generate
|
||||||
@@ -55,6 +51,10 @@ angular.module('Organizations', [
|
|||||||
parent: 'setup',
|
parent: 'setup',
|
||||||
label: N_('ORGANIZATIONS')
|
label: N_('ORGANIZATIONS')
|
||||||
},
|
},
|
||||||
|
data: {
|
||||||
|
activityStream: true,
|
||||||
|
activityStreamTarget: 'organization'
|
||||||
|
},
|
||||||
// concat manually-defined state definitions with generated defintions
|
// concat manually-defined state definitions with generated defintions
|
||||||
}).then((generated) => {
|
}).then((generated) => {
|
||||||
let linkoutDefinitions = _.map(OrganizationsLinkoutStates, (state) => stateExtender.buildDefinition(state));
|
let linkoutDefinitions = _.map(OrganizationsLinkoutStates, (state) => stateExtender.buildDefinition(state));
|
||||||
|
|||||||
Reference in New Issue
Block a user