Move restart button to log view

This commit is contained in:
Girish Ramakrishnan
2017-08-19 12:29:00 -07:00
parent 3d59b8a5b0
commit f04345a99a
4 changed files with 35 additions and 38 deletions

View File

@@ -177,7 +177,6 @@
</fieldset>
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-default pull-left" ng-click="restartApp(appConfigure.app)" ng-disabled="restartAppBusy"><i class="fa fa-circle-o-notch fa-spin" ng-show="restartAppBusy"></i> Restart</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" ng-click="doConfigure()" ng-disabled="appConfigureForm.$invalid || appConfigure.busy || (appConfigure.accessRestrictionOption === 'groups' && !appConfigure.isAccessRestrictionValid()) || (appConfigure.usingAltDomain && !appConfigure.isAltDomainValid())"><i class="fa fa-circle-o-notch fa-spin" ng-show="appConfigure.busy"></i> Save</button>
</div>

View File

@@ -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) {

View File

@@ -29,7 +29,8 @@
<select class="form-control pull-right inline" ng-options="log.name for log in logs track by log.value" ng-model="selected"></select>
<!-- logs actions -->
<a class="btn btn-default pull-right" ng-href="{{ selected.url }}&format=short&lines=800" ng-hide="terminalVisible"><i class="fa fa-download"></i> Download Full Logs</a>
<a class="btn btn-default pull-right" ng-href="{{ selected.url }}&format=short&lines=800" ng-hide="terminalVisible"><i class="fa fa-download"></i> Download Logs</a>
<a class="btn btn-default pull-right" ng-click="restartApp()" ng-show="!terminalVisible && selected.type === 'app'" ng-disabled="restartAppBusy"><i class="fa fa-circle-o-notch fa-spin" ng-show="restartAppBusy"></i> Restart App</a>
<input type="file" id="fileUpload" class="hide"/>

View File

@@ -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;