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 @@
-
+
打开
+ @click="openLogView($event, record.id)">
+
+ 打开
+
+
+
+
+
+ 打开
+
@@ -283,6 +294,12 @@ export default {
}
-
diff --git a/orion-ops-vue/src/views/log/LoggerView.vue b/orion-ops-vue/src/views/log/LoggerView.vue
index 2004eaf7..cb213896 100644
--- a/orion-ops-vue/src/views/log/LoggerView.vue
+++ b/orion-ops-vue/src/views/log/LoggerView.vue
@@ -50,40 +50,46 @@
:appendStyle="{height: 'calc(100vh - 100px)'}"
:relId="selectedTailFile.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(selectedTailFile)"
+ @close="loggerClosed(selectedTailFile)">
@@ -149,16 +155,18 @@ export default {
const tailListRes = await this.$api.getTailList({
limit: 10000
})
- this.tailList = tailListRes.data.rows.map(i => {
- return {
- id: i.id,
- name: i.name,
- path: i.path,
- fileName: i.fileName,
- machineName: i.machineName,
- machineHost: i.machineHost
- }
- })
+ this.tailList = tailListRes.data.rows
+ .filter(i => i.machineStatus === this.$enum.ENABLE_STATUS.ENABLE.value)
+ .map(i => {
+ return {
+ id: i.id,
+ name: i.name,
+ path: i.path,
+ fileName: i.fileName,
+ machineName: i.machineName,
+ machineHost: i.machineHost
+ }
+ })
this.filterTailList = [...this.tailList]
} catch (e) {
// ignore
@@ -185,7 +193,11 @@ export default {
path: filterTailFile.path,
fileName: filterTailFile.fileName,
machineName: filterTailFile.machineName,
- machineHost: filterTailFile.machineHost
+ machineHost: filterTailFile.machineHost,
+ visibleCommand: false,
+ command: null,
+ sendLf: true,
+ closed: false
})
this.$nextTick(() => {
const $ref = this.$refs['appender' + id]
@@ -219,6 +231,39 @@ export default {
}
this.selectedTailFiles = selectedTailFiles
this.activeTab = activeTab
+ },
+ loggerOpened(file) {
+ const $ref = this.$refs['appender' + file.id]
+ if ($ref && $ref.length) {
+ if ($ref[0].token.tailMode === this.$enum.FILE_TAIL_MODE.TAIL.value) {
+ setTimeout(() => {
+ if (!file.closed) {
+ file.visibleCommand = true
+ }
+ }, 200)
+ }
+ }
+ },
+ loggerClosed(file) {
+ file.closed = true
+ file.visibleCommand = false
+ },
+ sendCommand(file) {
+ const $ref = this.$refs['appender' + file.id]
+ if ($ref && $ref.length) {
+ let command = file.command || ''
+ if (file.sendLf) {
+ command += '\n'
+ }
+ if (!command) {
+ return
+ }
+ file.command = ''
+ this.$api.writeTailCommand({
+ token: $ref[0].token.token,
+ command
+ })
+ }
}
},
async mounted() {
@@ -293,4 +338,23 @@ export default {
padding: 6px 8px;
}
+.appender-left-tools {
+ display: flex;
+ 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;
+}
+