From 2079ddc36a20991675eacad2609d5d9e7801c56a Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Thu, 11 Feb 2016 15:54:17 -0500 Subject: [PATCH] Turned on the activity stream for inventory manage. Refactored the ModalToPlural function so that it returns the key that the getBasePath() function expects for that model. --- .../activity-stream/activitystream.route.js | 6 +- awx/ui/client/src/app.js | 5 ++ awx/ui/client/src/helpers/ApiModel.js | 71 ++++--------------- 3 files changed, 22 insertions(+), 60 deletions(-) diff --git a/awx/ui/client/src/activity-stream/activitystream.route.js b/awx/ui/client/src/activity-stream/activitystream.route.js index 74151e32df..8ba1357c6a 100644 --- a/awx/ui/client/src/activity-stream/activitystream.route.js +++ b/awx/ui/client/src/activity-stream/activitystream.route.js @@ -18,10 +18,10 @@ export default { subTitle: [ '$stateParams', 'Rest', - 'ModelToPlural', + 'ModelToBasePathKey', 'GetBasePath', 'ProcessErrors', - function($stateParams, rest, ModelToPlural, getBasePath, ProcessErrors) { + function($stateParams, rest, ModelToBasePathKey, getBasePath, ProcessErrors) { // If we have a target and an ID then we want to go grab the name of the object // that we're examining with the activity stream. This name will be used in the // subtitle. @@ -29,7 +29,7 @@ export default { var target = $stateParams.target; var id = $stateParams.id; - var url = getBasePath(ModelToPlural(target)) + id + '/'; + var url = getBasePath(ModelToBasePathKey(target)) + id + '/'; rest.setUrl(url); return rest.get() .then(function(data) { diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 7584d6b1a9..c0b72d9dcf 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -557,6 +557,11 @@ var tower = angular.module('Tower', [ url: '/inventories/:inventory_id/manage?groups', templateUrl: urlPrefix + 'partials/inventory-manage.html', controller: InventoriesManage, + data: { + activityStream: true, + activityStreamTarget: 'inventory', + activityStreamId: 'inventory_id' + }, resolve: { features: ['FeaturesService', function(FeaturesService) { return FeaturesService.get(); diff --git a/awx/ui/client/src/helpers/ApiModel.js b/awx/ui/client/src/helpers/ApiModel.js index 6a63d24583..ff1923ce0a 100644 --- a/awx/ui/client/src/helpers/ApiModel.js +++ b/awx/ui/client/src/helpers/ApiModel.js @@ -12,88 +12,45 @@ export default angular.module('ApiModelHelper', ['Utilities']) - .factory('ModelToSingular', [ + .factory('ModelToBasePathKey', [ function () { return function (model) { - // This function takes in the plural model string and spits out the singular - // version. + // This function takes in the singular model string and returns the key needed + // to get the base path from $rootScope/local storage. - var singularModel; - - switch(model) { - case 'projects': - singularModel = 'project'; - break; - case 'inventories': - singularModel = 'inventory'; - break; - case 'job_templates': - singularModel = 'job_template'; - break; - case 'credentials': - singularModel = 'credential'; - break; - case 'users': - singularModel = 'user'; - break; - case 'teams': - singularModel = 'team'; - break; - case 'organizations': - singularModel = 'organization'; - break; - case 'management_jobs': - singularModel = 'management_job'; - break; - case 'inventory_scripts': - singularModel = 'inventory_script'; - break; - } - - return singularModel; - - }; - } - ]) - .factory('ModelToPlural', [ - function () { - return function (model) { - // This function takes in the singular model string and spits out the plural - // version. - - var pluralModel; + var basePathKey; switch(model) { case 'project': - pluralModel = 'projects'; + basePathKey = 'projects'; break; case 'inventory': - pluralModel = 'inventories'; + basePathKey = 'inventory'; break; case 'job_template': - pluralModel = 'job_templates'; + basePathKey = 'job_templates'; break; case 'credential': - pluralModel = 'credentials'; + basePathKey = 'credentials'; break; case 'user': - pluralModel = 'users'; + basePathKey = 'users'; break; case 'team': - pluralModel = 'teams'; + basePathKey = 'teams'; break; case 'organization': - pluralModel = 'organizations'; + basePathKey = 'organizations'; break; case 'management_job': - pluralModel = 'management_jobs'; + basePathKey = 'management_jobs'; break; case 'inventory_script': - pluralModel = 'inventory_scripts'; + basePathKey = 'inventory_scripts'; break; } - return pluralModel; + return basePathKey; }; }