'use strict'; /* global angular:false */ /* global $:false */ angular.module('Application').controller('SupportController', ['$scope', '$location', 'Client', function ($scope, $location, Client) { Client.onReady(function () { if (!Client.getUserInfo().isAtLeastOwner) $location.path('/'); }); $scope.ready = false; $scope.config = Client.getConfig(); $scope.user = Client.getUserInfo(); $scope.toggleSshSupportError = ''; $scope.sshSupportEnabled = false; $scope.toggleSshSupport = function () { $scope.toggleSshSupportError = ''; Client.enableRemoteSupport(!$scope.sshSupportEnabled, function (error) { if (error) { if (error.statusCode === 412 || error.statusCode === 417) $scope.toggleSshSupportError = error.message; else console.error(error); return; } $scope.sshSupportEnabled = !$scope.sshSupportEnabled; }); }; Client.onReady(function () { Client.getRemoteSupport(function (error, enabled) { if (error) return console.error(error); $scope.sshSupportEnabled = enabled; $scope.ready = true; }); }); $('.modal-backdrop').remove(); }]);