🔨 优化执行日志查看.
This commit is contained in:
@@ -81,7 +81,7 @@ public class TerminalConnectLogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@PostMapping("/session")
|
@PostMapping("/sessions")
|
||||||
@Operation(summary = "查询全部终端连接会话")
|
@Operation(summary = "查询全部终端连接会话")
|
||||||
@PreAuthorize("@ss.hasPermission('asset:terminal-connect-session:management:query')")
|
@PreAuthorize("@ss.hasPermission('asset:terminal-connect-session:management:query')")
|
||||||
public List<TerminalConnectLogVO> getTerminalConnectSessions(@Validated @RequestBody TerminalConnectLogQueryRequest request) {
|
public List<TerminalConnectLogVO> getTerminalConnectSessions(@Validated @RequestBody TerminalConnectLogQueryRequest request) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export interface TerminalConnectLogQueryRequest extends Pagination {
|
|||||||
hostId?: number;
|
hostId?: number;
|
||||||
hostAddress?: string;
|
hostAddress?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
token?: string;
|
sessionId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
startTimeRange?: string[];
|
startTimeRange?: string[];
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ export interface TerminalConnectLogQueryResponse extends TableData {
|
|||||||
hostName: string;
|
hostName: string;
|
||||||
hostAddress: string;
|
hostAddress: string;
|
||||||
type: string;
|
type: string;
|
||||||
token: string;
|
sessionId: string;
|
||||||
status: string;
|
status: string;
|
||||||
startTime: number;
|
startTime: number;
|
||||||
endTime: number;
|
endTime: number;
|
||||||
@@ -65,7 +65,7 @@ export function getTerminalConnectLogPage(request: TerminalConnectLogQueryReques
|
|||||||
* 查询全部终端连接会话
|
* 查询全部终端连接会话
|
||||||
*/
|
*/
|
||||||
export function getTerminalConnectSessions(request: TerminalConnectLogQueryRequest) {
|
export function getTerminalConnectSessions(request: TerminalConnectLogQueryRequest) {
|
||||||
return axios.post<Array<TerminalConnectLogQueryResponse>>('/asset/terminal-connect-log/session', request);
|
return axios.post<Array<TerminalConnectLogQueryResponse>>('/asset/terminal-connect-log/sessions', request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import type {
|
|||||||
ExecLogInterruptRequest,
|
ExecLogInterruptRequest,
|
||||||
ExecLogQueryRequest,
|
ExecLogQueryRequest,
|
||||||
ExecLogQueryResponse,
|
ExecLogQueryResponse,
|
||||||
ExecLogStatusResponse,
|
ExecLogStatusResponse
|
||||||
ExecLogTailRequest
|
|
||||||
} from './exec-log';
|
} from './exec-log';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import qs from 'query-string';
|
import qs from 'query-string';
|
||||||
@@ -25,6 +24,13 @@ export function getExecCommandLog(id: number) {
|
|||||||
return axios.get<ExecLogQueryResponse>('/asset/exec-command-log/get', { params: { id } });
|
return axios.get<ExecLogQueryResponse>('/asset/exec-command-log/get', { params: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询主机计划任务日志
|
||||||
|
*/
|
||||||
|
export function getExecCommandHostLog(id: number) {
|
||||||
|
return axios.get<ExecHostLogQueryResponse>('/asset/exec-command-log/get-host', { params: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询主机批量执行日志
|
* 查询主机批量执行日志
|
||||||
*/
|
*/
|
||||||
@@ -98,8 +104,8 @@ export function clearExecCommandLog(request: ExecLogClearRequest) {
|
|||||||
/**
|
/**
|
||||||
* 查看批量执行日志
|
* 查看批量执行日志
|
||||||
*/
|
*/
|
||||||
export function getExecCommandLogTailToken(request: ExecLogTailRequest) {
|
export function getExecCommandLogTailToken(id: number) {
|
||||||
return axios.post<string>('/asset/exec-command-log/tail', request);
|
return axios.get<string>('/asset/exec-command-log/tail', { params: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type {
|
|||||||
ExecLogQueryRequest,
|
ExecLogQueryRequest,
|
||||||
ExecLogQueryResponse,
|
ExecLogQueryResponse,
|
||||||
ExecLogStatusResponse,
|
ExecLogStatusResponse,
|
||||||
ExecLogTailRequest
|
|
||||||
} from './exec-log';
|
} from './exec-log';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import qs from 'query-string';
|
import qs from 'query-string';
|
||||||
@@ -25,6 +24,13 @@ export function getExecJobLog(id: number) {
|
|||||||
return axios.get<ExecLogQueryResponse>('/asset/exec-job-log/get', { params: { id } });
|
return axios.get<ExecLogQueryResponse>('/asset/exec-job-log/get', { params: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询主机计划任务日志
|
||||||
|
*/
|
||||||
|
export function getExecJobHostLog(id: number) {
|
||||||
|
return axios.get<ExecHostLogQueryResponse>('/asset/exec-job-log/get-host', { params: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询主机计划任务日志
|
* 查询主机计划任务日志
|
||||||
*/
|
*/
|
||||||
@@ -91,8 +97,8 @@ export function clearExecJobLog(request: ExecLogClearRequest) {
|
|||||||
/**
|
/**
|
||||||
* 查看计划任务日志
|
* 查看计划任务日志
|
||||||
*/
|
*/
|
||||||
export function getExecJobLogTailToken(request: ExecLogTailRequest) {
|
export function getExecJobLogTailToken(id: number) {
|
||||||
return axios.post<string>('/asset/exec-job-log/tail', request);
|
return axios.get<string>('/asset/exec-job-log/tail', { params: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export interface ExecJobQueryRequest extends Pagination {
|
|||||||
name?: string;
|
name?: string;
|
||||||
command?: string;
|
command?: string;
|
||||||
status?: number;
|
status?: number;
|
||||||
execUserId?: number;
|
|
||||||
queryRecentLog?: boolean;
|
queryRecentLog?: boolean;
|
||||||
|
execUserId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export interface ExecLogQueryExtraResponse {
|
|||||||
/**
|
/**
|
||||||
* 主机执行日志查询响应
|
* 主机执行日志查询响应
|
||||||
*/
|
*/
|
||||||
export interface ExecHostLogQueryResponse extends TableData {
|
export interface ExecHostLogQueryResponse extends TableData, ExecHostLogQueryResponseExtra {
|
||||||
id: number;
|
id: number;
|
||||||
logId: number;
|
logId: number;
|
||||||
hostId: number;
|
hostId: number;
|
||||||
@@ -66,6 +66,13 @@ export interface ExecHostLogQueryResponse extends TableData {
|
|||||||
finishTime: number;
|
finishTime: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主机执行日志额外参数
|
||||||
|
*/
|
||||||
|
export interface ExecHostLogQueryResponseExtra {
|
||||||
|
refreshed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行状态查询响应
|
* 执行状态查询响应
|
||||||
*/
|
*/
|
||||||
@@ -74,14 +81,6 @@ export interface ExecLogStatusResponse {
|
|||||||
hostList: Array<ExecHostLogQueryResponse>;
|
hostList: Array<ExecHostLogQueryResponse>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行日志 tail 请求
|
|
||||||
*/
|
|
||||||
export interface ExecLogTailRequest {
|
|
||||||
execId?: number;
|
|
||||||
hostExecIdList?: Array<number>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行中断命令请求
|
* 执行中断命令请求
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,15 +47,21 @@
|
|||||||
<template #handle="{ record }">
|
<template #handle="{ record }">
|
||||||
<div class="table-handle-wrapper">
|
<div class="table-handle-wrapper">
|
||||||
<!-- 命令 -->
|
<!-- 命令 -->
|
||||||
<a-button type="text"
|
<a-button v-permission="['asset:exec-command-log:query']"
|
||||||
|
type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="emits('viewCommand', record.command)">
|
:disabled="record.status === ExecHostStatus.WAITING"
|
||||||
|
:title="record.status === ExecHostStatus.WAITING ? '命令正在等待执行' : '查看命令'"
|
||||||
|
@click="doViewCommand(record)">
|
||||||
命令
|
命令
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 参数 -->
|
<!-- 参数 -->
|
||||||
<a-button type="text"
|
<a-button v-permission="['asset:exec-command-log:query']"
|
||||||
|
type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="emits('viewParams', record.parameter)">
|
:disabled="record.status === ExecHostStatus.WAITING"
|
||||||
|
:title="record.status === ExecHostStatus.WAITING ? '命令正在等待执行' : '查看参数'"
|
||||||
|
@click="doViewParams(record)">
|
||||||
参数
|
参数
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 下载 -->
|
<!-- 下载 -->
|
||||||
@@ -102,7 +108,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||||
import { deleteExecCommandHostLog } from '@/api/exec/exec-command-log';
|
import { deleteExecCommandHostLog, getExecCommandHostLog } from '@/api/exec/exec-command-log';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { hostColumns } from '../types/table.columns';
|
import { hostColumns } from '../types/table.columns';
|
||||||
@@ -124,6 +130,43 @@
|
|||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const { toOptions, getDictValue } = useDictStore();
|
const { toOptions, getDictValue } = useDictStore();
|
||||||
|
|
||||||
|
// 查看命令
|
||||||
|
const doViewCommand = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
// 刷新记录
|
||||||
|
if (!record.refreshed) {
|
||||||
|
await refreshRecord(record);
|
||||||
|
}
|
||||||
|
emits('viewCommand', record.command);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 查看参数
|
||||||
|
const doViewParams = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
// 刷新记录
|
||||||
|
if (!record.refreshed) {
|
||||||
|
await refreshRecord(record);
|
||||||
|
}
|
||||||
|
emits('viewParams', record.parameter);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新记录
|
||||||
|
const refreshRecord = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const { data } = await getExecCommandHostLog(record.id);
|
||||||
|
record.status = data.status;
|
||||||
|
record.command = data.command;
|
||||||
|
record.parameter = data.parameter;
|
||||||
|
record.exitCode = data.exitCode;
|
||||||
|
record.errorMessage = data.errorMessage;
|
||||||
|
record.startTime = data.startTime;
|
||||||
|
record.finishTime = data.finishTime;
|
||||||
|
record.refreshed = true;
|
||||||
|
} catch (e) {
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadLogFile = async (id: number) => {
|
const downloadLogFile = async (id: number) => {
|
||||||
const data = await downloadExecCommandLogFile(id);
|
const data = await downloadExecCommandLogFile(id);
|
||||||
@@ -147,10 +190,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 删除当前行
|
// 删除当前行
|
||||||
const deleteRow = async ({ id, logId }: {
|
const deleteRow = async ({ id, logId }: ExecHostLogQueryResponse) => {
|
||||||
id: number,
|
|
||||||
logId: number
|
|
||||||
}) => {
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// 调用删除接口
|
// 调用删除接口
|
||||||
|
|||||||
@@ -47,15 +47,21 @@
|
|||||||
<template #handle="{ record }">
|
<template #handle="{ record }">
|
||||||
<div class="table-handle-wrapper">
|
<div class="table-handle-wrapper">
|
||||||
<!-- 命令 -->
|
<!-- 命令 -->
|
||||||
<a-button type="text"
|
<a-button v-permission="['asset:exec-job-log:query']"
|
||||||
|
type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="emits('viewCommand', record.command)">
|
:disabled="record.status === ExecHostStatus.WAITING"
|
||||||
|
:title="record.status === ExecHostStatus.WAITING ? '命令正在等待执行' : '查看命令'"
|
||||||
|
@click="doViewCommand(record)">
|
||||||
命令
|
命令
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 参数 -->
|
<!-- 参数 -->
|
||||||
<a-button type="text"
|
<a-button v-permission="['asset:exec-job-log:query']"
|
||||||
|
type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="emits('viewParams', record.parameter)">
|
:disabled="record.status === ExecHostStatus.WAITING"
|
||||||
|
:title="record.status === ExecHostStatus.WAITING ? '命令正在等待执行' : '查看参数'"
|
||||||
|
@click="doViewParams(record)">
|
||||||
参数
|
参数
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 下载 -->
|
<!-- 下载 -->
|
||||||
@@ -102,7 +108,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
|
||||||
import { deleteExecJobHostLog, interruptHostExecJob } from '@/api/exec/exec-job-log';
|
import { deleteExecJobHostLog, getExecJobHostLog, interruptHostExecJob } from '@/api/exec/exec-job-log';
|
||||||
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
|
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore } from '@/store';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
@@ -124,6 +130,43 @@
|
|||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const { toOptions, getDictValue } = useDictStore();
|
const { toOptions, getDictValue } = useDictStore();
|
||||||
|
|
||||||
|
// 查看命令
|
||||||
|
const doViewCommand = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
// 刷新记录
|
||||||
|
if (!record.refreshed) {
|
||||||
|
await refreshRecord(record);
|
||||||
|
}
|
||||||
|
emits('viewCommand', record.command);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 查看参数
|
||||||
|
const doViewParams = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
// 刷新记录
|
||||||
|
if (!record.refreshed) {
|
||||||
|
await refreshRecord(record);
|
||||||
|
}
|
||||||
|
emits('viewParams', record.parameter);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新记录
|
||||||
|
const refreshRecord = async (record: ExecHostLogQueryResponse) => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const { data } = await getExecJobHostLog(record.id);
|
||||||
|
record.status = data.status;
|
||||||
|
record.command = data.command;
|
||||||
|
record.parameter = data.parameter;
|
||||||
|
record.exitCode = data.exitCode;
|
||||||
|
record.errorMessage = data.errorMessage;
|
||||||
|
record.startTime = data.startTime;
|
||||||
|
record.finishTime = data.finishTime;
|
||||||
|
record.refreshed = true;
|
||||||
|
} catch (e) {
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadLogFile = async (id: number) => {
|
const downloadLogFile = async (id: number) => {
|
||||||
const data = await downloadExecJobLogFile(id);
|
const data = await downloadExecJobLogFile(id);
|
||||||
@@ -147,10 +190,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 删除当前行
|
// 删除当前行
|
||||||
const deleteRow = async ({ id, logId }: {
|
const deleteRow = async ({ id, logId }: ExecHostLogQueryResponse) => {
|
||||||
id: number,
|
|
||||||
logId: number
|
|
||||||
}) => {
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
// 调用删除接口
|
// 调用删除接口
|
||||||
|
|||||||
Reference in New Issue
Block a user