🔨 优化代码逻辑.
This commit is contained in:
70
orion-visor-ui/src/api/terminal/terminal-file-log.ts
Normal file
70
orion-visor-ui/src/api/terminal/terminal-file-log.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* 终端文件操作日志 查询请求
|
||||
*/
|
||||
export interface TerminalFileLogQueryRequest extends Pagination, OrderDirection {
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
type?: string;
|
||||
result?: number;
|
||||
startTimeRange?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端文件操作日志 查询响应
|
||||
*/
|
||||
export interface TerminalFileLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
hostId: number;
|
||||
hostName: string;
|
||||
hostAddress: string;
|
||||
address: string;
|
||||
location: string;
|
||||
userAgent: string;
|
||||
paths: string[];
|
||||
type: string;
|
||||
result: string;
|
||||
startTime: number;
|
||||
extra: TerminalFileLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端文件操作日志 拓展对象
|
||||
*/
|
||||
export interface TerminalFileLogExtra {
|
||||
mod: number;
|
||||
target: string;
|
||||
maxCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询终端文件操作日志
|
||||
*/
|
||||
export function getTerminalFileLogPage(request: TerminalFileLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalFileLogQueryResponse>>('/terminal/terminal-file-log/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询终端文件操作日志数量
|
||||
*/
|
||||
export function getTerminalFileLogCount(request: TerminalFileLogQueryRequest) {
|
||||
return axios.post<number>('/terminal/terminal-file-log/count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除终端文件操作日志
|
||||
*/
|
||||
export function deleteTerminalFileLog(idList: Array<number>) {
|
||||
return axios.delete('/terminal/terminal-file-log/delete', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,74 +1,5 @@
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import { httpBaseUrl } from '@/utils/env';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 查询请求
|
||||
*/
|
||||
export interface TerminalSftpLogQueryRequest extends Pagination, OrderDirection {
|
||||
userId?: number;
|
||||
hostId?: number;
|
||||
type?: string;
|
||||
result?: number;
|
||||
startTimeRange?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 查询响应
|
||||
*/
|
||||
export interface TerminalSftpLogQueryResponse extends TableData {
|
||||
id: number;
|
||||
userId: number;
|
||||
username: number;
|
||||
hostId: number;
|
||||
hostName: string;
|
||||
hostAddress: string;
|
||||
address: string;
|
||||
location: string;
|
||||
userAgent: string;
|
||||
paths: string[];
|
||||
type: string;
|
||||
result: string;
|
||||
startTime: number;
|
||||
extra: TerminalSftpLogExtra;
|
||||
}
|
||||
|
||||
/**
|
||||
* SFTP 操作日志 拓展对象
|
||||
*/
|
||||
export interface TerminalSftpLogExtra {
|
||||
mod: number;
|
||||
target: string;
|
||||
maxCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询 SFTP 操作日志
|
||||
*/
|
||||
export function getTerminalSftpLogPage(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<DataGrid<TerminalSftpLogQueryResponse>>('/terminal/terminal-sftp/query-log', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 SFTP 操作日志数量
|
||||
*/
|
||||
export function getTerminalSftpLogCount(request: TerminalSftpLogQueryRequest) {
|
||||
return axios.post<number>('/terminal/terminal-sftp/log-count', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 SFTP 操作日志
|
||||
*/
|
||||
export function deleteTerminalSftpLog(idList: Array<number>) {
|
||||
return axios.delete('/terminal/terminal-sftp/delete-log', {
|
||||
params: { idList },
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 SFTP 文件内容
|
||||
|
||||
@@ -8,19 +8,19 @@ const ASSET_AUDIT: AppRouteRecordRaw[] = [
|
||||
component: DEFAULT_LAYOUT,
|
||||
children: [
|
||||
{
|
||||
name: 'connectLog',
|
||||
path: '/audit/connect-log',
|
||||
component: () => import('@/views/asset-audit/connect-log/index.vue'),
|
||||
name: 'terminalConnectLog',
|
||||
path: '/audit/terminal-connect-log',
|
||||
component: () => import('@/views/asset-audit/terminal-connect-log/index.vue'),
|
||||
},
|
||||
{
|
||||
name: 'connectSession',
|
||||
path: '/audit/connect-session',
|
||||
component: () => import('@/views/asset-audit/connect-session/index.vue'),
|
||||
name: 'terminalConnectSession',
|
||||
path: '/audit/terminal-connect-session',
|
||||
component: () => import('@/views/asset-audit/terminal-connect-session/index.vue'),
|
||||
},
|
||||
{
|
||||
name: 'sftpLog',
|
||||
path: '/audit/sftp-log',
|
||||
component: () => import('@/views/asset-audit/sftp-log/index.vue'),
|
||||
name: 'terminalFileLog',
|
||||
path: '/audit/terminal-file-log',
|
||||
component: () => import('@/views/asset-audit/terminal-file-log/index.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// 表名称
|
||||
export const TableName = 'sftp-log';
|
||||
|
||||
// sftp 操作类型
|
||||
export const SftpOperatorType = {
|
||||
SFTP_MOVE: 'terminal:sftp-move',
|
||||
SFTP_CHMOD: 'terminal:sftp-chmod',
|
||||
};
|
||||
|
||||
// 最大展示数量
|
||||
export const showPathMaxCount = 5;
|
||||
|
||||
// sftp 操作类型 字典项
|
||||
export const sftpOperatorTypeKey = 'sftpOperatorType';
|
||||
|
||||
// sftp 操作结果 字典项
|
||||
export const sftpOperatorResultKey = 'operatorLogResult';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [sftpOperatorTypeKey, sftpOperatorResultKey];
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'connectLog'
|
||||
name: 'terminalConnectLog'
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="table-left-bar-handle">
|
||||
<!-- 标题 -->
|
||||
<div class="table-title">
|
||||
主机在线会话
|
||||
终端在线会话
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'connectSession'
|
||||
name: 'terminalConnectSession'
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import ConnectSessionTable from './components/connect-session-table.vue';
|
||||
|
||||
const render = ref(false);
|
||||
const eventDrawer = ref();
|
||||
|
||||
// 加载字典配置
|
||||
onBeforeMount(async () => {
|
||||
@@ -24,14 +24,14 @@
|
||||
<a-form-item field="type" label="操作类型">
|
||||
<a-select v-model="formModel.type"
|
||||
placeholder="请选择类型"
|
||||
:options="toOptions(sftpOperatorTypeKey)"
|
||||
:options="toOptions(terminalFileOperatorTypeKey)"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行结果 -->
|
||||
<a-form-item field="result" label="执行结果">
|
||||
<a-select v-model="formModel.result"
|
||||
placeholder="请选择执行结果"
|
||||
:options="toOptions(sftpOperatorResultKey)"
|
||||
:options="toOptions(operatorResultKey)"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 开始时间 -->
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="table-left-bar-handle">
|
||||
<!-- 标题 -->
|
||||
<div class="table-title">
|
||||
文件操作日志
|
||||
终端文件日志
|
||||
</div>
|
||||
</div>
|
||||
<!-- 右侧操作 -->
|
||||
@@ -61,7 +61,7 @@
|
||||
position="br"
|
||||
type="warning"
|
||||
@ok="deleteSelectedRows">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'terminal:terminal-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'terminal:terminal-file-log:management:delete']"
|
||||
type="primary"
|
||||
status="danger"
|
||||
:disabled="selectedKeys.length === 0">
|
||||
@@ -110,7 +110,7 @@
|
||||
<!-- 操作类型 -->
|
||||
<template #type="{ record }">
|
||||
<a-tag color="arcoblue">
|
||||
{{ getDictValue(sftpOperatorTypeKey, record.type) }}
|
||||
{{ getDictValue(terminalFileOperatorTypeKey, record.type) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<!-- 文件数量 -->
|
||||
@@ -127,11 +127,11 @@
|
||||
{{ path }}
|
||||
</span>
|
||||
<!-- 移动目标路径 -->
|
||||
<span class="table-cell-sub-value" v-if="SftpOperatorType.SFTP_MOVE === record.type">
|
||||
<span class="table-cell-sub-value" v-if="TerminalFileOperatorType.SFTP_MOVE === record.type">
|
||||
移动到 {{ record.extra?.target }}
|
||||
</span>
|
||||
<!-- 提权信息 -->
|
||||
<span class="table-cell-sub-value" v-if="SftpOperatorType.SFTP_CHMOD === record.type">
|
||||
<span class="table-cell-sub-value" v-if="TerminalFileOperatorType.SFTP_CHMOD === record.type">
|
||||
提权 {{ record.extra?.mod }} {{ permission10toString(record.extra?.mod as number) }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -145,8 +145,8 @@
|
||||
</template>
|
||||
<!-- 执行结果 -->
|
||||
<template #result="{ record }">
|
||||
<a-tag :color="getDictValue(sftpOperatorResultKey, record.result, 'color')">
|
||||
{{ getDictValue(sftpOperatorResultKey, record.result) }}
|
||||
<a-tag :color="getDictValue(operatorResultKey, record.result, 'color')">
|
||||
{{ getDictValue(operatorResultKey, record.result) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
<!-- 留痕地址 -->
|
||||
@@ -169,7 +169,7 @@
|
||||
position="left"
|
||||
type="warning"
|
||||
@ok="deleteRow(record)">
|
||||
<a-button v-permission="['infra:operator-log:delete', 'terminal:terminal-sftp-log:management:delete']"
|
||||
<a-button v-permission="['infra:operator-log:delete', 'terminal:terminal-file-log:management:delete']"
|
||||
type="text"
|
||||
size="mini"
|
||||
status="danger">
|
||||
@@ -184,15 +184,15 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'sftpLogTable'
|
||||
name: 'fileLogTable'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { TerminalSftpLogQueryRequest, TerminalSftpLogQueryResponse } from '@/api/terminal/terminal-sftp';
|
||||
import type { TerminalFileLogQueryRequest, TerminalFileLogQueryResponse } from '@/api/terminal/terminal-file-log';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { getTerminalSftpLogPage, deleteTerminalSftpLog } from '@/api/terminal/terminal-sftp';
|
||||
import { TableName, sftpOperatorTypeKey, sftpOperatorResultKey, SftpOperatorType, showPathMaxCount } from '../types/const';
|
||||
import { getTerminalFileLogPage, deleteTerminalFileLog } from '@/api/terminal/terminal-file-log';
|
||||
import { TableName, terminalFileOperatorTypeKey, operatorResultKey, TerminalFileOperatorType, showPathMaxCount } from '../types/const';
|
||||
import { useTablePagination, useRowSelection, useTableColumns } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
@@ -212,9 +212,9 @@
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
|
||||
const tableRenderData = ref<Array<TerminalSftpLogQueryResponse>>([]);
|
||||
const tableRenderData = ref<Array<TerminalFileLogQueryResponse>>([]);
|
||||
const selectedKeys = ref<Array<number>>([]);
|
||||
const formModel = reactive<TerminalSftpLogQueryRequest>({
|
||||
const formModel = reactive<TerminalFileLogQueryRequest>({
|
||||
userId: undefined,
|
||||
hostId: undefined,
|
||||
type: undefined,
|
||||
@@ -223,11 +223,11 @@
|
||||
});
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: TerminalSftpLogQueryRequest) => {
|
||||
const doFetchTableData = async (request: TerminalFileLogQueryRequest) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 查询
|
||||
const { data } = await getTerminalSftpLogPage(queryOrder.markOrderly(request));
|
||||
const { data } = await getTerminalFileLogPage(queryOrder.markOrderly(request));
|
||||
// 设置最大数量
|
||||
data.rows.forEach(s => {
|
||||
s.extra.maxCount = showPathMaxCount;
|
||||
@@ -253,7 +253,7 @@
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteTerminalSftpLog(selectedKeys.value);
|
||||
await deleteTerminalFileLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载
|
||||
@@ -265,11 +265,11 @@
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async (record: TerminalSftpLogQueryResponse) => {
|
||||
const deleteRow = async (record: TerminalFileLogQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteTerminalSftpLog([record.id]);
|
||||
await deleteTerminalFileLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<div class="layout-container" v-if="render">
|
||||
<!-- 列表-表格 -->
|
||||
<sftp-log-table />
|
||||
<file-log-table />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'sftpLog'
|
||||
name: 'terminalFileLog'
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import SftpLogTable from './components/sftp-log-table.vue';
|
||||
import FileLogTable from './components/file-log-table.vue';
|
||||
|
||||
const render = ref(false);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// 表名称
|
||||
export const TableName = 'file-log';
|
||||
|
||||
// 终端文件操作类型
|
||||
export const TerminalFileOperatorType = {
|
||||
SFTP_MOVE: 'terminal:sftp-move',
|
||||
SFTP_CHMOD: 'terminal:sftp-chmod',
|
||||
};
|
||||
|
||||
// 最大展示数量
|
||||
export const showPathMaxCount = 5;
|
||||
|
||||
// 终端文件操作类型 字典项
|
||||
export const terminalFileOperatorTypeKey = 'terminalFileOperatorType';
|
||||
|
||||
// 操作结果 字典项
|
||||
export const operatorResultKey = 'operatorLogResult';
|
||||
|
||||
// 加载的字典值
|
||||
export const dictKeys = [terminalFileOperatorTypeKey, operatorResultKey];
|
||||
@@ -30,7 +30,7 @@ const columns = [
|
||||
title: '操作类型',
|
||||
dataIndex: 'type',
|
||||
slotName: 'type',
|
||||
width: 116,
|
||||
width: 146,
|
||||
align: 'left',
|
||||
default: true,
|
||||
}, {
|
||||
@@ -6,7 +6,7 @@
|
||||
<!-- 跳转 -->
|
||||
<span class="pointer span-blue"
|
||||
title="详情"
|
||||
@click="router.push({ name: 'connectLog', query: { action: 'self' } })">
|
||||
@click="router.push({ name: 'terminalConnectLog', query: { action: 'self' } })">
|
||||
详情
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
background: isDark.value ? '#354276' : '#E8F3FF',
|
||||
iconColor: isDark.value ? '#4A7FF7' : '#165DFF',
|
||||
},
|
||||
go: () => router.push({ name: 'connectLog', query: { action: 'self' } })
|
||||
go: () => router.push({ name: 'terminalConnectLog', query: { action: 'self' } })
|
||||
}, {
|
||||
title: '今日批量执行次数',
|
||||
value: props.data.exec?.todayExecCommandCount || 0,
|
||||
|
||||
Reference in New Issue
Block a user