Add location and domain selector to repair dialog

This commit is contained in:
Johannes Zellner
2019-09-23 22:45:45 +02:00
parent db83508920
commit 9ed2fa734a
2 changed files with 49 additions and 37 deletions
+27 -34
View File
@@ -764,7 +764,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
busy: false,
error: {},
optionalDomains: [],
location: null,
domain: null,
alternateDomains: [],
backups: [],
backupId: '',
@@ -773,41 +775,23 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
show: function () {
$scope.repair.error = {};
$scope.repair.busy = false;
$scope.repair.optionalDomains = [];
$scope.repair.location = null;
$scope.repair.domain = null;
$scope.repair.alternateDomains = [];
$scope.repair.backupId = '';
var app = $scope.app;
// old versions may not have this set
if (!app.error.task) {
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_UPDATE) {
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_DATA_DIR_MIGRATION) {
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_UNINSTALL) {
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_DEBUG) {
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_RESIZE) {
// memory
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_RECREATE_CONTAINER) {
// email, mailbox
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_LOCATION_CHANGE || app.error.task.installationState === ISTATES.PENDING_INSTALL) {
$scope.repair.optionalDomains = $scope.app.alternateDomains;
$scope.repair.optionalDomains.forEach(function (d) {
d.enabled = true;
});
$('#repairModal').modal('show');
} else if (app.error.task.installationState === ISTATES.PENDING_RESTORE || app.error.task.installationState === ISTATES.PENDING_CLONE) {
$scope.repair.optionalDomains = $scope.app.alternateDomains;
$scope.repair.optionalDomains.forEach(function (d) {
if (app.error.domain) {
$scope.repair.location = app.location;
$scope.repair.domain = $scope.domains.filter(function (d) { return d.domain === app.domain; })[0];
$scope.repair.alternateDomains = $scope.app.alternateDomains;
$scope.repair.alternateDomains.forEach(function (d) {
d.enabled = true;
});
}
if (app.error.backupId) {
Client.getAppBackups($scope.app.id, function (error, backups) {
if (error) return Client.error(error);
@@ -816,19 +800,28 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$('#repairModal').modal('show');
});
} else {
// unhandled case last resort to simply call repair
$('#repairModal').modal('show');
return;
}
$('#repairModal').modal('show');
},
submit: function () {
$scope.repair.error = {};
$scope.repair.busy = true;
// TODO pass disabled domain info or backupId
var data = {};
if ($scope.app.error.domain) {
data.location = $scope.repair.location;
data.domain = $scope.repair.domain.domain;
data.alternateDomains = $scope.repair.alternateDomains.filter(function (a) { return a.enabled; });
}
Client.repairApp($scope.app.id, {}, function (error) {
if ($scope.app.error.backupId) {
data.backupId = $scope.repair.backupId;
}
Client.repairApp($scope.app.id, data, function (error) {
if (error) return Client.error(error);
$scope.repair.busy = false;