Remove logging parts from terminal/debug view
This commit is contained in:
@@ -1141,16 +1141,6 @@ footer {
|
||||
width: 250px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.uib-tab.active {
|
||||
a {
|
||||
background-color: white;
|
||||
|
||||
&:hover, &:focus {
|
||||
background-color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logs-container {
|
||||
@@ -1177,7 +1167,33 @@ footer {
|
||||
}
|
||||
}
|
||||
|
||||
.logs-and-term-container {
|
||||
|
||||
// ----------------------------
|
||||
// Terminal
|
||||
// ----------------------------
|
||||
|
||||
.terminal-controls {
|
||||
margin-top: 25px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.ng-isolate-scope {
|
||||
float: left;
|
||||
}
|
||||
|
||||
h3 {
|
||||
display: inline-block;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
select {
|
||||
display: inline-block;
|
||||
width: 250px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.terminal-container {
|
||||
flex-grow: 1;
|
||||
margin-left: calc(8.33% + 15px);
|
||||
margin-right: calc(8.33% + 15px);
|
||||
@@ -1188,22 +1204,6 @@ footer {
|
||||
padding: 5px;
|
||||
font-family: monospace;
|
||||
|
||||
.log-line {
|
||||
line-height: 1.2;
|
||||
|
||||
&:hover {
|
||||
background-color: #333333;
|
||||
}
|
||||
|
||||
.time {
|
||||
color: #00FFFF;
|
||||
}
|
||||
}
|
||||
|
||||
.dont-overflow {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&.placeholder {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -65,41 +65,37 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logs-controls">
|
||||
<div class="terminal-controls">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<uib-tabset active="active">
|
||||
<uib-tab index="0" heading="Logs" select="showLogs()"></uib-tab>
|
||||
<uib-tab index="1" heading="Terminal" select="showTerminal()"></uib-tab>
|
||||
</uib-tabset>
|
||||
<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 Logs</a>
|
||||
<h3>Terminal</h3>
|
||||
<select class="form-control pull-right inline" ng-options="app.name for app in apps track by app.value" ng-model="selected">
|
||||
<option value="" disabled selected>Select App</option>
|
||||
</select>
|
||||
|
||||
<input type="file" id="fileUpload" class="hide"/>
|
||||
|
||||
<!-- 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-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="uploadFile()" ng-show="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 && !appBusy"><i class="fa fa-wrench"></i> Repair</button>
|
||||
<button class="btn btn-default" ng-click="downloadFile.show()" ng-show="selected.type === 'app'"><i class="fa fa-download"></i> Download</button>
|
||||
<button class="btn btn-default" ng-click="repairApp()" ng-show="selected.type === 'app' && !selectedAppInfo.debugMode && !appBusy"><i class="fa fa-wrench"></i> Repair</button>
|
||||
<button class="btn btn-danger" ng-click="repairAppDone()" ng-show="selectedAppInfo.debugMode && !appBusy"><i class="fa fa-wrench"></i> Repair Done</button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right" style="margin-left: 10px;">
|
||||
<button class="btn btn-default" ng-click="terminalInject('mysql')" ng-show="terminalVisible && usesAddon('mysql')">MySQL</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('postgresql')" ng-show="terminalVisible && usesAddon('postgresql')">Postgres</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('mongodb')" ng-show="terminalVisible && usesAddon('mongodb')">MongoDB</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('redis')" ng-show="terminalVisible && usesAddon('redis')">Redis</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('mysql')" ng-show="usesAddon('mysql')">MySQL</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('postgresql')" ng-show="usesAddon('postgresql')">Postgres</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('mongodb')" ng-show="usesAddon('mongodb')">MongoDB</button>
|
||||
<button class="btn btn-default" ng-click="terminalInject('redis')" ng-show="usesAddon('redis')">Redis</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logs-and-term-container" id="logsAndTerminalContainer" ng-class="{ 'dont-overflow': terminalVisible }" ng-hide="terminalVisible && appBusy"></div>
|
||||
<div class="logs-and-term-container placeholder" ng-show="terminalVisible && appBusy">
|
||||
<div class="terminal-container" id="terminalContainer" ng-hide="appBusy"></div>
|
||||
<div class="terminal-container placeholder" ng-show="appBusy">
|
||||
<h4>
|
||||
<span ng-show="selectedAppInfo.installationState === 'pending_configure' && selectedAppInfo.debugMode">Restarting app for repair...</span>
|
||||
<span ng-show="selectedAppInfo.installationState === 'pending_configure' && !selectedAppInfo.debugMode ">App is being reconfigured...</span>
|
||||
|
||||
@@ -1,30 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
/* global moment */
|
||||
/* global Terminal */
|
||||
|
||||
|
||||
angular.module('Application').controller('DebugController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
||||
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.user = Client.getUserInfo();
|
||||
|
||||
$scope.terminalVisible = true;
|
||||
$scope.logs = [];
|
||||
$scope.apps = [];
|
||||
$scope.selected = '';
|
||||
$scope.activeEventSource = null;
|
||||
$scope.terminal = null;
|
||||
$scope.terminalSocket = null;
|
||||
$scope.lines = 10;
|
||||
$scope.restartAppBusy = false;
|
||||
$scope.appBusy = false;
|
||||
$scope.selectedAppInfo = null;
|
||||
|
||||
function ab2str(buf) {
|
||||
return String.fromCharCode.apply(null, new Uint16Array(buf));
|
||||
}
|
||||
|
||||
$scope.downloadFile = {
|
||||
error: '',
|
||||
filePath: '',
|
||||
@@ -105,22 +96,17 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
fileUpload.click();
|
||||
};
|
||||
|
||||
$scope.populateLogTypes = function () {
|
||||
$scope.logs.push({ name: 'System (All)', type: 'platform', value: 'all', url: Client.makeURL('/api/v1/cloudron/logs?units=all') });
|
||||
$scope.logs.push({ name: 'Box', type: 'platform', value: 'box', url: Client.makeURL('/api/v1/cloudron/logs?units=box') });
|
||||
$scope.logs.push({ name: 'Mail', type: 'platform', value: 'mail', url: Client.makeURL('/api/v1/cloudron/logs?units=mail') });
|
||||
|
||||
$scope.populateDropdown = function () {
|
||||
Client.getInstalledApps().sort(function (app1, app2) { return app1.fqdn.localeCompare(app2.fqdn); }).forEach(function (app) {
|
||||
$scope.logs.push({
|
||||
$scope.apps.push({
|
||||
type: 'app',
|
||||
value: app.id,
|
||||
name: app.fqdn + ' (' + app.manifest.title + ')',
|
||||
url: Client.makeURL('/api/v1/apps/' + app.id + '/logs'),
|
||||
addons: app.manifest.addons
|
||||
});
|
||||
});
|
||||
|
||||
$scope.selected = $scope.logs[0];
|
||||
// $scope.selected = $scope.apps[0];
|
||||
};
|
||||
|
||||
$scope.usesAddon = function (addon) {
|
||||
@@ -129,15 +115,6 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
};
|
||||
|
||||
function reset() {
|
||||
// close the old event source so we wont receive any new logs
|
||||
if ($scope.activeEventSource) {
|
||||
$scope.activeEventSource.close();
|
||||
$scope.activeEventSource = null;
|
||||
}
|
||||
|
||||
var logViewer = $('#logsAndTerminalContainer');
|
||||
logViewer.empty();
|
||||
|
||||
if ($scope.terminal) {
|
||||
$scope.terminal.destroy();
|
||||
$scope.terminal = null;
|
||||
@@ -212,63 +189,17 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showLogs = function () {
|
||||
$scope.terminalVisible = false;
|
||||
|
||||
reset();
|
||||
|
||||
if (!$scope.selected) return;
|
||||
|
||||
var func = $scope.selected.type === 'platform' ? Client.getPlatformLogs : Client.getAppLogs;
|
||||
func($scope.selected.value, true, $scope.lines, function handleLogs(error, result) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.activeEventSource = result;
|
||||
result.onmessage = function handleMessage(message) {
|
||||
var data;
|
||||
|
||||
try {
|
||||
data = JSON.parse(message.data);
|
||||
} catch (e) {
|
||||
return console.error(e);
|
||||
}
|
||||
|
||||
// check if we want to auto scroll (this is before the appending, as that skews the check)
|
||||
var tmp = $('#logsAndTerminalContainer');
|
||||
var autoScroll = tmp[0].scrollTop > (tmp[0].scrollTopMax - 24);
|
||||
|
||||
var logLine = $('<div class="log-line">');
|
||||
var timeString = moment.utc(data.realtimeTimestamp/1000).format('MMM DD HH:mm:ss');
|
||||
logLine.html('<span class="time">' + timeString + ' </span>' + window.ansiToHTML(typeof data.message === 'string' ? data.message : ab2str(data.message)));
|
||||
tmp.append(logLine);
|
||||
|
||||
if (autoScroll) tmp[0].lastChild.scrollIntoView({ behavior: 'instant', block: 'end' });
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showTerminal = function (retry) {
|
||||
$scope.terminalVisible = true;
|
||||
|
||||
reset();
|
||||
|
||||
if (!$scope.selected) return;
|
||||
|
||||
// we can only connect to apps here
|
||||
if ($scope.selected.type !== 'app') {
|
||||
var tmp = $('#logsAndTerminalContainer');
|
||||
var logLine = $('<div class="log-line">');
|
||||
logLine.html('Terminal is only supported for apps, not for ' + $scope.selected.name);
|
||||
tmp.append(logLine);
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch current app state
|
||||
Client.refreshInstalledApps(function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.terminal = new Terminal();
|
||||
$scope.terminal.open(document.querySelector('#logsAndTerminalContainer'));
|
||||
$scope.terminal.open(document.querySelector('#terminalContainer'));
|
||||
$scope.terminal.fit();
|
||||
|
||||
try {
|
||||
@@ -282,7 +213,7 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
$scope.terminalReconnectTimeout = setTimeout(function () {
|
||||
// if the scope was already destroyed, do not reconnect
|
||||
if ($scope.$$destroyed) return;
|
||||
if ($scope.terminalVisible) $scope.showTerminal(true);
|
||||
$scope.showTerminal(true);
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
@@ -319,11 +250,10 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
$scope.$watch('selected', function (newVal) {
|
||||
if (!newVal) return;
|
||||
|
||||
if ($scope.terminalVisible) $scope.showTerminal();
|
||||
else $scope.showLogs();
|
||||
$scope.showTerminal();
|
||||
});
|
||||
|
||||
Client.onReady($scope.populateLogTypes);
|
||||
Client.onReady($scope.populateDropdown);
|
||||
|
||||
Client.onApps(function () {
|
||||
if ($scope.$$destroyed) return;
|
||||
@@ -346,12 +276,6 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
if ($scope.activeEventSource) {
|
||||
$scope.activeEventSource.onmessage = function () {};
|
||||
$scope.activeEventSource.close();
|
||||
$scope.activeEventSource = null;
|
||||
}
|
||||
|
||||
if ($scope.terminal) {
|
||||
$scope.terminal.destroy();
|
||||
}
|
||||
@@ -381,7 +305,7 @@ angular.module('Application').controller('DebugController', ['$scope', '$locatio
|
||||
$scope.terminal.focus();
|
||||
});
|
||||
|
||||
$('#logsAndTerminalContainer').on('contextmenu', function (e) {
|
||||
$('#terminalContainer').on('contextmenu', function (e) {
|
||||
if (!$scope.terminal) return true;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
/* global moment */
|
||||
/* global Terminal */
|
||||
|
||||
angular.module('Application').controller('LogsController', ['$scope', '$location', '$route', '$routeParams', 'Client', function ($scope, $location, $route, $routeParams, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
||||
|
||||
Reference in New Issue
Block a user