Merge remote-tracking branch 'origin/1.3.0-beta1' into 1.3.0-beta1
This commit is contained in:
commit
a4c8916000
2
.env
2
.env
@ -4,7 +4,7 @@ VITE_APP_TITLE=Snail Job
|
||||
|
||||
VITE_APP_DESC=A flexible, reliable, and fast platform for distributed task retry and distributed task scheduling.
|
||||
|
||||
VITE_APP_VERSION=1.2.0-beta2
|
||||
VITE_APP_VERSION=1.2.0
|
||||
|
||||
VITE_APP_DEFAULT_TOKEN=SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { NButton, NCode, NTag } from 'naive-ui';
|
||||
import hljs from 'highlight.js/lib/core';
|
||||
import json from 'highlight.js/lib/languages/json';
|
||||
import { ref, render } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { taskStatusRecord, taskStatusRecordOptions } from '@/constants/business';
|
||||
import { $t } from '@/locales';
|
||||
import { isNotNull, parseArgsJson, translateOptions } from '@/utils/common';
|
||||
@ -251,6 +252,18 @@ const { columns, searchParams, columnChecks, data, getData, loading, mobilePagin
|
||||
title: $t('page.jobBatch.jobTask.createDt'),
|
||||
align: 'left',
|
||||
minWidth: 130
|
||||
},
|
||||
{
|
||||
key: 'duration',
|
||||
title: $t('page.jobBatch.duration'),
|
||||
align: 'center',
|
||||
width: 120,
|
||||
render: row => {
|
||||
if (row.taskStatus === 3) {
|
||||
return Math.round(dayjs(row.updateDt).diff(dayjs(row.createDt)) / 1000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@ -245,6 +245,15 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
function handleCopy(id: T['id']) {
|
||||
operateType.value = 'add';
|
||||
const findItem = data.value.find(item => item.id === id) || null;
|
||||
editingData.value = jsonClone(findItem);
|
||||
delete editingData.value?.id;
|
||||
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
/** the checked row keys of table */
|
||||
const checkedRowKeys = ref<string[]>([]);
|
||||
|
||||
@ -272,6 +281,7 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
|
||||
handleAdd,
|
||||
editingData,
|
||||
handleEdit,
|
||||
handleCopy,
|
||||
checkedRowKeys,
|
||||
onBatchDeleted,
|
||||
onDeleted
|
||||
|
2
src/typings/api.d.ts
vendored
2
src/typings/api.d.ts
vendored
@ -1073,6 +1073,8 @@ declare namespace Api {
|
||||
children: JobTaskTree[];
|
||||
/** 是否存在下级 */
|
||||
isLeaf: boolean;
|
||||
/** 执行时长(virtual) */
|
||||
duration?: number;
|
||||
}>;
|
||||
|
||||
type JobTaskTree = {
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
import { translateOptions, translateOptions2 } from '@/utils/common';
|
||||
@ -29,6 +30,7 @@ const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const { copy, isSupported } = useClipboard();
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
const { defaultRequiredRule } = useFormRules();
|
||||
|
||||
@ -160,6 +162,20 @@ watch(visible, () => {
|
||||
restoreValidation();
|
||||
}
|
||||
});
|
||||
|
||||
async function handleCopy(source: string) {
|
||||
if (!isSupported) {
|
||||
window.$message?.error('您的浏览器不支持 Clipboard API');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
await copy(source);
|
||||
window.$message?.success('复制成功');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -196,9 +212,17 @@ watch(visible, () => {
|
||||
:placeholder="$t('page.groupConfig.form.token')"
|
||||
:disabled="props.operateType === 'edit'"
|
||||
/>
|
||||
<NTooltip trigger="hover">
|
||||
<NTooltip v-if="props.operateType === 'edit'" trigger="hover">
|
||||
<template #trigger>
|
||||
<NButton type="default" ghost :disabled="props.operateType === 'edit'" @click="setToken">
|
||||
<NButton type="default" ghost @click="handleCopy(model.token)">
|
||||
<icon-ic:round-content-copy class="text-icon" />
|
||||
</NButton>
|
||||
</template>
|
||||
复制
|
||||
</NTooltip>
|
||||
<NTooltip v-else trigger="hover">
|
||||
<template #trigger>
|
||||
<NButton type="default" ghost @click="setToken">
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</NButton>
|
||||
</template>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { NButton, NDropdown, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { ref } from 'vue';
|
||||
import { fetchBatchDeleteJob, fetchGetJobPage, fetchTriggerJob, fetchUpdateJobStatus } from '@/service/api';
|
||||
@ -177,41 +177,86 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
||||
key: 'operate',
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmExecute'),
|
||||
trigger: () => (
|
||||
<NButton type="error" text ghost size="small">
|
||||
{$t('common.execute')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
<n-divider vertical />
|
||||
<NButton type="primary" ghost text size="small" onClick={() => goToBatch(row.id!)}>
|
||||
{$t('common.batchList')}
|
||||
</NButton>
|
||||
<n-divider vertical />
|
||||
<NButton type="warning" ghost text size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<n-divider vertical />
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" text ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
)
|
||||
render: row => {
|
||||
const options = [
|
||||
{
|
||||
label: $t('common.copy'),
|
||||
key: 'copy',
|
||||
click: () => copy(row.id!)
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
key: 'd2'
|
||||
},
|
||||
{
|
||||
label: $t('common.batchList'),
|
||||
key: 'batchList',
|
||||
click: () => goToBatch(row.id!)
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
key: 'd2'
|
||||
},
|
||||
{
|
||||
type: 'render',
|
||||
key: 'delete',
|
||||
render: () => (
|
||||
<div class="flex-center">
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton quaternary size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
const onSelect = (key: string) => {
|
||||
const fun = options.filter(o => o.key === key)[0].click;
|
||||
if (fun) fun();
|
||||
};
|
||||
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton text type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
|
||||
<n-divider vertical />
|
||||
|
||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmExecute'),
|
||||
trigger: () => (
|
||||
<NButton type="error" text ghost size="small">
|
||||
{$t('common.execute')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
|
||||
<n-divider vertical />
|
||||
|
||||
<NDropdown trigger="click" show-arrow={false} options={options} size="small" on-select={onSelect}>
|
||||
{{
|
||||
default: () => (
|
||||
<NButton text type="primary" ghost size="small">
|
||||
更多
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NDropdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@ -222,6 +267,7 @@ const {
|
||||
editingData,
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
handleCopy,
|
||||
checkedRowKeys,
|
||||
onDeleted,
|
||||
onBatchDeleted
|
||||
@ -244,6 +290,10 @@ function edit(id: string) {
|
||||
handleEdit(id);
|
||||
}
|
||||
|
||||
function copy(id: string) {
|
||||
handleCopy(id);
|
||||
}
|
||||
|
||||
async function handleTriggerJob(id: string) {
|
||||
const { error } = await fetchTriggerJob(id);
|
||||
if (error) {
|
||||
|
@ -218,7 +218,7 @@ function createDefaultScriptParams() {
|
||||
}
|
||||
|
||||
function handleUpdateModelWhenEdit() {
|
||||
if (props.operateType === 'add') {
|
||||
if (props.operateType === 'add' && !props.rowData) {
|
||||
Object.assign(model, createDefaultModel());
|
||||
executorCustomType.value = 0;
|
||||
httpHeaders.value = [];
|
||||
@ -227,7 +227,7 @@ function handleUpdateModelWhenEdit() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit' && props.rowData) {
|
||||
if (props.rowData) {
|
||||
Object.assign(model, props.rowData);
|
||||
if (model.taskType === 3 && model.argsStr) {
|
||||
Object.assign(dynamicForm, {
|
||||
|
@ -1,6 +1,7 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { NButton, NPopconfirm, NPopover } from 'naive-ui';
|
||||
import { ref } from 'vue';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { fetchDeleteNamespace, fetchGetNamespaceList } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
@ -14,12 +15,27 @@ import NamespaceSearch from './modules/namespace-search.vue';
|
||||
const appStore = useAppStore();
|
||||
const authStore = useAuthStore();
|
||||
const namespaceId = ref<string>(localStg.get('namespaceId')!);
|
||||
const { copy, isSupported } = useClipboard();
|
||||
|
||||
const handleChange = (uniqueId: string) => {
|
||||
namespaceId.value = uniqueId;
|
||||
authStore.setNamespaceId(uniqueId);
|
||||
};
|
||||
|
||||
async function handleCopy(source: string) {
|
||||
if (!isSupported) {
|
||||
window.$message?.error('您的浏览器不支持 Clipboard API');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
await copy(source);
|
||||
window.$message?.success('复制成功');
|
||||
}
|
||||
|
||||
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
|
||||
apiFn: fetchGetNamespaceList,
|
||||
apiParams: {
|
||||
@ -59,7 +75,19 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
key: 'uniqueId',
|
||||
title: $t('page.namespace.uniqueId'),
|
||||
align: 'left',
|
||||
width: 180
|
||||
width: 180,
|
||||
render: row => (
|
||||
<NPopover>
|
||||
{{
|
||||
trigger: () => (
|
||||
<NButton text type="primary" onClick={() => handleCopy(row.uniqueId)}>
|
||||
{row.uniqueId}
|
||||
</NButton>
|
||||
),
|
||||
default: () => <span>点击复制</span>
|
||||
}}
|
||||
</NPopover>
|
||||
)
|
||||
},
|
||||
{
|
||||
key: 'createDt',
|
||||
|
@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, watch } from 'vue';
|
||||
import { nanoid } from '@sa/utils';
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import OperateDrawer from '@/components/common/operate-drawer.vue';
|
||||
import { $t } from '@/locales';
|
||||
@ -26,6 +27,7 @@ interface Emits {
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const { copy, isSupported } = useClipboard();
|
||||
const authStore = useAuthStore();
|
||||
const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
@ -111,6 +113,20 @@ watch(visible, () => {
|
||||
restoreValidation();
|
||||
}
|
||||
});
|
||||
|
||||
async function handleCopy(source: string) {
|
||||
if (!isSupported) {
|
||||
window.$message?.error('您的浏览器不支持 Clipboard API');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
|
||||
await copy(source);
|
||||
window.$message?.success('复制成功');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -123,9 +139,17 @@ watch(visible, () => {
|
||||
:disabled="props.operateType === 'edit'"
|
||||
:placeholder="$t('page.namespace.form.uniqueId')"
|
||||
/>
|
||||
<NTooltip trigger="hover">
|
||||
<NTooltip v-if="props.operateType === 'edit'" trigger="hover">
|
||||
<template #trigger>
|
||||
<NButton type="default" ghost :disabled="props.operateType === 'edit'" @click="setUniqueId">
|
||||
<NButton type="default" ghost @click="handleCopy(model.uniqueId)">
|
||||
<icon-ic:round-content-copy class="text-icon" />
|
||||
</NButton>
|
||||
</template>
|
||||
复制
|
||||
</NTooltip>
|
||||
<NTooltip v-else trigger="hover">
|
||||
<template #trigger>
|
||||
<NButton type="default" ghost @click="setUniqueId">
|
||||
<icon-ic-round-refresh class="text-icon" />
|
||||
</NButton>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user