This is an automated email from the ASF dual-hosted git repository.

nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-webui.git


The following commit(s) were added to refs/heads/main by this push:
     new 9cd842ea [Bugfix] Support stopping getting job status with scheduling 
task (#334)
9cd842ea is described below

commit 9cd842eaae44c75943ab85c6bb9d47776666c9e3
Author: s7monk <[email protected]>
AuthorDate: Fri Jun 14 00:31:39 2024 +0800

    [Bugfix] Support stopping getting job status with scheduling task (#334)
---
 .../components/query/components/debugger/index.tsx        |  1 +
 .../src/views/playground/components/query/index.tsx       | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/paimon-web-ui/src/views/playground/components/query/components/debugger/index.tsx
 
b/paimon-web-ui/src/views/playground/components/query/components/debugger/index.tsx
index 3d664aa7..ccc78f3b 100644
--- 
a/paimon-web-ui/src/views/playground/components/query/components/debugger/index.tsx
+++ 
b/paimon-web-ui/src/views/playground/components/query/components/debugger/index.tsx
@@ -191,6 +191,7 @@ export default defineComponent({
           message.success(t('playground.job_submission_successfully'))
           jobStore.setCurrentJob(response.data)
           mittBus.emit('jobResult', response.data)
+          mittBus.emit('getStatus')
         }
         else {
           message.error(`${t('playground.job_submission_failed')}`)
diff --git a/paimon-web-ui/src/views/playground/components/query/index.tsx 
b/paimon-web-ui/src/views/playground/components/query/index.tsx
index 0b0c0172..535d4305 100644
--- a/paimon-web-ui/src/views/playground/components/query/index.tsx
+++ b/paimon-web-ui/src/views/playground/components/query/index.tsx
@@ -101,7 +101,13 @@ export default defineComponent({
 
     const getJobStatusIntervalId = ref<number | undefined>()
 
-    onMounted(() => {
+    const stopGetJobStatus = () => {
+      if (getJobStatusIntervalId.value)
+        clearInterval(getJobStatusIntervalId.value)
+    }
+
+    const startGetJobStatus = () => {
+      stopGetJobStatus()
       getJobStatusIntervalId.value = setInterval(async () => {
         if (currentJob.value && currentJob.value.jobId) {
           const response = await getJobStatus(currentJob.value.jobId)
@@ -109,6 +115,13 @@ export default defineComponent({
             jobStore.setJobStatus(response.data.status)
         }
       }, 1000)
+    }
+
+    mittBus.on('getStatus', () => startGetJobStatus())
+
+    watch(jobStatus, (jobStatus) => {
+      if (jobStatus === 'FINISHED' || jobStatus === 'CANCELED' || jobStatus 
=== 'FAILED')
+        stopGetJobStatus()
     })
 
     let computeExecutionTimeIntervalId: number

Reply via email to