Merge pull request #5708 from gconsidine/fix/job-prompt-revert-selection

Fix/job prompt revert selection
This commit is contained in:
Greg Considine
2017-03-14 15:23:36 -04:00
committed by GitHub
5 changed files with 40 additions and 53 deletions

View File

@@ -175,18 +175,12 @@
background-color: @btn-bg-hov; background-color: @btn-bg-hov;
color: @btn-txt; color: @btn-txt;
} }
.JobSubmission-revertButton {
background-color: @default-bg; .JobSubmission-revertLink {
color: @default-link; padding-left:10px;
text-transform: uppercase;
padding-left:15px;
padding-right: 15px;
font-size: 11px; font-size: 11px;
} }
.JobSubmission-revertButton:hover{
background-color: @default-bg;
color: @default-link-hov;
}
.JobSubmission-selectedItem { .JobSubmission-selectedItem {
display: flex; display: flex;
flex: 1 0 auto; flex: 1 0 auto;

View File

@@ -316,15 +316,6 @@ export default
$scope.revertToDefaultInventory = function() { $scope.revertToDefaultInventory = function() {
if($scope.has_default_inventory) { if($scope.has_default_inventory) {
$scope.selected_inventory = angular.copy($scope.defaults.inventory); $scope.selected_inventory = angular.copy($scope.defaults.inventory);
// Loop across inventories and set update the "checked" attribute for each row
$scope.inventories.forEach(function(row, i) {
if (row.id === $scope.selected_inventory.id) {
$scope.inventories[i].checked = 1;
} else {
$scope.inventories[i].checked = 0;
}
});
} }
}; };
@@ -332,15 +323,6 @@ export default
if($scope.has_default_credential) { if($scope.has_default_credential) {
$scope.selected_credential = angular.copy($scope.defaults.credential); $scope.selected_credential = angular.copy($scope.defaults.credential);
updateRequiredPasswords(); updateRequiredPasswords();
// Loop across credentials and set update the "checked" attribute for each row
$scope.credentials.forEach(function(row, i) {
if (row.id === $scope.selected_credential.id) {
$scope.credentials[i].checked = 1;
} else {
$scope.credentials[i].checked = 0;
}
});
} }
}; };

View File

@@ -26,10 +26,10 @@
<span class="JobSubmission-selectedItemNone" ng-show="!selected_inventory">None selected</span> <span class="JobSubmission-selectedItemNone" ng-show="!selected_inventory">None selected</span>
</div> </div>
<div class="JobSubmission-selectedItemRevert" ng-if="ask_inventory_on_launch && has_default_inventory"> <div class="JobSubmission-selectedItemRevert" ng-if="ask_inventory_on_launch && has_default_inventory">
<button class="btn btn-xs JobSubmission-revertButton" ng-hide="selected_inventory.id === defaults.inventory.id" ng-click="revertToDefaultInventory()">REVERT TO DEFAULT</button> <a class="Form-labelAction JobSubmission-revertLink" href="" ng-hide="selected_inventory.id === defaults.inventory.id" ng-click="revertToDefaultInventory()">REVERT</a>
</div> </div>
</div> </div>
<job-sub-inv-list ng-if="includeInventoryList"></job-sub-inv-list> <job-sub-inv-list ng-if="includeInventoryList" selected-inventory="$parent.selected_inventory"></job-sub-inv-list>
</div> </div>
</div> </div>
<div ng-if="ask_credential_on_launch || password_needed" ng-show="step === 'credential'" class="JobSubmission-form"> <div ng-if="ask_credential_on_launch || password_needed" ng-show="step === 'credential'" class="JobSubmission-form">
@@ -41,10 +41,10 @@
<span class="JobSubmission-selectedItemNone" ng-show="!selected_credential">None selected</span> <span class="JobSubmission-selectedItemNone" ng-show="!selected_credential">None selected</span>
</div> </div>
<div class="JobSubmission-selectedItemRevert" ng-if="ask_credential_on_launch && has_default_credential"> <div class="JobSubmission-selectedItemRevert" ng-if="ask_credential_on_launch && has_default_credential">
<button class="btn btn-xs JobSubmission-revertButton" ng-hide="selected_credential.id === defaults.credential.id" ng-click="revertToDefaultCredential()">REVERT TO DEFAULT</button> <a class="Form-labelAction JobSubmission-revertLink" href="" ng-hide="selected_credential.id === defaults.credential.id" ng-click="revertToDefaultCredential()">REVERT</a>
</div> </div>
</div> </div>
<job-sub-cred-list ng-if="includeCredentialList"></job-sub-cred-list> <job-sub-cred-list ng-if="includeCredentialList" selected-credential="$parent.selected_credential"></job-sub-cred-list>
<div ng-show="ssh_password_required || ssh_key_unlock_required || become_password_required || vault_password_required"> <div ng-show="ssh_password_required || ssh_key_unlock_required || become_password_required || vault_password_required">
<div class="JobSubmission-instructions">Launching this job requires the passwords listed below. Enter and confirm each password before continuing.</div> <div class="JobSubmission-instructions">Launching this job requires the passwords listed below. Enter and confirm each password before continuing.</div>
<form name="forms.credentialpasswords" autocomplete="off" novalidate> <form name="forms.credentialpasswords" autocomplete="off" novalidate>

