Strip dns setup from normal setup.html

This commit is contained in:
Johannes Zellner
2017-01-05 11:02:52 +01:00
parent 92c92db595
commit 2e0670a5c1
2 changed files with 4 additions and 107 deletions

View File

@@ -22,29 +22,12 @@ app.controller('SetupController', ['$scope', '$http', 'Client', function ($scope
$scope.setupToken = '';
$scope.createAppstoreAccount = true;
$scope.showDNSSetup = false;
$scope.dnsProvider = [
{ name: 'Manual/Wildcard', value: 'manual' },
{ name: 'Wildcard', value: 'wildcard' },
{ name: 'No-op', value: 'noop' },
{ name: 'AWS Route53', value: 'route53' },
{ name: 'Digital Ocean', value: 'digitalocean' }
];
$scope.dnsCredentials = {
error: null,
busy: false,
domain: '',
accessKeyId: '',
secretAccessKey: '',
digitalOceanToken: '',
provider: 'route53'
};
$scope.activateCloudron = function () {
$scope.busy = true;
function registerAppstoreAccountIfNeeded(callback) {
if (!$scope.createAppstoreAccount) return callback(null);
if ($scope.provider === 'caas') return callback(null);
$http.post($scope.apiServerOrigin + '/api/v1/users', { email: $scope.account.email, password: $scope.account.password }).success(function (data, status) {
if (status !== 201) return callback({ status: status, data: data });
@@ -63,52 +46,14 @@ app.controller('SetupController', ['$scope', '$http', 'Client', function ($scope
return;
}
// for caas we are done here
if ($scope.provider === 'caas') {
window.location.href = '/';
return;
}
registerAppstoreAccountIfNeeded(function (error) {
if (error) console.error('Unable to create appstore account.', error); // this is not fatal
$scope.busy = false;
$scope.showDNSSetup = true;
window.location.href = '/';
});
});
};
$scope.setDNSCredentials = function () {
$scope.busy = true;
var data = {
domain: $scope.dnsCredentials.domain,
provider: $scope.dnsCredentials.provider,
accessKeyId: $scope.dnsCredentials.accessKeyId,
secretAccessKey: $scope.dnsCredentials.secretAccessKey,
token: $scope.dnsCredentials.digitalOceanToken
};
// special case the wildcard provider
if (data.provider === 'wildcard') {
data.provider = 'manual';
data.wildcard = true;
}
Client.setDnsConfig(data, function (error) {
if (error) {
$scope.busy = false;
$scope.dnsCredentials.error = error.message;
return;
}
setTimeout(function () {
// TODO wait until domain is propagated and cert got acquired
window.location.href = 'https://my.' + $scope.dnsCredentials.domain;
}, 5000);
});
};
Client.getStatus(function (error, status) {
if (error) {
window.location.href = '/error.html';

View File

@@ -44,7 +44,7 @@
<div ng-show="busy">
<i class="fa fa-spinner fa-pulse fa-5x"></i>
</div>
<div ng-show="!showDNSSetup && !busy">
<div ng-hide="busy">
<form role="form" name="setupForm" ng-submit="activateCloudron()" novalidate>
<div class="row">
<div class="col-md-12 text-center">
@@ -84,55 +84,7 @@
</div>
<div class="row">
<div class="col-md-12 text-center">
<input type="submit" class="btn btn-primary" ng-hide="provider === 'caas'" ng-disabled="setupForm.$invalid" value="Next">
<input type="submit" class="btn btn-primary" ng-show="provider === 'caas'" ng-disabled="setupForm.$invalid" value="Done">
</div>
</div>
</form>
</div>
<div ng-show="showDNSSetup && !busy">
<form name="dnsCredentialsForm" role="form" novalidate ng-submit="setDnsCredentials()" autocomplete="off">
<div class="row">
<div class="col-md-12 text-center">
<h1>Domain Setup</h1>
<h3>Specify the domain for your Cloudron</h3>
<p>Apps will be installed on subdomains of that domain.</p>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4 text-center">
<p class="has-error text-center" ng-show="dnsCredentials.error">{{ dnsCredentials.error }}</p>
<div class="form-group" ng-class="{ 'has-error': dnsCredentialsForm.domain.$dirty && dnsCredentialsForm.domain.$invalid }">
<input type="text" class="form-control" ng-model="dnsCredentials.domain" name="domain" ng-minlength="4" ng-maxlength="128" placeholder="example.com" required autofocus>
</div>
<div class="form-group" ng-show="dnsConfig.provider !== 'caas'">
<label class="control-label">DNS API Provider</label>
<select class="form-control" ng-model="dnsCredentials.provider" ng-options="a.value as a.name for a in dnsProvider">
</select>
</div>
<!-- Route53 -->
<div class="form-group" ng-class="{ 'has-error': dnsCredentialsForm.accessKeyId.$dirty && dnsCredentialsForm.accessKeyId.$invalid }" ng-show="dnsCredentials.provider === 'route53'">
<label class="control-label">Access Key Id</label>
<input type="text" class="form-control" ng-model="dnsCredentials.accessKeyId" name="accessKeyId" ng-minlength="16" ng-maxlength="32" ng-required="dnsCredentials.provider === 'route53'">
</div>
<div class="form-group" ng-class="{ 'has-error': dnsCredentialsForm.secretAccessKey.$dirty && dnsCredentialsForm.secretAccessKey.$invalid }" ng-show="dnsCredentials.provider === 'route53'">
<label class="control-label">Secret Access Key</label>
<input type="text" class="form-control" ng-model="dnsCredentials.secretAccessKey" name="secretAccessKey" ng-required="dnsCredentials.provider === 'route53'">
</div>
<!-- DigitalOcean -->
<div class="form-group" ng-class="{ 'has-error': dnsCredentialsForm.digitalOceanToken.$dirty && dnsCredentialsForm.digitalOceanToken.$invalid }" ng-show="dnsCredentials.provider === 'digitalocean'">
<label class="control-label">API Token</label>
<input type="text" class="form-control" ng-model="dnsCredentials.digitalOceanToken" name="digitalOceanToken" ng-required="dnsCredentials.provider === 'digitalocean'">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<input type="submit" class="btn btn-primary" ng-disabled="dnsCredentialsForm.$invalid" value="Done"/>
<input type="submit" class="btn btn-primary" ng-disabled="setupForm.$invalid" value="Done">
</div>
</div>
</form>