mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Use org when showing host filter matches. Make org required before user can interact with host filter.
This commit is contained in:
parent
748c8543b9
commit
663d95c388
@ -2,7 +2,8 @@ export default ['templateUrl', function(templateUrl) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
hostFilter: '='
|
||||
hostFilter: '=',
|
||||
organization: '='
|
||||
},
|
||||
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal'),
|
||||
link: function(scope, element) {
|
||||
@ -27,12 +28,14 @@ export default ['templateUrl', function(templateUrl) {
|
||||
|
||||
$scope.host_default_params = {
|
||||
order_by: 'name',
|
||||
page_size: 5
|
||||
page_size: 5,
|
||||
inventory__organization: null
|
||||
};
|
||||
|
||||
$scope.host_queryset = _.merge({
|
||||
order_by: 'name',
|
||||
page_size: 5
|
||||
page_size: 5,
|
||||
inventory__organization: $scope.organization
|
||||
}, $scope.hostFilter ? $scope.hostFilter : {});
|
||||
|
||||
// Fire off the initial search
|
||||
|
@ -8,7 +8,14 @@ export default ['$scope', 'QuerySet', 'InventoryHostsStrings',
|
||||
function($scope, qs, InventoryHostsStrings) {
|
||||
$scope.hostFilterTags = [];
|
||||
|
||||
$scope.filterTooltip = $scope.fieldIsDisabled ? '' : InventoryHostsStrings.get('smartinventories.TOOLTIP');
|
||||
$scope.$watch('organization', function(){
|
||||
if($scope.hasEditPermissions) {
|
||||
$scope.filterTooltip = $scope.organization ? InventoryHostsStrings.get('smartinventories.hostfilter.INSTRUCTIONS') : InventoryHostsStrings.get('smartinventories.hostfilter.MISSING_ORG');
|
||||
}
|
||||
else {
|
||||
$scope.filterTooltip = InventoryHostsStrings.get('smartinventories.hostfilter.MISSING_PERMISSIONS');
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('hostFilter', function(){
|
||||
$scope.hostFilterTags = [];
|
||||
|
@ -11,14 +11,15 @@ export default ['templateUrl', '$compile',
|
||||
return {
|
||||
scope: {
|
||||
hostFilter: '=',
|
||||
fieldIsDisabled: '='
|
||||
hasEditPermissions: '=',
|
||||
organization: '='
|
||||
},
|
||||
restrict: 'E',
|
||||
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter'),
|
||||
controller: smartInventoryHostFilterController,
|
||||
link: function(scope) {
|
||||
scope.openHostFilterModal = function() {
|
||||
$('#content-container').append($compile('<host-filter-modal host-filter="hostFilter"></host-filter-modal>')(scope));
|
||||
$('#content-container').append($compile('<host-filter-modal host-filter="hostFilter" organization="organization"></host-filter-modal>')(scope));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
<div class="input-group Form-mixedInputGroup">
|
||||
<span class="input-group-btn Form-variableHeightButtonGroup">
|
||||
<button type="button" class="Form-lookupButton Form-lookupButton--variableHeight btn btn-default" ng-click="openHostFilterModal()" ng-disabled="fieldIsDisabled">
|
||||
<button type="button" class="Form-lookupButton Form-lookupButton--variableHeight btn btn-default" ng-click="openHostFilterModal()" ng-disabled="!hasEditPermissions || !organization">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
<span class="form-control Form-textInput Form-textInput--variableHeight input-medium lookup LabelList-lookupTags LabelList-lookupTags--disabled" aw-tool-tip="{{::filterTooltip}}" data-placement="top">
|
||||
<span class="form-control Form-textInput Form-textInput--variableHeight input-medium lookup LabelList-lookupTags LabelList-lookupTags--disabled" aw-tool-tip="{{filterTooltip}}" data-tip-watch="filterTooltip" data-placement="top">
|
||||
<span class="LabelList-tag" ng-repeat="tag in hostFilterTags">
|
||||
<span class="LabelList-name">{{tag}}</span>
|
||||
</span>
|
||||
|
@ -64,7 +64,7 @@ export default ['i18n', 'InventoryCompletedJobsList', function(i18n, InventoryCo
|
||||
smart_hosts: {
|
||||
label: i18n._('Smart Host Filter'),
|
||||
type: 'custom',
|
||||
control: '<smart-inventory-host-filter host-filter="smart_hosts" field-is-disabled="!(inventory_obj.summary_fields.user_capabilities.edit || canAdd)"></smart-inventory-host-filter>',
|
||||
control: '<smart-inventory-host-filter host-filter="smart_hosts" has-edit-permissions="inventory_obj.summary_fields.user_capabilities.edit || canAdd" organization="organization"></smart-inventory-host-filter>',
|
||||
awPopOver: "<p>" + i18n._("Populate the hosts for this inventory by using a search filter.") + "</p><p>" + i18n._("Example: ansible_facts.ansible_distribution:\"RedHat\"") + "</p><p>" + i18n._("Refer to the Ansible Tower documentation for further syntax and examples.") + "</p>",
|
||||
dataTitle: i18n._('Smart Host Filter'),
|
||||
dataPlacement: 'right',
|
||||
|
@ -22,7 +22,11 @@ function InventoryHostsStrings (BaseString) {
|
||||
};
|
||||
|
||||
ns.smartinventories = {
|
||||
TOOLTIP: t.s('Please click the icon to edit the host filter.')
|
||||
hostfilter: {
|
||||
MISSING_ORG: t.s('Please select an organization before editing the host filter.'),
|
||||
INSTRUCTIONS: t.s('Please click the icon to edit the host filter.'),
|
||||
MISSING_PERMISSIONS: t.s('You do not have sufficient permissions to edit the host filter.')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user