Disable the SMART INVENTORY button until the user performs a search on the host list

This commit is contained in:
Michael Abashian 2017-04-10 12:08:48 -04:00 committed by Jared Tabor
parent 2dd1901649
commit 3727c3a9a5
2 changed files with 18 additions and 1 deletions

View File

@ -103,11 +103,12 @@ export default ['i18n', function(i18n) {
smart_inventory: {
mode: 'all',
ngClick: "smartInventory()",
awToolTip: "Create a new Smart Inventory from results.",
awToolTip: "Create a new Smart Inventory from search results.",
actionClass: 'btn List-buttonDefault',
buttonContent: 'SMART INVENTORY',
ngShow: 'canAdd',
dataPlacement: "top",
ngDisabled: '!activeHostSearch'
}
}
};

View File

@ -15,6 +15,7 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
function init(){
$scope.canAdd = false;
$scope.activeHostSearch = false;
rbacUiControlService.canAdd('hosts')
.then(function(canAdd) {
@ -37,6 +38,21 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
setJobStatus();
});
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams) {
if(toParams && toParams.host_search) {
let hasMoreThanDefaultKeys = false;
angular.forEach(toParams.host_search, function(value, key) {
if(key !== 'order_by' && key !== 'page_size') {
hasMoreThanDefaultKeys = true;
}
});
$scope.activeHostSearch = hasMoreThanDefaultKeys ? true : false;
}
else {
$scope.activeHostSearch = false;
}
});
}
function setJobStatus(){