🔨 数据清理时添加条数限制.

This commit is contained in:
lijiahang
2024-08-29 18:26:26 +08:00
parent d7b747eac4
commit 104a9a0aa3
61 changed files with 490 additions and 283 deletions

View File

@@ -1,4 +1,4 @@
import type { DataGrid, Pagination } from '@/types/global';
import type { ClearRequest, DataGrid, Pagination } from '@/types/global';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import axios from 'axios';
import qs from 'query-string';
@@ -15,7 +15,12 @@ export interface HostConnectLogQueryRequest extends Pagination {
token?: string;
status?: string;
startTimeRange?: string[];
clearLimit?: number;
}
/**
* 主机连接日志清理请求
*/
export interface HostConnectLogClearRequest extends HostConnectLogQueryRequest, ClearRequest {
}
/**
@@ -89,13 +94,13 @@ export function deleteHostConnectLog(idList: Array<number>) {
* 查询主机连接日志数量
*/
export function getHostConnectLogCount(request: HostConnectLogQueryRequest) {
return axios.post<number>('/asset/host-connect-log/query-count', request);
return axios.post<number>('/asset/host-connect-log/count', request);
}
/**
* 清空主机连接日志
*/
export function clearHostConnectLog(request: HostConnectLogQueryRequest) {
export function clearHostConnectLog(request: HostConnectLogClearRequest) {
return axios.post<number>('/asset/host-connect-log/clear', request);
}

View File

@@ -1,3 +1,4 @@
import type { SelectOptionData } from '@arco-design/web-vue';
import type { DataGrid, Pagination } from '@/types/global';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import axios from 'axios';
@@ -160,6 +161,13 @@ export function getHostPage(request: HostQueryRequest) {
return axios.post<DataGrid<HostQueryResponse>>('/asset/host/query', request);
}
/**
* 查询主机数量
*/
export function getHostCount(request: HostQueryRequest) {
return axios.post<number>('/asset/host/count', request);
}
/**
* 通过 id 删除主机
*/

View File

@@ -1,6 +1,7 @@
import type { DataGrid } from '@/types/global';
import type {
ExecHostLogQueryResponse,
ExecLogClearRequest,
ExecLogInterruptRequest,
ExecLogQueryRequest,
ExecLogQueryResponse,
@@ -80,13 +81,13 @@ export function deleteExecCommandHostLog(id: number) {
* 查询批量执行日志数量
*/
export function getExecCommandLogCount(request: ExecLogQueryRequest) {
return axios.post<number>('/asset/exec-command-log/query-count', request);
return axios.post<number>('/asset/exec-command-log/count', request);
}
/**
* 清空批量执行日志
*/
export function clearExecCommandLog(request: ExecLogQueryRequest) {
export function clearExecCommandLog(request: ExecLogClearRequest) {
return axios.post<number>('/asset/exec-command-log/clear', request);
}

View File

@@ -1,4 +1,4 @@
import type { Pagination } from '@/types/global';
import type { ClearRequest, Pagination } from '@/types/global';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import { createAppWebSocket } from '@/utils/http';
@@ -13,7 +13,12 @@ export interface ExecLogQueryRequest extends Pagination {
command?: string;
status?: string;
startTimeRange?: string[];
clearLimit?: number;
}
/**
* 执行日志清理请求
*/
export interface ExecLogClearRequest extends ExecLogQueryRequest, ClearRequest {
}
/**

View File

@@ -1,4 +1,4 @@
import type { DataGrid, Pagination } from '@/types/global';
import type { ClearRequest, DataGrid, Pagination } from '@/types/global';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import axios from 'axios';
import qs from 'query-string';
@@ -40,7 +40,12 @@ export interface UploadTaskQueryRequest extends Pagination {
description?: string;
status?: string;
createTimeRange?: string[];
clearLimit?: number;
}
/**
* 上传任务清理请求
*/
export interface UploadTaskClearRequest extends UploadTaskQueryRequest, ClearRequest {
}
/**
@@ -170,12 +175,12 @@ export function batchDeleteUploadTask(idList: Array<number>) {
* 查询主机连接日志数量
*/
export function getUploadTaskCount(request: UploadTaskQueryRequest) {
return axios.post<number>('/asset/upload-task/query-count', request);
return axios.post<number>('/asset/upload-task/count', request);
}
/**
* 清空主机连接日志
*/
export function clearUploadTask(request: UploadTaskQueryRequest) {
export function clearUploadTask(request: UploadTaskClearRequest) {
return axios.post<number>('/asset/upload-task/clear', request);
}

View File

@@ -1,6 +1,7 @@
import type { DataGrid } from '@/types/global';
import type {
ExecHostLogQueryResponse,
ExecLogClearRequest,
ExecLogInterruptRequest,
ExecLogQueryRequest,
ExecLogQueryResponse,
@@ -73,13 +74,13 @@ export function deleteExecJobHostLog(id: number) {
* 查询计划任务日志数量
*/
export function getExecJobLogCount(request: ExecLogQueryRequest) {
return axios.post<number>('/asset/exec-job-log/query-count', request);
return axios.post<number>('/asset/exec-job-log/count', request);
}
/**
* 清空计划任务日志
*/
export function clearExecJobLog(request: ExecLogQueryRequest) {
export function clearExecJobLog(request: ExecLogClearRequest) {
return axios.post<number>('/asset/exec-job-log/clear', request);
}

View File

@@ -1,5 +1,19 @@
import axios from 'axios';
/**
* 应用信息查询响应
*/
export interface SystemLicenseResponse {
userCount: number;
hostCount: number;
release: string;
releaseName: string;
issueDate: number;
expireDate: number;
expireDay: number;
uuid: string;
}
/**
* 应用信息查询响应
*/
@@ -9,13 +23,20 @@ export interface AppInfoResponse {
}
/**
* 仓库版本信息查询响应
* 应用最新版本信息
*/
export interface RepoReleaseResponse {
tag_name: string;
export interface AppReleaseResponse {
tagName: string;
body: string;
}
/**
* 查询 license 信息
*/
export function getSystemLicenseInfo() {
return axios.get<SystemLicenseResponse>('/infra/system-setting/license');
}
/**
* 查询应用信息
*/
@@ -24,10 +45,10 @@ export function getSystemAppInfo() {
}
/**
* 获取仓库最后版本信息
* 获取应用最新版本信息
*/
export function getRepoLatestRelease() {
return axios.get<RepoReleaseResponse>('https://visor.orionsec.cn/releases-latest.json', {
export function getAppLatestRelease() {
return axios.get<AppReleaseResponse>('https://visor.orionsec.cn/releases-latest.json', {
// 不添加请求头 否则会报 401
setAuthorization: false,
// 返回原始输出

View File

@@ -1,4 +1,4 @@
import type { DataGrid, Pagination } from '@/types/global';
import type { ClearRequest, DataGrid, Pagination } from '@/types/global';
import axios from 'axios';
import qs from 'query-string';
@@ -13,7 +13,12 @@ export interface OperatorLogQueryRequest extends Pagination {
riskLevel?: string;
result?: number;
startTimeRange?: string[];
clearLimit?: number;
}
/**
* 操作日志清理参数
*/
export interface OperatorLogClearRequest extends OperatorLogQueryRequest, ClearRequest {
}
/**
@@ -65,12 +70,12 @@ export function deleteOperatorLog(idList: Array<number>) {
* 查询操作日志数量
*/
export function getOperatorLogCount(request: OperatorLogQueryRequest) {
return axios.post<number>('/infra/operator-log/query-count', request);
return axios.post<number>('/infra/operator-log/count', request);
}
/**
* 清空操作日志
*/
export function clearOperatorLog(request: OperatorLogQueryRequest) {
export function clearOperatorLog(request: OperatorLogClearRequest) {
return axios.post<number>('/infra/operator-log/clear', request);
}

View File

@@ -30,6 +30,10 @@ export interface Pagination {
limit?: number;
}
export interface ClearRequest {
limit?: number;
}
export interface NodeData {
[key: string]: any;
}

View File

@@ -55,12 +55,12 @@
:options="toOptions(connectTypeKey)"
allow-clear />
</a-form-item>
<!-- 清理数量 -->
<a-form-item field="clearLimit" label="清理数量">
<a-input-number v-model="formModel.clearLimit"
<!-- 数量限制 -->
<a-form-item field="limit" label="数量限制">
<a-input-number v-model="formModel.limit"
:min="1"
:max="clearLimit"
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
:max="maxLimit"
:placeholder="`请输入数量限制 最大: ${maxLimit}`"
hide-button
allow-clear />
</a-form-item>
@@ -80,7 +80,7 @@
import { ref } from 'vue';
import useLoading from '@/hooks/loading';
import useVisible from '@/hooks/visible';
import { connectStatusKey, connectTypeKey, clearLimit } from '../types/const';
import { connectStatusKey, connectTypeKey, maxClearLimit } from '../types/const';
import { getHostConnectLogCount, clearHostConnectLog } from '@/api/asset/host-connect-log';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
@@ -101,14 +101,16 @@
type: undefined,
status: undefined,
startTimeRange: undefined,
clearLimit,
limit: maxLimit.value,
};
};
const maxLimit = ref<number>(0);
const formModel = ref<HostConnectLogQueryRequest>({});
// 打开
const open = (record: any) => {
maxLimit.value = maxClearLimit;
renderForm({ ...defaultForm(), ...record });
setVisible(true);
};
@@ -122,8 +124,8 @@
// 确定
const handlerOk = async () => {
if (!formModel.value.clearLimit) {
Message.error('请输入清理数量');
if (!formModel.value.limit) {
Message.error('请输入数量限制');
return false;
}
setLoading(true);
@@ -148,7 +150,7 @@
const doClear = (count: number) => {
Modal.confirm({
title: '删除清空',
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
onOk: async () => {
setLoading(true);
try {

View File

@@ -12,8 +12,8 @@ export const HostConnectStatus = {
FORCE_OFFLINE: 'FORCE_OFFLINE',
};
// 清理数量
export const clearLimit = 2000;
// 最大清理数量
export const maxClearLimit = 2000;
// 主机连接状态 字典项
export const connectStatusKey = 'hostConnectStatus';

View File

@@ -14,7 +14,6 @@
@close="handleClose">
<a-spin class="full" :loading="loading">
<a-form :model="formModel"
ref="formRef"
label-align="right"
:auto-label-width="true">
<!-- 执行时间 -->
@@ -48,12 +47,12 @@
:options="toOptions(execStatusKey)"
placeholder="请选择执行状态" />
</a-form-item>
<!-- 清理数量 -->
<a-form-item field="clearLimit" label="清理数量">
<a-input-number v-model="formModel.clearLimit"
<!-- 数量限制 -->
<a-form-item field="limit" label="数量限制">
<a-input-number v-model="formModel.limit"
:min="1"
:max="clearLimit"
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
:max="maxLimit"
:placeholder="`请输入数量限制 最大: ${maxLimit}`"
hide-button
allow-clear />
</a-form-item>
@@ -77,7 +76,7 @@
import { getExecCommandLogCount, clearExecCommandLog } from '@/api/exec/exec-command-log';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
import { clearLimit } from '../types/const';
import { maxClearLimit } from '../types/const';
import UserSelector from '@/components/user/user/selector/index.vue';
const emits = defineEmits(['clear']);
@@ -86,7 +85,7 @@
const { loading, setLoading } = useLoading();
const { toOptions } = useDictStore();
const formRef = ref<any>();
const maxLimit = ref<number>(0);
const formModel = ref<ExecLogQueryRequest>({});
const defaultForm = (): ExecLogQueryRequest => {
@@ -97,12 +96,13 @@
command: undefined,
status: undefined,
startTimeRange: undefined,
clearLimit,
limit: maxLimit.value,
};
};
// 打开
const open = (record: any) => {
maxLimit.value = maxClearLimit;
renderForm({ ...defaultForm(), ...record });
setVisible(true);
};
@@ -116,8 +116,8 @@
// 确定
const handlerOk = async () => {
if (!formModel.value.clearLimit) {
Message.error('请输入清理数量');
if (!formModel.value.limit) {
Message.error('请输入数量限制');
return false;
}
setLoading(true);
@@ -142,7 +142,7 @@
const doClear = (count: number) => {
Modal.confirm({
title: '删除清空',
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
onOk: async () => {
setLoading(true);
try {

View File

@@ -1,2 +1,2 @@
// 清理数量
export const clearLimit = 1000;
// 最大清理数量
export const maxClearLimit = 1000;

View File

@@ -14,7 +14,6 @@
@close="handleClose">
<a-spin class="full" :loading="loading">
<a-form :model="formModel"
ref="formRef"
label-align="right"
:auto-label-width="true">
<!-- 上传时间 -->
@@ -49,12 +48,12 @@
placeholder="请选择状态"
allow-clear />
</a-form-item>
<!-- 清理数量 -->
<a-form-item field="clearLimit" label="清理数量">
<a-input-number v-model="formModel.clearLimit"
<!-- 数量限制 -->
<a-form-item field="limit" label="数量限制">
<a-input-number v-model="formModel.limit"
:min="1"
:max="clearLimit"
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
:max="maxLimit"
:placeholder="`请输入数量限制 最大: ${maxLimit}`"
hide-button
allow-clear />
</a-form-item>
@@ -74,7 +73,7 @@
import { ref } from 'vue';
import useLoading from '@/hooks/loading';
import useVisible from '@/hooks/visible';
import { clearLimit, uploadTaskStatusKey } from '../types/const';
import { maxClearLimit, uploadTaskStatusKey } from '../types/const';
import { getUploadTaskCount, clearUploadTask } from '@/api/exec/upload-task';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
@@ -86,7 +85,7 @@
const { loading, setLoading } = useLoading();
const { toOptions } = useDictStore();
const formRef = ref<any>();
const maxLimit = ref<number>(0);
const formModel = ref<UploadTaskQueryRequest>({});
const defaultForm = (): UploadTaskQueryRequest => {
@@ -96,11 +95,13 @@
description: undefined,
status: undefined,
createTimeRange: undefined,
limit: maxLimit.value,
};
};
// 打开
const open = (record: any) => {
maxLimit.value = maxClearLimit;
renderForm({ ...defaultForm(), ...record });
setVisible(true);
};
@@ -114,8 +115,8 @@
// 确定
const handlerOk = async () => {
if (!formModel.value.clearLimit) {
Message.error('请输入清理数量');
if (!formModel.value.limit) {
Message.error('请输入数量限制');
return false;
}
setLoading(true);
@@ -140,7 +141,7 @@
const doClear = (count: number) => {
Modal.confirm({
title: '删除清空',
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
onOk: async () => {
setLoading(true);
try {

View File

@@ -26,8 +26,8 @@ export const UploadTaskFileStatus = {
CANCELED: 'CANCELED',
};
// 清理数量
export const clearLimit = 2000;
// 最大清理数量
export const maxClearLimit = 2000;
// 上传任务状态 字典项
export const uploadTaskStatusKey = 'uploadTaskStatus';

View File

@@ -14,7 +14,6 @@
@close="handleClose">
<a-spin class="full" :loading="loading">
<a-form :model="formModel"
ref="formRef"
label-align="right"
:auto-label-width="true">
<!-- 执行时间 -->
@@ -43,12 +42,12 @@
:options="toOptions(execStatusKey)"
placeholder="请选择执行状态" />
</a-form-item>
<!-- 清理数量 -->
<a-form-item field="clearLimit" label="清理数量">
<a-input-number v-model="formModel.clearLimit"
<!-- 数量限制 -->
<a-form-item field="limit" label="数量限制">
<a-input-number v-model="formModel.limit"
:min="1"
:max="clearLimit"
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
:max="maxLimit"
:placeholder="`请输入数量限制 最大: ${maxLimit}`"
hide-button
allow-clear />
</a-form-item>
@@ -72,7 +71,7 @@
import { getExecJobLogCount, clearExecJobLog } from '@/api/job/exec-job-log';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
import { clearLimit } from '../types/const';
import { maxClearLimit } from '../types/const';
import ExecJobSelector from '@/components/exec/job/selector/index.vue';
const emits = defineEmits(['clear']);
@@ -81,7 +80,7 @@
const { loading, setLoading } = useLoading();
const { toOptions } = useDictStore();
const formRef = ref<any>();
const maxLimit = ref<number>(0);
const formModel = ref<ExecLogQueryRequest>({});
const defaultForm = (): ExecLogQueryRequest => {
@@ -92,12 +91,13 @@
command: undefined,
status: undefined,
startTimeRange: undefined,
clearLimit,
limit: maxLimit.value,
};
};
// 打开
const open = (record: any) => {
maxLimit.value = maxClearLimit;
renderForm({ ...defaultForm(), ...record });
setVisible(true);
};
@@ -111,8 +111,8 @@
// 确定
const handlerOk = async () => {
if (!formModel.value.clearLimit) {
Message.error('请输入清理数量');
if (!formModel.value.limit) {
Message.error('请输入数量限制');
return false;
}
setLoading(true);
@@ -137,7 +137,7 @@
const doClear = (count: number) => {
Modal.confirm({
title: '删除清空',
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
onOk: async () => {
setLoading(true);
try {

View File

@@ -1,2 +1,2 @@
// 清理数量
export const clearLimit = 1000;
// 最大清理数量
export const maxClearLimit = 1000;

View File

@@ -4,13 +4,13 @@
<!-- 不一致提示 -->
<a-alert v-if="app.version && webVersion !== app.version"
class="alert-wrapper">
当前前端版本与后端版本不一致, 请使用 Ctrl + F5 刷新页面
当前前端版本与后端版本不一致, 请使用 Ctrl + F5 强制刷新页面
</a-alert>
<!-- 升级提示 -->
<a v-if="app.version && repo.tag_name && ('v' + app.version) !== repo.tag_name"
<a v-if="app.version && repo.tagName && ('v' + app.version) !== repo.tagName"
class="alert-href"
target="_blank"
:href="`https://github.com/dromara/orion-visor/releases/tag/${repo.tag_name}`">
:href="`https://github.com/dromara/orion-visor/releases/tag/${repo.tagName}`">
<a-alert class="alert-wrapper">
新版本已发布, 请及时升级版本
</a-alert>
@@ -23,7 +23,7 @@
:column="1">
<!-- 机器码 -->
<a-descriptions-item label="机器码">
<span class="text-copy span-blue uuid-wrapper" @click="copy(app.uuid, true)">
<span class="text-copy uuid-wrapper" @click="copy(app.uuid, true)">
{{ app.uuid }}
</span>
</a-descriptions-item>
@@ -37,7 +37,7 @@
</a-descriptions-item>
<!-- 当前后端版本 -->
<a-descriptions-item label="最新发布版本">
{{ repo.tag_name }}
{{ repo.tagName }}
</a-descriptions-item>
<!-- 当前后端版本 -->
<a-descriptions-item label="最新更新日志">
@@ -58,9 +58,9 @@
</script>
<script lang="ts" setup>
import type { AppInfoResponse, RepoReleaseResponse } from '@/api/system/setting';
import type { AppInfoResponse, AppReleaseResponse } from '@/api/system/setting';
import { onMounted, reactive } from 'vue';
import { getRepoLatestRelease, getSystemAppInfo } from '@/api/system/setting';
import { getAppLatestRelease, getSystemAppInfo } from '@/api/system/setting';
import { copy } from '@/hooks/copy';
import { Message } from '@arco-design/web-vue';
@@ -71,8 +71,8 @@
uuid: '',
});
const repo = reactive<RepoReleaseResponse>({
tag_name: '',
const repo = reactive<AppReleaseResponse>({
tagName: '',
body: '',
});
@@ -86,14 +86,14 @@
}
});
// 加载仓库信息
// 加载版本信息
onMounted(async () => {
try {
const { data } = await getRepoLatestRelease();
repo.tag_name = data.tag_name;
const { data } = await getAppLatestRelease();
repo.tagName = data.tagName;
repo.body = data.body;
} catch (e) {
Message.error('获取仓库信息失败, 请等待后重试');
Message.error('获取应用最新版本失败, 请等待后重试');
}
});
@@ -116,6 +116,7 @@
}
.uuid-wrapper {
color: rgb(var(--arcoblue-6));
font-weight: 600;
}

View File

@@ -61,12 +61,12 @@
placeholder="请选择执行结果"
allow-clear />
</a-form-item>
<!-- 清理数量 -->
<a-form-item field="clearLimit" label="清理数量">
<a-input-number v-model="formModel.clearLimit"
<!-- 数量限制 -->
<a-form-item field="limit" label="数量限制">
<a-input-number v-model="formModel.limit"
:min="1"
:max="clearLimit"
:placeholder="`请输入最大清理数量 最大: ${clearLimit}`"
:max="maxLimit"
:placeholder="`请输入数量限制 最大: ${maxLimit}`"
hide-button
allow-clear />
</a-form-item>
@@ -90,7 +90,7 @@
import { getOperatorLogCount, clearOperatorLog } from '@/api/user/operator-log';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
import { operatorLogModuleKey, operatorLogResultKey, operatorLogTypeKey, operatorRiskLevelKey, clearLimit } from '../types/const';
import { operatorLogModuleKey, operatorLogResultKey, operatorLogTypeKey, operatorRiskLevelKey, maxClearLimit } from '../types/const';
import { labelFilter } from '@/types/form';
import UserSelector from '@/components/user/user/selector/index.vue';
@@ -105,10 +105,11 @@
riskLevel: undefined,
result: undefined,
startTimeRange: undefined,
clearLimit,
limit: maxLimit.value,
};
};
const maxLimit = ref<number>(0);
const typeOptions = ref<SelectOptionData[]>(toOptions(operatorLogTypeKey));
const formModel = ref<OperatorLogQueryRequest>({});
@@ -116,6 +117,7 @@
// 打开
const open = (record: OperatorLogQueryRequest) => {
maxLimit.value = maxClearLimit;
renderForm({ ...defaultForm(), ...record });
setVisible(true);
};
@@ -146,8 +148,8 @@
// 确定
const handlerOk = async () => {
if (!formModel.value.clearLimit) {
Message.error('请输入清理数量');
if (!formModel.value.limit) {
Message.error('请输入数量限制');
return false;
}
setLoading(true);
@@ -172,7 +174,7 @@
const doClear = (count: number) => {
Modal.confirm({
title: '删除清空',
content: `确定要删除 ${Math.min(count, formModel.value.clearLimit || 0)} 条数据吗? 确定后将立即删除且无法恢复!`,
content: `确定要删除 ${count} 条数据吗? 确定后将立即删除且无法恢复!`,
onOk: async () => {
setLoading(true);
try {

View File

@@ -27,8 +27,8 @@ export const getLogDetail = (record: OperatorLogQueryResponse): Record<string, a
}
};
// 清理数量
export const clearLimit = 2000;
// 最大清理数量
export const maxClearLimit = 2000;
// 操作日志模块 字典项
export const operatorLogModuleKey = 'operatorLogModule';