Add ssh support toggle button in the support view

This commit is contained in:
Johannes Zellner
2017-03-07 16:12:00 +01:00
parent 043a35111d
commit b5ddf1d24d
2 changed files with 48 additions and 14 deletions

View File

@@ -11,22 +11,10 @@
<div class="grid-item-top">
<div class="row animateMeOpacity">
<div class="col-lg-12">
<h3>Community</h3>
Chat with us live at <a href="https://chat.cloudron.io/" target="_blank">chat.cloudron.io</a>.
</div>
</div>
</div>
</div>
<br/>
<div class="card card-large">
<div class="grid-item-top">
<div class="row animateMeOpacity">
<div class="col-lg-12">
<h3>Docs</h3>
<h3>Documentation and Chat</h3>
For user manuals and developer related questions, please refer to our <a href="{{ config.webServerOrigin }}/documentation.html" target="_blank"> documentation</a>.
<br/>
Chat with us live at <a href="https://chat.cloudron.io/" target="_blank">chat.cloudron.io</a>.
<br/>
Cloudron is open source. To report issues, <a href="https://git.cloudron.io/cloudron/box/issues" target="_blank">open a ticket</a>.
</div>
@@ -67,6 +55,25 @@
</div>
</div>
</div>
<br/>
<div class="card card-large">
<div class="grid-item-top">
<div class="row animateMeOpacity">
<div class="col-lg-12">
<h3>Remote Support</h3>
To allow Cloudron engineers perform remote support directly on your Cloudron, enable temporary SSH access for Cloudron engineers.
<br/>
<br/>
Please contact us first at <a href="https://chat.cloudron.io/" target="_blank">chat.cloudron.io</a>.
<br/>
<br/>
<button class="btn" ng-class="{ 'btn-danger': !sshSupportEnabled, 'btn-primary': sshSupportEnabled }" ng-click="toggleSshSupport()">{{ sshSupportEnabled ? 'Disable SSH support access' : 'Enable SSH support access' }}</button>
</div>
</div>
</div>
</div>
</div>
<!-- Offset the footer -->

View File

@@ -12,6 +12,8 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
description: ''
};
$scope.sshSupportEnabled = false;
function resetFeedback() {
$scope.feedback.subject = '';
$scope.feedback.description = '';
@@ -38,5 +40,30 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
});
};
var CLOUDRON_SUPPORT_PUBLIC_KEY = '';
var CLOUDRON_SUPPORT_PUBLIC_KEY_IDENTIFIER = '';
$scope.toggleSshSupport = function () {
if ($scope.sshSupportEnabled) {
Client.delAuthorizedKey(CLOUDRON_SUPPORT_PUBLIC_KEY_IDENTIFIER, function (error) {
if (error) return console.error(error);
$scope.sshSupportEnabled = false;
});
} else {
Client.addAuthorizedKey(CLOUDRON_SUPPORT_PUBLIC_KEY, function (error) {
if (error) return console.error(error);
$scope.sshSupportEnabled = true;
});
}
};
Client.onReady(function () {
Client.getAuthorizedKeys(function (error, keys) {
if (error) return console.error(error);
$scope.sshSupportEnabled = keys.some(function (k) { return k.key === CLOUDRON_SUPPORT_PUBLIC_KEY; });
});
});
$('.modal-backdrop').remove();
}]);