2018-01-22 13:01:38 -08:00
|
|
|
'use strict';
|
|
|
|
|
|
2019-01-22 10:54:03 +01:00
|
|
|
/* global angular:false */
|
|
|
|
|
/* global $:false */
|
|
|
|
|
|
2018-01-22 13:01:38 -08:00
|
|
|
angular.module('Application').controller('SupportController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
|
2020-02-24 12:56:13 +01:00
|
|
|
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
|
2018-05-01 11:44:47 -07:00
|
|
|
|
2018-01-22 13:01:38 -08:00
|
|
|
$scope.config = Client.getConfig();
|
|
|
|
|
$scope.user = Client.getUserInfo();
|
2018-03-05 12:54:09 +01:00
|
|
|
$scope.apps = Client.getInstalledApps();
|
2020-02-05 14:15:46 -08:00
|
|
|
$scope.supportConfig = null;
|
2018-01-22 13:01:38 -08:00
|
|
|
|
|
|
|
|
$scope.feedback = {
|
|
|
|
|
error: null,
|
2019-05-28 10:04:18 -07:00
|
|
|
result: null,
|
2018-01-22 13:01:38 -08:00
|
|
|
busy: false,
|
2020-10-05 15:20:07 +02:00
|
|
|
enableSshSupport: false,
|
2018-01-22 13:01:38 -08:00
|
|
|
subject: '',
|
2020-10-05 15:10:23 +02:00
|
|
|
type: 'app_error',
|
2018-03-05 12:54:09 +01:00
|
|
|
description: '',
|
2019-10-15 11:39:57 -07:00
|
|
|
appId: '',
|
|
|
|
|
altEmail: ''
|
2018-01-22 13:01:38 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.sshSupportEnabled = false;
|
2019-10-18 18:23:49 -07:00
|
|
|
$scope.subscription = null;
|
2018-01-22 13:01:38 -08:00
|
|
|
|
|
|
|
|
function resetFeedback() {
|
2020-10-05 15:20:07 +02:00
|
|
|
$scope.feedback.enableSshSupport = false;
|
2018-01-22 13:01:38 -08:00
|
|
|
$scope.feedback.subject = '';
|
|
|
|
|
$scope.feedback.description = '';
|
2020-10-05 15:10:23 +02:00
|
|
|
$scope.feedback.type = 'app_error';
|
2018-03-05 12:54:09 +01:00
|
|
|
$scope.feedback.appId = '';
|
2019-10-15 11:39:57 -07:00
|
|
|
$scope.feedback.altEmail = '';
|
2018-01-22 13:01:38 -08:00
|
|
|
|
|
|
|
|
$scope.feedbackForm.$setUntouched();
|
|
|
|
|
$scope.feedbackForm.$setPristine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.submitFeedback = function () {
|
|
|
|
|
$scope.feedback.busy = true;
|
2019-05-28 10:04:18 -07:00
|
|
|
$scope.feedback.result = null;
|
2018-01-22 13:01:38 -08:00
|
|
|
$scope.feedback.error = null;
|
|
|
|
|
|
2020-10-05 15:20:07 +02:00
|
|
|
var data = {
|
|
|
|
|
enableSshSupport: $scope.feedback.enableSshSupport,
|
|
|
|
|
subject: $scope.feedback.subject,
|
|
|
|
|
description: $scope.feedback.description,
|
|
|
|
|
type: $scope.feedback.type,
|
|
|
|
|
appId: $scope.feedback.appId,
|
|
|
|
|
altEmail: $scope.feedback.altEmail
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Client.createTicket(data, function (error, result) {
|
2018-01-22 13:01:38 -08:00
|
|
|
if (error) {
|
|
|
|
|
$scope.feedback.error = error.message;
|
|
|
|
|
} else {
|
2019-05-28 10:04:18 -07:00
|
|
|
$scope.feedback.result = result;
|
2018-01-22 13:01:38 -08:00
|
|
|
resetFeedback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.feedback.busy = false;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.toggleSshSupport = function () {
|
2018-12-19 13:22:27 -08:00
|
|
|
Client.enableRemoteSupport(!$scope.sshSupportEnabled, function (error) {
|
|
|
|
|
if (error) return $scope.error(error);
|
|
|
|
|
|
|
|
|
|
$scope.sshSupportEnabled = !$scope.sshSupportEnabled;
|
|
|
|
|
});
|
2018-01-22 13:01:38 -08:00
|
|
|
};
|
|
|
|
|
|
2019-10-18 18:23:49 -07:00
|
|
|
function getSubscription() {
|
|
|
|
|
Client.getSubscription(function (error, result) {
|
|
|
|
|
if (error && error.statusCode === 412) return; // not yet registered
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
$scope.subscription = result;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 13:01:38 -08:00
|
|
|
Client.onReady(function () {
|
2020-02-19 14:19:35 +01:00
|
|
|
getSubscription();
|
|
|
|
|
|
2020-02-05 14:15:46 -08:00
|
|
|
Client.getSupportConfig(function (error, supportConfig) {
|
2018-01-22 13:01:38 -08:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2020-02-05 14:15:46 -08:00
|
|
|
$scope.supportConfig = supportConfig;
|
2019-10-18 18:23:49 -07:00
|
|
|
|
2020-02-05 14:15:46 -08:00
|
|
|
Client.getRemoteSupport(function (error, enabled) {
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
$scope.sshSupportEnabled = enabled;
|
|
|
|
|
});
|
2018-01-22 13:01:38 -08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.modal-backdrop').remove();
|
|
|
|
|
}]);
|