archive: appConfig is null for pre-8.2 backups

use backups.manifest when possible instead
This commit is contained in:
Girish Ramakrishnan
2024-12-19 14:21:39 +01:00
parent 40abb446d4
commit cd8be9ffb5
5 changed files with 41 additions and 22 deletions

View File

@@ -290,13 +290,15 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
busy: false,
error: {},
archive: null,
app: null, // just for simpler access . it's a fake app object!
title: '',
fqdn: '',
ask: function (archive) {
$scope.archiveDelete.busy = false;
$scope.archiveDelete.error = {};
$scope.archiveDelete.archive = archive;
$scope.archiveDelete.app = archive.appConfig;
$scope.archiveDelete.title = archive.manifest.title;
$scope.archiveDelete.fqdn = archive.appConfig?.fqdn || '-';
$('#archiveDeleteModal').modal('show');
},
@@ -319,7 +321,9 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
error: {},
archive: null,
app: null, // just for simpler access . it's a fake app object!
manifest: null,
appStoreId: '',
fqdn: '',
subdomain: '',
domain: null,
@@ -341,18 +345,26 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
show: function (archive) {
$scope.archiveRestore.error = {};
$scope.archiveRestore.archive = archive;
const manifest = archive.appConfig.manifest;
$scope.archiveRestore.manifest = archive.manifest;
$scope.archiveRestore.app = archive.appConfig;
$scope.archiveRestore.subdomain = $scope.archiveRestore.app.subdomain;
$scope.archiveRestore.domain = $scope.domains.find(function (d) { return $scope.archiveRestore.app.domain === d.domain; }); // try to pre-select the app's domain
const app = archive.appConfig || {
subdomain: '',
domain: $scope.domains[0].domain,
secondaryDomains: [],
portBindings: {}
}; // pre-8.2 backups do not have appConfig
$scope.archiveRestore.fqdn = archive.appConfig?.fqdn || '-';
$scope.archiveRestore.subdomain = app.subdomain;
$scope.archiveRestore.domain = $scope.domains.find(function (d) { return app.domain === d.domain; }); // try to pre-select the app's domain
$scope.archiveRestore.needsOverwrite = false;
$scope.archiveRestore.overwriteDns = false;
$scope.archiveRestore.secondaryDomains = {};
var httpPorts = manifest.httpPorts || {};
var httpPorts = archive.manifest.httpPorts || {};
for (var env2 in httpPorts) {
$scope.archiveRestore.secondaryDomains[env2] = {
subdomain: httpPorts[env2].defaultValue || '',
@@ -360,18 +372,18 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
};
}
// now fill secondaryDomains with real values, if it exists
$scope.archiveRestore.app.secondaryDomains.forEach(function (sd) {
app.secondaryDomains.forEach(function (sd) {
$scope.archiveRestore.secondaryDomains[sd.environmentVariable] = {
subdomain: sd.subdomain,
domain: $scope.domains.find(function (d) { return sd.domain === d.domain; })
};
});
$scope.archiveRestore.portInfo = angular.extend({}, manifest.tcpPorts, manifest.udpPorts); // Portbinding map only for information
$scope.archiveRestore.portInfo = angular.extend({}, archive.manifest.tcpPorts, archive.manifest.udpPorts); // Portbinding map only for information
// set default ports
for (var env in $scope.archiveRestore.portInfo) {
if ($scope.archiveRestore.app.portBindings[env]) { // was enabled in the app
$scope.archiveRestore.ports[env] = $scope.archiveRestore.app.portBindings[env].hostPort;
if (app.portBindings[env]) { // was enabled in the app
$scope.archiveRestore.ports[env] = app.portBindings[env].hostPort;
$scope.archiveRestore.portsEnabled[env] = true;
} else {
$scope.archiveRestore.ports[env] = $scope.archiveRestore.portInfo[env].defaultValue || 0;