36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
angular.module('Application').controller('DnsController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
|
|
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
|
|
|
$scope.certificateFile = null;
|
|
$scope.certificateFileName = '';
|
|
$scope.keyFile = null;
|
|
$scope.keyFileName = '';
|
|
|
|
document.getElementById('idCertificate').onchange = function (event) {
|
|
$scope.$apply(function () {
|
|
$scope.certificateFile = event.target.files[0];
|
|
$scope.certificateFileName = event.target.files[0].name;
|
|
});
|
|
};
|
|
|
|
document.getElementById('idKey').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);
|
|
|
|
window.setTimeout(window.location.reload.bind(window.location, true), 3000);
|
|
});
|
|
};
|
|
}]);
|