rename alternateDomains to redirectDomains

This commit is contained in:
Girish Ramakrishnan
2022-01-14 22:32:41 -08:00
parent 9109c89d8f
commit fd9efe3da3
5 changed files with 37 additions and 37 deletions
+13 -13
View File
@@ -166,10 +166,10 @@
</p>
</div>
<div ng-show="repair.alternateDomains.length">
<p ng-repeat="alternateDomain in repair.alternateDomains">
<label class="control-label"><input type="checkbox" ng-model="alternateDomain.enabled">
{{ alternateDomain.subdomain + (!alternateDomain.subdomain ? '' : '.') + alternateDomain.domain.domain }}
<div ng-show="repair.redirectDomains.length">
<p ng-repeat="redirectDomain in repair.redirectDomains">
<label class="control-label"><input type="checkbox" ng-model="redirectDomain.enabled">
{{ redirectDomain.subdomain + (!redirectDomain.subdomain ? '' : '.') + redirectDomain.domain.domain }}
</label>
</p>
</div>
@@ -687,34 +687,34 @@
<div style="margin-top: 5px;"><a href="" ng-click="location.addAliasDomain($event)">{{ 'app.location.addAliasAction' | tr }}</a></div>
</div>
<div class="form-group alternate-domains">
<div class="form-group redirect-domains">
<label class="control-label">{{ 'app.location.redirections' | tr }} <sup><a ng-href="https://docs.cloudron.io/apps/#redirections" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
<div class="has-error" ng-show="location.error.alternateDomains">{{ location.error.alternateDomains }}</div>
<div class="has-error" ng-show="location.error.redirectDomains">{{ location.error.redirectDomains }}</div>
<div class="row" ng-repeat="alternateDomain in location.alternateDomains">
<div class="row" ng-repeat="redirectDomain in location.redirectDomains">
<div class="col col-lg-11">
<div class="input-group input-group-sm">
<input type="text" class="form-control" id="alternateDomainsInput-{{ $index }}" ng-model="alternateDomain.subdomain" placeholder="{{ 'app.location.redirectionsPlaceholder' | tr }}">
<input type="text" class="form-control" id="redirectDomainsInput-{{ $index }}" ng-model="redirectDomain.subdomain" placeholder="{{ 'app.location.redirectionsPlaceholder' | tr }}">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span>.{{ alternateDomain.domain.domain }}</span>
<span>.{{ redirectDomain.domain.domain }}</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
<li ng-repeat="domain in domains">
<a href="" ng-click="alternateDomain.domain = domain">{{ domain.domain }}</a>
<a href="" ng-click="redirectDomain.domain = domain">{{ domain.domain }}</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col col-lg-1">
<button class="btn btn-danger btn-sm" ng-click="location.delAlternateDomain($event, $index)"><i class="far fa-trash-alt"></i></button>
<button class="btn btn-danger btn-sm" ng-click="location.delRedirectDomain($event, $index)"><i class="far fa-trash-alt"></i></button>
</div>
</div>
<div ng-show="location.alternateDomains.length === 0">{{ 'app.location.noRedirections' | tr }}</div>
<div style="margin-top: 5px;"><a href="" ng-click="location.addAlternateDomain($event)">{{ 'app.location.addRedirectionAction' | tr }}</a></div>
<div ng-show="location.redirectDomains.length === 0">{{ 'app.location.noRedirections' | tr }}</div>
<div style="margin-top: 5px;"><a href="" ng-click="location.addRedirectDomain($event)">{{ 'app.location.addRedirectionAction' | tr }}</a></div>
</div>
</form>
</div>
+17 -17
View File
@@ -289,27 +289,27 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
domain: null,
location: '',
alternateDomains: [],
redirectDomains: [],
aliasDomains: [],
portBindings: {},
portBindingsEnabled: {},
portBindingsInfo: {},
addAlternateDomain: function (event) {
addRedirectDomain: function (event) {
event.preventDefault();
$scope.location.alternateDomains.push({
$scope.location.redirectDomains.push({
domain: $scope.domains.filter(function (d) { return d.domain === $scope.app.domain; })[0], // pre-select app's domain by default
subdomain: ''
});
setTimeout(function () {
document.getElementById('alternateDomainsInput-' + ($scope.location.alternateDomains.length-1)).focus();
document.getElementById('redirectDomainsInput-' + ($scope.location.redirectDomains.length-1)).focus();
}, 200);
},
delAlternateDomain: function (event, index) {
delRedirectDomain: function (event, index) {
event.preventDefault();
$scope.location.alternateDomains.splice(index, 1);
$scope.location.redirectDomains.splice(index, 1);
},
addAliasDomain: function (event) {
@@ -337,7 +337,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.location.location = app.location;
$scope.location.domain = $scope.domains.filter(function (d) { return d.domain === app.domain; })[0];
$scope.location.portBindingsInfo = angular.extend({}, app.manifest.tcpPorts, app.manifest.udpPorts); // Portbinding map only for information
$scope.location.alternateDomains = app.alternateDomains.map(function (a) { return { subdomain: a.subdomain, domain: $scope.domains.filter(function (d) { return d.domain === a.domain; })[0] };});
$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
@@ -372,15 +372,15 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
location: $scope.location.location,
domain: $scope.location.domain.domain,
portBindings: portBindings,
alternateDomains: $scope.location.alternateDomains.map(function (a) { return { subdomain: a.subdomain, domain: a.domain.domain };}),
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 };})
};
// pre-flight only for changed domains
var domains = [];
if ($scope.app.domain !== data.domain || $scope.app.location !== data.location) domains.push({ subdomain: data.location, domain: data.domain, type: 'main' });
data.alternateDomains.forEach(function (a) {
if ($scope.app.alternateDomains.some(function (d) { return d.domain === a.domain && d.subdomain === a.subdomain; })) return;
data.redirectDomains.forEach(function (a) {
if ($scope.app.redirectDomains.some(function (d) { return d.domain === a.domain && d.subdomain === a.subdomain; })) return;
domains.push({ subdomain: a.subdomain, domain: a.domain, type: 'redirect' });
});
data.aliasDomains.forEach(function (a) {
@@ -399,7 +399,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
} else if (domain.type === 'alias') {
$scope.location.error.aliasDomains = domain.domain + ' ' + result.error.message;
} else {
$scope.location.error.alternateDomains = domain.domain + ' ' + result.error.message;
$scope.location.error.redirectDomains = domain.domain + ' ' + result.error.message;
}
$scope.location.busy = false;
return;
@@ -427,7 +427,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.location.error.location = error.message;
$scope.locationForm.$setPristine();
} else { // FIXME: check error in aliasDomains
$scope.location.error.alternateDomains = error.message;
$scope.location.error.redirectDomains = error.message;
}
} else if (error.portName || error.field === 'portBindings') {
$scope.location.error.port = error.message;
@@ -1569,7 +1569,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
location: null,
domain: null,
alternateDomains: [],
redirectDomains: [],
aliasDomains: [],
backups: [],
@@ -1583,7 +1583,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.repair.retryBusy = false;
$scope.repair.location = null;
$scope.repair.domain = null;
$scope.repair.alternateDomains = [];
$scope.repair.redirectDomains = [];
$scope.repair.aliasDomains = [];
$scope.repair.backupId = '';
@@ -1604,8 +1604,8 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
};
});
$scope.repair.alternateDomains = $scope.app.alternateDomains;
$scope.repair.alternateDomains = $scope.app.alternateDomains.map(function (altDomain) {
$scope.repair.redirectDomains = $scope.app.redirectDomains;
$scope.repair.redirectDomains = $scope.app.redirectDomains.map(function (altDomain) {
return {
subdomain: altDomain.subdomain,
enabled: true,
@@ -1648,7 +1648,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
data.domain = $scope.repair.domain.domain;
data.aliasDomains = $scope.repair.aliasDomains.filter(function (a) { return a.enabled; })
.map(function (d) { return { subdomain: d.subdomain, domain: d.domain.domain }; });
data.alternateDomains = $scope.repair.alternateDomains.filter(function (a) { return a.enabled; })
data.redirectDomains = $scope.repair.redirectDomains.filter(function (a) { return a.enabled; })
.map(function (d) { return { subdomain: d.subdomain, domain: d.domain.domain }; });
data.overwriteDns = true; // always overwriteDns. user can anyway check and uncheck above
repairFunc = Client.configureApp.bind(null, $scope.app.id, 'location', data);