@@ -388,6 +388,21 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.debugApp = function (id, state, callback) {
|
||||
var data = {
|
||||
appId: id,
|
||||
debugMode: state ? {
|
||||
readonlyRootfs: true,
|
||||
cmd: [ '/bin/bash', '-c', 'echo "Repair mode. Use the webterminal or cloudron exec to repair. Sleeping" && sleep infinity' ]
|
||||
} : null
|
||||
};
|
||||
|
||||
post('/api/v1/apps/' + id + '/configure', data).success(function (data, status) {
|
||||
if (status !== 202) return callback(new ClientError(status, data));
|
||||
callback(null);
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.progress = function (callback, errorCallback) {
|
||||
// this is used in the defaultErrorHandler itself, and avoids a loop
|
||||
if (typeof errorCallback !== 'function') errorCallback = defaultErrorHandler(callback);
|
||||
|
||||
@@ -46,6 +46,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal repair info -->
|
||||
<div class="modal fade" id="repairAppModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2>Restart app in repair mode?</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>This will restart the app in repair mode and will startup in a paused state, in order to allow fixing for example broken plugins or database content.</p>
|
||||
<p class="text-danger text-bold">The app will not be reachable while in repair mode!</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="repairAppBegin()">Repair</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logs-controls">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<uib-tabset active="active">
|
||||
@@ -61,10 +80,12 @@
|
||||
|
||||
<!-- terminal actions -->
|
||||
<div class="btn-group pull-right" style="margin-left: 10px;">
|
||||
<button class="btn btn-default" ng-click="restartApp()" ng-show="selected.type === 'app'" ng-disabled="restartAppBusy"><i class="fa fa-circle-o-notch fa-spin" ng-show="restartAppBusy"></i> Restart</button>
|
||||
<button class="btn btn-default" ng-click="restartApp()" ng-show="selected.type === 'app'" ng-disabled="restartAppBusy"><i class="fa fa-refresh" ng-class="{ 'fa-spin': restartAppBusy }"></i> Restart</button>
|
||||
<button class="btn btn-default" ng-click="uploadFile()" ng-show="terminalVisible && selected.type === 'app' && !uploadProgress.busy"><i class="fa fa-upload"></i> Upload to /tmp</button>
|
||||
<button class="btn btn-default" ng-click="uploadProgress.show()" ng-show="uploadProgress.busy"><i class="fa fa-circle-o-notch fa-spin"></i> Uploading...</button>
|
||||
<button class="btn btn-default" ng-click="downloadFile.show()" ng-show="terminalVisible && selected.type === 'app'"><i class="fa fa-download"></i> Download</button>
|
||||
<button class="btn btn-default" ng-click="repairApp()" ng-show="terminalVisible && selected.type === 'app' && !selectedAppInfo.debugMode"><i class="fa fa-wrench"></i> Repair</button>
|
||||
<button class="btn btn-danger" ng-click="repairAppDone()" ng-show="selectedAppInfo.debugMode"><i class="fa fa-wrench"></i> Repair Done</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right" style="margin-left: 10px;">
|
||||
|
||||
@@ -18,6 +18,7 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
$scope.terminalSocket = null;
|
||||
$scope.lines = 10;
|
||||
$scope.restartAppBusy = false;
|
||||
$scope.selectedAppInfo = null;
|
||||
|
||||
function ab2str(buf) {
|
||||
return String.fromCharCode.apply(null, new Uint16Array(buf));
|
||||
@@ -144,6 +145,8 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
if ($scope.terminalSocket) {
|
||||
$scope.terminalSocket = null;
|
||||
}
|
||||
|
||||
$scope.selectedAppInfo = null;
|
||||
}
|
||||
|
||||
$scope.restartApp = function () {
|
||||
@@ -178,6 +181,33 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
});
|
||||
};
|
||||
|
||||
$scope.repairApp = function () {
|
||||
$('#repairAppModal').modal('show');
|
||||
};
|
||||
|
||||
$scope.repairAppBegin = function () {
|
||||
var appId = $scope.selected.value;
|
||||
|
||||
Client.debugApp(appId, true, function (error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$('#repairAppModal').modal('hide');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.repairAppDone = function () {
|
||||
var appId = $scope.selected.value;
|
||||
|
||||
Client.debugApp(appId, false, function (error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
Client.getApp(appId, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
$scope.selectedAppInfo = result;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showLogs = function () {
|
||||
$scope.terminalVisible = false;
|
||||
|
||||
@@ -229,6 +259,12 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch current app state
|
||||
Client.getApp($scope.selected.value, function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
$scope.selectedAppInfo = result;
|
||||
});
|
||||
|
||||
$scope.terminal = new Terminal();
|
||||
$scope.terminal.open(document.querySelector('.logs-and-term-container'));
|
||||
$scope.terminal.fit();
|
||||
|
||||
Reference in New Issue
Block a user