update canAdd and move org admin scope var off of rootScope

This commit is contained in:
John Mitchell
2016-09-13 16:14:26 -04:00
parent 8cff8e4202
commit a7cbfdc242
17 changed files with 101 additions and 120 deletions

View File

@@ -841,11 +841,6 @@ var tower = angular.module('Tower', [
$rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser'); $rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser');
$rootScope.user_is_system_auditor = Authorization.getUserInfo('is_system_auditor'); $rootScope.user_is_system_auditor = Authorization.getUserInfo('is_system_auditor');
Rest.setUrl($rootScope.current_user.related.admin_of_organizations);
Rest.get()
.success(function(data) {
$rootScope.current_user_admin_orgs = data.results.map(i => i.name);
});
// state the user refreshes we want to open the socket, except if the user is on the login page, which should happen after the user logs in (see the AuthService module for that call to OpenSocket) // state the user refreshes we want to open the socket, except if the user is on the login page, which should happen after the user logs in (see the AuthService module for that call to OpenSocket)
if (!_.contains($location.$$url, '/login')) { if (!_.contains($location.$$url, '/login')) {
ConfigService.getConfig().then(function() { ConfigService.getConfig().then(function() {

View File

@@ -17,16 +17,6 @@ export function CredentialsList($scope, $rootScope, $location, $log,
SelectionInit, GetChoices, Wait, $state, $filter) { SelectionInit, GetChoices, Wait, $state, $filter) {
ClearScope(); ClearScope();
$scope.canAdd = false;
Rest.setUrl(GetBasePath('credentials'));
Rest.options()
.success(function(data) {
if (data.actions.POST) {
$scope.canAdd = true;
}
});
Wait('start'); Wait('start');
var list = CredentialList, var list = CredentialList,
@@ -148,16 +138,6 @@ export function CredentialsAdd($scope, $rootScope, $compile, $location, $log,
ReturnToCaller, ClearScope, GenerateList, SearchInit, PaginateInit, ReturnToCaller, ClearScope, GenerateList, SearchInit, PaginateInit,
LookUpInit, OrganizationList, GetBasePath, GetChoices, Empty, KindChange, LookUpInit, OrganizationList, GetBasePath, GetChoices, Empty, KindChange,
OwnerChange, FormSave, $state, CreateSelect2) { OwnerChange, FormSave, $state, CreateSelect2) {
Rest.setUrl(GetBasePath('credentials'));
Rest.options()
.success(function(data) {
if (!data.actions.POST) {
$state.go("^");
Alert('Permission Error', 'You do not have permission to add a credential.', 'alert-info');
}
});
ClearScope(); ClearScope();
// Inject dynamic view // Inject dynamic view

View File

@@ -15,17 +15,14 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
Rest, Alert, ProjectList, GenerateList, Prompt, SearchInit, Rest, Alert, ProjectList, GenerateList, Prompt, SearchInit,
PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath,
SelectionInit, ProjectUpdate, Refresh, Wait, GetChoices, Empty, SelectionInit, ProjectUpdate, Refresh, Wait, GetChoices, Empty,
Find, GetProjectIcon, GetProjectToolTip, $filter, $state) { Find, GetProjectIcon, GetProjectToolTip, $filter, $state, rbacUiControlService) {
ClearScope(); ClearScope();
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('projects')); rbacUiControlService.canAdd('projects')
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
Wait('start'); Wait('start');
@@ -378,7 +375,7 @@ ProjectsList.$inject = ['$scope', '$rootScope', '$location', '$log',
'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'GetBasePath', 'SelectionInit', 'ProjectUpdate', 'ProcessErrors', 'GetBasePath', 'SelectionInit', 'ProjectUpdate',
'Refresh', 'Wait', 'GetChoices', 'Empty', 'Find', 'Refresh', 'Wait', 'GetChoices', 'Empty', 'Find',
'GetProjectIcon', 'GetProjectToolTip', '$filter', '$state' 'GetProjectIcon', 'GetProjectToolTip', '$filter', '$state', 'rbacUiControlService'
]; ];

View File

@@ -14,17 +14,14 @@
export function TeamsList($scope, $rootScope, $location, $log, $stateParams, export function TeamsList($scope, $rootScope, $location, $log, $stateParams,
Rest, Alert, TeamList, GenerateList, Prompt, SearchInit, PaginateInit, Rest, Alert, TeamList, GenerateList, Prompt, SearchInit, PaginateInit,
ReturnToCaller, ClearScope, ProcessErrors, SetTeamListeners, GetBasePath, ReturnToCaller, ClearScope, ProcessErrors, SetTeamListeners, GetBasePath,
SelectionInit, Wait, $state, Refresh, $filter) { SelectionInit, Wait, $state, Refresh, $filter, rbacUiControlService) {
ClearScope(); ClearScope();
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('teams')); rbacUiControlService.canAdd('teams')
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
var list = TeamList, var list = TeamList,
@@ -135,7 +132,7 @@ TeamsList.$inject = ['$scope', '$rootScope', '$location', '$log',
'$stateParams', 'Rest', 'Alert', 'TeamList', 'generateList', 'Prompt', '$stateParams', 'Rest', 'Alert', 'TeamList', 'generateList', 'Prompt',
'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'SetTeamListeners', 'GetBasePath', 'SelectionInit', 'Wait', 'ProcessErrors', 'SetTeamListeners', 'GetBasePath', 'SelectionInit', 'Wait',
'$state', 'Refresh', '$filter' '$state', 'Refresh', '$filter', 'rbacUiControlService'
]; ];

View File

@@ -34,17 +34,14 @@ function user_type_sync($scope) {
export function UsersList($scope, $rootScope, $location, $log, $stateParams, export function UsersList($scope, $rootScope, $location, $log, $stateParams,
Rest, Alert, UserList, GenerateList, Prompt, SearchInit, PaginateInit, Rest, Alert, UserList, GenerateList, Prompt, SearchInit, PaginateInit,
ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit,
Wait, $state, Refresh, $filter) { Wait, $state, Refresh, $filter, rbacUiControlService) {
ClearScope(); ClearScope();
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('users')); rbacUiControlService.canAdd('users')
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
var list = UserList, var list = UserList,
@@ -145,7 +142,7 @@ UsersList.$inject = ['$scope', '$rootScope', '$location', '$log',
'$stateParams', 'Rest', 'Alert', 'UserList', 'generateList', 'Prompt', '$stateParams', 'Rest', 'Alert', 'UserList', 'generateList', 'Prompt',
'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'GetBasePath', 'SelectionInit', 'Wait', '$state', 'ProcessErrors', 'GetBasePath', 'SelectionInit', 'Wait', '$state',
'Refresh', '$filter' 'Refresh', '$filter', 'rbacUiControlService'
]; ];

View File

@@ -14,16 +14,13 @@ function InventoriesList($scope, $rootScope, $location, $log,
$stateParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList, $stateParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList,
generateList, Prompt, SearchInit, PaginateInit, ReturnToCaller, generateList, Prompt, SearchInit, PaginateInit, ReturnToCaller,
ClearScope, ProcessErrors, GetBasePath, Wait, ClearScope, ProcessErrors, GetBasePath, Wait,
Find, Empty, $state) { Find, Empty, $state, rbacUiControlService) {
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('inventory')); rbacUiControlService.canAdd('inventory')
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
var list = InventoryList, var list = InventoryList,
@@ -386,4 +383,4 @@ function InventoriesList($scope, $rootScope, $location, $log,
export default ['$scope', '$rootScope', '$location', '$log', export default ['$scope', '$rootScope', '$location', '$log',
'$stateParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList', '$stateParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList',
'generateList', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'generateList', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller',
'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state', InventoriesList]; 'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state', 'rbacUiControlService', InventoriesList];

View File

@@ -5,9 +5,9 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryGroups', 'generateList', 'InventoryUpdate', 'GroupManageService', 'GroupsCancelUpdate', 'ViewUpdateStatus', ['$scope', '$rootScope', '$state', '$stateParams', 'InventoryGroups', 'generateList', 'InventoryUpdate', 'GroupManageService', 'GroupsCancelUpdate', 'ViewUpdateStatus',
'InventoryManageService', 'groupsUrl', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'Rest', 'GetBasePath', 'InventoryManageService', 'groupsUrl', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'Rest', 'GetBasePath', 'rbacUiControlService',
function($scope, $rootScope, $state, $stateParams, InventoryGroups, generateList, InventoryUpdate, GroupManageService, GroupsCancelUpdate, ViewUpdateStatus, function($scope, $rootScope, $state, $stateParams, InventoryGroups, generateList, InventoryUpdate, GroupManageService, GroupsCancelUpdate, ViewUpdateStatus,
InventoryManageService, groupsUrl, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, Rest, GetBasePath){ InventoryManageService, groupsUrl, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, Rest, GetBasePath, rbacUiControlService){
var list = InventoryGroups, var list = InventoryGroups,
view = generateList, view = generateList,
pageSize = 20; pageSize = 20;
@@ -15,12 +15,9 @@
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('inventory') + $scope.inventory_id + "/groups"); rbacUiControlService.canAdd(GetBasePath('inventory') + $scope.inventory_id + "/groups")
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });

View File

@@ -5,24 +5,21 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$rootScope', '$state', '$stateParams', 'InventoryHosts', 'generateList', 'InventoryManageService', 'HostManageService', ['$scope', '$rootScope', '$state', '$stateParams', 'InventoryHosts', 'generateList', 'InventoryManageService', 'HostManageService',
'hostsUrl', 'SearchInit', 'PaginateInit', 'SetStatus', 'Prompt', 'Wait', 'inventoryData', '$filter', 'Rest', 'GetBasePath', 'hostsUrl', 'SearchInit', 'PaginateInit', 'SetStatus', 'Prompt', 'Wait', 'inventoryData', '$filter', 'Rest', 'GetBasePath', 'rbacUiControlService',
function($scope, $rootScope, $state, $stateParams, InventoryHosts, generateList, InventoryManageService, HostManageService, function($scope, $rootScope, $state, $stateParams, InventoryHosts, generateList, InventoryManageService, HostManageService,
hostsUrl, SearchInit, PaginateInit, SetStatus, Prompt, Wait, inventoryData, $filter, Rest, GetBasePath){ hostsUrl, SearchInit, PaginateInit, SetStatus, Prompt, Wait, inventoryData, $filter, Rest, GetBasePath, rbacUiControlService){
var list = InventoryHosts, var list = InventoryHosts,
view = generateList, view = generateList,
pageSize = 20; pageSize = 20;
$scope.canAdd = false;
$scope.inventory_id = $stateParams.inventory_id; $scope.inventory_id = $stateParams.inventory_id;
Rest.setUrl(GetBasePath('inventory') + $scope.inventory_id + "/hosts"); $scope.canAdd = false;
Rest.options()
.success(function(data) { rbacUiControlService.canAdd(GetBasePath('inventory') + $scope.inventory_id + "/hosts")
if (data.actions.POST) { .then(function(canAdd) {
$scope.canAdd = true; $scope.canAdd = canAdd;
}
}); });
// The ncy breadcrumb directive will look at this attribute when attempting to bind to the correct scope. // The ncy breadcrumb directive will look at this attribute when attempting to bind to the correct scope.

View File

@@ -7,11 +7,11 @@
export default export default
[ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject', [ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject',
'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' , 'ProcessErrors', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' , 'ProcessErrors',
'Prompt', '$state', '$filter', 'Prompt', '$state', '$filter', 'rbacUiControlService',
function( function(
$rootScope,Wait, GenerateList, inventoryScriptsListObject, $rootScope,Wait, GenerateList, inventoryScriptsListObject,
GetBasePath, SearchInit, PaginateInit, GetBasePath, SearchInit, PaginateInit,
Rest, ProcessErrors, Prompt, $state, $filter Rest, ProcessErrors, Prompt, $state, $filter, rbacUiControlService
) { ) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
defaultUrl = GetBasePath('inventory_scripts'), defaultUrl = GetBasePath('inventory_scripts'),
@@ -20,12 +20,9 @@ export default
scope.canAdd = false; scope.canAdd = false;
Rest.setUrl(GetBasePath('inventory_scripts')); rbacUiControlService.canAdd("inventory_scripts")
Rest.options() .then(function(canAdd) {
.success(function(data) { scope.canAdd = canAdd;
if (data.actions.POST) {
scope.canAdd = true;
}
}); });
view.inject( list, { view.inject( list, {

View File

@@ -10,25 +10,22 @@ export default
'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'GetBasePath', 'JobTemplateForm', 'CredentialList', 'ProcessErrors', 'GetBasePath', 'JobTemplateForm', 'CredentialList',
'LookUpInit', 'InitiatePlaybookRun', 'Wait', '$compile', 'LookUpInit', 'InitiatePlaybookRun', 'Wait', '$compile',
'$state', '$filter', '$state', '$filter', 'rbacUiControlService',
function( function(
$scope, $rootScope, $location, $log, $scope, $rootScope, $location, $log,
$stateParams, Rest, Alert, JobTemplateList, GenerateList, Prompt, $stateParams, Rest, Alert, JobTemplateList, GenerateList, Prompt,
SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors,
GetBasePath, JobTemplateForm, CredentialList, LookUpInit, InitiatePlaybookRun, GetBasePath, JobTemplateForm, CredentialList, LookUpInit, InitiatePlaybookRun,
Wait, $compile, $state, $filter Wait, $compile, $state, $filter, rbacUiControlService
) { ) {
ClearScope(); ClearScope();
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('job_templates')); rbacUiControlService.canAdd("job_templates")
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
var list = JobTemplateList, var list = JobTemplateList,

View File

@@ -58,8 +58,7 @@ export default
ngClick: 'addCredential()', ngClick: 'addCredential()',
awToolTip: 'Create a new credential', awToolTip: 'Create a new credential',
actionClass: 'btn List-buttonSubmit', actionClass: 'btn List-buttonSubmit',
buttonContent: '+ ADD', buttonContent: '+ ADD'
ngShow: 'canAdd'
} }
}, },

View File

@@ -8,12 +8,12 @@ export default
[ '$rootScope','Wait', 'generateList', 'NotificationTemplatesList', [ '$rootScope','Wait', 'generateList', 'NotificationTemplatesList',
'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' , 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' ,
'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find', 'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find',
'ngToast', '$compile', '$filter', 'ngToast', '$compile', '$filter', 'rbacUiControlService',
function( function(
$rootScope,Wait, GenerateList, NotificationTemplatesList, $rootScope,Wait, GenerateList, NotificationTemplatesList,
GetBasePath, SearchInit, PaginateInit, Rest, GetBasePath, SearchInit, PaginateInit, Rest,
ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast, ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast,
$compile, $filter) { $compile, $filter, rbacUiControlService) {
var scope = $rootScope.$new(), var scope = $rootScope.$new(),
defaultUrl = GetBasePath('notification_templates'), defaultUrl = GetBasePath('notification_templates'),
list = NotificationTemplatesList, list = NotificationTemplatesList,
@@ -26,12 +26,9 @@ export default
scope.canAdd = false; scope.canAdd = false;
Rest.setUrl(GetBasePath('notification_templates')); rbacUiControlService.canAdd("notification_templates")
Rest.options() .then(function(canAdd) {
.success(function(data) { scope.canAdd = canAdd;
if (data.actions.POST) {
scope.canAdd = true;
}
}); });
scope.removePostRefresh = scope.$on('PostRefresh', function () { scope.removePostRefresh = scope.$on('PostRefresh', function () {

View File

@@ -15,13 +15,21 @@
*/ */
export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices',
'$state', '$state', '$rootScope',
function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices, $state) { function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices, $state, $rootScope) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
url = params.url, url = params.url,
id = params.id; id = params.id;
scope.current_user_admin_orgs = [];
Rest.setUrl($rootScope.current_user.related.admin_of_organizations);
Rest.get()
.success(function(data) {
scope.current_user_admin_orgs = data.results.map(i => i.name);
});
scope.addNotificationTemplate = function(){ scope.addNotificationTemplate = function(){
$state.go('notifications.add'); $state.go('notifications.add');
}; };

View File

@@ -8,23 +8,20 @@ export default ['$stateParams', '$scope', '$rootScope', '$location',
'$log', '$compile', 'Rest', 'PaginateInit', '$log', '$compile', 'Rest', 'PaginateInit',
'SearchInit', 'OrganizationList', 'Alert', 'Prompt', 'ClearScope', 'SearchInit', 'OrganizationList', 'Alert', 'Prompt', 'ClearScope',
'ProcessErrors', 'GetBasePath', 'Wait', 'ProcessErrors', 'GetBasePath', 'Wait',
'$state', 'generateList', 'Refresh', '$filter', '$state', 'generateList', 'Refresh', '$filter', 'rbacUiControlService',
function($stateParams, $scope, $rootScope, $location, function($stateParams, $scope, $rootScope, $location,
$log, $compile, Rest, PaginateInit, $log, $compile, Rest, PaginateInit,
SearchInit, OrganizationList, Alert, Prompt, ClearScope, SearchInit, OrganizationList, Alert, Prompt, ClearScope,
ProcessErrors, GetBasePath, Wait, ProcessErrors, GetBasePath, Wait,
$state, generateList, Refresh, $filter) { $state, generateList, Refresh, $filter, rbacUiControlService) {
ClearScope(); ClearScope();
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(GetBasePath('organizations')); rbacUiControlService.canAdd("organizations")
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
var defaultUrl = GetBasePath('organizations'), var defaultUrl = GetBasePath('organizations'),

View File

@@ -14,11 +14,11 @@
export default [ export default [
'$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest', '$scope', '$compile', '$location', '$stateParams', 'SchedulesList', 'Rest',
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait', 'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'Wait',
'Find', 'LoadSchedulesScope', 'GetChoices', '$q', '$state', 'Find', 'LoadSchedulesScope', 'GetChoices', '$q', '$state', 'rbacUiControlService',
function ($scope, $compile, $location, $stateParams, function ($scope, $compile, $location, $stateParams,
SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope, SchedulesList, Rest, ProcessErrors, ReturnToCaller, ClearScope,
GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices, GetBasePath, Wait, Find, LoadSchedulesScope, GetChoices,
$q, $state) { $q, $state, rbacUiControlService) {
var schedList = _.cloneDeep(SchedulesList); var schedList = _.cloneDeep(SchedulesList);
ClearScope(); ClearScope();
@@ -51,12 +51,9 @@ export default [
$scope.canAdd = false; $scope.canAdd = false;
Rest.setUrl(url); rbacUiControlService.canAdd(url)
Rest.options() .then(function(canAdd) {
.success(function(data) { $scope.canAdd = canAdd;
if (data.actions.POST) {
$scope.canAdd = true;
}
}); });
schedList.well = true; schedList.well = true;

View File

@@ -11,12 +11,14 @@ import lodashAsPromised from './lodash-as-promised';
import stringFilters from './string-filters/main'; import stringFilters from './string-filters/main';
import truncatedText from './truncated-text.directive'; import truncatedText from './truncated-text.directive';
import stateExtender from './stateExtender.provider'; import stateExtender from './stateExtender.provider';
import rbacUiControl from './rbacUiControl';
export default export default
angular.module('shared', [listGenerator.name, angular.module('shared', [listGenerator.name,
pagination.name, pagination.name,
stringFilters.name, stringFilters.name,
'ui.router' 'ui.router',
rbacUiControl.name
]) ])
.factory('lodashAsPromised', lodashAsPromised) .factory('lodashAsPromised', lodashAsPromised)
.directive('truncatedText', truncatedText) .directive('truncatedText', truncatedText)

View File

@@ -0,0 +1,30 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default
angular.module('rbacUiControl', [])
.service('rbacUiControlService', ['$q', 'GetBasePath', 'Rest', function($q, GetBasePath, Rest){
this.canAdd = function(apiPath) {
var canAddVal = $q.defer();
if (apiPath.indexOf("api/v1") > -1) {
Rest.setUrl(apiPath);
} else {
Rest.setUrl(GetBasePath(apiPath));
}
Rest.options()
.success(function(data) {
if (data.actions.POST) {
canAddVal.resolve(true);
} else {
canAddVal.reject(false);
}
});
return canAddVal.promise;
};
}]);