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
3 changed files with 22 additions and 60 deletions

View File

@@ -18,10 +18,10 @@ export default {
subTitle: subTitle:
[ '$stateParams', [ '$stateParams',
'Rest', 'Rest',
'ModelToPlural', 'ModelToBasePathKey',
'GetBasePath', 'GetBasePath',
'ProcessErrors', '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 // 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 // that we're examining with the activity stream. This name will be used in the
// subtitle. // subtitle.
@@ -29,7 +29,7 @@ export default {
var target = $stateParams.target; var target = $stateParams.target;
var id = $stateParams.id; var id = $stateParams.id;
var url = getBasePath(ModelToPlural(target)) + id + '/'; var url = getBasePath(ModelToBasePathKey(target)) + id + '/';
rest.setUrl(url); rest.setUrl(url);
return rest.get() return rest.get()
.then(function(data) { .then(function(data) {

View File

@@ -557,6 +557,11 @@ var tower = angular.module('Tower', [
url: '/inventories/:inventory_id/manage?groups', url: '/inventories/:inventory_id/manage?groups',
templateUrl: urlPrefix + 'partials/inventory-manage.html', templateUrl: urlPrefix + 'partials/inventory-manage.html',
controller: InventoriesManage, controller: InventoriesManage,
data: {
activityStream: true,
activityStreamTarget: 'inventory',
activityStreamId: 'inventory_id'
},
resolve: { resolve: {
features: ['FeaturesService', function(FeaturesService) { features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get(); return FeaturesService.get();

View File

@@ -12,88 +12,45 @@
export default export default
angular.module('ApiModelHelper', ['Utilities']) angular.module('ApiModelHelper', ['Utilities'])
.factory('ModelToSingular', [ .factory('ModelToBasePathKey', [
function () { function () {
return function (model) { return function (model) {
// This function takes in the plural model string and spits out the singular // This function takes in the singular model string and returns the key needed
// version. // to get the base path from $rootScope/local storage.
var singularModel; var basePathKey;
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;
switch(model) { switch(model) {
case 'project': case 'project':
pluralModel = 'projects'; basePathKey = 'projects';
break; break;
case 'inventory': case 'inventory':
pluralModel = 'inventories'; basePathKey = 'inventory';
break; break;
case 'job_template': case 'job_template':
pluralModel = 'job_templates'; basePathKey = 'job_templates';
break; break;
case 'credential': case 'credential':
pluralModel = 'credentials'; basePathKey = 'credentials';
break; break;
case 'user': case 'user':
pluralModel = 'users'; basePathKey = 'users';
break; break;
case 'team': case 'team':
pluralModel = 'teams'; basePathKey = 'teams';
break; break;
case 'organization': case 'organization':
pluralModel = 'organizations'; basePathKey = 'organizations';
break; break;
case 'management_job': case 'management_job':
pluralModel = 'management_jobs'; basePathKey = 'management_jobs';
break; break;
case 'inventory_script': case 'inventory_script':
pluralModel = 'inventory_scripts'; basePathKey = 'inventory_scripts';
break; break;
} }
return pluralModel; return basePathKey;
}; };
} }