misc_pterodactyl-panel/resources/assets/scripts/components/server/subpages/ConsolePage.vue

69 lines
2.1 KiB
Vue
Raw Normal View History

2018-07-21 05:34:30 +00:00
<template>
<div>
<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="mb-2 text-grey-light" ref="terminal"></div>
2018-07-21 07:04:56 +00:00
</div>
<div class="rounded-b bg-grey-darkest text-white flex">
<div class="flex-no-shrink p-2">
<span class="font-bold">$</span>
</div>
<div class="w-full">
<input type="text" aria-label="Send console command" class="bg-transparent text-white p-2 pl-0 w-full" placeholder="enter command and press enter to send"
ref="command"
v-model="command"
v-on:keyup.enter="sendCommand"
>
2018-07-21 07:04:56 +00:00
</div>
2018-07-21 05:34:30 +00:00
</div>
</div>
</div>
</template>
<script>
import { Terminal } from 'xterm';
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
Terminal.applyAddon(TerminalFit);
2018-07-21 05:34:30 +00:00
export default {
name: 'console-page',
mounted: function () {
this.terminal.open(this.$refs.terminal);
this.terminal.fit();
this.$parent.$on('console', data => {
this.terminal.writeln(data);
});
},
data: function () {
return {
terminal: new Terminal({
disableStdin: true,
allowTransparency: true,
fontSize: 12,
fontFamily: 'Menlo,Monaco,Consolas,monospace',
rows: 30,
theme: {
background: 'transparent',
}
}),
command: '',
};
},
methods: {
sendCommand: function () {
this.$parent.$emit('send-command', this.command);
this.command = '';
}
}
2018-07-21 05:34:30 +00:00
};
</script>
<style lang="postcss">
@import "~xterm/src/xterm.css";
</style>