diff --git a/webadmin/src/views/apps.html b/webadmin/src/views/apps.html index 7c8650705..4fe3738cf 100644 --- a/webadmin/src/views/apps.html +++ b/webadmin/src/views/apps.html @@ -177,7 +177,6 @@ diff --git a/webadmin/src/views/apps.js b/webadmin/src/views/apps.js index 8f744cfa0..3335585ca 100644 --- a/webadmin/src/views/apps.js +++ b/webadmin/src/views/apps.js @@ -10,7 +10,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location $scope.dnsConfig = {}; $scope.groups = []; $scope.users = []; - $scope.restartAppBusy = false; $scope.mailConfig = {}; $scope.backupConfig = {}; @@ -536,41 +535,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location return app.manifest && app.manifest.configurePath; }; - $scope.restartApp = function (app) { - $scope.restartAppBusy = true; - - function waitUntilStopped(callback) { - Client.refreshInstalledApps(function (error) { - if (error) return callback(error); - - Client.getApp(app.id, function (error, result) { - if (error) return callback(error); - - if (result.runState === 'stopped') return callback(); - setTimeout(waitUntilStopped.bind(null, callback), 2000); - }); - }); - } - - Client.stopApp(app.id, function (error) { - $scope.restartAppBusy = false; - - if (error) return console.error('Failed to stop app.', error); - - // close dialog to allow user see the app restarting - $('#appConfigureModal').modal('hide'); - $scope.reset(); - - waitUntilStopped(function (error) { - if (error) return console.error('Failed to get app status.', error); - - Client.startApp(app.id, function (error) { - if (error) console.error('Failed to start app.', error); - }); - }); - }); - }; - function fetchUsers() { Client.getUsers(function (error, users) { if (error) { diff --git a/webadmin/src/views/debug.html b/webadmin/src/views/debug.html index 314be9ba3..dec83b48d 100644 --- a/webadmin/src/views/debug.html +++ b/webadmin/src/views/debug.html @@ -29,7 +29,8 @@ - Download Full Logs + Download Logs + Restart App diff --git a/webadmin/src/views/debug.js b/webadmin/src/views/debug.js index e768e69c5..49f531c29 100644 --- a/webadmin/src/views/debug.js +++ b/webadmin/src/views/debug.js @@ -17,6 +17,7 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio $scope.terminal = null; $scope.terminalSocket = null; $scope.lines = 10; + $scope.restartAppBusy = false; function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); @@ -80,6 +81,38 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio } } + $scope.restartApp = function () { + $scope.restartAppBusy = true; + var appId = $scope.selected.value; + + function waitUntilStopped(callback) { + Client.refreshInstalledApps(function (error) { + if (error) return callback(error); + + Client.getApp(appId, function (error, result) { + if (error) return callback(error); + + if (result.runState === 'stopped') return callback(); + setTimeout(waitUntilStopped.bind(null, callback), 2000); + }); + }); + } + + Client.stopApp(appId, function (error) { + if (error) return console.error('Failed to stop app.', error); + + waitUntilStopped(function (error) { + if (error) return console.error('Failed to get app status.', error); + + Client.startApp(appId, function (error) { + if (error) console.error('Failed to start app.', error); + + $scope.restartAppBusy = false; + }); + }); + }); + }; + $scope.showLogs = function () { $scope.terminalVisible = false;