');
- var timeString = moment.utc(data.realtimeTimestamp/1000).format('MMM DD HH:mm:ss');
- logLine.html('
' + timeString + ' ' + 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 = $('
');
- 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();
diff --git a/webadmin/src/views/logs.js b/webadmin/src/views/logs.js
index 164d5aaa9..128a0510b 100644
--- a/webadmin/src/views/logs.js
+++ b/webadmin/src/views/logs.js
@@ -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('/'); });