Add pre-flight and fix clone dialog

This commit is contained in:
Johannes Zellner
2019-09-24 18:50:52 +02:00
parent 2ea3ba492e
commit 3ff781139e
3 changed files with 50 additions and 24 deletions

View File

@@ -6,6 +6,7 @@
/* global asyncForEach */
/* global RSTATES */
/* global ISTATES */
/* global ERROR */
// TODO use this once we enable custom SSL certificate ui again
@@ -690,7 +691,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
};
$scope.clone = {
busy: true,
busy: false,
error: {},
backup: null,
@@ -734,28 +735,52 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
backupId: $scope.clone.backup.id
};
Client.cloneApp($scope.app.id, data, function (error/*, clonedApp */) {
$scope.clone.busy = false;
Client.checkDNSRecords(data.domain, data.location, function (error, result) {
if (error) {
if (error.statusCode === 409) {
if (error.portName) {
$scope.clone.error.port = error.message;
} else if (error.domain) {
$scope.clone.error.location = 'This location is already taken.';
$('#cloneLocationInput').focus();
} else {
Client.error(error);
}
Client.error(error);
$scope.clone.busy = false;
return;
}
if (result.error) {
if (result.error.reason === ERROR.ACCESS_DENIED) {
$scope.clone.error.location = 'DNS credentials for ' + data.domain + ' are invalid. Update it in Domains & Certs view';
} else {
Client.error(error);
$scope.clone.error.location = result.error.message;
}
$scope.clone.needsOverwrite = true;
$scope.clone.busy = false;
return;
}
if (result.needsOverwrite) {
$scope.clone.error.location = 'DNS Record already exists. Confirm that the domain is not in use for services external to Cloudron';
$scope.clone.needsOverwrite = true;
$scope.clone.busy = false;
return;
}
$('#cloneModal').modal('hide');
Client.cloneApp($scope.app.id, data, function (error/*, clonedApp */) {
$scope.clone.busy = false;
$location.path('/apps');
if (error) {
if (error.statusCode === 409) {
if (error.portName) {
$scope.clone.error.port = error.message;
} else if (error.domain) {
$scope.clone.error.location = 'This location is already taken.';
$('#cloneLocationInput').focus();
} else {
Client.error(error);
}
} else {
Client.error(error);
}
return;
}
$('#cloneModal').modal('hide');
$location.path('/apps');
});
});
}
};