diff --git a/dashboard/src/components/AppArchive.vue b/dashboard/src/components/AppArchive.vue
index daa77ac19..b9626ac74 100644
--- a/dashboard/src/components/AppArchive.vue
+++ b/dashboard/src/components/AppArchive.vue
@@ -80,7 +80,6 @@ const domains = ref([]);
const restoreSecondaryDomains = ref([]);
async function onRestore(archive) {
- console.log(archive)
restoreBusy.value = false;
restoreError.value = {};
@@ -96,16 +95,19 @@ async function onRestore(archive) {
portBindings: {}
}; // pre-8.2 backups do not have appConfig
+ // appConfig also has a manifest but it has incomplete port objects!
+ const manifest = archive.manifest;
+
restoreLocation.value = app.subdomain;
const d = domains.value.find(function (d) { return app.domain === d.domain; });
restoreDomain.value = d ? d.domain : domains.value[0].domain; // try to pre-select the app's domain
restoreSecondaryDomains.value = {};
restoreNeedsOverwrite.value = false;
restoreArchive.value = archive;
- restoreFqdn.value =archive.appConfig?.fqdn || '-';
- restoreManifest.value = archive.manifest;
+ restoreFqdn.value = archive.appConfig?.fqdn || '-';
+ restoreManifest.value = manifest;
- const httpPorts = archive.manifest.httpPorts || {};
+ const httpPorts = manifest.httpPorts || {};
for (const env in httpPorts) {
restoreSecondaryDomains.value[env] = {
title: httpPorts[env].title,
@@ -125,25 +127,29 @@ async function onRestore(archive) {
});
}
- // Portbinding map only for information
- restoreTcpPorts.value = archive.manifest.tcpPorts || {};
- restoreUdpPorts.value = archive.manifest.udpPorts || {};
+ // Portbinding map only for information we make copies
+ restoreTcpPorts.value = manifest.tcpPorts ? JSON.parse(JSON.stringify(manifest.tcpPorts)) : {};
+ restoreUdpPorts.value = manifest.udpPorts ? JSON.parse(JSON.stringify(manifest.udpPorts)) : {};
// set default ports for tcp
for (const env in restoreTcpPorts.value) {
- if (archive.portBindings[env]) { // was enabled in the app
- restoreTcpPorts.value[env] = app.portBindings[env].hostPort;
+ if (app.portBindings[env]) { // was enabled in the app
+ restoreTcpPorts.value[env].value = app.portBindings[env].hostPort;
+ restoreTcpPorts.value[env].enabled = true;
} else {
- restoreTcpPorts.value[env] = restoreTcpPorts.value[env].defaultValue || 0;
+ restoreTcpPorts.value[env].value = restoreTcpPorts.value[env].defaultValue || 0;
+ restoreTcpPorts.value[env].enabled = false;
}
}
// set default ports for udp
for (const env in restoreUdpPorts.value) {
- if (archive.portBindings[env]) { // was enabled in the app
- restoreUdpPorts.value[env] = app.portBindings[env].hostPort;
+ if (app.portBindings[env]) { // was enabled in the app
+ restoreUdpPorts.value[env].value = app.portBindings[env].hostPort;
+ restoreUdpPorts.value[env].enabled = true;
} else {
- restoreUdpPorts.value[env] = restoreUdpPorts.value[env].defaultValue || 0;
+ restoreUdpPorts.value[env].value = restoreUdpPorts.value[env].defaultValue || 0;
+ restoreUdpPorts.value[env].enabled = false;
}
}
@@ -163,41 +169,26 @@ async function onRestoreSubmit() {
}
// only use enabled ports
- // const finalPorts = {};
- // for (var env in $scope.archiveRestore.ports) {
- // if ($scope.archiveRestore.portsEnabled[env]) {
- // finalPorts[env] = $scope.archiveRestore.ports[env];
- // }
- // }
+ const finalPorts = {};
+ for (const env in restoreTcpPorts.value) {
+ if (restoreTcpPorts.value[env].enabled) {
+ finalPorts[env] = restoreTcpPorts.value[env].value;
+ }
+ }
+ for (const env in restoreUdpPorts.value) {
+ if (restoreUdpPorts.value[env].enabled) {
+ finalPorts[env] = restoreUdpPorts.value[env].value;
+ }
+ }
const data = {
subdomain: restoreLocation.value,
domain: restoreDomain.value,
secondaryDomains,
- // ports: finalPorts,
- ports: {},
+ ports: finalPorts,
overwriteDns: restoreNeedsOverwrite.value,
};
-
- // Client.unarchiveApp($scope.archiveRestore.archive.id, data, function (error/*, newApp */) {
- // $scope.archiveRestore.busy = false;
-
- // if (error) {
- // var errorMessage = error.message.toLowerCase();
- // if (errorMessage.indexOf('port') !== -1) {
- // $scope.archiveRestore.error.port = error.message;
- // } else if (error.message.indexOf('location') !== -1 || error.message.indexOf('subdomain') !== -1) {
- // // TODO extract fqdn from error message, currently we just set it always to the main location
- // $scope.archiveRestore.error.location = { type: 'internally_exists', fqdn: data.subdomain + '.' + data.domain, message: error.message };
- // $('#cloneLocationInput').focus();
- // } else {
- // Client.error(error);
- // }
- // return;
- // }
-
-
const [error] = await archivesModel.restore(restoreArchive.value.id, data);
if (error) {
if (error.type === 'externally_exists') {
@@ -277,7 +268,7 @@ onMounted(async () => {
-
+