Skip to content

Commit

Permalink
feat(task): fix Issue Where Task Logs Continue Periodic Requests Afte…
Browse files Browse the repository at this point in the history
…r Being Opened (#7567)
  • Loading branch information
zhengkunwang223 authored Dec 26, 2024
1 parent 4a4e568 commit 008c369
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
9 changes: 5 additions & 4 deletions core/constant/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var WebUrlMap = map[string]struct{}{
"/apps/all": {},
"/apps/installed": {},
"/apps/upgrade": {},
"apps/setting": {},
"/apps/setting": {},

"/containers": {},
"/containers/container": {},
Expand All @@ -56,7 +56,7 @@ var WebUrlMap = map[string]struct{}{
"/containers/compose": {},
"/containers/template": {},
"/containers/setting": {},
"containers/dashboard": {},
"/containers/dashboard": {},

"/cronjobs": {},

Expand Down Expand Up @@ -88,6 +88,7 @@ var WebUrlMap = map[string]struct{}{
"/logs/website": {},
"/logs/system": {},
"/logs/ssh": {},
"/logs/task": {},

"/settings": {},
"/settings/panel": {},
Expand Down Expand Up @@ -134,8 +135,8 @@ var WebUrlMap = map[string]struct{}{
"/xpack/alert/log": {},
"/xpack/alert/setting": {},
"/xpack/setting": {},
"xpack/node": {},
"xpack/waf/stat": {},
"/xpack/node": {},
"/xpack/waf/stat": {},
}

var DynamicRoutes = []string{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/modules/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const searchTasks = (req: Log.SearchTaskReq) => {
};

export const countExecutingTask = () => {
return http.get<number>(`/tasks/executing/count`);
return http.get<number>(`/logs/tasks/executing/count`);
};
23 changes: 10 additions & 13 deletions frontend/src/components/log-file/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-loading="isLoading">
<div v-loading="initLog && isLoading">
<div v-if="defaultButton">
<el-checkbox border v-model="tailLog" class="float-left" @change="changeTail(false)">
{{ $t('commons.button.watch') }}
Expand Down Expand Up @@ -94,6 +94,7 @@ const maxPage = ref(0);
const minPage = ref(0);
let timer: NodeJS.Timer | null = null;
const logPath = ref('');
const initLog = ref(false);
const firstLoading = ref(false);
const logs = ref<string[]>([]);
Expand Down Expand Up @@ -213,6 +214,7 @@ const getContent = async (pre: boolean) => {
}
nextTick(() => {
console.log('pre', pre);
if (pre) {
logContainer.value.scrollTop = 2000;
} else {
Expand Down Expand Up @@ -249,10 +251,14 @@ const getContent = async (pre: boolean) => {
const onCloseLog = async () => {
tailLog.value = false;
clearInterval(Number(timer));
if (timer) {
clearInterval(Number(timer));
timer = null;
}
timer = null;
isLoading.value = false;
emit('update:isReading', false);
initLog.value = false;
};
watch(
Expand All @@ -263,6 +269,7 @@ watch(
);
const init = async () => {
initLog.value = true;
if (props.config.tail) {
tailLog.value = props.config.tail;
} else {
Expand All @@ -287,20 +294,10 @@ onMounted(async () => {
});
onUnmounted(() => {
console.log('onUnmounted');
onCloseLog();
});
onMounted(async () => {
firstLoading.value = true;
await init();
nextTick(() => {
if (logContainer.value) {
logContainer.value.scrollTop = totalHeight.value;
containerHeight.value = logContainer.value.getBoundingClientRect().height;
}
});
});
defineExpose({ changeTail, onDownload, clearLog });
</script>
<style lang="scss" scoped>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/task-log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ defineProps({
type: String,
default: '30%',
},
tail: {
type: Boolean,
default: true,
},
});
const config = reactive({
Expand All @@ -33,6 +37,7 @@ const config = reactive({
taskOperate: '',
resourceID: 0,
taskType: '',
tail: true,
});
const open = ref(false);
Expand Down

0 comments on commit 008c369

Please sign in to comment.