Fixup secondary domains for restoring of apps from the archive
This commit is contained in:
@@ -98,7 +98,6 @@ async function onRestore(archive) {
|
||||
|
||||
restoreLocation.value = app.subdomain;
|
||||
const d = domains.value.find(function (d) { return app.domain === d.domain; });
|
||||
console.log(d)
|
||||
restoreDomain.value = d ? d.domain : domains.value[0].domain; // try to pre-select the app's domain
|
||||
restoreSecondaryDomains.value = {};
|
||||
restoreNeedsOverwrite.value = false;
|
||||
@@ -109,18 +108,20 @@ async function onRestore(archive) {
|
||||
const httpPorts = archive.manifest.httpPorts || {};
|
||||
for (const env in httpPorts) {
|
||||
restoreSecondaryDomains.value[env] = {
|
||||
title: httpPorts[env].title,
|
||||
description: httpPorts[env].description,
|
||||
subdomain: httpPorts[env].defaultValue || '',
|
||||
domain: restoreSecondaryDomains.value.domain
|
||||
domain: restoreDomain.value,
|
||||
};
|
||||
}
|
||||
|
||||
// now fill secondaryDomains with real values, if exists
|
||||
if (archive.secondaryDomains) {
|
||||
archive.secondaryDomains.forEach(function (sd) {
|
||||
restoreSecondaryDomains.value[sd.environmentVariable] = {
|
||||
subdomain: sd.subdomain,
|
||||
domain: domains.value.find(function (d) { return sd.domain === d.domain; })
|
||||
};
|
||||
if (app.secondaryDomains) {
|
||||
app.secondaryDomains.forEach(function (sd) {
|
||||
const usedDomain = domains.value.find(function (d) { return sd.domain === d.domain; });
|
||||
|
||||
restoreSecondaryDomains.value[sd.environmentVariable].subdomain = sd.subdomain;
|
||||
restoreSecondaryDomains.value[sd.environmentVariable].domain = usedDomain ? usedDomain.domain : restoreDomain.value;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@ async function onRestoreSubmit() {
|
||||
for (const env in restoreSecondaryDomains.value) {
|
||||
secondaryDomains[env] = {
|
||||
subdomain: restoreSecondaryDomains.value[env].subdomain,
|
||||
domain: restoreSecondaryDomains.value[env].domain.domain
|
||||
domain: restoreSecondaryDomains.value[env].domain
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,7 +173,7 @@ async function onRestoreSubmit() {
|
||||
const data = {
|
||||
subdomain: restoreLocation.value,
|
||||
domain: restoreDomain.value,
|
||||
secondaryDomains: secondaryDomains,
|
||||
secondaryDomains,
|
||||
// ports: finalPorts,
|
||||
ports: {},
|
||||
overwriteDns: restoreNeedsOverwrite.value,
|
||||
@@ -200,6 +201,7 @@ async function onRestoreSubmit() {
|
||||
const [error] = await archivesModel.restore(restoreArchive.value.id, data);
|
||||
if (error) {
|
||||
if (error.type === 'externally_exists') {
|
||||
restoreError.value.dnsInUse = 'Some DNS records exist. Submit again to overwrite.';
|
||||
restoreNeedsOverwrite.value = true;
|
||||
} else {
|
||||
restoreError.value.generic = error.body ? error.body.message : 'Internal error';
|
||||
@@ -251,6 +253,7 @@ onMounted(async () => {
|
||||
<p v-html="$t('backups.restoreArchiveDialog.description', { appId: restoreManifest.id, fqdn: restoreFqdn, creationTime: prettyLongDate(restoreArchive.creationTime) })"></p>
|
||||
|
||||
<div class="text-danger" v-show="restoreError.generic">{{ restoreError.generic }}</div>
|
||||
<div class="text-danger" v-show="restoreError.dnsInUse">{{ restoreError.dnsInUse }}</div>
|
||||
<!-- <div ng-show="archiveRestore.error.location.fqdn === archiveRestore.subdomain + '.' + archiveRestore.domain.domain"><small>{{ archiveRestore.error.location.message }}</small></div> -->
|
||||
|
||||
<form @submit.prevent="onRestoreSubmit()" autocomplete="off">
|
||||
@@ -263,12 +266,12 @@ onMounted(async () => {
|
||||
</div>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup v-for="(port, key) in restoreSecondaryDomains" :key="key">
|
||||
<label :for="'secondaryDomainInput' + key">{{ port.title }}</label>
|
||||
<small>{{ port.description }}</small>
|
||||
<FormGroup v-for="(domain, key) in restoreSecondaryDomains" :key="key">
|
||||
<label :for="'secondaryDomainInput-' + key">{{ domain.title }}</label>
|
||||
<small>{{ domain.description }}</small>
|
||||
<div style="display: flex;">
|
||||
<TextInput :id="'secondaryDomainInput' + key" v-model="port.value" :placeholder="$t('appstore.installDialog.locationPlaceholder')" style="flex-grow: 1;" />
|
||||
<Dropdown v-model="port.domain" :options="domains" option-label="domain" option-key="domain" />
|
||||
<TextInput :id="'secondaryDomainInput-' + key" v-model="domain.subdomain" :placeholder="$t('appstore.installDialog.locationPlaceholder')" style="flex-grow: 1;" />
|
||||
<Dropdown v-model="domain.domain" :options="domains" option-label="domain" option-key="domain" />
|
||||
</div>
|
||||
</FormGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user