🔨 抽象执行日志.
This commit is contained in:
36
orion-ops-ui/src/components/exec/log/const.ts
Normal file
36
orion-ops-ui/src/components/exec/log/const.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// 批量执行状态
|
||||
export const execStatus = {
|
||||
// 等待中
|
||||
WAITING: 'WAITING',
|
||||
// 运行中
|
||||
RUNNING: 'RUNNING',
|
||||
// 执行完成
|
||||
COMPLETED: 'COMPLETED',
|
||||
// 执行失败
|
||||
FAILED: 'FAILED',
|
||||
};
|
||||
|
||||
// 主机执行状态
|
||||
export const execHostStatus = {
|
||||
// 等待中
|
||||
WAITING: 'WAITING',
|
||||
// 运行中
|
||||
RUNNING: 'RUNNING',
|
||||
// 执行完成
|
||||
COMPLETED: 'COMPLETED',
|
||||
// 执行失败
|
||||
FAILED: 'FAILED',
|
||||
// 执行超时
|
||||
TIMEOUT: 'TIMEOUT',
|
||||
// 已中断
|
||||
INTERRUPTED: 'INTERRUPTED',
|
||||
};
|
||||
|
||||
// 执行状态 字典项
|
||||
export const execStatusKey = 'execStatus';
|
||||
|
||||
// 执行状态 字典项
|
||||
export const execHostStatusKey = 'execHostStatus';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [execStatusKey, execHostStatusKey];
|
||||
@@ -5,7 +5,7 @@ import type { WebLinksAddon } from 'xterm-addon-web-links';
|
||||
import type { WebglAddon } from 'xterm-addon-webgl';
|
||||
|
||||
// appender 配置
|
||||
export const AppenderOptions: ITerminalOptions & ITerminalInitOnlyOptions = {
|
||||
export const LogAppenderOptions: ITerminalOptions & ITerminalInitOnlyOptions = {
|
||||
theme: {
|
||||
foreground: '#FFFFFF',
|
||||
background: '#202020',
|
||||
@@ -97,44 +97,3 @@ export interface ILogAppender {
|
||||
// 关闭
|
||||
close(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量执行状态
|
||||
*/
|
||||
export const execStatus = {
|
||||
// 等待中
|
||||
WAITING: 'WAITING',
|
||||
// 运行中
|
||||
RUNNING: 'RUNNING',
|
||||
// 执行完成
|
||||
COMPLETED: 'COMPLETED',
|
||||
// 执行失败
|
||||
FAILED: 'FAILED',
|
||||
};
|
||||
|
||||
/**
|
||||
* 主机执行状态
|
||||
*/
|
||||
export const execHostStatus = {
|
||||
// 等待中
|
||||
WAITING: 'WAITING',
|
||||
// 运行中
|
||||
RUNNING: 'RUNNING',
|
||||
// 执行完成
|
||||
COMPLETED: 'COMPLETED',
|
||||
// 执行失败
|
||||
FAILED: 'FAILED',
|
||||
// 执行超时
|
||||
TIMEOUT: 'TIMEOUT',
|
||||
// 已中断
|
||||
INTERRUPTED: 'INTERRUPTED',
|
||||
};
|
||||
|
||||
// 执行状态 字典项
|
||||
export const execStatusKey = 'execStatus';
|
||||
|
||||
// 执行状态 字典项
|
||||
export const execHostStatusKey = 'execHostStatus';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [execStatusKey, execHostStatusKey];
|
||||
@@ -41,14 +41,14 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import { useDictStore } from '@/store';
|
||||
import { execHostStatusKey } from './const';
|
||||
import { execHostStatusKey } from '../const';
|
||||
|
||||
const props = defineProps<{
|
||||
visibleBack: boolean;
|
||||
current: number;
|
||||
hosts: Array<ExecCommandHostLogQueryResponse>;
|
||||
hosts: Array<ExecHostLogQueryResponse>;
|
||||
}>();
|
||||
const emits = defineEmits(['back', 'selected']);
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||
import type { ILogAppender } from './const';
|
||||
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import type { ILogAppender } from './appender-const';
|
||||
import { onUnmounted, ref, nextTick, onMounted } from 'vue';
|
||||
import { getExecCommandLogStatus } from '@/api/exec/exec-command-log';
|
||||
import { dictKeys, execHostStatus, execStatus } from './const';
|
||||
import { dictKeys, execHostStatus, execStatus } from '../const';
|
||||
import { useDictStore } from '@/store';
|
||||
import ExecHost from './exec-host.vue';
|
||||
import LogView from './log-view.vue';
|
||||
import LogAppender from '@/components/exec/log/panel/log-appender';
|
||||
import { useDictStore } from '@/store';
|
||||
|
||||
const props = defineProps<{
|
||||
visibleBack: boolean
|
||||
@@ -43,11 +43,11 @@
|
||||
const currentHostExecId = ref();
|
||||
const statusIntervalId = ref();
|
||||
const finishIntervalId = ref();
|
||||
const execLog = ref<ExecCommandLogQueryResponse>();
|
||||
const execLog = ref<ExecLogQueryResponse>();
|
||||
const appender = ref<ILogAppender>();
|
||||
|
||||
// 打开
|
||||
const open = (record: ExecCommandLogQueryResponse) => {
|
||||
const open = (record: ExecLogQueryResponse) => {
|
||||
appender.value = new LogAppender({ execId: record.id });
|
||||
execLog.value = record;
|
||||
currentHostExecId.value = record.hosts[0].id;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ILogAppender, LogAddons, LogAppenderConf, LogDomRef } from './const';
|
||||
import { AppenderOptions } from './const';
|
||||
import type { ExecCommandLogTailRequest } from '@/api/exec/exec-command-log';
|
||||
import type { ILogAppender, LogAddons, LogAppenderConf, LogDomRef } from './appender-const';
|
||||
import { LogAppenderOptions } from './appender-const';
|
||||
import type { ExecLogTailRequest } from '@/api/exec/exec-log';
|
||||
import { getExecCommandLogTailToken } from '@/api/exec/exec-command-log';
|
||||
import { webSocketBaseUrl } from '@/utils/env';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
@@ -21,7 +21,7 @@ export default class LogAppender implements ILogAppender {
|
||||
|
||||
private client?: WebSocket;
|
||||
|
||||
private readonly config: ExecCommandLogTailRequest;
|
||||
private readonly config: ExecLogTailRequest;
|
||||
|
||||
private readonly appenderRel: Record<string, LogAppenderConf>;
|
||||
|
||||
@@ -29,7 +29,7 @@ export default class LogAppender implements ILogAppender {
|
||||
|
||||
private readonly fitAllFn: () => {};
|
||||
|
||||
constructor(config: ExecCommandLogTailRequest) {
|
||||
constructor(config: ExecLogTailRequest) {
|
||||
this.current = undefined as unknown as LogAppenderConf;
|
||||
this.config = config;
|
||||
this.appenderRel = {};
|
||||
@@ -49,7 +49,7 @@ export default class LogAppender implements ILogAppender {
|
||||
// 打开 log-view
|
||||
for (let logDomRef of logDomRefs) {
|
||||
// 初始化 terminal
|
||||
const terminal = new Terminal(AppenderOptions);
|
||||
const terminal = new Terminal(LogAppenderOptions);
|
||||
// 初始化快捷键
|
||||
this.initCustomKey(terminal);
|
||||
// 初始化插件
|
||||
|
||||
@@ -160,10 +160,10 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||
import type { ILogAppender } from './const';
|
||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import type { ILogAppender } from './appender-const';
|
||||
import { ref } from 'vue';
|
||||
import { execHostStatus, execHostStatusKey } from './const';
|
||||
import { execHostStatus, execHostStatusKey } from '../const';
|
||||
import { formatDuration } from '@/utils';
|
||||
import { useDictStore } from '@/store';
|
||||
import { downloadExecCommandLogFile } from '@/api/exec/exec-command-log';
|
||||
@@ -172,7 +172,7 @@
|
||||
import 'xterm/css/xterm.css';
|
||||
|
||||
const props = defineProps<{
|
||||
host: ExecCommandHostLogQueryResponse;
|
||||
host: ExecHostLogQueryResponse;
|
||||
appender: ILogAppender
|
||||
}>();
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { VNodeRef } from 'vue';
|
||||
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||
import type { LogDomRef, ILogAppender } from './const';
|
||||
import type { LogDomRef, ILogAppender } from './appender-const';
|
||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import LogItem from './log-item.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
current: number;
|
||||
hosts: Array<ExecCommandHostLogQueryResponse>;
|
||||
hosts: Array<ExecHostLogQueryResponse>;
|
||||
appender: ILogAppender;
|
||||
}>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user