diff --git a/src/js/client.js b/src/js/client.js index 0ab2e62ee..f05f9e3de 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -639,6 +639,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout appStoreId: id + '@' + manifest.version, subdomain: config.subdomain, domain: config.domain, + secondaryDomains: config.secondaryDomains, portBindings: config.portBindings, accessRestriction: config.accessRestriction, cert: config.cert, diff --git a/src/views/app.html b/src/views/app.html index 1dbf5d652..a54d4c232 100644 --- a/src/views/app.html +++ b/src/views/app.html @@ -641,6 +641,36 @@ +
{{ location.error.secondaryDomain }}
+
+ +
+ + +
+ + +
+ + +
+
+
+
+
+
{{ location.error.port }}
diff --git a/src/views/app.js b/src/views/app.js index dd0488c6c..0253976d0 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -287,8 +287,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location' error: {}, domainCollisions: [], - domain: null, + domain: null, // object and not the string subdomain: '', + secondaryDomains: {}, redirectDomains: [], aliasDomains: [], portBindings: {}, @@ -336,6 +337,25 @@ angular.module('Application').controller('AppController', ['$scope', '$location' $scope.location.domainCollisions = []; $scope.location.subdomain = app.subdomain; $scope.location.domain = $scope.domains.filter(function (d) { return d.domain === app.domain; })[0]; + + // for compat, secondary domain can be empty after an upgrade. so it may not exist in app.secondaryDomains + $scope.location.secondaryDomains = {}; + var httpPorts = app.manifest.httpPorts || {}; + for (var env2 in httpPorts) { + $scope.location.secondaryDomains[env2] = { + location: httpPorts[env2].defaultValue || '', + domain: $scope.location.domain + }; + } + + // now fill secondaryDomains with real values, if it exists + app.secondaryDomains.forEach(function (sd) { + $scope.location.secondaryDomains[sd.environmentVariable] = { + subdomain: sd.subdomain, + domain: $scope.domains.filter(function (d) { return d.domain === sd.domain; })[0] + }; + }); + $scope.location.portBindingsInfo = angular.extend({}, app.manifest.tcpPorts, app.manifest.udpPorts); // Portbinding map only for information $scope.location.redirectDomains = app.redirectDomains.map(function (a) { return { subdomain: a.subdomain, domain: $scope.domains.filter(function (d) { return d.domain === a.domain; })[0] };}); $scope.location.aliasDomains = app.aliasDomains.map(function (a) { return { subdomain: a.subdomain, domain: $scope.domains.filter(function (d) { return d.domain === a.domain; })[0] };}); @@ -359,6 +379,14 @@ angular.module('Application').controller('AppController', ['$scope', '$location' $scope.location.error = {}; $scope.location.domainCollisions = []; + var secondaryDomains = {}; + for (var env2 in $scope.location.secondaryDomains) { + secondaryDomains[env2] = { + subdomain: $scope.location.secondaryDomains[env2].subdomain, + domain: $scope.location.secondaryDomains[env2].domain.domain + }; + } + // only use enabled ports from portBindings var portBindings = {}; for (var env in $scope.location.portBindings) { @@ -372,6 +400,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' subdomain: $scope.location.subdomain, domain: $scope.location.domain.domain, portBindings: portBindings, + secondaryDomains: secondaryDomains, redirectDomains: $scope.location.redirectDomains.map(function (a) { return { subdomain: a.subdomain, domain: a.domain.domain };}), aliasDomains: $scope.location.aliasDomains.map(function (a) { return { subdomain: a.subdomain, domain: a.domain.domain };}) }; @@ -423,7 +452,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' Client.configureApp($scope.app.id, 'location', data, function (error) { if (error && (error.statusCode === 409 || error.statusCode === 400)) { if ((error.subdomain && error.domain) || error.field === 'location') { - if (data.domain === error.domain && data.location === error.subdomain) { // the primary + if (data.domain === error.domain && data.subdomain === error.subdomain) { // the primary $scope.location.error.location = error.message; $scope.locationForm.$setPristine(); } else { // FIXME: check error in aliasDomains @@ -431,6 +460,8 @@ angular.module('Application').controller('AppController', ['$scope', '$location' } } else if (error.portName || error.field === 'portBindings') { $scope.location.error.port = error.message; + } else if (error.message.indexOf('secondaryDomain') !== -1) { + $scope.location.error.secondaryDomain = error.message; } $scope.location.busy = false; diff --git a/src/views/appstore.html b/src/views/appstore.html index f6dbdcab9..e6194ddfa 100644 --- a/src/views/appstore.html +++ b/src/views/appstore.html @@ -38,6 +38,36 @@

