groups and hosts rbac conditional showing in ui implementation

This commit is contained in:
John Mitchell
2016-09-06 17:10:16 -04:00
parent 94efd034de
commit 1f586091e2
9 changed files with 142 additions and 44 deletions

View File

@@ -26,14 +26,16 @@ export default
type: 'text', type: 'text',
addRequired: true, addRequired: true,
editRequired: true, editRequired: true,
tab: 'properties' tab: 'properties',
ngDisabled: '!canEdit'
}, },
description: { description: {
label: 'Description', label: 'Description',
type: 'text', type: 'text',
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
tab: 'properties' tab: 'properties',
ngDisabled: '!canEdit'
}, },
variables: { variables: {
label: 'Variables', label: 'Variables',
@@ -65,7 +67,8 @@ export default
ngChange: 'sourceChange(source)', ngChange: 'sourceChange(source)',
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
ngModel: 'source' ngModel: 'source',
ngDisabled: '!canEdit'
}, },
credential: { credential: {
label: 'Cloud Credential', label: 'Cloud Credential',
@@ -77,7 +80,8 @@ export default
awRequiredWhen: { awRequiredWhen: {
reqExpression: "cloudCredentialRequired", reqExpression: "cloudCredentialRequired",
init: "false" init: "false"
} },
ngDisabled: '!canEdit'
}, },
source_regions: { source_regions: {
label: 'Regions', label: 'Regions',
@@ -92,7 +96,8 @@ export default
awPopOver: "<p>Click on the regions field to see a list of regions for your cloud provider. You can select multiple regions, " + awPopOver: "<p>Click on the regions field to see a list of regions for your cloud provider. You can select multiple regions, " +
"or choose <em>All</em> to include all regions. Tower will only be updated with Hosts associated with the selected regions." + "or choose <em>All</em> to include all regions. Tower will only be updated with Hosts associated with the selected regions." +
"</p>", "</p>",
dataContainer: 'body' dataContainer: 'body',
ngDisabled: '!canEdit'
}, },
instance_filters: { instance_filters: {
label: 'Instance Filters', label: 'Instance Filters',
@@ -112,7 +117,8 @@ export default
"<blockquote>tag:Name=test*</blockquote>\n" + "<blockquote>tag:Name=test*</blockquote>\n" +
"<p>View the <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\" target=\"_blank\">Describe Instances documentation</a> " + "<p>View the <a href=\"http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html\" target=\"_blank\">Describe Instances documentation</a> " +
"for a complete list of supported filters.</p>", "for a complete list of supported filters.</p>",
dataContainer: 'body' dataContainer: 'body',
ngDisabled: '!canEdit'
}, },
group_by: { group_by: {
label: 'Only Group By', label: 'Only Group By',
@@ -137,7 +143,8 @@ export default
"<li>VPC ID: <strong>vpcs &raquo; vpc-5ca1ab1e</strong></li>" + "<li>VPC ID: <strong>vpcs &raquo; vpc-5ca1ab1e</strong></li>" +
"<li>Tag None: <strong>tags &raquo; tag_none</strong></li>" + "<li>Tag None: <strong>tags &raquo; tag_none</strong></li>" +
"</ul><p>If blank, all groups above are created except <em>Instance ID</em>.</p>", "</ul><p>If blank, all groups above are created except <em>Instance ID</em>.</p>",
dataContainer: 'body' dataContainer: 'body',
ngDisabled: '!canEdit'
}, },
inventory_script: { inventory_script: {
label : "Custom Inventory Script", label : "Custom Inventory Script",
@@ -149,6 +156,7 @@ export default
addRequired: true, addRequired: true,
editRequired: true, editRequired: true,
ngRequired: "source && source.value === 'custom'", ngRequired: "source && source.value === 'custom'",
ngDisabled: '!canEdit',
}, },
custom_variables: { custom_variables: {
id: 'custom_variables', id: 'custom_variables',
@@ -269,7 +277,8 @@ export default
dataTitle: 'Overwrite', dataTitle: 'Overwrite',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'right', dataPlacement: 'right',
labelClass: 'checkbox-options' labelClass: 'checkbox-options',
ngDisabled: '!canEdit'
}, { }, {
name: 'overwrite_vars', name: 'overwrite_vars',
label: 'Overwrite Variables', label: 'Overwrite Variables',
@@ -283,7 +292,8 @@ export default
dataTitle: 'Overwrite Variables', dataTitle: 'Overwrite Variables',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'right', dataPlacement: 'right',
labelClass: 'checkbox-options' labelClass: 'checkbox-options',
ngDisabled: '!canEdit'
}, { }, {
name: 'update_on_launch', name: 'update_on_launch',
label: 'Update on Launch', label: 'Update on Launch',
@@ -296,7 +306,8 @@ export default
dataTitle: 'Update on Launch', dataTitle: 'Update on Launch',
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'right', dataPlacement: 'right',
labelClass: 'checkbox-options' labelClass: 'checkbox-options',
ngDisabled: '!canEdit'
}] }]
}, },
update_cache_timeout: { update_cache_timeout: {
@@ -321,11 +332,17 @@ export default
buttons: { buttons: {
cancel: { cancel: {
ngClick: 'formCancel()' ngClick: 'formCancel()',
ngShow: 'canEdit'
},
close: {
ngClick: 'formCancel()',
ngShow: '!canEdit'
}, },
save: { save: {
ngClick: 'formSave()', ngClick: 'formSave()',
ngDisabled: true ngDisabled: true,
ngShow: 'canEdit'
} }
}, },

View File

@@ -46,13 +46,15 @@ export default
"</blockquote>", "</blockquote>",
dataTitle: 'Host Name', dataTitle: 'Host Name',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: 'body' dataContainer: 'body',
ngDisabled: '!canEdit'
}, },
description: { description: {
label: 'Description', label: 'Description',
type: 'text', type: 'text',
addRequired: false, addRequired: false,
editRequired: false editRequired: false,
ngDisabled: '!canEdit'
}, },
variables: { variables: {
label: 'Variables', label: 'Variables',
@@ -83,10 +85,16 @@ export default
buttons: { buttons: {
cancel: { cancel: {
ngClick: 'formCancel()', ngClick: 'formCancel()',
ngShow: 'canEdit'
},
close: {
ngClick: 'formCancel()',
ngShow: '!canEdit'
}, },
save: { save: {
ngClick: 'formSave()', ngClick: 'formSave()',
ngDisabled: true ngDisabled: true,
ngShow: 'canEdit'
} }
}, },

View File

@@ -7,10 +7,21 @@
export default export default
['$state', '$stateParams', '$scope', 'GroupForm', 'CredentialList', 'inventoryScriptsListObject', 'ToggleNotification', 'ParseVariableString', ['$state', '$stateParams', '$scope', 'GroupForm', 'CredentialList', 'inventoryScriptsListObject', 'ToggleNotification', 'ParseVariableString',
'ParseTypeChange', 'GenerateForm', 'LookUpInit', 'RelatedSearchInit', 'RelatedPaginateInit', 'NotificationsListInit', 'ParseTypeChange', 'GenerateForm', 'LookUpInit', 'RelatedSearchInit', 'RelatedPaginateInit', 'NotificationsListInit',
'GroupManageService','GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'groupData', 'inventorySourceData', 'GroupManageService','GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'groupData', 'inventorySourceData', 'Rest',
function($state, $stateParams, $scope, GroupForm, CredentialList, InventoryScriptsList, ToggleNotification, ParseVariableString, function($state, $stateParams, $scope, GroupForm, CredentialList, InventoryScriptsList, ToggleNotification, ParseVariableString,
ParseTypeChange, GenerateForm, LookUpInit, RelatedSearchInit, RelatedPaginateInit, NotificationsListInit, ParseTypeChange, GenerateForm, LookUpInit, RelatedSearchInit, RelatedPaginateInit, NotificationsListInit,
GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions, groupData, inventorySourceData){ GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions, groupData, inventorySourceData, Rest){
$scope.canEdit = false;
Rest.setUrl(GetBasePath('groups') + $stateParams.group_id);
Rest.options()
.success(function(data) {
if (data.actions.PUT) {
$scope.canEdit = true;
}
});
var generator = GenerateForm, var generator = GenerateForm,
form = GroupForm(); form = GroupForm();

View File

@@ -5,13 +5,25 @@
*************************************************/ *************************************************/
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', 'InventoryManageService', 'groupsUrl', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'Rest', 'GetBasePath',
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){ InventoryManageService, groupsUrl, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, Rest, GetBasePath){
var list = InventoryGroups, var list = InventoryGroups,
view = generateList, view = generateList,
pageSize = 20; pageSize = 20;
$scope.inventory_id = $stateParams.inventory_id; $scope.inventory_id = $stateParams.inventory_id;
$scope.canAdd = false;
Rest.setUrl(GetBasePath('inventory') + $scope.inventory_id + "/groups");
Rest.options()
.success(function(data) {
if (data.actions.POST) {
$scope.canAdd = true;
}
});
// 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.
// In this case, we don't want to incidentally bind to this scope when editing a host or a group. See: // In this case, we don't want to incidentally bind to this scope when editing a host or a group. See:
// https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the // https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the

View File

@@ -5,8 +5,18 @@
*************************************************/ *************************************************/
export default export default
['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'host', ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'host', 'GetBasePath', 'Rest',
function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, host){ function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, host, GetBasePath, Rest){
$scope.canEdit = false;
Rest.setUrl(GetBasePath('hosts') + $stateParams.host_id);
Rest.options()
.success(function(data) {
if (data.actions.PUT) {
$scope.canEdit = true;
}
});
var generator = GenerateForm, var generator = GenerateForm,
form = HostForm; form = HostForm;
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';

View File

@@ -5,12 +5,26 @@
*************************************************/ *************************************************/
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', 'hostsUrl', 'SearchInit', 'PaginateInit', 'SetStatus', 'Prompt', 'Wait', 'inventoryData', '$filter', 'Rest', 'GetBasePath',
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){ hostsUrl, SearchInit, PaginateInit, SetStatus, Prompt, Wait, inventoryData, $filter, Rest, GetBasePath){
var list = InventoryHosts, var list = InventoryHosts,
view = generateList, view = generateList,
pageSize = 20; pageSize = 20;
$scope.canAdd = false;
$scope.inventory_id = $stateParams.inventory_id;
Rest.setUrl(GetBasePath('inventory') + $scope.inventory_id + "/hosts");
Rest.options()
.success(function(data) {
if (data.actions.POST) {
$scope.canAdd = true;
}
});
// 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.
// In this case, we don't want to incidentally bind to this scope when editing a host or a group. See: // In this case, we don't want to incidentally bind to this scope when editing a host or a group. See:
// https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the // https://github.com/ncuillery/angular-breadcrumb/issues/42 for a little more information on the

View File

@@ -3,21 +3,26 @@
* *
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
export default export default
['$scope', '$state', function($scope, $state){ ['$scope', '$state', 'inventoryData', function($scope, $state, inventoryData){
$scope.groupsSelected = false; $scope.groupsSelected = false;
$scope.hostsSelected = false; $scope.hostsSelected = false;
$scope.hostsSelectedItems = []; $scope.hostsSelectedItems = [];
$scope.groupsSelectedItems = []; $scope.groupsSelectedItems = [];
$scope.setAdhocPattern = function(){
var pattern = _($scope.groupsSelectedItems) $scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
.concat($scope.hostsSelectedItems)
.map(function(item){ $scope.setAdhocPattern = function(){
return item.name; var pattern = _($scope.groupsSelectedItems)
}).value().join(':'); .concat($scope.hostsSelectedItems)
$state.go('inventoryManage.adhoc', {pattern: pattern}); .map(function(item){
}; return item.name;
}).value().join(':');
$state.go('inventoryManage.adhoc', {pattern: pattern});
};
$scope.$watchGroup(['groupsSelected', 'hostsSelected'], function(newVals) { $scope.$watchGroup(['groupsSelected', 'hostsSelected'], function(newVals) {
$scope.adhocCommandTooltip = (newVals[0] || newVals[1]) ? "Run a command on the selected inventory" : "Select an inventory source by clicking the check box beside it. The inventory source can be a single group or host, a selection of multiple hosts, or a selection of multiple groups."; $scope.adhocCommandTooltip = (newVals[0] || newVals[1]) ? "Run a command on the selected inventory" : "Select an inventory source by clicking the check box beside it. The inventory source can be a single group or host, a selection of multiple hosts, or a selection of multiple groups.";
}); });
}]; }];

View File

@@ -143,7 +143,8 @@ export default
actionClass: 'btn List-buttonDefault', actionClass: 'btn List-buttonDefault',
buttonContent: 'RUN COMMANDS', buttonContent: 'RUN COMMANDS',
showTipWhenDisabled: true, showTipWhenDisabled: true,
tooltipInnerClass: "Tooltip-wide" tooltipInnerClass: "Tooltip-wide",
ngShow: 'canAdhoc'
// TODO: set up a tip watcher and change text based on when // TODO: set up a tip watcher and change text based on when
// things are selected/not selected. This is started and // things are selected/not selected. This is started and
// commented out in the inventory controller within the watchers. // commented out in the inventory controller within the watchers.
@@ -155,7 +156,8 @@ export default
ngClick: "createGroup()", ngClick: "createGroup()",
awToolTip: "Create a new group", awToolTip: "Create a new group",
actionClass: 'btn List-buttonSubmit', actionClass: 'btn List-buttonSubmit',
buttonContent: '&#43; ADD GROUP' buttonContent: '&#43; ADD GROUP',
ngShow: 'canAdd'
} }
}, },
@@ -208,6 +210,14 @@ export default
dataPlacement: "top", dataPlacement: "top",
ngShow: "group.summary_fields.user_capabilities.edit" ngShow: "group.summary_fields.user_capabilities.edit"
}, },
view: {
//label: 'Edit',
mode: 'all',
ngClick: "editGroup(group.id)",
awToolTip: 'View group',
dataPlacement: "top",
ngShow: "!group.summary_fields.user_capabilities.edit"
},
"delete": { "delete": {
//label: 'Delete', //label: 'Delete',
mode: 'all', mode: 'all',

View File

@@ -78,21 +78,31 @@ export default
mode: 'all', mode: 'all',
ngClick: "copyMoveHost(host.id)", ngClick: "copyMoveHost(host.id)",
awToolTip: 'Copy or move host to another group', awToolTip: 'Copy or move host to another group',
dataPlacement: "top" dataPlacement: "top",
ngShow: 'host.summary_fields.user_capabilities.edit'
}, },
edit: { edit: {
//label: 'Edit', //label: 'Edit',
ngClick: "editHost(host.id)", ngClick: "editHost(host.id)",
icon: 'icon-edit', icon: 'icon-edit',
awToolTip: 'Edit host', awToolTip: 'Edit host',
dataPlacement: 'top' dataPlacement: 'top',
ngShow: 'host.summary_fields.user_capabilities.edit'
},
view: {
//label: 'Edit',
ngClick: "editHost(host.id)",
awToolTip: 'View host',
dataPlacement: 'top',
ngShow: '!host.summary_fields.user_capabilities.edit'
}, },
"delete": { "delete": {
//label: 'Delete', //label: 'Delete',
ngClick: "deleteHost(host.id, host.name)", ngClick: "deleteHost(host.id, host.name)",
icon: 'icon-trash', icon: 'icon-trash',
awToolTip: 'Delete host', awToolTip: 'Delete host',
dataPlacement: 'top' dataPlacement: 'top',
ngShow: 'host.summary_fields.user_capabilities.delete'
} }
}, },
@@ -122,7 +132,8 @@ export default
ngClick: "createHost()", ngClick: "createHost()",
awToolTip: "Create a new host", awToolTip: "Create a new host",
actionClass: 'btn List-buttonSubmit', actionClass: 'btn List-buttonSubmit',
buttonContent: '&#43; ADD HOST' buttonContent: '&#43; ADD HOST',
ngShow: 'canAdd'
} }
} }