You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.7 KiB

  1. <template lang='pug'>
  2. v-dialog(v-model='isShown', width='90vw', max-width='1200')
  3. .dialog-header
  4. span Live Console
  5. v-spacer
  6. .caption.blue--text.text--lighten-3.mr-3 Streaming...
  7. v-progress-circular(
  8. indeterminate
  9. color='blue lighten-3'
  10. :size='20'
  11. :width='2'
  12. )
  13. .consoleTerm(ref='consoleContainer')
  14. v-toolbar(flat, color='grey darken-3', dark)
  15. v-spacer
  16. v-btn(outline, @click='clear')
  17. v-icon(left) cancel_presentation
  18. span Clear
  19. v-btn(outline, @click='close')
  20. v-icon(left) close
  21. span Close
  22. </template>
  23. <script>
  24. import _ from 'lodash'
  25. import { Terminal } from 'xterm'
  26. import * as fit from 'xterm/lib/addons/fit/fit'
  27. Terminal.applyAddon(fit)
  28. export default {
  29. term: null,
  30. props: {
  31. value: {
  32. type: Boolean,
  33. default: false
  34. }
  35. },
  36. computed: {
  37. isShown: {
  38. get() { return this.value },
  39. set(val) { this.$emit('input', val) }
  40. }
  41. },
  42. watch: {
  43. value(newValue, oldValue) {
  44. if (newValue) {
  45. _.delay(() => {
  46. this.term = new Terminal()
  47. this.term.open(this.$refs.consoleContainer)
  48. this.term.writeln('Connecting to \x1B[1;3;31mconsole output\x1B[0m...')
  49. }, 100)
  50. } else {
  51. this.term.dispose()
  52. this.term = null
  53. }
  54. }
  55. },
  56. mounted() {
  57. this.term = new Terminal()
  58. this.term.open(this.$refs.consoleContainer)
  59. },
  60. methods: {
  61. clear() {
  62. this.term.clear()
  63. },
  64. close() {
  65. this.isShown = false
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang='scss'>
  71. .consoleTerm {
  72. background-color: #000;
  73. padding: 16px;
  74. width: 100%;
  75. height: 415px;
  76. }
  77. </style>