🔨 批量执行.
This commit is contained in:
@@ -33,9 +33,9 @@ export interface ExecCommandResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令
|
||||
* 批量执行命令
|
||||
*/
|
||||
export function execCommand(request: ExecCommandRequest) {
|
||||
export function batchExecCommand(request: ExecCommandRequest) {
|
||||
return axios.post<ExecCommandResponse>('/asset/exec/exec-command', request);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,11 @@
|
||||
// 内置参数提示
|
||||
builtinsParams.forEach(s => {
|
||||
suggestions.push({
|
||||
label: s.name,
|
||||
kind: monaco.languages.CompletionItemKind.Function,
|
||||
label: '_' + s.name,
|
||||
kind: monaco.languages.CompletionItemKind.Variable,
|
||||
insertText: `@{{ ${s.name} }}`,
|
||||
detail: s.desc || '',
|
||||
documentation: s.desc || '',
|
||||
});
|
||||
});
|
||||
// 命令参数提示
|
||||
@@ -60,10 +61,11 @@
|
||||
return;
|
||||
}
|
||||
suggestions.push({
|
||||
label: s.name,
|
||||
kind: monaco.languages.CompletionItemKind.Function,
|
||||
label: '_' + s.name,
|
||||
kind: monaco.languages.CompletionItemKind.Field,
|
||||
insertText: `@{{ ${s.name} }}`,
|
||||
detail: s.desc || '',
|
||||
documentation: s.desc || '',
|
||||
});
|
||||
});
|
||||
return {
|
||||
|
||||
@@ -108,6 +108,9 @@ export function formatDuration(start: number, end?: number): string {
|
||||
return '';
|
||||
}
|
||||
const duration = (end - start) / 1000;
|
||||
if (duration < 1) {
|
||||
return `${duration.toFixed(1)}s`;
|
||||
}
|
||||
const minutes = Math.floor(duration / 60);
|
||||
const seconds = Math.floor(duration % 60);
|
||||
let result = '';
|
||||
@@ -188,7 +191,7 @@ export const resetObject = (obj: any, ignore: string[] = []) => {
|
||||
export const objectTruthKeyCount = (obj: any, ignore: string[] = []) => {
|
||||
return Object.keys(obj)
|
||||
.filter(s => !ignore.includes(s))
|
||||
.reduce(function(acc, curr) {
|
||||
.reduce(function (acc, curr) {
|
||||
const currVal = obj[curr];
|
||||
return acc + ~~(currVal !== undefined && currVal !== null && currVal?.length !== 0 && currVal !== '');
|
||||
}, 0);
|
||||
@@ -221,7 +224,7 @@ export function detectZoom() {
|
||||
* 获取唯一的 UUID
|
||||
*/
|
||||
export function getUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
placeholder="请选择主机"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 主机地址 -->
|
||||
<a-form-item field="hostAddress" label="主机地址">
|
||||
<a-input v-model="formModel.hostAddress" placeholder="请输入主机地址" allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 状态 -->
|
||||
<a-form-item field="status" label="状态">
|
||||
<a-select v-model="formModel.status"
|
||||
@@ -30,6 +26,10 @@
|
||||
:options="toOptions(connectStatusKey)"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 主机地址 -->
|
||||
<a-form-item field="hostAddress" label="主机地址">
|
||||
<a-input v-model="formModel.hostAddress" placeholder="请输入主机地址" allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 类型 -->
|
||||
<a-form-item field="type" label="类型">
|
||||
<a-select v-model="formModel.type"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<template>
|
||||
<div>123</div>
|
||||
<div class="layout-container">
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -7,31 +7,12 @@
|
||||
@submit="fetchTableData"
|
||||
@reset="fetchTableData"
|
||||
@keyup.enter="() => fetchTableData()">
|
||||
<!-- id -->
|
||||
<a-form-item field="id" label="id">
|
||||
<a-input-number v-model="formModel.id"
|
||||
placeholder="请输入id"
|
||||
allow-clear
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
<!-- 执行用户 -->
|
||||
<a-form-item field="userId" label="执行用户">
|
||||
<user-selector v-model="formModel.userId"
|
||||
placeholder="请选择执行用户"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行描述 -->
|
||||
<a-form-item field="description" label="执行描述">
|
||||
<a-input v-model="formModel.description"
|
||||
placeholder="请输入执行描述"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command" label="执行命令">
|
||||
<a-input v-model="formModel.command"
|
||||
placeholder="请输入执行命令"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行状态 -->
|
||||
<a-form-item field="status" label="执行状态">
|
||||
<a-select v-model="formModel.status"
|
||||
@@ -39,6 +20,25 @@
|
||||
placeholder="请选择执行状态"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行用户 -->
|
||||
<a-form-item field="userId" label="执行用户">
|
||||
<user-selector v-model="formModel.userId"
|
||||
placeholder="请选择执行用户"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command" label="执行命令">
|
||||
<a-input v-model="formModel.command"
|
||||
placeholder="请输入执行命令"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
<!-- id -->
|
||||
<a-form-item field="id" label="id">
|
||||
<a-input-number v-model="formModel.id"
|
||||
placeholder="请输入id"
|
||||
allow-clear
|
||||
hide-button />
|
||||
</a-form-item>
|
||||
<!-- 执行时间 -->
|
||||
<a-form-item field="startTimeRange" label="执行时间">
|
||||
<a-range-picker v-model="formModel.startTimeRange"
|
||||
@@ -204,6 +204,7 @@
|
||||
</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 { reactive, ref, onMounted, onUnmounted } from 'vue';
|
||||
import { batchDeleteExecLog, deleteExecLog, getExecHostLogList, getExecLogPage, getExecLogStatus } from '@/api/exec/exec-log';
|
||||
@@ -312,7 +313,7 @@
|
||||
};
|
||||
|
||||
// 加载主机数据
|
||||
const loadHostExecData = async (key: number, record: ExecLogQueryResponse) => {
|
||||
const loadHostExecData = async (key: number | string, record: TableData) => {
|
||||
if (record.hosts) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,10 +44,11 @@
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<!-- 模板命令 -->
|
||||
<!-- 执行命令 -->
|
||||
<a-form-item field="command"
|
||||
label="模板命令"
|
||||
:wrapper-col-props="{ span: 24 }">
|
||||
label="执行命令"
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<exec-editor v-model="formModel.command"
|
||||
containerClass="command-editor"
|
||||
theme="vs-dark"
|
||||
@@ -72,7 +73,7 @@
|
||||
:field="item.name as string"
|
||||
:label="item.name"
|
||||
required>
|
||||
<a-input v-model="parameterFormModel[item.name]"
|
||||
<a-input v-model="parameterFormModel[item.name as string]"
|
||||
:placeholder="item.desc"
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
@@ -101,7 +102,7 @@
|
||||
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 { execCommand } from '@/api/exec/exec';
|
||||
import { batchExecCommand } from '@/api/exec/exec';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -166,7 +167,8 @@
|
||||
if (error) {
|
||||
return false;
|
||||
}
|
||||
await execCommand({
|
||||
// 执行命令
|
||||
await batchExecCommand({
|
||||
...formModel.value,
|
||||
parameter: JSON.stringify(parameterFormModel.value),
|
||||
parameterSchema: JSON.stringify(parameterSchema.value),
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
<!-- 模板命令 -->
|
||||
<a-form-item field="command"
|
||||
label="模板命令"
|
||||
:wrapper-col-props="{ span: 24 }">
|
||||
:wrapper-col-props="{ span: 24 }"
|
||||
:help="'使用 @{{ xxx }} 来替换参数, 输入_可以获取全部变量'">
|
||||
<exec-editor v-model="formModel.command"
|
||||
containerClass="command-editor"
|
||||
theme="vs-dark"
|
||||
|
||||
@@ -79,7 +79,8 @@
|
||||
<a-button v-permission="['asset:exec:exec-command']"
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="emits('openExec', record)">
|
||||
title="ctrl + 鼠标左键新页面打开"
|
||||
@click="openExec($event, record)">
|
||||
执行
|
||||
</a-button>
|
||||
<!-- 修改 -->
|
||||
@@ -120,7 +121,6 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import {} from '../types/const';
|
||||
import { usePagination } from '@/types/table';
|
||||
import useCopy from '@/hooks/copy';
|
||||
|
||||
@@ -137,6 +137,15 @@
|
||||
command: undefined,
|
||||
});
|
||||
|
||||
// 打开执行
|
||||
const openExec = (e: any, record: ExecTemplateQueryResponse) => {
|
||||
if (e.ctrlKey) {
|
||||
// TODO 新页面打开
|
||||
} else {
|
||||
emits('openExec', record);
|
||||
}
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
|
||||
Reference in New Issue
Block a user