+
{{ appInstall.error.secondaryDomain }}
+
+ +
+ + +
+ + +
+ + +
+
+
+
+
+
{{ appInstall.error.port }}
diff --git a/src/views/appstore.js b/src/views/appstore.js index 6fbe1d222..6fda25d5d 100644 --- a/src/views/appstore.js +++ b/src/views/appstore.js @@ -94,7 +94,8 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran app: {}, needsOverwrite: false, subdomain: '', - domain: null, + domain: null, // object and not the string + secondaryDomains: {}, portBindings: {}, mediaLinks: [], certificateFile: null, @@ -118,6 +119,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran $scope.appInstall.needsOverwrite = false; $scope.appInstall.subdomain = ''; $scope.appInstall.domain = null; + $scope.appInstall.secondaryDomains = {}; $scope.appInstall.portBindings = {}; $scope.appInstall.state = 'appInfo'; $scope.appInstall.mediaLinks = []; @@ -178,6 +180,16 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran $scope.appInstall.mediaLinks = $scope.appInstall.app.manifest.mediaLinks || []; $scope.appInstall.domain = $scope.domains.find(function (d) { return $scope.config.adminDomain === d.domain; }); // pre-select the adminDomain + + $scope.appInstall.secondaryDomains = {}; + var httpPorts = $scope.appInstall.app.manifest.httpPorts || {}; + for (var env2 in httpPorts) { + $scope.appInstall.secondaryDomains[env2] = { + subdomain: httpPorts[env2].defaultValue || '', + domain: $scope.appInstall.domain + }; + } + $scope.appInstall.portBindingsInfo = angular.extend({}, $scope.appInstall.app.manifest.tcpPorts, $scope.appInstall.app.manifest.udpPorts); // Portbinding map only for information $scope.appInstall.portBindings = {}; // This is the actual model holding the env:port pair $scope.appInstall.portBindingsEnabled = {}; // This is the actual model holding the enabled/disabled flag @@ -205,6 +217,14 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran $scope.appInstall.error.location = null; $scope.appInstall.error.port = null; + var secondaryDomains = {}; + for (var env2 in $scope.appInstall.secondaryDomains) { + secondaryDomains[env2] = { + subdomain: $scope.appInstall.secondaryDomains[env2].subdomain, + domain: $scope.appInstall.secondaryDomains[env2].domain.domain + }; + } + // only use enabled ports from portBindings var finalPortBindings = {}; for (var env in $scope.appInstall.portBindings) { @@ -224,6 +244,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran overwriteDns: $scope.appInstall.needsOverwrite, subdomain: $scope.appInstall.subdomain || '', domain: $scope.appInstall.domain.domain, + secondaryDomains: secondaryDomains, portBindings: finalPortBindings, accessRestriction: finalAccessRestriction, cert: $scope.appInstall.certificateFile, @@ -231,7 +252,7 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran sso: !$scope.appInstall.optionalSso ? undefined : ($scope.appInstall.accessRestrictionOption !== 'nosso') }; - Client.checkDNSRecords(data.domain, data.subdomain, function (error, result) { + Client.checkDNSRecords(data.domain, data.subdomain, function (error, result) { // TODO: also check secondaryDomain if (error) return Client.error(error); if (!data.overwriteDns) { @@ -266,9 +287,13 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$tran if (error.portName) { $scope.appInstall.error.port = error.message; } else if (error.domain) { - $scope.appInstall.error.location = error.message; - $scope.appInstallForm.location.$setPristine(); - $('#appInstallLocationInput').focus(); + if (error.message.indexOf('secondaryDomain') === -1) { + $scope.appInstall.error.location = error.message; + $scope.appInstallForm.location.$setPristine(); + $('#appInstallLocationInput').focus(); + } else { + $scope.appInstall.error.secondaryDomain = error.message; + } } else { $scope.appInstall.error.other = error.message; }