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

songjian pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel-web.git


The following commit(s) were added to refs/heads/main by this push:
     new cdd0a082 [Feat][UI] Complete the view log function. (#35)
cdd0a082 is described below

commit cdd0a082b4507ae51bba0e2dbd38fafff6af8399
Author: songjianet <[email protected]>
AuthorDate: Thu Mar 2 10:42:54 2023 +0800

    [Feat][UI] Complete the view log function. (#35)
---
 seatunnel-ui/src/locales/en_US/tasks.ts            |  3 +-
 seatunnel-ui/src/service/task/index.ts             |  2 +-
 seatunnel-ui/src/service/types.ts                  |  2 +-
 .../data-pipes}/components/log/index.tsx           |  0
 seatunnel-ui/src/views/data-pipes/create/index.tsx | 18 +++--
 .../detail/components/detail-overview.tsx          |  2 +-
 .../src/views/tasks/list/components/log-modal.tsx  | 79 ++++++++++++++++++++++
 seatunnel-ui/src/views/tasks/list/index.tsx        | 13 ++++
 seatunnel-ui/src/views/tasks/list/use-table.ts     | 15 +++-
 9 files changed, 123 insertions(+), 11 deletions(-)

diff --git a/seatunnel-ui/src/locales/en_US/tasks.ts 
b/seatunnel-ui/src/locales/en_US/tasks.ts
index e059b942..39a82a27 100644
--- a/seatunnel-ui/src/locales/en_US/tasks.ts
+++ b/seatunnel-ui/src/locales/en_US/tasks.ts
@@ -37,5 +37,6 @@ export default {
   rerun: 'Rerun',
   kill: 'Kill',
   operation: 'Operation',
-  view_log: 'View Log'
+  view_log: 'View Log',
+  log: 'Log'
 }
diff --git a/seatunnel-ui/src/service/task/index.ts 
b/seatunnel-ui/src/service/task/index.ts
index 7a48434e..5efd7aab 100644
--- a/seatunnel-ui/src/service/task/index.ts
+++ b/seatunnel-ui/src/service/task/index.ts
@@ -49,7 +49,7 @@ export function taskRecycle(scriptId: number): any {
   })
 }
 
