fix(endpoints-creation): remove endpoint if an error is raised during creation (#1678)

pull/1679/head
Anthony Lapenna 2018-02-28 07:52:40 +01:00 committed by GitHub
parent 0c5152fb5f
commit b8f8df5f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -30,18 +30,21 @@ function ($scope, $state, $filter, EndpointService, Notifications, ExtensionMana
var TLSCertFile = TLSSkipClientVerify ? null : securityData.TLSCert;
var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey;
var endpointId;
$scope.state.actionInProgress = true;
EndpointService.createRemoteEndpoint(name, URL, PublicURL, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
.then(function success(data) {
endpointId = data.Id;
var currentEndpointId = EndpointProvider.endpointID();
EndpointProvider.setEndpointID(data.Id);
ExtensionManager.initEndpointExtensions(data.Id)
EndpointProvider.setEndpointID(endpointId);
ExtensionManager.initEndpointExtensions(endpointId)
.then(function success(data) {
Notifications.success('Endpoint created', name);
$state.reload();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to create endpoint');
EndpointService.deleteEndpoint(endpointId);
})
.finally(function final() {
$scope.state.actionInProgress = false;