Merge pull request #361 from mabashian/7544-host-filter-org

Org-centric smart inventory UI changes
This commit is contained in:
Michael Abashian
2017-08-30 15:46:53 -04:00
committed by GitHub
6 changed files with 25 additions and 10 deletions

View File

@@ -2,7 +2,8 @@ export default ['templateUrl', function(templateUrl) {
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
hostFilter: '=' hostFilter: '=',
organization: '='
}, },
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal'), templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/host-filter-modal/host-filter-modal'),
link: function(scope, element) { link: function(scope, element) {
@@ -27,12 +28,14 @@ export default ['templateUrl', function(templateUrl) {
$scope.host_default_params = { $scope.host_default_params = {
order_by: 'name', order_by: 'name',
page_size: 5 page_size: 5,
inventory__organization: null
}; };
$scope.host_queryset = _.merge({ $scope.host_queryset = _.merge({
order_by: 'name', order_by: 'name',
page_size: 5 page_size: 5,
inventory__organization: $scope.organization
}, $scope.hostFilter ? $scope.hostFilter : {}); }, $scope.hostFilter ? $scope.hostFilter : {});
// Fire off the initial search // Fire off the initial search

View File

@@ -8,7 +8,14 @@ export default ['$scope', 'QuerySet', 'InventoryHostsStrings',
function($scope, qs, InventoryHostsStrings) { function($scope, qs, InventoryHostsStrings) {
$scope.hostFilterTags = []; $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.$watch('hostFilter', function(){
$scope.hostFilterTags = []; $scope.hostFilterTags = [];

View File

@@ -11,14 +11,15 @@ export default ['templateUrl', '$compile',
return { return {
scope: { scope: {
hostFilter: '=', hostFilter: '=',
fieldIsDisabled: '=' hasEditPermissions: '=',
organization: '='
}, },
restrict: 'E', restrict: 'E',
templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter'), templateUrl: templateUrl('inventories-hosts/inventories/smart-inventory/smart-inventory-host-filter/smart-inventory-host-filter'),
controller: smartInventoryHostFilterController, controller: smartInventoryHostFilterController,
link: function(scope) { link: function(scope) {
scope.openHostFilterModal = function() { 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));
}; };
} }
}; };

View File

@@ -1,10 +1,10 @@
<div class="input-group Form-mixedInputGroup"> <div class="input-group Form-mixedInputGroup">
<span class="input-group-btn Form-variableHeightButtonGroup"> <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> <i class="fa fa-search"></i>
</button> </button>
</span> </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-tag" ng-repeat="tag in hostFilterTags">
<span class="LabelList-name">{{tag}}</span> <span class="LabelList-name">{{tag}}</span>
</span> </span>

View File

@@ -61,7 +61,7 @@ export default ['i18n', 'InventoryCompletedJobsList', function(i18n, InventoryCo
smart_hosts: { smart_hosts: {
label: i18n._('Smart Host Filter'), label: i18n._('Smart Host Filter'),
type: 'custom', 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>", 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'), dataTitle: i18n._('Smart Host Filter'),
dataPlacement: 'right', dataPlacement: 'right',

View File

@@ -22,7 +22,11 @@ function InventoryHostsStrings (BaseString) {
}; };
ns.smartinventories = { 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.')
}
}; };
} }