diff --git a/orion-ops-vue/src/components/log/LogAppender.vue b/orion-ops-vue/src/components/log/LogAppender.vue index e2ab4297..4012253d 100644 --- a/orion-ops-vue/src/components/log/LogAppender.vue +++ b/orion-ops-vue/src/components/log/LogAppender.vue @@ -202,7 +202,8 @@ export default { fit: null, search: null, links: null - } + }, + token: {} } }, methods: { @@ -212,6 +213,7 @@ export default { type: this.tailType, relId: this.relId }).then(({ data }) => { + this.token = data this.initLogTailView(data) }) }) @@ -263,6 +265,7 @@ export default { this.client = new WebSocket(this.$api.fileTail({ token: data.token })) this.client.onopen = () => { this.status = this.$enum.LOG_TAIL_STATUS.RUNNABLE.value + this.$emit('open') } this.client.onerror = () => { this.status = this.$enum.LOG_TAIL_STATUS.ERROR.value @@ -270,7 +273,10 @@ export default { this.client.onclose = (e) => { console.log('closed', e.code, e.reason) this.status = this.$enum.LOG_TAIL_STATUS.CLOSE.value - // this.term.write('\r\n\x1b[31m已断开连接...\x1b[0m') + if (e.code > 4000 && e.code < 5000) { + // 自定义错误信息 + this.term.write(`\x1b[93m${e.reason}\x1b[0m`) + } this.$emit('close') } this.client.onmessage = async event => { diff --git a/orion-ops-vue/src/components/log/LoggerViewModal.vue b/orion-ops-vue/src/components/log/LoggerViewModal.vue index 6214bfe8..5977a806 100644 --- a/orion-ops-vue/src/components/log/LoggerViewModal.vue +++ b/orion-ops-vue/src/components/log/LoggerViewModal.vue @@ -16,40 +16,46 @@ :appendStyle="{height: 'calc(100vh - 92px)'}" :relId="id" :tailType="$enum.FILE_TAIL_TYPE.TAIL_LIST.value" - :downloadType="$enum.FILE_DOWNLOAD_TYPE.TAIL_LIST_FILE.value"> + :downloadType="$enum.FILE_DOWNLOAD_TYPE.TAIL_LIST_FILE.value" + @open="loggerOpened" + @close="loggerClosed"> @@ -69,11 +75,20 @@ export default { return { id: null, file: {}, - visible: false + visible: false, + visibleCommand: false, + command: null, + sendLf: true, + closed: false } }, methods: { open(id) { + this.file = {} + this.visibleCommand = false + this.command = null + this.sendLf = true + this.closed = false this.visible = true this.id = id this.$api.getTailDetail({ @@ -86,12 +101,38 @@ export default { }, close() { this.id = null - this.file = {} this.visible = false this.$nextTick(() => { this.$refs.appender.clear() this.$refs.appender.close() }) + }, + loggerOpened() { + if (this.$refs.appender.token.tailMode === this.$enum.FILE_TAIL_MODE.TAIL.value) { + setTimeout(() => { + if (!this.closed) { + this.visibleCommand = true + } + }, 200) + } + }, + loggerClosed() { + this.closed = true + this.visibleCommand = false + }, + sendCommand() { + let command = this.command || '' + if (this.sendLf) { + command += '\n' + } + if (!command) { + return + } + this.command = '' + this.$api.writeTailCommand({ + token: this.$refs.appender.token.token, + command + }) } } } @@ -104,4 +145,17 @@ export default { align-items: center; } +.machine-log-info-container { + margin-right: 16px; + margin-top: -9px; + height: 1em; +} + +.log-info-wrapper { + color: rgba(0, 0, 0, .8); + max-width: 200px; + text-overflow: ellipsis; + display: inline-block; + overflow: hidden; +} diff --git a/orion-ops-vue/src/lib/api.js b/orion-ops-vue/src/lib/api.js index 2a8def75..7d669ab6 100644 --- a/orion-ops-vue/src/lib/api.js +++ b/orion-ops-vue/src/lib/api.js @@ -931,6 +931,13 @@ const $api = { return $http.$post('/file-tail/config', param, { skipErrorMessage: true }) }, + /** + * tail 输入命令 + */ + writeTailCommand: param => { + return $http.$post('/file-tail/write', param) + }, + /** * 应用环境列表 */ diff --git a/orion-ops-vue/src/views/log/LoggerList.vue b/orion-ops-vue/src/views/log/LoggerList.vue index e7003878..94a9c528 100644 --- a/orion-ops-vue/src/views/log/LoggerList.vue +++ b/orion-ops-vue/src/views/log/LoggerList.vue @@ -82,10 +82,21 @@