Add error handling for upstream URI in app configure

This commit is contained in:
Johannes Zellner
2022-09-29 19:27:22 +02:00
parent 2dafa771f2
commit f9b7183a5e
2 changed files with 17 additions and 7 deletions
+13 -4
View File
@@ -1039,27 +1039,36 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.proxy = {
busy: false,
error: {},
error: null,
success: false,
upstreamUri: '',
show: function () {
$scope.proxy.error = {};
$scope.proxyForm.$setPristine();
$scope.proxy.error = null;
$scope.proxy.upstreamUri = $scope.app.upstreamUri || '';
},
submit: function () {
$scope.proxy.busy = true;
$scope.proxy.error = {};
$scope.proxy.error = null;
var upstreamUri = $scope.proxy.upstreamUri.replace(/\/$/, '');
Client.configureApp($scope.app.id, 'upstream_uri', { upstreamUri: upstreamUri }, function (error) {
$scope.proxy.busy = false;
if (error && error.statusCode === 400) {
$scope.proxy.error = error.message;
$scope.proxyForm.$setPristine();
return;
}
if (error) return Client.error(error);
$scope.proxyForm.$setPristine();
$timeout(function () {
$scope.proxy.success = true;
$scope.proxy.busy = false;
}, 1000);
});
}