mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
issue network calls for setting and getting webhook key
This commit is contained in:
committed by
Jeff Bradberry
parent
48eb502161
commit
e0a363beb8
@@ -19,7 +19,7 @@ export default
|
|||||||
'initSurvey', '$state', 'CreateSelect2', 'isNotificationAdmin',
|
'initSurvey', '$state', 'CreateSelect2', 'isNotificationAdmin',
|
||||||
'ToggleNotification','$q', 'InstanceGroupsService', 'InstanceGroupsData',
|
'ToggleNotification','$q', 'InstanceGroupsService', 'InstanceGroupsData',
|
||||||
'MultiCredentialService', 'availableLabels', 'projectGetPermissionDenied',
|
'MultiCredentialService', 'availableLabels', 'projectGetPermissionDenied',
|
||||||
'inventoryGetPermissionDenied', 'jobTemplateData', 'ParseVariableString', 'ConfigData', '$compile',
|
'inventoryGetPermissionDenied', 'jobTemplateData', 'ParseVariableString', 'ConfigData', '$compile', 'webhookKey',
|
||||||
function(
|
function(
|
||||||
$filter, $scope,
|
$filter, $scope,
|
||||||
$stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
$stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||||
@@ -29,7 +29,7 @@ export default
|
|||||||
SurveyControllerInit, $state, CreateSelect2, isNotificationAdmin,
|
SurveyControllerInit, $state, CreateSelect2, isNotificationAdmin,
|
||||||
ToggleNotification, $q, InstanceGroupsService, InstanceGroupsData,
|
ToggleNotification, $q, InstanceGroupsService, InstanceGroupsData,
|
||||||
MultiCredentialService, availableLabels, projectGetPermissionDenied,
|
MultiCredentialService, availableLabels, projectGetPermissionDenied,
|
||||||
inventoryGetPermissionDenied, jobTemplateData, ParseVariableString, ConfigData, $compile
|
inventoryGetPermissionDenied, jobTemplateData, ParseVariableString, ConfigData, $compile, webhookKey
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$scope.$watch('job_template_obj.summary_fields.user_capabilities.edit', function(val) {
|
$scope.$watch('job_template_obj.summary_fields.user_capabilities.edit', function(val) {
|
||||||
@@ -80,7 +80,7 @@ export default
|
|||||||
//
|
//
|
||||||
// webhook credential - all handlers, dynamic state, etc. live here
|
// webhook credential - all handlers, dynamic state, etc. live here
|
||||||
//
|
//
|
||||||
|
$scope.webhook_key = webhookKey;
|
||||||
$scope.webhookCredential = {
|
$scope.webhookCredential = {
|
||||||
id: _.get(jobTemplateData, ['summary_fields', 'webhook_credential', 'id']),
|
id: _.get(jobTemplateData, ['summary_fields', 'webhook_credential', 'id']),
|
||||||
name: _.get(jobTemplateData, ['summary_fields', 'webhook_credential', 'name']),
|
name: _.get(jobTemplateData, ['summary_fields', 'webhook_credential', 'name']),
|
||||||
@@ -704,6 +704,13 @@ export default
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let webhookKeyPromise = Promise.resolve();
|
||||||
|
if ($scope.webhook_key !== webhookKey) {
|
||||||
|
Rest.setUrl(jobTemplateData.related.webhook_key);
|
||||||
|
webhookKeyPromise = Rest.post({ webhook_key: $scope.webhook_key });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var orgDefer = $q.defer();
|
var orgDefer = $q.defer();
|
||||||
var associationDefer = $q.defer();
|
var associationDefer = $q.defer();
|
||||||
var associatedLabelsDefer = $q.defer();
|
var associatedLabelsDefer = $q.defer();
|
||||||
@@ -776,6 +783,7 @@ export default
|
|||||||
for (var i = 0; i < toPost.length; i++) {
|
for (var i = 0; i < toPost.length; i++) {
|
||||||
defers.push(Rest.post(toPost[i]));
|
defers.push(Rest.post(toPost[i]));
|
||||||
}
|
}
|
||||||
|
defers.push(webhookKeyPromise);
|
||||||
$q.all(defers)
|
$q.all(defers)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
@@ -884,6 +892,7 @@ export default
|
|||||||
if (!data.webhook_credential) {
|
if (!data.webhook_credential) {
|
||||||
data.webhook_service = null;
|
data.webhook_service = null;
|
||||||
}
|
}
|
||||||
|
delete data.webhook_key;
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + $state.params.job_template_id);
|
Rest.setUrl(defaultUrl + $state.params.job_template_id);
|
||||||
Rest.patch(data)
|
Rest.patch(data)
|
||||||
|
|||||||
@@ -296,7 +296,21 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
|
|||||||
msg: i18n._('Failed to get organizations for which this user is a notification administrator. GET returned ') + status
|
msg: i18n._('Failed to get organizations for which this user is a notification administrator. GET returned ') + status
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}]
|
}],
|
||||||
|
webhookKey: ['Rest', 'ProcessErrors', 'jobTemplateData', 'i18n',
|
||||||
|
function(Rest, ProcessErrors, jobTemplateData, i18n) {
|
||||||
|
Rest.setUrl(jobTemplateData.related.webhook_key);
|
||||||
|
return Rest.get()
|
||||||
|
.then(({ data = {} }) => {
|
||||||
|
return data.webhook_key || '';
|
||||||
|
})
|
||||||
|
.catch(({data, status}) => {
|
||||||
|
ProcessErrors(null, data, status, null, {
|
||||||
|
hdr: i18n._('Error!'),
|
||||||
|
msg: i18n._('Failed to get webhook key GET returned ') + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user