Show a spinner on the console when loading the contents initially
This commit is contained in:
parent
71d2a648ca
commit
034e759298
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidenav">
|
<div class="sidenav">
|
||||||
<router-link :to="{ name: '', params: { id: this.$route.params.id } }">
|
<router-link :to="{ name: 'server', params: { id: this.$route.params.id } }">
|
||||||
<terminal-icon style="height: 1em;"></terminal-icon>
|
<terminal-icon style="height: 1em;"></terminal-icon>
|
||||||
Console
|
Console
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -67,13 +67,12 @@
|
||||||
import Navigation from '../core/Navigation';
|
import Navigation from '../core/Navigation';
|
||||||
import ProgressBar from './components/ProgressBar';
|
import ProgressBar from './components/ProgressBar';
|
||||||
import {mapState} from 'vuex';
|
import {mapState} from 'vuex';
|
||||||
import { ConsolePage } from './subpages/ConsolePage';
|
|
||||||
|
|
||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ProgressBar, Navigation, ConsolePage, TerminalIcon, FolderIcon, UsersIcon,
|
ProgressBar, Navigation, TerminalIcon, FolderIcon, UsersIcon,
|
||||||
CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon
|
CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -87,6 +86,10 @@
|
||||||
this.$on('send-command', data => {
|
this.$on('send-command', data => {
|
||||||
this.socket.emit('send command', data);
|
this.socket.emit('send command', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$on('send-initial-log', () => {
|
||||||
|
this.socket.emit('send server log');
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
|
@ -126,14 +129,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
_socket_error: function (err) {
|
_socket_error: function (err) {
|
||||||
console.error('there was a socket error:', err);
|
this.$emit('socket-error', {err});
|
||||||
},
|
},
|
||||||
|
|
||||||
_socket_connect: function () {
|
_socket_connect: function () {
|
||||||
this.socket.emit('send server log');
|
this.$emit('socket-connected');
|
||||||
},
|
},
|
||||||
|
|
||||||
_socket_status: function (data) {
|
_socket_status: function (data) {
|
||||||
|
this.$emit('socket-status', {data});
|
||||||
},
|
},
|
||||||
|
|
||||||
_socket_serverLog: function (data) {
|
_socket_serverLog: function (data) {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="text-xs font-mono">
|
<div class="text-xs font-mono">
|
||||||
<div class="rounded-t p-2 bg-black overflow-scroll w-full" style="min-height: 16rem;max-height:64rem;">
|
<div class="rounded-t p-2 bg-black overflow-scroll w-full" style="min-height: 16rem;max-height:64rem;">
|
||||||
|
<div v-if="loadingConsole">
|
||||||
|
<div class="spinner spinner-xl mt-24"></div>
|
||||||
|
</div>
|
||||||
<div class="mb-2 text-grey-light" ref="terminal"></div>
|
<div class="mb-2 text-grey-light" ref="terminal"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-b bg-grey-darkest text-white flex">
|
<div class="rounded-b bg-grey-darkest text-white flex">
|
||||||
|
@ -24,19 +27,36 @@
|
||||||
<script>
|
<script>
|
||||||
import { Terminal } from 'xterm';
|
import { Terminal } from 'xterm';
|
||||||
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
|
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
|
||||||
|
import Status from './../../../helpers/statuses';
|
||||||
|
|
||||||
Terminal.applyAddon(TerminalFit);
|
Terminal.applyAddon(TerminalFit);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'console-page',
|
name: 'console-page',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mount the component and setup all of the terminal actions. Also fetches the initial
|
||||||
|
* logs from the server to populate into the terminal.
|
||||||
|
*/
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.terminal.open(this.$refs.terminal);
|
this.$parent.$on('socket-connected', () => {
|
||||||
this.terminal.fit();
|
this.terminal.open(this.$refs.terminal);
|
||||||
|
this.terminal.fit();
|
||||||
|
this.terminal.clear();
|
||||||
|
|
||||||
|
this.$parent.$emit('send-initial-log');
|
||||||
|
});
|
||||||
|
|
||||||
this.$parent.$on('console', data => {
|
this.$parent.$on('console', data => {
|
||||||
|
this.loadingConsole = false;
|
||||||
this.terminal.writeln(data);
|
this.terminal.writeln(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$parent.$on('socket-status', s => {
|
||||||
|
if (s === Status.STATUS_OFF) {
|
||||||
|
this.loadingConsole = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
|
@ -56,10 +76,14 @@
|
||||||
command: '',
|
command: '',
|
||||||
commandHistory: [],
|
commandHistory: [],
|
||||||
commandHistoryIndex: -1,
|
commandHistoryIndex: -1,
|
||||||
|
loadingConsole: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* Send a command to the server using the configured websocket.
|
||||||
|
*/
|
||||||
sendCommand: function () {
|
sendCommand: function () {
|
||||||
this.commandHistoryIndex = -1;
|
this.commandHistoryIndex = -1;
|
||||||
this.commandHistory.unshift(this.command);
|
this.commandHistory.unshift(this.command);
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
STATUS_OFF: 0,
|
||||||
|
STATUS_ON: 1,
|
||||||
|
STATUS_STARTING: 2,
|
||||||
|
STATUS_STOPPING: 3,
|
||||||
|
};
|
Loading…
Reference in New Issue