Move app clone into app view
This commit is contained in:
@@ -21,80 +21,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
|
||||
$scope.backupsEnabled = true;
|
||||
$scope.disableIndexingTemplate = '# Disable search engine indexing\n\nUser-agent: *\nDisallow: /';
|
||||
|
||||
$scope.appClone = {
|
||||
busy: false,
|
||||
error: {},
|
||||
app: {},
|
||||
backup: {},
|
||||
|
||||
// form
|
||||
location: '',
|
||||
domain: null,
|
||||
portBindings: {},
|
||||
portBindingsInfo: {},
|
||||
portBindingsEnabled: {},
|
||||
|
||||
show: function (app, backup) {
|
||||
$scope.appClone.busy = false;
|
||||
$scope.appClone.error = {};
|
||||
$scope.appClone.app = app;
|
||||
$scope.appClone.backup = backup;
|
||||
$scope.appClone.location = '';
|
||||
$scope.appClone.domain = $scope.domains.find(function (d) { return app.domain === d.domain; }); // pre-select the app's domain
|
||||
$scope.appClone.portBindingsInfo = angular.extend({}, $scope.appClone.app.manifest.tcpPorts, $scope.appClone.app.manifest.udpPorts); // Portbinding map only for information
|
||||
// set default ports
|
||||
for (var env in $scope.appClone.portBindingsInfo) {
|
||||
$scope.appClone.portBindings[env] = $scope.appClone.portBindingsInfo[env].defaultValue || 0;
|
||||
$scope.appClone.portBindingsEnabled[env] = true;
|
||||
}
|
||||
|
||||
$('#appCloneModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.appClone.busy = true;
|
||||
|
||||
// only use enabled ports from portBindings
|
||||
var finalPortBindings = {};
|
||||
for (var env in $scope.appClone.portBindings) {
|
||||
if ($scope.appClone.portBindingsEnabled[env]) {
|
||||
finalPortBindings[env] = $scope.appClone.portBindings[env];
|
||||
}
|
||||
}
|
||||
|
||||
var data = {
|
||||
location: $scope.appClone.location,
|
||||
domain: $scope.appClone.domain.domain,
|
||||
portBindings: finalPortBindings,
|
||||
backupId: $scope.appClone.backup.id
|
||||
};
|
||||
|
||||
Client.cloneApp($scope.appClone.app.id, data, function (error, clonedApp) {
|
||||
$scope.appClone.busy = false;
|
||||
|
||||
if (error) {
|
||||
if (error.statusCode === 409) {
|
||||
if (error.portName) {
|
||||
$scope.appClone.error.port = error.message;
|
||||
} else if (error.domain) {
|
||||
$scope.appClone.error.location = 'This location is already taken.';
|
||||
$('#appCloneLocationInput').focus();
|
||||
} else {
|
||||
Client.error(error);
|
||||
}
|
||||
} else {
|
||||
Client.error(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$('#appCloneModal').modal('hide');
|
||||
|
||||
Client.refreshAppCache(clonedApp.id); // reflect the new app state immediately
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$scope.appPostInstallConfirm = {
|
||||
app: {},
|
||||
message: '',
|
||||
|
||||
Reference in New Issue
Block a user