support: add hidden troubleshooting section

This commit is contained in:
Girish Ramakrishnan
2024-07-12 15:35:38 +02:00
parent 10bd2e930f
commit 9adeaed1b9
3 changed files with 75 additions and 0 deletions
+1
View File
@@ -4,6 +4,7 @@
/* global $:false */
/* global APP_TYPES */
/* global onAppClick */
/* global localStorage, document, FileReader */
angular.module('Application').controller('AppsController', ['$scope', '$translate', '$interval', '$location', 'Client', function ($scope, $translate, $interval, $location, Client) {
var ALL_DOMAINS_DOMAIN = { _alldomains: true, domain: 'All Domains' }; // dummy record for the single select filter
+19
View File
@@ -18,6 +18,25 @@
</div>
</div>
<div class="text-left" ng-if="troubleshoot">
<h3>Troubleshoot</h3>
</div>
<div class="card" ng-if="troubleshoot">
<div class="grid-item-top">
<div class="row">
<div class="col-lg-12">
<p>Troubleshooting tools</p>
<div>
<button class="btn btn-default pull-right" ng-click="repairAll()"><i ng-show="repairAllBusy" class="fa fa-circle-notch fa-spin"></i> Repair All</button>
<button class="btn btn-default pull-right" ng-click="updateAll()"><i ng-show="updateAllBusy" class="fa fa-circle-notch fa-spin"></i> Update All</button>
</div>
<p class="text-small text-warning">{{ troubleshootingMessage }}</p>
</div>
</div>
</div>
</div>
<div class="text-left section-header">
<h3>{{ 'support.remoteSupport.title' | tr }}</h3>
</div>
+55
View File
@@ -2,6 +2,8 @@
/* global angular:false */
/* global $:false */
/* global ISTATES */
/* global async */
angular.module('Application').controller('SupportController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastOwner) $location.path('/'); });
@@ -9,10 +11,63 @@ angular.module('Application').controller('SupportController', ['$scope', '$locat
$scope.ready = false;
$scope.config = Client.getConfig();
$scope.user = Client.getUserInfo();
$scope.installedApps = Client.getInstalledApps();
$scope.toggleSshSupportError = '';
$scope.sshSupportEnabled = false;
$scope.troubleshoot = $location.search().troubleshoot;
$scope.updateAllBusy = false;
$scope.repairAllBusy = false;
$scope.troubleshootingMessage = '';
$scope.updateAll = function () {
$scope.updateAllBusy = true;
$scope.troubleshootingMessage = '';
let count = 0, unstable = 0;
Client.checkForUpdates(function (error) {
if (error) Client.error(error);
async.eachSeries(Object.keys($scope.config.update), function (appId, iteratorDone) {
if ($scope.config.update[appId].unstable) { ++unstable; return iteratorDone(); }
Client.updateApp(appId, $scope.config.update[appId].manifest, { skipBackup: false }, function (error) {
if (error) Client.error(error);
else ++count;
iteratorDone();
});
}, function () {
$scope.troubleshootingMessage = `${count} apps updated. ${unstable} apps with unstable updates skipped.`;
$scope.updateAllBusy = false;
});
});
};
$scope.repairAll = function () {
$scope.repairAllBusy = true;
$scope.troubleshootingMessage = '';
let count = 0;
Client.refreshInstalledApps(function () {
async.eachSeries($scope.installedApps, function (app, iteratorDone) {
if (app.installationState !== ISTATES.ERROR) return iteratorDone();
Client.repairApp(app.id, {}, function (error) {
if (error) Client.error(error);
else ++count;
iteratorDone();
});
}, function () {
$scope.troubleshootingMessage = `${count} apps repaired.`;
$scope.repairAllBusy = false;
});
});
};
$scope.toggleSshSupport = function () {
$scope.toggleSshSupportError = '';