mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 05:19:19 +08:00
feat: Task center supports switching nodes (#11315)
This commit is contained in:
parent
51846895d5
commit
1ef3f540c2
3 changed files with 61 additions and 11 deletions
|
|
@ -18,8 +18,9 @@ export const cleanLogs = (param: Log.CleanLog) => {
|
||||||
return http.post(`/core/logs/clean`, param);
|
return http.post(`/core/logs/clean`, param);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const searchTasks = (req: Log.SearchTaskReq) => {
|
export const searchTasks = (req: Log.SearchTaskReq, node?: string) => {
|
||||||
return http.post<ResPage<Log.Task>>(`/logs/tasks/search`, req);
|
const params = node ? `?operateNode=${node}` : '';
|
||||||
|
return http.post<ResPage<Log.Task>>(`/logs/tasks/search${params}`, req);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const countExecutingTask = () => {
|
export const countExecutingTask = () => {
|
||||||
|
|
|
||||||
48
frontend/src/components/node-select/index.vue
Normal file
48
frontend/src/components/node-select/index.vue
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<el-select
|
||||||
|
:model-value="modelValue"
|
||||||
|
@update:model-value="handleChange"
|
||||||
|
class="p-w-200"
|
||||||
|
:placeholder="$t('setting.selectNode')"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in nodes"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name === 'local' ? globalStore.getMasterAlias() : item.name"
|
||||||
|
:value="item.name"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { defineProps, defineEmits } from 'vue';
|
||||||
|
import { listAllNodes } from '@/api/modules/setting';
|
||||||
|
import { useGlobalStore } from '@/composables/useGlobalStore';
|
||||||
|
const { globalStore } = useGlobalStore();
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nodes = ref([]);
|
||||||
|
const emit = defineEmits(['update:modelValue', 'change']);
|
||||||
|
|
||||||
|
const handleChange = (value) => {
|
||||||
|
emit('update:modelValue', value);
|
||||||
|
emit('change', value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const listNodes = async () => {
|
||||||
|
try {
|
||||||
|
const res = await listAllNodes();
|
||||||
|
nodes.value = res.data || [];
|
||||||
|
} catch (error) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
listNodes();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<DrawerPro
|
<DrawerPro v-model="open" size="large" :header="$t('menu.msgCenter')" @close="handleClose">
|
||||||
v-model="open"
|
|
||||||
size="large"
|
|
||||||
:header="$t('menu.msgCenter')"
|
|
||||||
:resource="globalStore.currentNode"
|
|
||||||
@close="handleClose"
|
|
||||||
>
|
|
||||||
<template #content>
|
<template #content>
|
||||||
<LayoutContent v-loading="loading" :title="$t('logs.task')">
|
<LayoutContent v-loading="loading" :title="$t('logs.task')">
|
||||||
|
<template #leftToolBar>
|
||||||
|
<NodeSelect v-model="targeNode" @change="search()" />
|
||||||
|
</template>
|
||||||
<template #rightToolBar>
|
<template #rightToolBar>
|
||||||
<el-select v-model="req.status" @change="search()" clearable class="p-w-200">
|
<el-select v-model="req.status" @change="search()" clearable class="p-w-200">
|
||||||
<template #prefix>{{ $t('commons.table.status') }}</template>
|
<template #prefix>{{ $t('commons.table.status') }}</template>
|
||||||
|
|
@ -50,11 +47,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import TaskLog from '@/components/log/task/index.vue';
|
||||||
|
import NodeSelect from '@/components/node-select/index.vue';
|
||||||
|
|
||||||
import { dateFormat } from '@/utils/util';
|
import { dateFormat } from '@/utils/util';
|
||||||
import { searchTasks } from '@/api/modules/log';
|
import { searchTasks } from '@/api/modules/log';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { Log } from '@/api/interface/log';
|
import { Log } from '@/api/interface/log';
|
||||||
import TaskLog from '@/components/log/task/index.vue';
|
|
||||||
import bus from '@/global/bus';
|
import bus from '@/global/bus';
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
|
|
@ -79,6 +78,7 @@ const req = reactive({
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
const targeNode = ref('local');
|
||||||
|
|
||||||
const search = async () => {
|
const search = async () => {
|
||||||
bus.emit('refreshTask', true);
|
bus.emit('refreshTask', true);
|
||||||
|
|
@ -86,7 +86,7 @@ const search = async () => {
|
||||||
req.pageSize = paginationConfig.pageSize;
|
req.pageSize = paginationConfig.pageSize;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await searchTasks(req);
|
const res = await searchTasks(req, targeNode.value);
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
data.value = res.data.items;
|
data.value = res.data.items;
|
||||||
paginationConfig.total = res.data.total;
|
paginationConfig.total = res.data.total;
|
||||||
|
|
@ -101,6 +101,7 @@ const openTaskLog = (row: Log.Task) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const acceptParams = () => {
|
const acceptParams = () => {
|
||||||
|
targeNode.value = globalStore.currentNode;
|
||||||
search();
|
search();
|
||||||
open.value = true;
|
open.value = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue