Browse Source

fix: 数据湖传参、可视化定时

leo 1 year ago
parent
commit
9444ebf38e

+ 2 - 2
src/module/datasource/component/DatasourceData.jsx

@@ -179,7 +179,7 @@ const DatasourceData = props => {
             dataSource={contentData}
             bordered
             loading={contentLoading}
-            scroll={{ x: contentCols.length * 120 }}
+            scroll={{ x: contentCols.length * 200 }}
           />
         </TabPane>
         <TabPane tab="预览表结构" key="schema">
@@ -188,7 +188,7 @@ const DatasourceData = props => {
             dataSource={schemaData}
             bordered
             loading={schemaLoading}
-            scroll={{ x: schemaCols.length * 120 }}
+            scroll={{ x: schemaCols.length * 200 }}
           />
         </TabPane>
       </Tabs>

+ 14 - 11
src/module/datasource/component/DatasourceManage.jsx

@@ -259,12 +259,12 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
     setScheamData(dataList)
   }
 
-  const fetchAilabDataPreview = async (key, type) => {
+  const fetchAilabDataPreview = async (params, type) => {
     setContentLoading(true)
     const { data } =
       type === 'ailab'
-        ? await ailabTablePreview(key)
-        : await lakeTablePreview(key)
+        ? await ailabTablePreview(params)
+        : await lakeTablePreview(params)
     if (data.code === 200) {
       handleContent(data.data)
     } else {
@@ -273,10 +273,10 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
     setContentLoading(false)
   }
 
-  const fetchAilabSchema = async (key, type) => {
+  const fetchAilabSchema = async (params, type) => {
     setSchemaLoading(true)
     const { data } =
-      type === 'ailab' ? await ailabSchema(key) : await lakeSchema(key)
+      type === 'ailab' ? await ailabSchema(params) : await lakeSchema(params)
     if (data.code === 200) {
       handleSchema(data.data)
     } else {
@@ -291,9 +291,9 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
     setDataPreviewVisible(true)
   }
 
-  const watchLakeData = async table_name => {
-    fetchAilabDataPreview(table_name, 'lake')
-    fetchAilabSchema(table_name, 'lake')
+  const watchLakeData = async params => {
+    fetchAilabDataPreview(params, 'lake')
+    fetchAilabSchema(params, 'lake')
     setDataPreviewVisible(true)
   }
 
@@ -502,7 +502,10 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
         <Space size="middle">
           <Button
             onClick={() => {
-              watchLakeData(record.datatable_name)
+              watchLakeData({
+                db_name: record.database_name,
+                table_name: record.datatable_name,
+              })
             }}
             type="link">
             查看
@@ -577,7 +580,7 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
               dataSource={contentData}
               bordered
               loading={contentLoading}
-              scroll={{ x: contentCols.length * 120 }}
+              scroll={{ x: contentCols.length * 200 }}
             />
           </TabPane>
           <TabPane
@@ -589,7 +592,7 @@ const DatasourceManage = forwardRef(({ dataType }, ref) => {
               dataSource={schemaData}
               bordered
               loading={schemaLoading}
-              scroll={{ x: schemaCols.length * 120 }}
+              scroll={{ x: schemaCols.length * 200 }}
             />
           </TabPane>
         </Tabs>

+ 4 - 4
src/module/datasource/services/index.js

@@ -194,14 +194,14 @@ export const ailabSchema = (table_name) =>
     method: 'get',
   })
 
-export const lakeTablePreview = (table_name) =>
+export const lakeTablePreview = (params) =>
   request({
-    url: `jpt/datasource/preview_lake_table?table_name=${table_name}`,
+    url: `jpt/datasource/preview_lake_table?db_name=${params.db_name}&table_name=${params.table_name}`,
     method: 'get',
   })
-export const lakeSchema = (table_name) =>
+export const lakeSchema = (params) =>
   request({
-    url: `jpt/datasource/lake_table_schema?table_name=${table_name}`,
+    url: `jpt/datasource/lake_table_schema?db_name=${params.db_name}&table_name=${params.table_name}`,
     method: 'get',
   })
 

+ 26 - 3
src/module/jptmgmt/page/JptMgmt.jsx

@@ -22,6 +22,9 @@ const JptWrapper = styled.div`
 const FormItem = Form.Item
 const { Password } = Input
 
+let timer = ''
+let timeout = ''
+
 const JptMgmt = () => {
   const [jptList, setJptList] = useState([])
   const [dataLoading, setDataLoading] = useState(false)
@@ -30,6 +33,7 @@ const JptMgmt = () => {
   const [isCreateJptProgram, setIsCreateJptProgram] = useState(false)
   const [isEditJptPsd, setIsEditJptPsd] = useState(false)
   const [currentJpt, setCurrentJpt] = useState(null)
+  const [timerState, setTimerState] = useState(false)
   const [jptForm] = Form.useForm()
   const [psdForm] = Form.useForm()
 
@@ -65,16 +69,35 @@ const JptMgmt = () => {
     setDataLoading(false)
   }
 
+  const getJptState = () => {
+    setTimerState(true)
+    timeout = setTimeout(() => {
+      clearInterval(timer)
+      setSwitchLoading(false)
+    }, 100000)
+    timer = setInterval(() => {
+      fetchJptList()
+    }, 10000)
+  }
+
+  useEffect(() => {
+    if (timerState && jptList[0].programStatus) {
+      clearTimeout(timeout)
+      clearInterval(timer)
+      message.success('开启成功')
+      setSwitchLoading(false)
+    }
+  }, [timerState, jptList])
+
   const startJpt = async programme_id => {
     setSwitchLoading(true)
     const { data } = await startJupyter({ programme_id })
     if (data.code === 200) {
-      message.success('开启成功')
-      fetchJptList()
+      getJptState()
     } else {
       message.error(data.msg)
+      setSwitchLoading(false)
     }
-    setSwitchLoading(false)
   }
   const stopJpt = async programme_id => {
     setSwitchLoading(true)