🎨 修改批量执行模块格式.
This commit is contained in:
@@ -1,74 +0,0 @@
|
|||||||
import type { TableData } from '@arco-design/web-vue/es/table/interface';
|
|
||||||
import axios from 'axios';
|
|
||||||
import qs from 'query-string';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行记录查询响应
|
|
||||||
*/
|
|
||||||
export interface ExecLogQueryResponse extends TableData, ExecLogQueryExtraResponse {
|
|
||||||
id: number;
|
|
||||||
userId: number;
|
|
||||||
username: string;
|
|
||||||
description: string;
|
|
||||||
command: string;
|
|
||||||
parameterSchema: string;
|
|
||||||
timeout: number;
|
|
||||||
status: string;
|
|
||||||
startTime: number;
|
|
||||||
finishTime: number;
|
|
||||||
hostIdList: Array<number>;
|
|
||||||
hosts: Array<ExecHostLogQueryResponse>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行记录查询响应 拓展
|
|
||||||
*/
|
|
||||||
export interface ExecLogQueryExtraResponse {
|
|
||||||
hosts: Array<ExecHostLogQueryResponse>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主机执行记录查询响应
|
|
||||||
*/
|
|
||||||
export interface ExecHostLogQueryResponse extends TableData {
|
|
||||||
id: number;
|
|
||||||
logId: number;
|
|
||||||
hostId: number;
|
|
||||||
hostName: string;
|
|
||||||
hostAddress: string;
|
|
||||||
status: string;
|
|
||||||
command: string;
|
|
||||||
parameter: string;
|
|
||||||
exitStatus: number;
|
|
||||||
errorMessage: string;
|
|
||||||
startTime: number;
|
|
||||||
finishTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行状态查询响应
|
|
||||||
*/
|
|
||||||
export interface ExecStatusResponse {
|
|
||||||
logList: Array<ExecLogQueryResponse>;
|
|
||||||
hostList: Array<ExecHostLogQueryResponse>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询执行记录
|
|
||||||
*/
|
|
||||||
export function getExecLog(id: number) {
|
|
||||||
return axios.get<ExecLogQueryResponse>('/asset/exec-log/get', { params: { id } });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询命令执行状态
|
|
||||||
*/
|
|
||||||
export function getExecLogStatus(idList: Array<number>) {
|
|
||||||
return axios.get<ExecStatusResponse>('/asset/exec-log/status', {
|
|
||||||
params: { idList },
|
|
||||||
paramsSerializer: params => {
|
|
||||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 中断命令请求
|
|
||||||
*/
|
|
||||||
export interface ExecTailRequest {
|
|
||||||
execId?: number;
|
|
||||||
hostExecIdList?: Array<number>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看执行日志
|
|
||||||
*/
|
|
||||||
export function getExecLogTailToken(request: ExecTailRequest) {
|
|
||||||
return axios.post<string>('/asset/exec/tail-log', request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载执行日志文件
|
|
||||||
*/
|
|
||||||
export function downloadExecLogFile(id: number) {
|
|
||||||
return axios.get('/asset/exec/download-log', { unwrap: true, params: { id } });
|
|
||||||
}
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
import useVisible from '@/hooks/visible';
|
import useVisible from '@/hooks/visible';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { nextTick, ref } from 'vue';
|
import { nextTick, ref } from 'vue';
|
||||||
import { getExecLog } from '@/api/exec/exec-log';
|
import { getExecCommandLog } from '@/api/exec/exec-command-log';
|
||||||
import ExecLogPanel from '../panel/index.vue';
|
import ExecLogPanel from '../panel/index.vue';
|
||||||
|
|
||||||
const { visible, setVisible } = useVisible();
|
const { visible, setVisible } = useVisible();
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
// 获取执行日志
|
// 获取执行日志
|
||||||
const { data } = await getExecLog(id);
|
const { data } = await getExecCommandLog(id);
|
||||||
// 打开日志
|
// 打开日志
|
||||||
await nextTick(() => {
|
await nextTick(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -41,14 +41,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import { execHostStatusKey } from './const';
|
import { execHostStatusKey } from './const';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visibleBack: boolean;
|
visibleBack: boolean;
|
||||||
current: number;
|
current: number;
|
||||||
hosts: Array<ExecHostLogQueryResponse>;
|
hosts: Array<ExecCommandHostLogQueryResponse>;
|
||||||
}>();
|
}>();
|
||||||
const emits = defineEmits(['back', 'selected']);
|
const emits = defineEmits(['back', 'selected']);
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||||
import type { ILogAppender } from './const';
|
import type { ILogAppender } from './const';
|
||||||
import { onUnmounted, ref, nextTick, onMounted } from 'vue';
|
import { onUnmounted, ref, nextTick, onMounted } from 'vue';
|
||||||
import { getExecLogStatus } from '@/api/exec/exec-log';
|
import { getExecCommandLogStatus } from '@/api/exec/exec-command-log';
|
||||||
import { dictKeys, execHostStatus, execStatus } from './const';
|
import { dictKeys, execHostStatus, execStatus } from './const';
|
||||||
import ExecHost from './exec-host.vue';
|
import ExecHost from './exec-host.vue';
|
||||||
import LogView from './log-view.vue';
|
import LogView from './log-view.vue';
|
||||||
@@ -43,11 +43,11 @@
|
|||||||
const currentHostExecId = ref();
|
const currentHostExecId = ref();
|
||||||
const statusIntervalId = ref();
|
const statusIntervalId = ref();
|
||||||
const finishIntervalId = ref();
|
const finishIntervalId = ref();
|
||||||
const execLog = ref<ExecLogQueryResponse>();
|
const execLog = ref<ExecCommandLogQueryResponse>();
|
||||||
const appender = ref<ILogAppender>();
|
const appender = ref<ILogAppender>();
|
||||||
|
|
||||||
// 打开
|
// 打开
|
||||||
const open = (record: ExecLogQueryResponse) => {
|
const open = (record: ExecCommandLogQueryResponse) => {
|
||||||
appender.value = new LogAppender({ execId: record.id });
|
appender.value = new LogAppender({ execId: record.id });
|
||||||
execLog.value = record;
|
execLog.value = record;
|
||||||
currentHostExecId.value = record.hosts[0].id;
|
currentHostExecId.value = record.hosts[0].id;
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载状态
|
// 加载状态
|
||||||
const { data: { logList, hostList } } = await getExecLogStatus([execLog.value.id]);
|
const { data: { logList, hostList } } = await getExecCommandLogStatus([execLog.value.id]);
|
||||||
if (logList.length) {
|
if (logList.length) {
|
||||||
execLog.value.status = logList[0].status;
|
execLog.value.status = logList[0].status;
|
||||||
execLog.value.startTime = logList[0].startTime;
|
execLog.value.startTime = logList[0].startTime;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { ILogAppender, LogAddons, LogAppenderConf, LogDomRef } from './const';
|
import type { ILogAppender, LogAddons, LogAppenderConf, LogDomRef } from './const';
|
||||||
import { AppenderOptions } from './const';
|
import { AppenderOptions } from './const';
|
||||||
import type { ExecTailRequest } from '@/api/exec/exec';
|
import type { ExecCommandLogTailRequest } from '@/api/exec/exec-command-log';
|
||||||
import { getExecLogTailToken } from '@/api/exec/exec';
|
import { getExecCommandLogTailToken } from '@/api/exec/exec-command-log';
|
||||||
import { webSocketBaseUrl } from '@/utils/env';
|
import { webSocketBaseUrl } from '@/utils/env';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import { createWebSocket } from '@/utils';
|
import { createWebSocket } from '@/utils';
|
||||||
@@ -21,7 +21,7 @@ export default class LogAppender implements ILogAppender {
|
|||||||
|
|
||||||
private client?: WebSocket;
|
private client?: WebSocket;
|
||||||
|
|
||||||
private readonly config: ExecTailRequest;
|
private readonly config: ExecCommandLogTailRequest;
|
||||||
|
|
||||||
private readonly appenderRel: Record<string, LogAppenderConf>;
|
private readonly appenderRel: Record<string, LogAppenderConf>;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export default class LogAppender implements ILogAppender {
|
|||||||
|
|
||||||
private readonly fitAllFn: () => {};
|
private readonly fitAllFn: () => {};
|
||||||
|
|
||||||
constructor(config: ExecTailRequest) {
|
constructor(config: ExecCommandLogTailRequest) {
|
||||||
this.current = undefined as unknown as LogAppenderConf;
|
this.current = undefined as unknown as LogAppenderConf;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.appenderRel = {};
|
this.appenderRel = {};
|
||||||
@@ -142,7 +142,7 @@ export default class LogAppender implements ILogAppender {
|
|||||||
// 初始化 client
|
// 初始化 client
|
||||||
async openClient() {
|
async openClient() {
|
||||||
// 获取 token
|
// 获取 token
|
||||||
const { data } = await getExecLogTailToken(this.config);
|
const { data } = await getExecCommandLogTailToken(this.config);
|
||||||
// 打开会话
|
// 打开会话
|
||||||
try {
|
try {
|
||||||
this.client = await createWebSocket(`${webSocketBaseUrl}/exec/log/${data}`);
|
this.client = await createWebSocket(`${webSocketBaseUrl}/exec/log/${data}`);
|
||||||
|
|||||||
@@ -160,19 +160,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||||
import type { ILogAppender } from './const';
|
import type { ILogAppender } from './const';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { execHostStatus, execHostStatusKey } from './const';
|
import { execHostStatus, execHostStatusKey } from './const';
|
||||||
import { formatDuration } from '@/utils';
|
import { formatDuration } from '@/utils';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import { downloadExecLogFile } from '@/api/exec/exec';
|
import { downloadExecCommandLogFile } from '@/api/exec/exec-command-log';
|
||||||
import { downloadFile } from '@/utils/file';
|
import { downloadFile } from '@/utils/file';
|
||||||
import XtermSearchModal from '@/components/xtrem/search-modal/index.vue';
|
import XtermSearchModal from '@/components/xtrem/search-modal/index.vue';
|
||||||
import 'xterm/css/xterm.css';
|
import 'xterm/css/xterm.css';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
host: ExecHostLogQueryResponse;
|
host: ExecCommandHostLogQueryResponse;
|
||||||
appender: ILogAppender
|
appender: ILogAppender
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadLogFile = async (id: number) => {
|
const downloadLogFile = async (id: number) => {
|
||||||
const data = await downloadExecLogFile(id);
|
const data = await downloadExecCommandLogFile(id);
|
||||||
downloadFile(data);
|
downloadFile(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { VNodeRef } from 'vue';
|
import type { VNodeRef } from 'vue';
|
||||||
import type { ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
|
||||||
import type { LogDomRef, ILogAppender } from './const';
|
import type { LogDomRef, ILogAppender } from './const';
|
||||||
import { nextTick, ref, watch } from 'vue';
|
import { nextTick, ref, watch } from 'vue';
|
||||||
import LogItem from './log-item.vue';
|
import LogItem from './log-item.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
current: number;
|
current: number;
|
||||||
hosts: Array<ExecHostLogQueryResponse>;
|
hosts: Array<ExecCommandHostLogQueryResponse>;
|
||||||
appender: ILogAppender;
|
appender: ILogAppender;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref, nextTick } from 'vue';
|
import { onMounted, ref, nextTick } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { getExecLog } from '@/api/exec/exec-log';
|
import { getExecCommandLog } from '@/api/exec/exec-command-log';
|
||||||
import ExecLogPanel from '@/components/exec/log/panel/index.vue';
|
import ExecLogPanel from '@/components/exec/log/panel/index.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
// 初始化
|
// 初始化
|
||||||
const init = async (id: number) => {
|
const init = async (id: number) => {
|
||||||
// 获取执行日志
|
// 获取执行日志
|
||||||
const { data } = await getExecLog(id);
|
const { data } = await getExecCommandLog(id);
|
||||||
// 打开日志
|
// 打开日志
|
||||||
await nextTick(() => {
|
await nextTick(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -110,8 +110,8 @@
|
|||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import { useExpandable } from '@/types/table';
|
import { useExpandable } from '@/types/table';
|
||||||
import { dateFormat, formatDuration } from '@/utils';
|
import { dateFormat, formatDuration } from '@/utils';
|
||||||
import { downloadExecLogFile } from '@/api/exec/exec';
|
|
||||||
import { interruptHostExecCommand } from '@/api/exec/exec-command';
|
import { interruptHostExecCommand } from '@/api/exec/exec-command';
|
||||||
|
import { downloadExecCommandLogFile } from '@/api/exec/exec-command-log';
|
||||||
import { copy } from '@/hooks/copy';
|
import { copy } from '@/hooks/copy';
|
||||||
import { downloadFile } from '@/utils/file';
|
import { downloadFile } from '@/utils/file';
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadLogFile = async (id: number) => {
|
const downloadLogFile = async (id: number) => {
|
||||||
const data = await downloadExecLogFile(id);
|
const data = await downloadExecCommandLogFile(id);
|
||||||
downloadFile(data);
|
downloadFile(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user