-export function taskInstanceDetail(taskInstanceId: number): any {
+export function taskInstanceLog(taskInstanceId: number): any {
   return axios({
     url: `/task/${taskInstanceId}`,
     method: 'get'
diff --git a/seatunnel-ui/src/service/types.ts 
b/seatunnel-ui/src/service/types.ts
index 3bc79fff..dbe12056 100644
--- a/seatunnel-ui/src/service/types.ts
+++ b/seatunnel-ui/src/service/types.ts
@@ -31,4 +31,4 @@ type ResponseTable<T> = ResponseBasic<{
   data: T
 }>
 
-export { ResponseTable }
+export { ResponseBasic, ResponseTable }
diff --git a/seatunnel-ui/src/components/log/index.tsx 
b/seatunnel-ui/src/views/data-pipes/components/log/index.tsx
similarity index 100%
rename from seatunnel-ui/src/components/log/index.tsx
rename to seatunnel-ui/src/views/data-pipes/components/log/index.tsx
diff --git a/seatunnel-ui/src/views/data-pipes/create/index.tsx 
b/seatunnel-ui/src/views/data-pipes/create/index.tsx
index 88d9863b..ff2c242b 100644
--- a/seatunnel-ui/src/views/data-pipes/create/index.tsx
+++ b/seatunnel-ui/src/views/data-pipes/create/index.tsx
@@ -31,7 +31,7 @@ import {
 } from 'naive-ui'
 import { BulbOutlined } from '@vicons/antd'
 import MonacoEditor from '@/components/monaco-editor'
-import Log from '@/components/log'
+import Log from '@/views/data-pipes/components/log'
 import ConfigurationModal from './components/configuration-modal'
 import type { Router } from 'vue-router'
 import type { Ref } from 'vue'
@@ -94,7 +94,9 @@ const DataPipesCreate = defineComponent({
             'header-extra': () => (
               <NSpace>
                 <NButton secondary>{this.t('data_pipes.cancel')}</NButton>
-                <NButton secondary 
type='primary'>{this.t('data_pipes.save')}</NButton>
+                <NButton secondary type='primary'>
+                  {this.t('data_pipes.save')}
+                </NButton>
               </NSpace>
             )
           }}
@@ -125,9 +127,15 @@ const DataPipesCreate = defineComponent({
         <NCard>
           <NSpace vertical>
             <NSpace justify='end'>
-              <NButton secondary 
type='success'>{this.t('data_pipes.execute')}</NButton>
-              <NButton secondary 
type='error'>{this.t('data_pipes.kill')}</NButton>
-              <NButton secondary 
type='warning'>{this.t('data_pipes.stop')}</NButton>
+              <NButton secondary type='success'>
+                {this.t('data_pipes.execute')}
+              </NButton>
+              <NButton secondary type='error'>
+                {this.t('data_pipes.kill')}
+              </NButton>
+              <NButton secondary type='warning'>
+                {this.t('data_pipes.stop')}
+              </NButton>
               <NDropdown
                 trigger='click'
                 options={[
diff --git 
a/seatunnel-ui/src/views/data-pipes/detail/components/detail-overview.tsx 
b/seatunnel-ui/src/views/data-pipes/detail/components/detail-overview.tsx
index 485bf8c1..0151f77d 100644
--- a/seatunnel-ui/src/views/data-pipes/detail/components/detail-overview.tsx
+++ b/seatunnel-ui/src/views/data-pipes/detail/components/detail-overview.tsx
@@ -19,7 +19,7 @@ import { defineComponent, onMounted, toRefs } from 'vue'
 import { NGi, NGrid, NSpace, NTabs, NTabPane, NDataTable } from 'naive-ui'
 import { useI18n } from 'vue-i18n'
 import { useDetailOverview } from './use-detail-overview'
-import Log from '@/components/log'
+import Log from '@/views/data-pipes/components/log'
 
 const DetailOverview = defineComponent({
   setup() {
diff --git a/seatunnel-ui/src/views/tasks/list/components/log-modal.tsx 
b/seatunnel-ui/src/views/tasks/list/components/log-modal.tsx
new file mode 100644
index 00000000..ea8ca14d
--- /dev/null
+++ b/seatunnel-ui/src/views/tasks/list/components/log-modal.tsx
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { defineComponent, onMounted, ref } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { NLog } from 'naive-ui'
+import { taskInstanceLog } from '@/service/task'
+import Modal from '@/components/modal'
+import type { PropType, Ref } from 'vue'
+import type { ResponseBasic } from '@/service/types'
+
+const props = {
+  showModal: {
+    type: Boolean as PropType<boolean>,
+    default: false
+  },
+  row: {
+    type: Object as PropType<any>,
+    default: {}
+  }
+}
+
+const LogModal = defineComponent({
+  name: 'LogModal',
+  props,
+  emits: ['confirmModal'],
+  setup(props, ctx) {
+    const { t } = useI18n()
+    const log: Ref<string> = ref('')
+
+    const handleConfirm = () => {
+      ctx.emit('confirmModal')
+    }
+
+    onMounted(() => {
+      props.row.instanceId &&
+        taskInstanceLog(props.row.instanceId).then(
+          (res: ResponseBasic<{ instanceId: number; logContent: string }>) => {
+            log.value = res.data.logContent
+          }
+        )
+    })
+
+    return {
+      t,
+      log,
+      handleConfirm
+    }
+  },
+  render() {
+    return (
+      <Modal
+        title={this.t('tasks.log')}
+        show={this.showModal}
+        cancelShow={false}
+        onConfirm={this.handleConfirm}
+        style={{ width: '80%' }}
+      >
+        <NLog log={this.log} rows={35} />
+      </Modal>
+    )
+  }
+})
+
+export default LogModal
diff --git a/seatunnel-ui/src/views/tasks/list/index.tsx 
b/seatunnel-ui/src/views/tasks/list/index.tsx
index e52bda2c..f581163d 100644
--- a/seatunnel-ui/src/views/tasks/list/index.tsx
+++ b/seatunnel-ui/src/views/tasks/list/index.tsx
@@ -26,6 +26,7 @@ import {
 } from 'naive-ui'
 import { useI18n } from 'vue-i18n'
 import { useTable } from './use-table'
+import LogModal from '@/views/tasks/list/components/log-modal'
 
 const TasksList = defineComponent({
   setup() {
@@ -50,6 +51,10 @@ const TasksList = defineComponent({
       requestData()
     }
 
+    const handleConfirmLogModal = () => {
+      state.showLogModal = false
+    }
+
     onMounted(() => {
       createColumns(state)
       requestData()
@@ -60,6 +65,7 @@ const TasksList = defineComponent({
       handleSearch,
       handlePageSize,
       requestData,
+      handleConfirmLogModal,
       ...toRefs(state)
     }
   },
@@ -104,6 +110,13 @@ const TasksList = defineComponent({
             </NSpace>
           </NSpace>
         </NCard>
+        {this.showLogModal && (
+          <LogModal
+            showModal={this.showLogModal}
+            row={this.row}
+            onConfirmModal={this.handleConfirmLogModal}
+          />
+        )}
       </NSpace>
     )
   }
diff --git a/seatunnel-ui/src/views/tasks/list/use-table.ts 
b/seatunnel-ui/src/views/tasks/list/use-table.ts
index d033ec47..753f2afb 100644
--- a/seatunnel-ui/src/views/tasks/list/use-table.ts
+++ b/seatunnel-ui/src/views/tasks/list/use-table.ts
@@ -32,7 +32,9 @@ export function useTable() {
     pageSize: ref(10),
     totalPage: ref(1),
     loading: ref(false),
-    name: ref('')
+    name: ref(''),
+    showLogModal: ref(false),
+    row: ref({})
   })
 
   const createColumns = (state: any) => {
@@ -93,7 +95,11 @@ export function useTable() {
                 },
                 t('tasks.kill')
               ),
-              h(NButton, { text: true }, t('tasks.view_log'))
+              h(
+                NButton,
+                { text: true, onClick: () => handleViewLog(row) },
+                t('tasks.view_log')
+              )
             ]
           })
       }
@@ -123,6 +129,11 @@ export function useTable() {
     })
   }
 
+  const handleViewLog = (row: JobDetail) => {
+    state.showLogModal = true
+    state.row = row
+  }
+
   return {
     state,
     createColumns,

Reply via email to