mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Only allow user with super_user access to see activity stream button. Fixed collision between is_superuser rootscope variable and credential.is_superuser on credential detail page. Added AS to user/n/permissions page.
This commit is contained in:
parent
e2e8a7e346
commit
94bbab566b
@ -301,7 +301,7 @@ angular.module('ansible', [
|
||||
}
|
||||
CheckLicense();
|
||||
}
|
||||
|
||||
|
||||
// Make the correct tab active
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
if (base == '') {
|
||||
@ -319,6 +319,10 @@ angular.module('ansible', [
|
||||
$cookieStore.put('sessionExpired', false);
|
||||
$location.path('/login');
|
||||
}
|
||||
else {
|
||||
// If browser refresh, set the user_is_superuser value
|
||||
$rootScope['user_is_superuser'] = Authorization.getUserInfo('is_superuser');
|
||||
}
|
||||
|
||||
// If browser refresh, activate the correct tab
|
||||
var base = ($location.path().replace(/^\//,'').split('/')[0]);
|
||||
|
||||
@ -96,6 +96,7 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
||||
Authorization.getUser()
|
||||
.success(function(data, status, headers, config) {
|
||||
Authorization.setUserInfo(data);
|
||||
$rootScope['user_is_superuser'] = data.results[0].is_superuser;
|
||||
Authorization.getLicense()
|
||||
.success(function(data, status, headers, config) {
|
||||
Authorization.setLicense(data['license_info']);
|
||||
|
||||
@ -208,6 +208,10 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
||||
generator.reset();
|
||||
|
||||
if (scope.removePostRefresh) {
|
||||
scope.removePostRefresh();
|
||||
}
|
||||
|
||||
scope.PermissionAddAllowed = false;
|
||||
|
||||
// After the Organization is loaded, retrieve each related set
|
||||
|
||||
@ -23,7 +23,8 @@ angular.module('CredentialFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ angular.module('InventoryFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -112,7 +112,8 @@ angular.module('InventoryHostsFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ angular.module('JobTemplateFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -23,7 +23,8 @@ angular.module('OrganizationFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -16,6 +16,17 @@ angular.module('PermissionFormDefinition', [])
|
||||
name: 'permission', //entity or model name in singular form
|
||||
well: true, //Wrap the form with TB well/
|
||||
|
||||
stream: {
|
||||
'class': "btn-primary btn-xs activity-btn",
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
},
|
||||
|
||||
fields: {
|
||||
category: {
|
||||
label: 'Permission Type',
|
||||
|
||||
@ -25,7 +25,8 @@ angular.module('ProjectFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -27,7 +27,8 @@ angular.module('TeamFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ angular.module('UserFormDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'edit',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -69,7 +69,8 @@ angular.module('CredentialsListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -117,7 +117,8 @@ angular.module('HomeGroupListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -88,7 +88,8 @@ angular.module('HomeHostListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -96,7 +96,8 @@ angular.module('InventoriesListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -143,7 +143,8 @@ angular.module('InventorySummaryDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -45,7 +45,8 @@ angular.module('JobTemplatesListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -52,7 +52,8 @@ angular.module('OrganizationListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -50,6 +50,16 @@ angular.module('PermissionListDefinition', [])
|
||||
"class": 'btn-success btn-xs',
|
||||
awToolTip: 'Add a new permission',
|
||||
ngShow: 'PermissionAddAllowed'
|
||||
},
|
||||
stream: {
|
||||
'class': "btn-primary btn-xs activity-btn",
|
||||
ngClick: "showActivity()",
|
||||
awToolTip: "View Activity Stream",
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -88,7 +88,8 @@ angular.module('ProjectsListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -50,7 +50,8 @@ angular.module('TeamsListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -50,7 +50,8 @@ angular.module('UserListDefinition', [])
|
||||
dataPlacement: "top",
|
||||
icon: "icon-comments-alt",
|
||||
mode: 'all',
|
||||
iconSize: 'large'
|
||||
iconSize: 'large',
|
||||
ngShow: "user_is_superuser"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefinition', 'SearchHelper', 'PaginateHelper',
|
||||
'RefreshHelper', 'ListGenerator', 'StreamWidget'])
|
||||
'RefreshHelper', 'ListGenerator', 'StreamWidget', 'AuthService'])
|
||||
|
||||
.factory('setStreamHeight', [ function() {
|
||||
return function() {
|
||||
@ -20,7 +20,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
||||
}
|
||||
}])
|
||||
|
||||
.factory('ShowStream', [ 'setStreamHeight', function(setStreamHeight) {
|
||||
.factory('ShowStream', [ 'setStreamHeight', 'Authorization', function(setStreamHeight, Authorization) {
|
||||
return function() {
|
||||
// Slide in the Stream widget
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
|
||||
setUserInfo: function(response) {
|
||||
// store the response values in $rootScope so we can get to them later
|
||||
$rootScope.current_user = response.results[0];
|
||||
$cookieStore.put('current_user', response.results[0]); //keep in session cookie incase user hits refresh
|
||||
$cookieStore.put('current_user', response.results[0]); //keep in session cookie in the event of browser refresh
|
||||
},
|
||||
|
||||
restoreUserInfo: function() {
|
||||
@ -113,7 +113,14 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
|
||||
|
||||
getUserInfo: function(key) {
|
||||
// Access values returned from the Me API call
|
||||
return ($rootScope.current_user[key]) ? $rootScope.current_user[key] : null;
|
||||
if ($rootScope.current_user ) {
|
||||
return $rootScope.current_user[key]
|
||||
}
|
||||
else {
|
||||
this.restoreUserInfo();
|
||||
var cu = $cookieStore.get('current_user');
|
||||
return cu[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="col-lg-12">
|
||||
<div class="list-actions pull-right">
|
||||
<button type="button" class="btn btn-primary btn-xs refresh-btn" ng-click="refresh()" id="refresh_btn" aw-tool-tip="Refresh page" data-placement="top"><i class="icon-refresh icon-large"></i></button>
|
||||
<button type="button" class="btn btn-primary btn-xs activity-btn" ng-click="showActivity()" id="activity_btn" aw-tool-tip="View activity stream" data-placement="top"><i class="icon-comments-alt icon-large"></i></button>
|
||||
<button type="button" class="btn btn-primary btn-xs activity-btn" ng-click="showActivity()" id="activity_btn" aw-tool-tip="View activity stream" data-placement="top" ng-show="user_is_superuser"><i class="icon-comments-alt icon-large"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user