🎨 修改批量执行模块格式.

This commit is contained in:
lijiahangmax
2024-04-11 00:06:43 +08:00
parent e2c0b9c44a
commit bcef835de3
20 changed files with 113 additions and 213 deletions

View File

@@ -8,7 +8,7 @@ import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLe
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L;
/**
* 批量执行 操作记录类型
* 批量执行日志 操作记录类型
*
* @author Jiahang Li
* @version 1.0.1
@@ -29,8 +29,8 @@ public class ExecCommandLogOperatorType extends InitializingOperatorTypes {
public OperatorType[] types() {
return new OperatorType[]{
new OperatorType(H, DELETE, "删除执行记录 <sb>${count}</sb> 条"),
new OperatorType(H, CLEAR, "清理执行记录 <sb>${count}</sb> 条"),
new OperatorType(H, DELETE_HOST, "删除主机执行记录 <sb>${logId}</sb> <sb>${hostName}</sb>"),
new OperatorType(H, CLEAR, "清理执行记录 <sb>${count}</sb> 条"),
new OperatorType(L, DOWNLOAD, "下载主机执行日志 <sb>${logId}</sb> <sb>${hostName}</sb>"),
};
}

View File

@@ -13,7 +13,7 @@ import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLe
* @version 1.0.1
* @since 2024-3-11 11:31
*/
@Module("asset:exec-command-log")
@Module("asset:exec-command")
public class ExecCommandOperatorType extends InitializingOperatorTypes {
public static final String EXEC = "exec-command:exec";

View File

@@ -1,4 +1,4 @@
import type { ExecLogQueryResponse } from './exec-log';
import type { ExecCommandLogQueryResponse } from './exec-command-log';
import axios from 'axios';
/**
@@ -25,14 +25,14 @@ export interface ExecCommandInterruptRequest {
* 批量执行命令
*/
export function batchExecCommand(request: ExecCommandRequest) {
return axios.post<ExecLogQueryResponse>('/asset/exec-command/exec', request);
return axios.post<ExecCommandLogQueryResponse>('/asset/exec-command/exec', request);
}
/**
* 重新执行命令
*/
export function reExecCommand(request: ExecCommandRequest) {
return axios.post<ExecLogQueryResponse>('/asset/exec-command/re-exec', request);
return axios.post<ExecCommandLogQueryResponse>('/asset/exec-command/re-exec', request);
}
/**

View File

@@ -1,20 +1,7 @@
import type { 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';
/**
* 执行记录查询请求
*/
export interface ExecLogQueryRequest extends Pagination {
id?: number;
userId?: number;
description?: string;
command?: string;
status?: string;
startTimeRange?: string[];
}
/**
* 执行记录查询响应
*/
@@ -66,13 +53,6 @@ export interface ExecStatusResponse {
hostList: Array<ExecHostLogQueryResponse>;
}
/**
* 分页查询执行记录
*/
export function getExecLogPage(request: ExecLogQueryRequest) {
return axios.post<DataGrid<ExecLogQueryResponse>>('/asset/exec-log/query', request);
}
/**
* 查询执行记录
*/
@@ -80,12 +60,6 @@ export function getExecLog(id: number) {
return axios.get<ExecLogQueryResponse>('/asset/exec-log/get', { params: { id } });
}
/**
* 查询主机执行记录
*/
export function getExecHostLogList(logId: number) {
return axios.get<Array<ExecHostLogQueryResponse>>('/asset/exec-log/host-list', { params: { logId } });
}
/**
* 查询命令执行状态
@@ -98,50 +72,3 @@ export function getExecLogStatus(idList: Array<number>) {
}
});
}
/**
* 查询历史执行记录
*/
export function getExecLogHistory(limit: number) {
return axios.get<Array<ExecLogQueryResponse>>('/asset/exec-log/history', { params: { page: 1, limit } });
}
/**
* 删除执行记录
*/
export function deleteExecLog(id: number) {
return axios.delete('/asset/exec-log/delete', { params: { id } });
}
/**
* 批量删除执行记录
*/
export function batchDeleteExecLog(idList: Array<number>) {
return axios.delete('/asset/exec-log/batch-delete', {
params: { idList },
paramsSerializer: params => {
return qs.stringify(params, { arrayFormat: 'comma' });
}
});
}
/**
* 删除主机执行记录
*/
export function deleteExecHostLog(id: number) {
return axios.delete('/asset/exec-log/delete-host', { params: { id } });
}
/**
* 查询操作日志数量
*/
export function getExecLogCount(request: ExecLogQueryRequest) {
return axios.post<number>('/asset/exec-log/query-count', request);
}
/**
* 清空操作日志
*/
export function clearExecLog(request: ExecLogQueryRequest) {
return axios.post<number>('/asset/exec-log/clear', request);
}

View File

@@ -1,26 +1,5 @@
import type { ExecLogQueryResponse } from './exec-log';
import axios from 'axios';
/**
* 执行命令请求
*/
export interface ExecCommandRequest {
logId?: number;
description?: string;
timeout?: number;
command?: string;
parameterSchema?: string;
hostIdList?: Array<number>;
}
/**
* 中断命令请求
*/
export interface ExecInterruptRequest {
logId?: number;
hostLogId?: number;
}
/**
* 中断命令请求
*/
@@ -29,34 +8,6 @@ export interface ExecTailRequest {
hostExecIdList?: Array<number>;
}
/**
* 批量执行命令
*/
export function batchExecCommand(request: ExecCommandRequest) {
return axios.post<ExecLogQueryResponse>('/asset/exec/exec-command', request);
}
/**
* 重新执行命令
*/
export function reExecCommand(request: ExecCommandRequest) {
return axios.post<ExecLogQueryResponse>('/asset/exec/re-exec-command', request);
}
/**
* 中断执行命令
*/
export function interruptExec(request: ExecInterruptRequest) {
return axios.put('/asset/exec/interrupt', request);
}
/**
* 中断执行主机命令
*/
export function interruptHostExec(request: ExecInterruptRequest) {
return axios.put('/asset/exec/interrupt-host', request);
}
/**
* 查看执行日志
*/

View File

@@ -17,6 +17,16 @@ const EXEC: AppRouteRecordRaw[] = [
path: '/exec-command-log',
component: () => import('@/views/exec/exec-command-log/index.vue'),
},
{
name: 'execJob',
path: '/exec-job',
component: () => import('@/views/exec/exec-job/index.vue'),
},
{
name: 'execJobLog',
path: '/exec-job-log',
component: () => import('@/views/exec/exec-job-log/index.vue'),
},
{
name: 'execTemplate',
path: '/exec-template',
@@ -30,9 +40,14 @@ const EXEC: AppRouteRecordRaw[] = [
component: FULL_LAYOUT,
children: [
{
name: 'execLogView',
path: '/exec-log-view',
component: () => import('@/views/exec/exec-log-view/index.vue'),
name: 'execCommandLogView',
path: '/exec-command-log-view',
component: () => import('@/views/exec/exec-command-log-view/index.vue'),
},
{
name: 'execJobLogView',
path: '/exec-job-log-view',
component: () => import('@/views/exec/exec-job-log-view/index.vue'),
},
],
}

View File

@@ -8,7 +8,7 @@
<script lang="ts">
export default {
name: 'execExecLogView'
name: 'execCommandLogView'
};
</script>

View File

@@ -96,13 +96,13 @@
<script lang="ts">
export default {
name: 'execHostLogTable'
name: 'execCommandHostLogTable'
};
</script>
<script lang="ts" setup>
import type { ExecLogQueryResponse, ExecHostLogQueryResponse } from '@/api/exec/exec-log';
import { deleteExecHostLog } from '@/api/exec/exec-log';
import type { ExecCommandLogQueryResponse, ExecCommandHostLogQueryResponse } from '@/api/exec/exec-command-log';
import { deleteExecCommandHostLog } from '@/api/exec/exec-command-log';
import { Message } from '@arco-design/web-vue';
import useLoading from '@/hooks/loading';
import columns from '../types/host-table.columns';
@@ -110,12 +110,13 @@
import { useDictStore } from '@/store';
import { useExpandable } from '@/types/table';
import { dateFormat, formatDuration } from '@/utils';
import { downloadExecLogFile, interruptHostExec } from '@/api/exec/exec';
import { downloadExecLogFile } from '@/api/exec/exec';
import { interruptHostExecCommand } from '@/api/exec/exec-command';
import { copy } from '@/hooks/copy';
import { downloadFile } from '@/utils/file';
const props = defineProps<{
row: ExecLogQueryResponse;
row: ExecCommandLogQueryResponse;
}>();
const emits = defineEmits(['viewCommand', 'viewParams']);
@@ -131,11 +132,11 @@
};
//
const interruptedHost = async (record: ExecHostLogQueryResponse) => {
const interruptedHost = async (record: ExecCommandHostLogQueryResponse) => {
try {
setLoading(true);
//
await interruptHostExec({
await interruptHostExecCommand({
hostLogId: record.id
});
Message.success('已中断');
@@ -153,7 +154,7 @@
try {
setLoading(true);
//
await deleteExecHostLog(id);
await deleteExecCommandHostLog(id);
Message.success('删除成功');
} catch (e) {
} finally {

View File

@@ -56,17 +56,17 @@
<script lang="ts">
export default {
name: 'execLogClearModal'
name: 'execCommandLogClearModal'
};
</script>
<script lang="ts" setup>
import type { ExecLogQueryRequest } from '@/api/exec/exec-log';
import type { ExecCommandLogQueryRequest } from '@/api/exec/exec-command-log';
import { ref } from 'vue';
import useLoading from '@/hooks/loading';
import useVisible from '@/hooks/visible';
import { execStatusKey } from '../types/const';
import { getExecLogCount, clearExecLog } from '@/api/exec/exec-log';
import { getExecCommandLogCount, clearExecCommandLog } from '@/api/exec/exec-command-log';
import { Message, Modal } from '@arco-design/web-vue';
import { useDictStore } from '@/store';
import UserSelector from '@/components/user/user/selector/index.vue';
@@ -78,9 +78,9 @@
const { toOptions } = useDictStore();
const formRef = ref<any>();
const formModel = ref<ExecLogQueryRequest>({});
const formModel = ref<ExecCommandLogQueryRequest>({});
const defaultForm = (): ExecLogQueryRequest => {
const defaultForm = (): ExecCommandLogQueryRequest => {
return {
id: undefined,
userId: undefined,
@@ -108,7 +108,7 @@
setLoading(true);
try {
//
const { data } = await getExecLogCount(formModel.value);
const { data } = await getExecCommandLogCount(formModel.value);
if (data) {
//
doClear(data);
@@ -132,7 +132,7 @@
setLoading(true);
try {
//
await clearExecLog(formModel.value);
await clearExecCommandLog(formModel.value);
emits('clear');
//
setVisible(false);

View File

@@ -113,9 +113,9 @@
@expand="loadHostExecData">
<!-- 展开表格 -->
<template #expand-row="{ record }">
<exec-host-log-table :row="record"
@view-command="s => emits('viewCommand', s)"
@view-params="s => emits('viewParams', s)" />
<exec-command-host-log-table :row="record"
@view-command="s => emits('viewCommand', s)"
@view-params="s => emits('viewParams', s)" />
</template>
<!-- 执行命令 -->
<template #command="{ record }">
@@ -171,7 +171,7 @@
<a-popconfirm content="确定要中断执行吗?"
position="left"
type="warning"
@ok="doInterruptExec(record)">
@ok="doInterruptExecCommand(record)">
<a-button v-permission="['asset:exec:interrupt-exec']"
type="text"
size="mini"
@@ -200,15 +200,21 @@
<script lang="ts">
export default {
name: 'execLogTable'
name: 'execCommandLogTable'
};
</script>
<script lang="ts" setup>
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import type { ExecLogQueryRequest, ExecLogQueryResponse } from '@/api/exec/exec-log';
import type { ExecCommandLogQueryRequest, ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
import { reactive, ref, onMounted, onUnmounted } from 'vue';
import { batchDeleteExecLog, deleteExecLog, getExecHostLogList, getExecLogPage, getExecLogStatus } from '@/api/exec/exec-log';
import {
batchDeleteExecCommandLog,
deleteExecCommandLog,
getExecCommandHostLogList,
getExecCommandLogPage,
getExecCommandLogStatus
} from '@/api/exec/exec-command-log';
import { Message } from '@arco-design/web-vue';
import useLoading from '@/hooks/loading';
import columns from '../types/table.columns';
@@ -216,9 +222,9 @@
import { useExpandable, usePagination, useRowSelection } from '@/types/table';
import { useDictStore } from '@/store';
import { dateFormat, formatDuration } from '@/utils';
import { interruptExec, reExecCommand } from '@/api/exec/exec';
import { reExecCommand, interruptExecCommand } from '@/api/exec/exec-command';
import UserSelector from '@/components/user/user/selector/index.vue';
import ExecHostLogTable from './exec-host-log-table.vue';
import ExecCommandHostLogTable from './exec-command-host-log-table.vue';
const emits = defineEmits(['viewCommand', 'viewParams', 'viewLog', 'openClear']);
@@ -231,8 +237,8 @@
const intervalId = ref();
const tableRef = ref();
const selectedKeys = ref<number[]>([]);
const tableRenderData = ref<ExecLogQueryResponse[]>([]);
const formModel = reactive<ExecLogQueryRequest>({
const tableRenderData = ref<ExecCommandLogQueryResponse[]>([]);
const formModel = reactive<ExecCommandLogQueryRequest>({
id: undefined,
userId: undefined,
description: undefined,
@@ -251,7 +257,7 @@
try {
setLoading(true);
//
await batchDeleteExecLog(selectedKeys.value);
await batchDeleteExecCommandLog(selectedKeys.value);
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
selectedKeys.value = [];
//
@@ -269,7 +275,7 @@
try {
setLoading(true);
//
await deleteExecLog(id);
await deleteExecCommandLog(id);
Message.success('删除成功');
//
fetchTableData();
@@ -280,7 +286,7 @@
};
//
const doReExecCommand = async (record: ExecLogQueryResponse) => {
const doReExecCommand = async (record: ExecCommandLogQueryResponse) => {
try {
setLoading(true);
//
@@ -296,11 +302,11 @@
};
//
const doInterruptExec = async (record: ExecLogQueryResponse) => {
const doInterruptExecCommand = async (record: ExecCommandLogQueryResponse) => {
try {
setLoading(true);
//
await interruptExec({
await interruptExecCommand({
logId: record.id
});
Message.success('已中断');
@@ -317,7 +323,7 @@
return;
}
//
const { data } = await getExecHostLogList(record.id);
const { data } = await getExecCommandHostLogList(record.id);
record.hosts = data;
};
@@ -330,7 +336,7 @@
return;
}
//
const { data: { logList, hostList } } = await getExecLogStatus(unCompleteIdList);
const { data: { logList, hostList } } = await getExecCommandLogStatus(unCompleteIdList);
//
logList.forEach(s => {
const tableRow = tableRenderData.value.find(r => r.id === s.id);
@@ -359,10 +365,10 @@
};
//
const doFetchTableData = async (request: ExecLogQueryRequest) => {
const doFetchTableData = async (request: ExecCommandLogQueryRequest) => {
try {
setLoading(true);
const { data } = await getExecLogPage(request);
const { data } = await getExecCommandLogPage(request);
tableRenderData.value = data.rows;
pagination.total = data.total;
pagination.current = request.page;

View File

@@ -1,14 +1,14 @@
<template>
<div class="layout-container" v-if="render">
<!-- 列表-表格 -->
<exec-log-table ref="tableRef"
@view-command="viewCommand"
@view-params="viewParams"
@view-log="viewLog"
@open-clear="openClearModal" />
<exec-command-log-table ref="tableRef"
@view-command="viewCommand"
@view-params="viewParams"
@view-log="viewLog"
@open-clear="openClearModal" />
<!-- 清理模态框 -->
<exec-log-clear-modal ref="clearModal"
@clear="clearCallback" />
<exec-command-log-clear-modal ref="clearModal"
@clear="clearCallback" />
<!-- 执行日志模态框 -->
<exec-log-panel-modal ref="logModal" />
<!-- json 模态框 -->
@@ -23,7 +23,7 @@
<script lang="ts">
export default {
name: 'execLog'
name: 'execCommandLog'
};
</script>
@@ -33,8 +33,8 @@
import { dictKeys } from './types/const';
import { useRouter } from 'vue-router';
import { openNewRoute } from '@/router';
import ExecLogTable from './components/exec-log-table.vue';
import ExecLogClearModal from './components/exec-log-clear-modal.vue';
import ExecCommandLogTable from './components/exec-command-log-table.vue';
import ExecCommandLogClearModal from './components/exec-command-log-clear-modal.vue';
import JsonEditorModal from '@/components/view/json-editor/modal/index.vue';
import ShellEditorModal from '@/components/view/shell-editor/modal/index.vue';
import ExecLogPanelModal from '@/components/exec/log/panel-modal/index.vue';
@@ -68,7 +68,7 @@
if (newWindow) {
//
openNewRoute({
name: 'execLogView',
name: 'execCommandLogView',
query: {
id
}

View File

@@ -25,7 +25,7 @@
<script lang="ts">
export default {
name: 'execPanelEditor'
name: 'execCommandPanelEditor'
};
</script>

View File

@@ -23,7 +23,7 @@
<script lang="ts">
export default {
name: 'execPanelForm'
name: 'execCommandPanelForm'
};
</script>

View File

@@ -38,15 +38,15 @@
<script lang="ts">
export default {
name: 'execPanelHistory'
name: 'execCommandPanelHistory'
};
</script>
<script lang="ts" setup>
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
import type { ExecCommandRequest } from '@/api/exec/exec';
import type { ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
import type { ExecCommandRequest } from '@/api/exec/exec-command';
import { onMounted, ref } from 'vue';
import { getExecLogHistory } from '@/api/exec/exec-log';
import { getExecCommandLogHistory } from '@/api/exec/exec-command-log';
import { historyCount } from '../types/const';
import useLoading from '@/hooks/loading';
@@ -54,7 +54,7 @@
const { loading, setLoading } = useLoading(true);
const historyLogs = ref<Array<ExecLogQueryResponse>>([]);
const historyLogs = ref<Array<ExecCommandLogQueryResponse>>([]);
//
const add = (record: ExecCommandRequest) => {
@@ -67,7 +67,7 @@
parameterSchema: record.parameterSchema,
timeout: record.timeout,
hostIdList: record.hostIdList
} as ExecLogQueryResponse);
} as ExecCommandLogQueryResponse);
} else {
//
const his = historyLogs.value[index];
@@ -78,7 +78,7 @@
parameterSchema: record.parameterSchema,
timeout: record.timeout,
hostIdList: record.hostIdList
} as ExecLogQueryResponse);
} as ExecCommandLogQueryResponse);
}
};
@@ -88,7 +88,7 @@
const fetchExecHistory = async () => {
setLoading(true);
try {
const { data } = await getExecLogHistory(historyCount);
const { data } = await getExecCommandLogHistory(historyCount);
historyLogs.value = data;
} catch (e) {
} finally {

View File

@@ -2,10 +2,10 @@
<!-- 命令执行 -->
<a-spin class="exec-container" :loading="loading">
<!-- 执行参数 -->
<exec-panel-form class="exec-form-container"
:schema-count="parameterSchema.length"
@exec="execCommand"
@reset="resetForm">
<exec-command-panel-form class="exec-form-container"
:schema-count="parameterSchema.length"
@exec="execCommand"
@reset="resetForm">
<!-- 命令表单 -->
<template #form>
<a-form :model="formModel"
@@ -67,18 +67,18 @@
</a-form-item>
</a-form>
</template>
</exec-panel-form>
</exec-command-panel-form>
<!-- 执行命令 -->
<exec-panel-editor class="exec-command-container"
@selected="setWithTemplate">
<exec-command-panel-editor class="exec-command-container"
@selected="setWithTemplate">
<exec-editor v-model="formModel.command"
theme="vs-dark"
:parameter="parameterSchema" />
</exec-panel-editor>
</exec-command-panel-editor>
<!-- 执行历史 -->
<exec-panel-history class="exec-history-container"
ref="historyRef"
@selected="setWithExecLog" />
<exec-command-panel-history class="exec-history-container"
ref="historyRef"
@selected="setWithExecLog" />
<!-- 主机模态框 -->
<authorized-host-modal ref="hostModal"
@selected="setSelectedHost" />
@@ -92,20 +92,20 @@
</script>
<script lang="ts" setup>
import type { ExecCommandRequest } from '@/api/exec/exec';
import type { ExecCommandRequest } from '@/api/exec/exec-command';
import type { TemplateParam } from '@/components/view/exec-editor/const';
import type { ExecTemplateQueryResponse } from '@/api/exec/exec-template';
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
import type { ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
import { ref } from 'vue';
import formRules from '../types/form.rules';
import useLoading from '@/hooks/loading';
import { batchExecCommand } from '@/api/exec/exec';
import { batchExecCommand } from '@/api/exec/exec-command';
import { Message } from '@arco-design/web-vue';
import ExecEditor from '@/components/view/exec-editor/index.vue';
import AuthorizedHostModal from '@/components/asset/host/authorized-host-modal/index.vue';
import ExecPanelForm from './exec-panel-form.vue';
import ExecPanelHistory from './exec-panel-history.vue';
import ExecPanelEditor from './exec-panel-editor.vue';
import ExecCommandPanelForm from './exec-command-panel-form.vue';
import ExecCommandPanelHistory from './exec-command-panel-history.vue';
import ExecCommandPanelEditor from './exec-command-panel-editor.vue';
const emits = defineEmits(['submit']);
@@ -156,7 +156,7 @@
};
//
const setWithExecLog = (record: ExecLogQueryResponse) => {
const setWithExecLog = (record: ExecCommandLogQueryResponse) => {
formModel.value = {
...formModel.value,
command: record.command,

View File

@@ -2,7 +2,7 @@
<div class="layout-container full">
<!-- 执行面板 -->
<div v-show="!logVisible" class="panel-wrapper">
<exec-panel @submit="openLog" />
<exec-command-panel @submit="openLog" />
</div>
<!-- 执行日志 -->
<div v-if="logVisible" class="panel-wrapper">
@@ -20,12 +20,12 @@
</script>
<script lang="ts" setup>
import type { ExecLogQueryResponse } from '@/api/exec/exec-log';
import type { ExecCommandLogQueryResponse } from '@/api/exec/exec-command-log';
import { nextTick, onMounted, ref } from 'vue';
import useVisible from '@/hooks/visible';
import { useDictStore } from '@/store';
import { dictKeys } from '@/views/exec/exec-log/types/const';
import ExecPanel from './components/exec-panel.vue';
import { dictKeys } from '@/views/exec/exec-command-log/types/const';
import ExecCommandPanel from './components/exec-command-panel.vue';
import ExecLogPanel from '@/components/exec/log/panel/index.vue';
const { visible: logVisible, setVisible: setLogVisible } = useVisible();
@@ -33,7 +33,7 @@
const log = ref();
// 打开日志
const openLog = (record: ExecLogQueryResponse) => {
const openLog = (record: ExecCommandLogQueryResponse) => {
setLogVisible(true);
nextTick(() => {
log.value.open(record);

View File

@@ -91,13 +91,13 @@
<script lang="ts" setup>
import type { TemplateParam } from '@/components/view/exec-editor/const';
import type { ExecTemplateQueryResponse } from '@/api/exec/exec-template';
import type { ExecCommandRequest } from '@/api/exec/exec';
import type { ExecCommandRequest } from '@/api/exec/exec-command';
import { onUnmounted, ref } from 'vue';
import useLoading from '@/hooks/loading';
import useVisible from '@/hooks/visible';
import formRules from '../../exec-command/types/form.rules';
import { Message } from '@arco-design/web-vue';
import { batchExecCommand } from '@/api/exec/exec';
import { batchExecCommand } from '@/api/exec/exec-command';
import ExecEditor from '@/components/view/exec-editor/index.vue';
const emits = defineEmits(['openHost']);