Add app restart button in configure dialog

This has come up often now where people need to install the cli just for
app restarts, or would click the restore button, picking up an older
backup, where a simple restart of the app would have been sufficient.

Did this now after live-chat user asking again for this while an app got
stuck without anything obvious in the app logs.
This commit is contained in:
Johannes Zellner
2016-12-06 15:31:21 +01:00
parent e83cb0fb3c
commit 4ed2651c5f
2 changed files with 37 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.user = Client.getUserInfo();
$scope.groups = [];
$scope.users = [];
$scope.restartAppBusy = false;
$scope.appConfigure = {
busy: false,
@@ -489,6 +490,41 @@ 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) {