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

@@ -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();
}]);