Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions agent/app/service/cronjob_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
}, nil, int(cronjob.RetryTimes), time.Duration(cronjob.Timeout)*time.Second)
}

func (u *CronjobService) handleSyncIpGroup(cronjob model.Cronjob, taskItem *task.Task) {

Check failure on line 270 in agent/app/service/cronjob_helper.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 33 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZsRK586o-E7ro42ZCjw&open=AZsRK586o-E7ro42ZCjw&pullRequest=11317
taskItem.AddSubTaskWithOps(i18n.GetWithName("SyncIpGroup", cronjob.Name), func(t *task.Task) error {
appInstall, err := getAppInstallByKey(constant.AppOpenresty)
if err != nil {
Expand All @@ -275,6 +275,10 @@
}
ipGroupDir := pathUtils.Join(appInstall.GetPath(), "1pwaf", "data", "rules", "ip_group")
urlDir := pathUtils.Join(ipGroupDir, "ip_group_url")
_, err = os.Stat(urlDir)
if err != nil && os.IsNotExist(err) {
return buserr.New("WafIpGroupNotFound")
}

urlsFiles, err := os.ReadDir(urlDir)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "The current task is being executed, please do not repeat the execu
NoSuchResource: "No backup content found in the database, skipping..."
CleanLog: "Clean Log"
CleanLogByName: "Clean {{.name}} Log"
WafIpGroupNotFound: "WAF IP group not found, please add it first!"

#toolbox
ErrNotExistUser: 'The current user does not exist, please modify and try again!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/es-ES.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ InExecuting: "La tarea actual se está ejecutando, por favor no la repita"
NoSuchResource: "No se encontraron contenidos de respaldo en la base de datos, omitiendo..."
CleanLog: "Limpiar registro"
CleanLogByName: "Limpiar registro de {{.name}}"
WafIpGroupNotFound: "¡Grupo de IP de WAF no encontrado, por favor añádalo primero!"

#toolbox
ErrNotExistUser: 'El usuario actual no existe, modifíquelo e intente de nuevo'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ InExecuting: "現在のタスクは実行中です。重複して実行しない
NoSuchResource: "データベースにバックアップ内容が見つかりませんでした。スキップします..."
CleanLog: "ログをクリーン"
CleanLogByName: "{{.name}} のログをクリーン"
WafIpGroupNotFound: "WAF IPグループが見つかりません。先に追加してください!"

#toolbox
ErrNotExistUser: '現在のユーザーは存在しません。変更してもう一度お試しください。'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "현재 작업이 실행 중입니다. 중복 실행하지 마세
NoSuchResource: "데이터베이스에서 백업 내용을 찾을 수 없어 건너뜁니다..."
CleanLog: "로그 정리"
CleanLogByName: "{{.name}} 로그 정리"
WafIpGroupNotFound: "WAF IP 그룹을 찾을 수 없습니다. 먼저 추가해 주세요!"

#도구상자
ErrNotExistUser: '현재 사용자가 존재하지 않습니다. 수정한 후 다시 시도하세요!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "Tugas semasa sedang dilaksanakan, jangan ulangi pelaksanaan!"
NoSuchResource: "Tiada kandungan sandaran ditemui dalam pangkalan data, dilangkau..."
CleanLog: "Bersihkan log"
CleanLogByName: "Bersihkan log {{.name}}"
WafIpGroupNotFound: "Kumpulan IP WAF tidak dijumpai, sila tambahkannya dahulu!"

#kotak alat
ErrNotExistUser: 'Pengguna semasa tidak wujud, sila ubah suai dan cuba lagi!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/pt-BR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "A tarefa atual está sendo executada, não repita a execução!"
NoSuchResource: "Nenhum conteúdo de backup encontrado no banco de dados, ignorando..."
CleanLog: "Limpar log"
CleanLogByName: "Limpar log de {{.name}}"
WafIpGroupNotFound: "Grupo de IP do WAF não encontrado, por favor, adicione-o primeiro!"

#caixa de ferramentas
ErrNotExistUser: 'O usuário atual não existe, modifique e tente novamente!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "Текущая задача выполняется, не повт
NoSuchResource: "В базе данных не найдено содержимое резервной копии, пропускаем..."
CleanLog: "Очистить журнал"
CleanLogByName: "Очистить журнал {{.name}}"
WafIpGroupNotFound: "Группа IP WAF не найдена, пожалуйста, сначала добавьте её!"

#ящик для инструментов
ErrNotExistUser: 'Текущий пользователь не существует, измените его и повторите попытку!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/tr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ InExecuting: "Mevcut görev yürütülüyor, lütfen tekrar yürütmeyin!"
NoSuchResource: "Veritabanında yedek içeriği bulunamadı, atlanıyor..."
CleanLog: "Günlüğü temizle"
CleanLogByName: "{{.name}} günlüğünü temizle"
WafIpGroupNotFound: "WAF IP grubu bulunamadı, lütfen önce ekleyin!"

#toolbox
ErrNotExistUser: 'Mevcut kullanıcı mevcut değil, lütfen değiştirin ve tekrar deneyin!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ InExecuting: "目前任務正在執行中,請勿重複執行!"
NoSuchResource: "資料庫中未能查詢到備份內容,跳過..."
CleanLog: "清理日誌"
CleanLogByName: "清理 {{.name}} 日誌"
WafIpGroupNotFound: "WAF IP 群組未找到,請先新增!"

#toolbox
ErrNotExistUser: '目前使用者不存在,請修改後重試!'
Expand Down
1 change: 1 addition & 0 deletions agent/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ InExecuting: "当前任务正在执行中,请勿重复执行!"
NoSuchResource: "数据库中未能查询到备份内容,跳过..."
CleanLog: "清理日志"
CleanLogByName: "清理 {{.name}} 日志"
WafIpGroupNotFound: "WAF IP 组未找到,请先添加!"

#toolbox
ErrNotExistUser: "当前用户不存在,请修改后重试!"
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/api/modules/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export const cleanLogs = (param: Log.CleanLog) => {
return http.post(`/core/logs/clean`, param);
};

export const searchTasks = (req: Log.SearchTaskReq) => {
return http.post<ResPage<Log.Task>>(`/logs/tasks/search`, req);
export const searchTasks = (req: Log.SearchTaskReq, node?: string) => {
const params = node ? `?operateNode=${node}` : '';
return http.post<ResPage<Log.Task>>(`/logs/tasks/search${params}`, req);
};

export const countExecutingTask = () => {
Expand Down
48 changes: 48 additions & 0 deletions frontend/src/components/node-select/index.vue
Original file line number Diff line number Diff line change
@@ -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) {}

Check warning on line 42 in frontend/src/components/node-select/index.vue

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Handle this exception or don't catch it at all.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZsRK55Uo-E7ro42ZCjv&open=AZsRK55Uo-E7ro42ZCjv&pullRequest=11317
};

onMounted(() => {
listNodes();
});
</script>
19 changes: 10 additions & 9 deletions frontend/src/components/task-list/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<template>
<DrawerPro
v-model="open"
size="large"
:header="$t('menu.msgCenter')"
:resource="globalStore.currentNode"
@close="handleClose"
>
<DrawerPro v-model="open" size="large" :header="$t('menu.msgCenter')" @close="handleClose">
<template #content>
<LayoutContent v-loading="loading" :title="$t('logs.task')">
<template #leftToolBar>
<NodeSelect v-model="targeNode" @change="search()" />
</template>
<template #rightToolBar>
<el-select v-model="req.status" @change="search()" clearable class="p-w-200">
<template #prefix>{{ $t('commons.table.status') }}</template>
Expand Down Expand Up @@ -50,11 +47,13 @@
</template>

<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 { searchTasks } from '@/api/modules/log';
import { reactive, ref } from 'vue';
import { Log } from '@/api/interface/log';
import TaskLog from '@/components/log/task/index.vue';
import bus from '@/global/bus';
import { GlobalStore } from '@/store';
const globalStore = GlobalStore();
Expand All @@ -79,14 +78,15 @@ const req = reactive({
page: 1,
pageSize: 10,
});
const targeNode = ref('local');

const search = async () => {
bus.emit('refreshTask', true);
req.page = paginationConfig.currentPage;
req.pageSize = paginationConfig.pageSize;
loading.value = true;
try {
const res = await searchTasks(req);
const res = await searchTasks(req, targeNode.value);
loading.value = false;
data.value = res.data.items;
paginationConfig.total = res.data.total;
Expand All @@ -101,6 +101,7 @@ const openTaskLog = (row: Log.Task) => {
};

const acceptParams = () => {
targeNode.value = globalStore.currentNode;
search();
open.value = true;
};
Expand Down
Loading