mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Merge pull request #6467 from mabashian/6458-inventory-activity-stream
Fixed various activity stream bugs
This commit is contained in:
commit
cecde6fe63
@ -51,6 +51,9 @@ export default function ModelToBasePathKey() {
|
||||
case 'workflow_job_template':
|
||||
basePathKey = 'workflow_job_templates';
|
||||
break;
|
||||
case 'host':
|
||||
basePathKey = 'hosts';
|
||||
break;
|
||||
}
|
||||
|
||||
return basePathKey;
|
||||
|
@ -8,12 +8,59 @@ export default
|
||||
|
||||
var streamConfig = {}, originalRoute;
|
||||
|
||||
function init() {
|
||||
let init = function() {
|
||||
|
||||
scope.showActivityStreamButton = false;
|
||||
scope.showRefreshButton = false;
|
||||
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(){
|
||||
BreadCrumbService.truncateCrumbs();
|
||||
}
|
||||
@ -24,7 +71,7 @@ export default
|
||||
|
||||
angular.element($window).on('resize', onResize);
|
||||
scope.$on('$destroy', cleanUp);
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
@ -34,103 +81,56 @@ export default
|
||||
|
||||
scope.toggleActivityStream = function() {
|
||||
|
||||
// If the user is not already on the activity stream then they want to navigate to it
|
||||
if(!scope.activityStreamActive) {
|
||||
var stateGoParams = {};
|
||||
// If the user is not already on the activity stream then they want to navigate to it
|
||||
if(!scope.activityStreamActive) {
|
||||
var stateGoParams = {};
|
||||
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
if(streamConfig.activityStreamTarget) {
|
||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||
let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget);
|
||||
stateGoParams.activity_search = {
|
||||
or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
order_by: '-timestamp',
|
||||
page_size: '20',
|
||||
};
|
||||
if (streamConfig.activityStreamTarget && streamConfig.activityStreamId) {
|
||||
stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params[streamConfig.activityStreamId];
|
||||
}
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
if(streamConfig.activityStreamTarget) {
|
||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||
let isTemplateTarget = _.contains(['template', 'job_template', 'workflow_job_template'], streamConfig.activityStreamTarget);
|
||||
stateGoParams.activity_search = {
|
||||
or__object1__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
or__object2__in: isTemplateTarget ? 'job_template,workflow_job_template' : streamConfig.activityStreamTarget,
|
||||
order_by: '-timestamp',
|
||||
page_size: '20',
|
||||
};
|
||||
if (streamConfig.activityStreamTarget && 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 {
|
||||
// If for some reason something went wrong (like local storage was wiped, etc) take the
|
||||
// user back to the dashboard
|
||||
$state.go('dashboard');
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
originalRoute = $state.current;
|
||||
$state.go('activityStream', stateGoParams);
|
||||
}
|
||||
// The user is navigating away from the activity stream - take them back from whence they came
|
||||
else {
|
||||
|
||||
scope.showActivityStreamButton = false;
|
||||
if(originalRoute) {
|
||||
$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: {
|
||||
label: N_('INVENTORIES')
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'inventory'
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
templateUrl: templateUrl('inventories/inventories')
|
||||
|
@ -110,6 +110,10 @@ angular.module('inventory', [
|
||||
},
|
||||
breadcrumbs: {
|
||||
edit: '{{breadcrumb.inventory_name}}'
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'inventory'
|
||||
}
|
||||
});
|
||||
|
||||
@ -146,6 +150,10 @@ angular.module('inventory', [
|
||||
},
|
||||
breadcrumbs: {
|
||||
edit: '{{breadcrumb.inventory_name}}'
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'inventory'
|
||||
}
|
||||
});
|
||||
|
||||
@ -285,6 +293,10 @@ angular.module('inventory', [
|
||||
urls: {
|
||||
list: '/hosts'
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'host'
|
||||
},
|
||||
resolve: {
|
||||
edit: {
|
||||
host: ['Rest', '$stateParams', 'GetBasePath',
|
||||
|
@ -34,10 +34,6 @@ angular.module('Organizations', [
|
||||
$stateProvider.state({
|
||||
name: 'organizations',
|
||||
url: '/organizations',
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'organization'
|
||||
},
|
||||
lazyLoad: () => stateDefinitions.generateTree({
|
||||
parent: 'organizations', // top-most node in the generated tree
|
||||
modes: ['add', 'edit'], // form nodes to generate
|
||||
@ -55,6 +51,10 @@ angular.module('Organizations', [
|
||||
parent: 'setup',
|
||||
label: N_('ORGANIZATIONS')
|
||||
},
|
||||
data: {
|
||||
activityStream: true,
|
||||
activityStreamTarget: 'organization'
|
||||
},
|
||||
// concat manually-defined state definitions with generated defintions
|
||||
}).then((generated) => {
|
||||
let linkoutDefinitions = _.map(OrganizationsLinkoutStates, (state) => stateExtender.buildDefinition(state));
|
||||
|
Loading…
Reference in New Issue
Block a user