mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 07:56:06 -03:30
Prevent duplicate host filter strings
This commit is contained in:
@@ -54,10 +54,7 @@ function SmartInventoryAdd($scope, $location,
|
|||||||
|
|
||||||
data.variables = ToJSON($scope.parseType, $scope.smartinventory_variables, true);
|
data.variables = ToJSON($scope.parseType, $scope.smartinventory_variables, true);
|
||||||
|
|
||||||
let decodedHostFilter = decodeURIComponent($scope.smart_hosts.host_filter);
|
data.host_filter = decodeURIComponent($scope.smart_hosts.host_filter);
|
||||||
decodedHostFilter = decodedHostFilter.replace(/__icontains_DEFAULT/g, "__icontains");
|
|
||||||
decodedHostFilter = decodedHostFilter.replace(/__search_DEFAULT/g, "__search");
|
|
||||||
data.host_filter = decodedHostFilter;
|
|
||||||
|
|
||||||
data.kind = "smart";
|
data.kind = "smart";
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ export default ['$scope', 'QuerySet', 'InventoryHostsStrings',
|
|||||||
|
|
||||||
$.each(searchParam, function(index, param) {
|
$.each(searchParam, function(index, param) {
|
||||||
let paramParts = decodeURIComponent(param).split(/=(.+)/);
|
let paramParts = decodeURIComponent(param).split(/=(.+)/);
|
||||||
paramParts[0] = paramParts[0].replace(/__icontains(_DEFAULT)?/g, "");
|
$scope.hostFilterTags.push(qs.decodeParam(paramParts[1], paramParts[0]));
|
||||||
paramParts[0] = paramParts[0].replace(/__search(_DEFAULT)?/g, "");
|
|
||||||
let reconstructedSearchString = qs.decodeParam(paramParts[1], paramParts[0]);
|
|
||||||
$scope.hostFilterTags.push(reconstructedSearchString);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.hostFilterTags = $scope.hostFilterTags.concat(qs.stripDefaultParams(hostFilterCopy));
|
$scope.hostFilterTags = $scope.hostFilterTags.concat(qs.stripDefaultParams(hostFilterCopy));
|
||||||
|
|||||||
@@ -80,10 +80,20 @@ export default ['$q', 'Rest', 'ProcessErrors', '$rootScope', 'Wait', 'DjangoSear
|
|||||||
let valueString = paramParts[1];
|
let valueString = paramParts[1];
|
||||||
if(keySplit.length === 1) {
|
if(keySplit.length === 1) {
|
||||||
if(params.searchTerm && !lessThanGreaterThan) {
|
if(params.searchTerm && !lessThanGreaterThan) {
|
||||||
paramString += keySplit[0] + '__icontains_DEFAULT';
|
if(params.singleSearchParam) {
|
||||||
|
paramString += keySplit[0] + '__icontains';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paramString += keySplit[0] + '__icontains_DEFAULT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(params.relatedSearchTerm) {
|
else if(params.relatedSearchTerm) {
|
||||||
paramString += keySplit[0] + '__search_DEFAULT';
|
if(params.singleSearchParam) {
|
||||||
|
paramString += keySplit[0] + '__search';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
paramString += keySplit[0] + '__search_DEFAULT';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
paramString += keySplit[0];
|
paramString += keySplit[0];
|
||||||
|
|||||||
@@ -236,7 +236,14 @@ export default ['$stateParams', '$scope', '$state', 'GetBasePath', 'QuerySet', '
|
|||||||
return sourceValue;
|
return sourceValue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return object[key] + "%20and%20" + sourceValue;
|
let singleSearchParamKeys = object[key].split("%20and%20");
|
||||||
|
|
||||||
|
if(_.includes(singleSearchParamKeys, sourceValue)) {
|
||||||
|
return object[key];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return object[key] + "%20and%20" + sourceValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start the array of keys
|
// Start the array of keys
|
||||||
|
|||||||
Reference in New Issue
Block a user