2018-05-27 22:37:03 +00:00
|
|
|
<template>
|
2018-06-03 06:36:20 +00:00
|
|
|
<div>
|
|
|
|
<navigation></navigation>
|
2018-07-19 05:48:19 +00:00
|
|
|
<div v-if="loadingServerData">
|
|
|
|
<div class="mt-6 h-16">
|
|
|
|
<div class="spinner spinner-xl spinner-thick blue"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="m-6 flex flex-no-shrink rounded animate fadein" v-else>
|
2018-06-03 16:31:43 +00:00
|
|
|
<div class="sidebar border-grey-lighter flex-no-shrink w-1/3 max-w-xs">
|
2018-07-16 02:47:31 +00:00
|
|
|
<div class="mr-6">
|
|
|
|
<div class="p-6 text-center bg-white border rounded">
|
2018-07-19 05:48:19 +00:00
|
|
|
<h3 class="mb-2 text-blue font-medium">{{server.name}}</h3>
|
|
|
|
<span class="text-grey-dark text-sm">{{server.node}}</span>
|
2018-07-16 02:47:31 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-6 p-4 text-center bg-white border rounded">
|
|
|
|
<button class="btn btn-red uppercase text-xs px-4 py-2">Stop</button>
|
|
|
|
<button class="btn btn-secondary uppercase text-xs px-4 py-2">Restart</button>
|
|
|
|
<button class="btn btn-secondary uppercase text-xs px-4 py-2">Kill</button>
|
2018-05-27 22:37:03 +00:00
|
|
|
</div>
|
2018-07-16 02:47:31 +00:00
|
|
|
<div class="mt-6 p-4 bg-white border rounded">
|
|
|
|
<progress-bar title="Memory" percent="33"></progress-bar>
|
|
|
|
<progress-bar title="CPU" percent="80" class="mt-4"></progress-bar>
|
|
|
|
<progress-bar title="Disk" percent="97" class="mt-4"></progress-bar>
|
2018-06-03 06:36:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="sidenav">
|
2018-07-21 05:34:30 +00:00
|
|
|
<router-link :to="{ name: '', params: { id: this.$route.params.id } }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<terminal-icon style="height: 1em;"></terminal-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Console
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-files' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<folder-icon style="height: 1em;"></folder-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Files
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-subusers' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<users-icon style="height: 1em;"></users-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Subusers
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-schedules' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<calendar-icon style="height: 1em;"></calendar-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Schedules
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-databases' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<database-icon style="height: 1em;"></database-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Databases
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-allocations' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<globe-icon style="height: 1em;"></globe-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Allocations
|
|
|
|
</router-link>
|
|
|
|
<router-link :to="{ name: 'server-settings' }">
|
2018-06-11 19:06:12 +00:00
|
|
|
<settings-icon style="height: 1em;"></settings-icon>
|
2018-06-03 16:31:43 +00:00
|
|
|
Settings
|
|
|
|
</router-link>
|
2018-05-27 22:37:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-07-21 22:20:37 +00:00
|
|
|
<div class="bg-white p-6 rounded border border-grey-light h-full w-full">
|
2018-07-19 05:48:19 +00:00
|
|
|
<router-view></router-view>
|
2018-05-27 22:37:03 +00:00
|
|
|
</div>
|
2018-07-19 05:48:19 +00:00
|
|
|
</div>
|
2018-05-27 22:37:03 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-07-19 05:48:19 +00:00
|
|
|
import { TerminalIcon, FolderIcon, UsersIcon, CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon } from 'vue-feather-icons'
|
2018-06-03 06:36:20 +00:00
|
|
|
import Navigation from '../core/Navigation';
|
2018-07-16 02:47:31 +00:00
|
|
|
import ProgressBar from './components/ProgressBar';
|
2018-07-19 05:48:19 +00:00
|
|
|
import {mapState} from 'vuex';
|
2018-07-21 05:34:30 +00:00
|
|
|
import { ConsolePage } from './subpages/ConsolePage';
|
2018-06-03 16:31:43 +00:00
|
|
|
|
2018-07-21 06:45:07 +00:00
|
|
|
import io from 'socket.io-client';
|
|
|
|
|
2018-05-27 22:37:03 +00:00
|
|
|
export default {
|
2018-06-11 19:06:12 +00:00
|
|
|
components: {
|
2018-07-21 05:34:30 +00:00
|
|
|
ProgressBar, Navigation, ConsolePage, TerminalIcon, FolderIcon, UsersIcon,
|
2018-06-11 19:06:12 +00:00
|
|
|
CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon
|
2018-07-19 05:48:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2018-07-21 06:45:07 +00:00
|
|
|
...mapState('server', ['server', 'credentials']),
|
2018-07-19 05:48:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted: function () {
|
|
|
|
this.loadServer();
|
2018-07-21 22:20:37 +00:00
|
|
|
|
|
|
|
this.$on('send-command', data => {
|
|
|
|
this.socket.emit('send command', data);
|
|
|
|
});
|
2018-07-19 05:48:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data: function () {
|
|
|
|
return {
|
2018-07-21 06:45:07 +00:00
|
|
|
socket: null,
|
2018-07-19 05:48:19 +00:00
|
|
|
loadingServerData: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2018-07-21 06:45:07 +00:00
|
|
|
/**
|
|
|
|
* Load the core server information needed for these pages to be functional.
|
|
|
|
*/
|
2018-07-19 05:48:19 +00:00
|
|
|
loadServer: function () {
|
2018-07-21 06:45:07 +00:00
|
|
|
Promise.all([
|
|
|
|
this.$store.dispatch('server/getServer', {server: this.$route.params.id}),
|
|
|
|
this.$store.dispatch('server/getCredentials', {server: this.$route.params.id})
|
|
|
|
])
|
2018-07-19 05:48:19 +00:00
|
|
|
.then(() => {
|
|
|
|
this.loadingServerData = false;
|
2018-07-21 06:45:07 +00:00
|
|
|
this.initalizeWebsocket();
|
2018-07-19 05:48:19 +00:00
|
|
|
})
|
2018-07-21 06:45:07 +00:00
|
|
|
.catch(console.error);
|
|
|
|
},
|
|
|
|
|
|
|
|
initalizeWebsocket: function () {
|
|
|
|
this.socket = io(this.credentials.node + '/v1/ws/' + this.server.uuid, {
|
|
|
|
query: 'token=' + this.credentials.key,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.socket.on('error', this._socket_error);
|
|
|
|
this.socket.on('connect', this._socket_connect);
|
|
|
|
this.socket.on('status', this._socket_status);
|
|
|
|
this.socket.on('initial status', this._socket_status);
|
|
|
|
this.socket.on('server log', this._socket_serverLog);
|
|
|
|
this.socket.on('console', this._socket_consoleLine);
|
|
|
|
},
|
|
|
|
|
|
|
|
_socket_error: function (err) {
|
|
|
|
console.error('there was a socket error:', err);
|
|
|
|
},
|
|
|
|
|
|
|
|
_socket_connect: function () {
|
|
|
|
this.socket.emit('send server log');
|
|
|
|
},
|
|
|
|
|
|
|
|
_socket_status: function (data) {
|
|
|
|
},
|
|
|
|
|
|
|
|
_socket_serverLog: function (data) {
|
|
|
|
data.split(/\n/g).forEach(item => {
|
2018-07-21 22:20:37 +00:00
|
|
|
this.$emit('console', item);
|
2018-07-21 06:45:07 +00:00
|
|
|
});
|
2018-07-19 05:48:19 +00:00
|
|
|
},
|
2018-07-21 06:45:07 +00:00
|
|
|
|
|
|
|
_socket_consoleLine: function (data) {
|
|
|
|
if(data.line) {
|
2018-07-21 22:20:37 +00:00
|
|
|
data.line.split(/\n/g).forEach(item => {
|
|
|
|
this.$emit('console', item);
|
2018-07-21 06:45:07 +00:00
|
|
|
});
|
|
|
|
}
|
2018-07-21 22:20:37 +00:00
|
|
|
},
|
2018-07-21 06:45:07 +00:00
|
|
|
},
|
2018-05-27 22:37:03 +00:00
|
|
|
}
|
|
|
|
</script>
|