mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 05:01:09 -02:30
Fix error where controller was accessing wrong prompt_for_days_form scope.
This commit is contained in:
@@ -30,41 +30,27 @@ export default
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
getManagementJobs();
|
getManagementJobs();
|
||||||
var scope = $rootScope.$new();
|
|
||||||
scope.cleanupJob = true;
|
|
||||||
|
|
||||||
|
$scope.cleanupJob = true;
|
||||||
// This handles the case where the user refreshes the management job notifications page.
|
// This handles the case where the user refreshes the management job notifications page.
|
||||||
if($state.current.name === 'managementJobsList.notifications') {
|
if($state.current.name === 'managementJobsList.notifications') {
|
||||||
$scope.activeCard = parseInt($state.params.management_id);
|
$scope.activeCard = parseInt($state.params.management_id);
|
||||||
$scope.cardAction = "notifications";
|
$scope.cardAction = "notifications";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel
|
|
||||||
scope.cancelConfigure = function () {
|
|
||||||
try {
|
|
||||||
$('#configure-dialog').dialog('close');
|
|
||||||
$("#configure-save-button").remove();
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
//ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
Wait('stop');
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.submitCleanupJob = function(id, name){
|
$scope.submitCleanupJob = function(id, name){
|
||||||
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
|
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
|
||||||
CreateDialog({
|
CreateDialog({
|
||||||
id: 'prompt-for-days-facts',
|
id: 'prompt-for-days-facts',
|
||||||
title: name,
|
title: name,
|
||||||
scope: scope,
|
scope: $scope,
|
||||||
width: 500,
|
width: 500,
|
||||||
height: 470,
|
height: 470,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
callback: 'PromptForDaysFacts',
|
callback: 'PromptForDaysFacts',
|
||||||
resizable: false,
|
resizable: false,
|
||||||
onOpen: function(){
|
onOpen: function(){
|
||||||
scope.$watch('prompt_for_days_facts_form.$invalid', function(invalid) {
|
$scope.$watch('prompt_for_days_facts_form.$invalid', function(invalid) {
|
||||||
if (invalid === true) {
|
if (invalid === true) {
|
||||||
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
$('#prompt-for-days-facts-launch').prop("disabled", true);
|
||||||
} else {
|
} else {
|
||||||
@@ -72,10 +58,11 @@ export default
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var fieldScope = scope.$parent;
|
var fieldScope = $scope.$parent;
|
||||||
|
|
||||||
|
// set these form elements up on the $scope where the form
|
||||||
|
// is the parent of the current $scope
|
||||||
|
|
||||||
// set these form elements up on the scope where the form
|
|
||||||
// is the parent of the current scope
|
|
||||||
fieldScope.keep_unit_choices = [{
|
fieldScope.keep_unit_choices = [{
|
||||||
"label" : "Days",
|
"label" : "Days",
|
||||||
"value" : "d"
|
"value" : "d"
|
||||||
@@ -100,9 +87,9 @@ export default
|
|||||||
"label" : "Years",
|
"label" : "Years",
|
||||||
"value" : "y"
|
"value" : "y"
|
||||||
}];
|
}];
|
||||||
scope.prompt_for_days_facts_form.$setPristine();
|
$scope.prompt_for_days_facts_form.$setPristine();
|
||||||
scope.prompt_for_days_facts_form.$invalid = false;
|
$scope.prompt_for_days_facts_form.$invalid = false;
|
||||||
fieldScope.keep_unit = fieldScope.keep_unit_choices[0];
|
fieldScope.keep_unit = fieldScope.keep_unit_choices[0];
|
||||||
fieldScope.granularity_keep_unit = fieldScope.granularity_keep_unit_choices[1];
|
fieldScope.granularity_keep_unit = fieldScope.granularity_keep_unit_choices[1];
|
||||||
fieldScope.keep_amount = 30;
|
fieldScope.keep_amount = 30;
|
||||||
fieldScope.granularity_keep_amount = 1;
|
fieldScope.granularity_keep_amount = 1;
|
||||||
@@ -120,8 +107,8 @@ export default
|
|||||||
"label": "Launch",
|
"label": "Launch",
|
||||||
"onClick": function() {
|
"onClick": function() {
|
||||||
var extra_vars = {
|
var extra_vars = {
|
||||||
"older_than": scope.keep_amount+scope.keep_unit.value,
|
"older_than": $scope.keep_amount+$scope.keep_unit.value,
|
||||||
"granularity": scope.granularity_keep_amount+scope.granularity_keep_unit.value
|
"granularity": $scope.granularity_keep_amount+$scope.granularity_keep_unit.value
|
||||||
},
|
},
|
||||||
data = {};
|
data = {};
|
||||||
data.extra_vars = JSON.stringify(extra_vars);
|
data.extra_vars = JSON.stringify(extra_vars);
|
||||||
@@ -135,9 +122,9 @@ export default
|
|||||||
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
let template_id = scope.job_template_id;
|
let template_id = $scope.job_template_id;
|
||||||
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
||||||
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
|
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
|
||||||
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -147,10 +134,10 @@ export default
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removePromptForDays) {
|
if ($scope.removePromptForDays) {
|
||||||
scope.removePromptForDays();
|
$scope.removePromptForDays();
|
||||||
}
|
}
|
||||||
scope.removePromptForDays = scope.$on('PromptForDaysFacts', function() {
|
$scope.removePromptForDays = $scope.$on('PromptForDaysFacts', function() {
|
||||||
// $('#configure-dialog').dialog('close');
|
// $('#configure-dialog').dialog('close');
|
||||||
$('#prompt-for-days-facts').show();
|
$('#prompt-for-days-facts').show();
|
||||||
$('#prompt-for-days-facts').dialog('open');
|
$('#prompt-for-days-facts').dialog('open');
|
||||||
@@ -179,14 +166,14 @@ export default
|
|||||||
CreateDialog({
|
CreateDialog({
|
||||||
id: 'prompt-for-days' ,
|
id: 'prompt-for-days' ,
|
||||||
title: name,
|
title: name,
|
||||||
scope: scope,
|
scope: $scope,
|
||||||
width: 500,
|
width: 500,
|
||||||
height: 300,
|
height: 300,
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
callback: 'PromptForDays',
|
callback: 'PromptForDays',
|
||||||
resizable: false,
|
resizable: false,
|
||||||
onOpen: function(){
|
onOpen: function(){
|
||||||
scope.$watch('prompt_for_days_form.$invalid', function(invalid) {
|
$scope.$watch('prompt_for_days_form.$invalid', function(invalid) {
|
||||||
if (invalid === true) {
|
if (invalid === true) {
|
||||||
$('#prompt-for-days-launch').prop("disabled", true);
|
$('#prompt-for-days-launch').prop("disabled", true);
|
||||||
} else {
|
} else {
|
||||||
@@ -194,10 +181,10 @@ export default
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var fieldScope = scope.$parent;
|
let fieldScope = $scope.$parent;
|
||||||
fieldScope.days_to_keep = 30;
|
fieldScope.days_to_keep = 30;
|
||||||
scope.prompt_for_days_form.$setPristine();
|
$scope.prompt_for_days_form.$setPristine();
|
||||||
scope.prompt_for_days_form.$invalid = false;
|
$scope.prompt_for_days_form.$invalid = false;
|
||||||
},
|
},
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
@@ -212,7 +199,7 @@ export default
|
|||||||
{
|
{
|
||||||
"label": "Launch",
|
"label": "Launch",
|
||||||
"onClick": function() {
|
"onClick": function() {
|
||||||
var extra_vars = {"days": scope.days_to_keep },
|
const extra_vars = {"days": $scope.days_to_keep },
|
||||||
data = {};
|
data = {};
|
||||||
data.extra_vars = JSON.stringify(extra_vars);
|
data.extra_vars = JSON.stringify(extra_vars);
|
||||||
|
|
||||||
@@ -225,9 +212,9 @@ export default
|
|||||||
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
$state.go('jobz', { id: data.system_job, type: 'system' }, { reload: true });
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
let template_id = scope.job_template_id;
|
let template_id = $scope.job_template_id;
|
||||||
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
template_id = (template_id === undefined) ? "undefined" : i18n.sprintf("%d", template_id);
|
||||||
ProcessErrors(scope, data, status, null, { hdr: i18n._('Error!'),
|
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'),
|
||||||
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
msg: i18n.sprintf(i18n._('Failed updating job %s with variables. POST returned: %d'), template_id, status) });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -237,10 +224,10 @@ export default
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removePromptForDays) {
|
if ($scope.removePromptForDays) {
|
||||||
scope.removePromptForDays();
|
$scope.removePromptForDays();
|
||||||
}
|
}
|
||||||
scope.removePromptForDays = scope.$on('PromptForDays', function() {
|
$scope.removePromptForDays = $scope.$on('PromptForDays', function() {
|
||||||
// $('#configure-dialog').dialog('close');
|
// $('#configure-dialog').dialog('close');
|
||||||
$('#prompt-for-days').show();
|
$('#prompt-for-days').show();
|
||||||
$('#prompt-for-days').dialog('open');
|
$('#prompt-for-days').dialog('open');
|
||||||
|
|||||||
Reference in New Issue
Block a user