View File

@@ -7,13 +7,17 @@
import jobSubCredListController from './job-sub-cred-list.controller'; import jobSubCredListController from './job-sub-cred-list.controller';
export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'CredentialList', export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'CredentialList',
function(templateUrl, qs, GetBasePath, GenerateList, $compile, CredentialList) { (templateUrl, qs, GetBasePath, GenerateList, $compile, CredentialList) => {
return { return {
scope: {}, scope: {
selectedCredential: '='
},
templateUrl: templateUrl('job-submission/lists/credential/job-sub-cred-list'), templateUrl: templateUrl('job-submission/lists/credential/job-sub-cred-list'),
controller: jobSubCredListController, controller: jobSubCredListController,
restrict: 'E', restrict: 'E',
link: function(scope) { link: scope => {
let toDestroy = [];
scope.credential_default_params = { scope.credential_default_params = {
order_by: 'name', order_by: 'name',
page_size: 5, page_size: 5,
@@ -28,11 +32,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
// Fire off the initial search // Fire off the initial search
qs.search(GetBasePath('credentials'), scope.credential_default_params) qs.search(GetBasePath('credentials'), scope.credential_default_params)
.then(function(res) { .then(res => {
scope.credential_dataset = res.data; scope.credential_dataset = res.data;
scope.credentials = scope.credential_dataset.results; scope.credentials = scope.credential_dataset.results;
var credList = _.cloneDeep(CredentialList); let credList = _.cloneDeep(CredentialList);
let html = GenerateList.build({ let html = GenerateList.build({
list: credList, list: credList,
input_type: 'radio', input_type: 'radio',
@@ -43,11 +47,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
$('#job-submission-credential-lookup').append($compile(html)(scope)); $('#job-submission-credential-lookup').append($compile(html)(scope));
scope.$watchCollection('credentials', function () { toDestroy.push(scope.$watchCollection('selectedCredential', () => {
if(scope.selected_credential) { if(scope.selectedCredential) {
// Loop across the inventories and see if one of them should be "checked" // Loop across the inventories and see if one of them should be "checked"
scope.credentials.forEach(function(row, i) { scope.credentials.forEach((row, i) => {
if (row.id === scope.selected_credential.id) { if (row.id === scope.selectedCredential.id) {
scope.credentials[i].checked = 1; scope.credentials[i].checked = 1;
} }
else { else {
@@ -55,9 +59,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
} }
}); });
} }
}); }));
}); });
scope.$on('$destroy', () => toDestroy.forEach(watcher => watcher()));
} }
}; };
}]; }];

View File

@@ -7,13 +7,17 @@
import jobSubInvListController from './job-sub-inv-list.controller'; import jobSubInvListController from './job-sub-inv-list.controller';
export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'InventoryList', export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'InventoryList',
function(templateUrl, qs, GetBasePath, GenerateList, $compile, InventoryList) { (templateUrl, qs, GetBasePath, GenerateList, $compile, InventoryList) => {
return { return {
scope: {}, scope: {
selectedInventory: '='
},
templateUrl: templateUrl('job-submission/lists/inventory/job-sub-inv-list'), templateUrl: templateUrl('job-submission/lists/inventory/job-sub-inv-list'),
controller: jobSubInvListController, controller: jobSubInvListController,
restrict: 'E', restrict: 'E',
link: function(scope) { link: scope => {
let toDestroy = [];
scope.inventory_default_params = { scope.inventory_default_params = {
order_by: 'name', order_by: 'name',
page_size: 5 page_size: 5
@@ -26,11 +30,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
// Fire off the initial search // Fire off the initial search
qs.search(GetBasePath('inventory'), scope.inventory_default_params) qs.search(GetBasePath('inventory'), scope.inventory_default_params)
.then(function(res) { .then(res => {
scope.inventory_dataset = res.data; scope.inventory_dataset = res.data;
scope.inventories = scope.inventory_dataset.results; scope.inventories = scope.inventory_dataset.results;
var invList = _.cloneDeep(InventoryList); let invList = _.cloneDeep(InventoryList);
let html = GenerateList.build({ let html = GenerateList.build({
list: invList, list: invList,
input_type: 'radio', input_type: 'radio',
@@ -41,11 +45,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
$('#job-submission-inventory-lookup').append($compile(html)(scope)); $('#job-submission-inventory-lookup').append($compile(html)(scope));
scope.$watchCollection('inventories', function () { toDestroy.push(scope.$watchCollection('selectedInventory', () => {
if(scope.selected_inventory) { if(scope.selectedInventory) {
// Loop across the inventories and see if one of them should be "checked" // Loop across the inventories and see if one of them should be "checked"
scope.inventories.forEach(function(row, i) { scope.inventories.forEach((row, i) => {
if (row.id === scope.selected_inventory.id) { if (row.id === scope.selectedInventory.id) {
scope.inventories[i].checked = 1; scope.inventories[i].checked = 1;
} }
else { else {
@@ -53,8 +57,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com
} }
}); });
} }
}); }));
}); });
scope.$on('$destroy', () => toDestroy.forEach(watcher => watcher()));
} }
}; };
}]; }];