Move certificate upload form from dns to settings

This commit is contained in:
Johannes Zellner
2015-10-27 10:39:02 +01:00
parent 01ec16f472
commit 5d589e7330
2 changed files with 72 additions and 0 deletions

View File

@@ -143,6 +143,47 @@
</div>
</div>
<div style="max-width: 600px; margin: 0 auto;" ng-show="user.admin && config.isCustomDomain">
<div class="text-left">
<h3>Default Certificates</h3>
</div>
</div>
<div class="card" style="margin-bottom: 15px;" ng-show="user.admin && config.isCustomDomain">
<div class="row">
<div class="col-md-12">
These certificates have to be wildcard certificates and will be used for all apps, which were not configured to use a specific certificate.
<br/>
<br/>
<form name="certificateForm" ng-submit="submitCertificate()">
<fieldset>
<div class="form-group" ng-class="{ 'has-error': false }">
<label class="control-label" for="certificateCertInput">Certificate</label>
<div class="input-group">
<input type="file" id="certificateFileInput" style="display:none"/>
<input type="text" class="form-control" ng-model="certificateFileName" id="certificateCertInput" name="certificate" onclick="getElementById('certificateFileInput').click();" style="cursor: pointer;" required>
<span class="input-group-addon">
<i class="fa fa-upload" onclick="getElementById('certificateFileInput').click();"></i>
</span>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': false }">
<label class="control-label" for="certificateCertInput">Key</label>
<div class="input-group">
<input type="file" id="keyFileInput" style="display:none"/>
<input type="text" class="form-control" ng-model="keyFileName" id="certificateKeyInput" name="key" onclick="getElementById('keyFileInput').click();" style="cursor: pointer;" required>
<span class="input-group-addon">
<i class="fa fa-upload" onclick="getElementById('keyFileInput').click();"></i>
</span>
</div>
</div>
<button type="submit" class="btn btn-outline btn-success pull-right" ng-click="setCertificate()">Upload Certificate</button>
</fieldset>
</form>
</div>
</div>
</div>
<div style="max-width: 600px; margin: 0 auto;" ng-show="user.admin">
<div class="text-left">
<h3>Developer Mode</h3>

View File

@@ -83,6 +83,37 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}]
};
$scope.certificateFile = null;
$scope.certificateFileName = '';
$scope.keyFile = null;
$scope.keyFileName = '';
document.getElementById('certificateFileInput').onchange = function (event) {
$scope.$apply(function () {
$scope.certificateFile = event.target.files[0];
$scope.certificateFileName = event.target.files[0].name;
});
};
document.getElementById('keyFileInput').onchange = function (event) {
$scope.$apply(function () {
$scope.keyFile = event.target.files[0];
$scope.keyFileName = event.target.files[0].name;
});
};
$scope.setCertificate = function () {
if (!$scope.certificateFile) return console.log('Certificate not set');
if (!$scope.keyFile) return console.log('Key not set');
Client.setCertificate($scope.certificateFile, $scope.keyFile, function (error) {
if (error) return console.error(error);
// give nginx reconfigure some time and then force reload
window.setTimeout(window.location.reload.bind(window.location, true), 5000);
});
};
$scope.setPreviewAvatar = function (avatar) {
$scope.avatarChange.avatar = avatar;
};