Merge pull request #921 from mabashian/add-stream-inv-manage

Turned on the activity stream for inventory manage
This commit is contained in:
Michael Abashian 2016-02-12 09:15:10 -05:00
commit 1bcc3b9269
3 changed files with 22 additions and 60 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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;
};
}