apps: rework portBindings
ports is REST API input . Map of env var to the host port portBinding is the database structure. Map of env var to host port, count, type etc also, rename portCount -> count in various places to keep things consistent
This commit is contained in:
@@ -305,9 +305,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
secondaryDomains: {},
|
||||
redirectDomains: [],
|
||||
aliasDomains: [],
|
||||
portBindings: {},
|
||||
portBindingsEnabled: {},
|
||||
portBindingsInfo: {},
|
||||
ports: {},
|
||||
portsEnabled: {},
|
||||
portInfo: {},
|
||||
|
||||
addRedirectDomain: function (event) {
|
||||
event.preventDefault();
|
||||
@@ -369,18 +369,18 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
};
|
||||
});
|
||||
|
||||
$scope.location.portBindingsInfo = angular.extend({}, app.manifest.tcpPorts, app.manifest.udpPorts); // Portbinding map only for information
|
||||
$scope.location.portInfo = 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] };});
|
||||
|
||||
// fill the portBinding structures. There might be holes in the app.portBindings, which signalizes a disabled port
|
||||
for (var env in $scope.location.portBindingsInfo) {
|
||||
for (var env in $scope.location.portInfo) {
|
||||
if (app.portBindings && app.portBindings[env]) {
|
||||
$scope.location.portBindings[env] = app.portBindings[env];
|
||||
$scope.location.portBindingsEnabled[env] = true;
|
||||
$scope.location.ports[env] = app.portBindings[env].hostPort;
|
||||
$scope.location.portsEnabled[env] = true;
|
||||
} else {
|
||||
$scope.location.portBindings[env] = $scope.location.portBindingsInfo[env].defaultValue || 0;
|
||||
$scope.location.portBindingsEnabled[env] = false;
|
||||
$scope.location.ports[env] = $scope.location.portInfo[env].defaultValue || 0;
|
||||
$scope.location.portsEnabled[env] = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -400,11 +400,11 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
};
|
||||
}
|
||||
|
||||
// only use enabled ports from portBindings
|
||||
var portBindings = {};
|
||||
for (var env in $scope.location.portBindings) {
|
||||
if ($scope.location.portBindingsEnabled[env]) {
|
||||
portBindings[env] = $scope.location.portBindings[env];
|
||||
// only use enabled ports
|
||||
var ports = {};
|
||||
for (var env in $scope.location.ports) {
|
||||
if ($scope.location.portsEnabled[env]) {
|
||||
ports[env] = $scope.location.ports[env];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
overwriteDns: !!overwriteDns,
|
||||
subdomain: $scope.location.subdomain,
|
||||
domain: $scope.location.domain.domain,
|
||||
portBindings: portBindings,
|
||||
ports: ports,
|
||||
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 };})
|
||||
@@ -1794,9 +1794,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
secondaryDomains: {},
|
||||
needsOverwrite: false,
|
||||
overwriteDns: false,
|
||||
portBindings: {},
|
||||
portBindingsInfo: {},
|
||||
portBindingsEnabled: {},
|
||||
ports: {},
|
||||
portsEnabled: {},
|
||||
portInfo: {},
|
||||
|
||||
show: function (backup) {
|
||||
var app = $scope.app;
|
||||
@@ -1818,11 +1818,11 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
};
|
||||
}
|
||||
|
||||
$scope.clone.portBindingsInfo = angular.extend({}, backup.manifest.tcpPorts, backup.manifest.udpPorts); // Portbinding map only for information
|
||||
$scope.clone.portInfo = angular.extend({}, backup.manifest.tcpPorts, backup.manifest.udpPorts); // Portbinding map only for information
|
||||
// set default ports
|
||||
for (var env in $scope.clone.portBindingsInfo) {
|
||||
$scope.clone.portBindings[env] = $scope.clone.portBindingsInfo[env].defaultValue || 0;
|
||||
$scope.clone.portBindingsEnabled[env] = true;
|
||||
for (var env in $scope.clone.portInfo) {
|
||||
$scope.clone.ports[env] = $scope.clone.portInfo[env].defaultValue || 0;
|
||||
$scope.clone.portsEnabled[env] = true;
|
||||
}
|
||||
|
||||
$('#appCloneModal').modal('show');
|
||||
@@ -1839,11 +1839,11 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
};
|
||||
}
|
||||
|
||||
// only use enabled ports from portBindings
|
||||
var finalPortBindings = {};
|
||||
for (var env in $scope.clone.portBindings) {
|
||||
if ($scope.clone.portBindingsEnabled[env]) {
|
||||
finalPortBindings[env] = $scope.clone.portBindings[env];
|
||||
// only use enabled ports
|
||||
var finalPorts = {};
|
||||
for (var env in $scope.clone.ports) {
|
||||
if ($scope.clone.portsEnabled[env]) {
|
||||
finalPorts[env] = $scope.clone.ports[env];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1851,7 +1851,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
subdomain: $scope.clone.subdomain,
|
||||
domain: $scope.clone.domain.domain,
|
||||
secondaryDomains: secondaryDomains,
|
||||
portBindings: finalPortBindings,
|
||||
ports: finalPorts,
|
||||
backupId: $scope.clone.backup.id,
|
||||
overwriteDns: $scope.clone.overwriteDns
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user