2018-08-13 04:12:44 +00:00
|
|
|
<template lang='pug'>
|
|
|
|
v-dialog(v-model='isShown', width='90vw', max-width='1200')
|
|
|
|
.dialog-header
|
|
|
|
span Live Console
|
|
|
|
v-spacer
|
|
|
|
.caption.blue--text.text--lighten-3.mr-3 Streaming...
|
|
|
|
v-progress-circular(
|
|
|
|
indeterminate
|
|
|
|
color='blue lighten-3'
|
|
|
|
:size='20'
|
|
|
|
:width='2'
|
|
|
|
)
|
|
|
|
.consoleTerm(ref='consoleContainer')
|
|
|
|
v-toolbar(flat, color='grey darken-3', dark)
|
|
|
|
v-spacer
|
|
|
|
v-btn(outline, @click='clear')
|
|
|
|
v-icon(left) cancel_presentation
|
|
|
|
span Clear
|
|
|
|
v-btn(outline, @click='close')
|
|
|
|
v-icon(left) close
|
|
|
|
span Close
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import _ from 'lodash'
|
2019-09-16 03:20:40 +00:00
|
|
|
// import { Terminal } from 'xterm'
|
|
|
|
// import * as fit from 'xterm/lib/addons/fit/fit'
|
2018-08-13 04:12:44 +00:00
|
|
|
|
2018-09-30 18:20:26 +00:00
|
|
|
import livetrailSubscription from 'gql/admin/logging/logging-subscription-livetrail.gql'
|
|
|
|
|
2019-09-16 03:20:40 +00:00
|
|
|
// Terminal.applyAddon(fit)
|
2018-08-13 04:12:44 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
term: null,
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isShown: {
|
|
|
|
get() { return this.value },
|
|
|
|
set(val) { this.$emit('input', val) }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(newValue, oldValue) {
|
|
|
|
if (newValue) {
|
|
|
|
_.delay(() => {
|
2019-09-16 03:20:40 +00:00
|
|
|
// this.term = new Terminal()
|
2018-08-13 04:12:44 +00:00
|
|
|
this.term.open(this.$refs.consoleContainer)
|
|
|
|
this.term.writeln('Connecting to \x1B[1;3;31mconsole output\x1B[0m...')
|
2018-09-30 18:20:26 +00:00
|
|
|
|
|
|
|
this.attach()
|
2018-08-13 04:12:44 +00:00
|
|
|
}, 100)
|
|
|
|
} else {
|
|
|
|
this.term.dispose()
|
|
|
|
this.term = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-09-30 18:20:26 +00:00
|
|
|
|
2018-08-13 04:12:44 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clear() {
|
|
|
|
this.term.clear()
|
|
|
|
},
|
|
|
|
close() {
|
|
|
|
this.isShown = false
|
2018-09-30 18:20:26 +00:00
|
|
|
},
|
|
|
|
attach() {
|
|
|
|
const self = this
|
|
|
|
const observer = this.$apollo.subscribe({
|
|
|
|
query: livetrailSubscription
|
|
|
|
})
|
|
|
|
observer.subscribe({
|
|
|
|
next(data) {
|
|
|
|
const item = _.get(data, `data.loggingLiveTrail`, {})
|
|
|
|
console.info(item)
|
|
|
|
self.term.writeln(`${item.level}: ${item.output}`)
|
|
|
|
},
|
|
|
|
error(error) {
|
|
|
|
self.$store.commit('showNotification', {
|
|
|
|
style: 'red',
|
|
|
|
message: error.message,
|
|
|
|
icon: 'warning'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2018-08-13 04:12:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
.consoleTerm {
|
|
|
|
background-color: #000;
|
|
|
|
padding: 16px;
|
|
|
|
width: 100%;
|
|
|
|
height: 415px;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|