浏览代码

bug修复

Leo 2 年之前
父节点
当前提交
8fd8a2535d

文件差异内容过多而无法显示
+ 0 - 0
demo1.dag


+ 18 - 0
packages/filebrowser/src/api/datamanage.ts

@@ -83,3 +83,21 @@ export const tableContent = async (params: ITableContent): Promise<any> => {
     return 'error';
   }
 };
+
+export const uploadTableStatus = async (id: number): Promise<any> => {
+  const url = `${endpoint}/jpt/datamanagement/info?id=${id}`;
+  try {
+    const resp = await fetch(url, { method: 'get' });
+    if (!resp.ok) {
+      return 'error';
+    }
+    const data = await resp.json();
+    if (data.code !== 200) {
+      return 'error';
+    }
+    return data.data;
+  } catch (e) {
+    console.log(e);
+    return 'error';
+  }
+};

+ 31 - 3
packages/filebrowser/src/datamanage.tsx

@@ -1,8 +1,13 @@
 import React from 'react';
-import { deleteDataMgmt, getDataMgmtList } from './api/datamanage';
+import {
+  deleteDataMgmt,
+  getDataMgmtList,
+  uploadTableStatus
+} from './api/datamanage';
 import Menu from '@mui/material/Menu';
 import MenuItem from '@mui/material/MenuItem';
 import fileIcon from '../style/img/table.png';
+import { message } from 'antd';
 interface IProps {
   onOpenData: (tableInfo: any) => void;
 }
@@ -24,7 +29,7 @@ const DataManage: React.FC<IProps> = props => {
   );
 
   const tableClick = (table: any) => {
-    props.onOpenData(table);
+    void fetchTableStatus(table);
   };
 
   const handleContextMenu = (event: React.MouseEvent, table: any) => {
@@ -49,7 +54,7 @@ const DataManage: React.FC<IProps> = props => {
 
   const handleWatch = () => {
     setContextMenu(null);
-    props.onOpenData(currentTable);
+    void fetchTableStatus(currentTable);
   };
 
   const handleDelete = async () => {
@@ -58,6 +63,29 @@ const DataManage: React.FC<IProps> = props => {
     refresh();
   };
 
+  const fetchTableStatus = async (table: any) => {
+    if (table.status === 1) {
+      const data = await uploadTableStatus(table.id);
+      switch (data.status) {
+        case 1:
+          void message.info('数据表正在转存');
+          break;
+        case 2:
+          props.onOpenData(table);
+          break;
+        case 3:
+          void message.error('数据表转存失败');
+          break;
+        default:
+          break;
+      }
+    } else if (table.status === 3) {
+      void message.error('数据表转存失败');
+    } else {
+      props.onOpenData(table);
+    }
+  };
+
   const contextMenuView = (
     <Menu
       open={contextMenu !== null}

+ 0 - 1
packages/filebrowser/src/dataviewwidget.tsx

@@ -12,7 +12,6 @@ class DataTableWidget extends ReactWidget {
   }
 
   private _requestData = async (table: any, page: number, size: number) => {
-    console.log(table);
     const res = await tableContent({
       table_name: table.table_name,
       page,

+ 3 - 0
packages/yili-dag/src/Dag.tsx

@@ -907,6 +907,7 @@ export default class Dag extends React.Component<any, any> {
               <DatasourceNodeInfo
                 nodeInfo={this.state.selectedNodeData}
                 node={this.state.currentDblNode}
+                close={this.hideNodeInfo}
               />
             )}
             {/* 脚本节点 */}
@@ -917,6 +918,7 @@ export default class Dag extends React.Component<any, any> {
                 node={this.state.currentDblNode}
                 scriptInputs={this.state.scriptInputNodes}
                 dagId={this.state.dagId}
+                close={this.hideNodeInfo}
               />
             )}
             {/* 输出源节点 */}
@@ -924,6 +926,7 @@ export default class Dag extends React.Component<any, any> {
               <OutputNodeInfo
                 nodeInfo={this.state.selectedNodeData}
                 node={this.state.currentDblNode}
+                close={this.hideNodeInfo}
               />
             )}
           </Drawer>

+ 55 - 14
packages/yili-dag/src/DatasourceNodeInfo.tsx

@@ -1,6 +1,15 @@
 import React from 'react';
 // import { PlusCircleOutlined } from '@ant-design/icons';
-import { Form, Input, Space, Select, message, Checkbox, Radio } from 'antd';
+import {
+  Form,
+  Input,
+  Space,
+  Select,
+  message,
+  Checkbox,
+  Radio,
+  Button
+} from 'antd';
 import { getDebugTable, getLocalDebugTable, getSchema } from './request';
 import { CheckboxChangeEvent } from 'antd/es/checkbox';
 
@@ -48,10 +57,10 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
           dataType: strs[2]
         };
       });
-      this.props.nodeInfo.inputSource = input;
       (this.formRef.current as any).setFieldsValue({
         inputDatasource: input
       });
+      this.setState({ checkAll: false });
     } else {
       message.error('获取本地调试数据表失败');
     }
@@ -63,12 +72,8 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
     this.getLocalDebugTableList();
   }
 
-  componentWillUnmount() {
-    this.props.node.setData({ ...this.props.nodeInfo });
-  }
-
   onCheckAll(e: CheckboxChangeEvent) {
-    const val = this.props.nodeInfo.inputSource;
+    const val = (this.formRef.current as any).getFieldValue('inputDatasource');
     const checkData = val.map((item: any) => ({
       ...item,
       dataSelect: e.target.checked
@@ -76,12 +81,34 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
     (this.formRef.current as any).setFieldsValue({
       inputDatasource: checkData
     });
-    this.props.nodeInfo.inputSource = checkData;
     this.setState({
       checkAll: e.target.checked
     });
   }
 
+  submit() {
+    const { inputDatasource, nodeName, tablePath, dataTable } = (this.formRef
+      .current as any).getFieldsValue();
+    if (nodeName) {
+      this.props.nodeInfo.inputSource = inputDatasource;
+      this.props.nodeInfo.nodeName = nodeName;
+      this.props.nodeInfo.tablePath = tablePath;
+      this.props.nodeInfo.dataTableId = dataTable;
+      this.props.node.setData({ ...this.props.nodeInfo });
+      this.props.close();
+    } else {
+      message.error('请输入节点名字');
+    }
+  }
+
+  onReset() {
+    (this.formRef.current as any).resetFields();
+    (this.formRef.current as any).setFieldValue(
+      'nodeName',
+      this.props.nodeInfo.nodeName
+    );
+  }
+
   render() {
     return (
       <div className="node-datasource">
@@ -109,7 +136,6 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
           <Form.Item name="tablePath" label="选择调试表路径:">
             <Radio.Group
               onChange={e => {
-                this.props.nodeInfo.tablePath = e.target.value;
                 this.setState({ currentTablePath: e.target.value });
               }}
             >
@@ -135,9 +161,7 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
                     })
               }
               placeholder="选择调试数据表"
-              onSelect={(val: any, option: any) => {
-                this.props.nodeInfo.dataTableId = val;
-                this.props.nodeInfo.dataTableName = option.label;
+              onSelect={(val: any) => {
                 this.getTableSchema(val);
               }}
             />
@@ -168,8 +192,6 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
                           this.setState({
                             checkAll: false
                           });
-                          this.props.nodeInfo.inputSource = (this.formRef
-                            .current as any).getFieldsValue().inputDatasource;
                         }}
                       />
                     </Form.Item>
@@ -209,6 +231,25 @@ export default class DatasourceNodeInfo extends React.Component<any, any> {
               </>
             )}
           </Form.List>
+          <Form.Item style={{ marginTop: '20px' }}>
+            <Space>
+              <Button
+                type="primary"
+                onClick={() => {
+                  this.submit();
+                }}
+              >
+                保存
+              </Button>
+              <Button
+                onClick={() => {
+                  this.onReset();
+                }}
+              >
+                重置
+              </Button>
+            </Space>
+          </Form.Item>
         </Form>
       </div>
     );

+ 48 - 11
packages/yili-dag/src/OutputNodeInfo.tsx

@@ -26,7 +26,6 @@ export default class OutputNodeInfo extends React.Component<any, any> {
           dataType: strs[2]
         };
       });
-      this.props.nodeInfo.outputSource = output;
       (this.formRef.current as any)?.setFieldsValue({
         outputSource: output
       });
@@ -64,12 +63,33 @@ export default class OutputNodeInfo extends React.Component<any, any> {
     this.getLocalDebugTableList();
   }
 
-  componentWillUnmount() {
-    this.props.node.setData({ ...this.props.nodeInfo });
+  submit() {
+    const { outputSource, nodeName, tablePath, dataTable } = (this.formRef
+      .current as any).getFieldsValue();
+    if (nodeName) {
+      this.props.nodeInfo.outputSource = outputSource;
+      this.props.nodeInfo.nodeName = nodeName;
+      this.props.nodeInfo.tablePath = tablePath;
+      this.props.nodeInfo.dataTableId = dataTable;
+      this.props.node.setData({ ...this.props.nodeInfo });
+      this.props.close();
+    } else {
+      message.error('请输入节点名字');
+    }
+  }
+
+  onReset() {
+    (this.formRef.current as any).resetFields();
+    (this.formRef.current as any).setFieldValue(
+      'nodeName',
+      this.props.nodeInfo.nodeName
+    );
   }
 
   enterOutputField(e: any, index: number) {
-    const outputSource = this.props.nodeInfo.outputSource;
+    const outputSource = (this.formRef.current as any).getFieldValue(
+      'outputSource'
+    );
     if (outputSource[index]) {
       outputSource[index]['dataField'] = e.target.value.trim();
     } else {
@@ -78,7 +98,9 @@ export default class OutputNodeInfo extends React.Component<any, any> {
   }
 
   changeOutputFieldType(val: string, index: number) {
-    const outputSource = this.props.nodeInfo.outputSource;
+    const outputSource = (this.formRef.current as any).getFieldValue(
+      'outputSource'
+    );
     if (outputSource[index]) {
       outputSource[index]['dataType'] = val;
     } else {
@@ -91,11 +113,9 @@ export default class OutputNodeInfo extends React.Component<any, any> {
       dataTable: '',
       tablePath: ''
     });
-    this.props.nodeInfo.dataTableId = '';
-    this.props.nodeInfo.tablePath = '';
-    const data = this.props.nodeInfo.outputSource;
+    const data = (this.formRef.current as any).getFieldValue('outputSource');
     const checkData = data.filter((_: any, index: number) => index !== val);
-    this.props.nodeInfo.outputSource = checkData;
+    (this.formRef.current as any).setFieldValue('outputSource', checkData);
   }
 
   render() {
@@ -125,7 +145,6 @@ export default class OutputNodeInfo extends React.Component<any, any> {
           <Form.Item name="tablePath" label="选择调试表路径:">
             <Radio.Group
               onChange={e => {
-                this.props.nodeInfo.tablePath = e.target.value;
                 this.setState({ currentTablePath: e.target.value });
               }}
             >
@@ -152,7 +171,6 @@ export default class OutputNodeInfo extends React.Component<any, any> {
               }
               placeholder="选择调试数据表"
               onSelect={(val: any) => {
-                this.props.nodeInfo.dataTableId = val;
                 this.getTableSchema(val);
               }}
             />
@@ -221,6 +239,25 @@ export default class OutputNodeInfo extends React.Component<any, any> {
               </>
             )}
           </Form.List>
+          <Form.Item style={{ marginTop: '20px' }}>
+            <Space>
+              <Button
+                type="primary"
+                onClick={() => {
+                  this.submit();
+                }}
+              >
+                保存
+              </Button>
+              <Button
+                onClick={() => {
+                  this.onReset();
+                }}
+              >
+                重置
+              </Button>
+            </Space>
+          </Form.Item>
         </Form>
       </div>
     );

+ 64 - 15
packages/yili-dag/src/ScriptNodeInfo.tsx

@@ -22,6 +22,8 @@ import { getNodeResult } from './request';
 const { Panel } = Collapse;
 
 export default class ScriptNodeInfo extends React.Component<any, any> {
+  formRef = React.createRef();
+
   constructor(props: any) {
     super(props);
     this.state = {
@@ -62,8 +64,41 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
     });
   }
 
-  componentWillUnmount() {
-    this.props.node.setData({ ...this.props.nodeInfo });
+  submit() {
+    const { nodeId, nodeName, outputData } = (this.formRef
+      .current as any).getFieldsValue();
+    if (nodeName) {
+      const id = this.props.nodeInfo.id;
+      const node = this.props.graph.getCellById(id);
+      this.props.nodeInfo.inputNumber = this.state.inputNumber;
+      this.updateInputPorts(node, this.state.inputNumber);
+      this.props.nodeInfo.nodeName = nodeName;
+      this.props.nodeInfo.nodeId = nodeId;
+      this.props.nodeInfo.outputData = outputData;
+      this.updateOutputPorts(outputData);
+      this.props.node.setData({ ...this.props.nodeInfo });
+      this.props.close();
+    } else {
+      message.error('请输入节点名字');
+    }
+    this.setState({ outputEditing: true });
+  }
+
+  onReset() {
+    (this.formRef.current as any).resetFields();
+    (this.formRef.current as any).setFieldValue(
+      'nodeName',
+      this.props.nodeInfo.nodeName
+    );
+    console.log(
+      this.props.nodeInfo,
+      (this.formRef.current as any).getFieldsValue()
+    );
+    this.setState({
+      inputNumber: this.props.nodeInfo.inputNumber,
+      outputData: this.props.nodeInfo.outputData
+    });
+    this.setState({ outputEditing: false });
   }
 
   // 添加输入端点
@@ -83,11 +118,11 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
 
   // 更新输入数量
   updateNumber = (inputNumber: number) => {
-    const id = this.props.nodeInfo.id;
-    const node = this.props.graph.getCellById(id);
+    // const id = this.props.nodeInfo.id;
+    // const node = this.props.graph.getCellById(id);
     this.setState({ inputNumber });
-    this.props.nodeInfo.inputNumber = inputNumber;
-    this.updateInputPorts(node, inputNumber);
+    // this.props.nodeInfo.inputNumber = inputNumber;
+    // this.updateInputPorts(node, inputNumber);
   };
 
   updateOutputPorts = (outputData: any) => {
@@ -117,17 +152,11 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
   enterOutputVar = (e: any) => {
     const value = e.target.value.trim();
     if (e.key === 'Enter' && value) {
-      // e.target.setAttribute('disabled', 'disabled')
       this.setState({ outputEditing: false });
-      // const outputData = values.outputData?.filter((item: any) => {
-      //   return item && item.outputVar
-      // })
-      // this.setState({outputData})
-      const outputData = this.state.outputData;
+      const outputData = [...this.state.outputData];
       outputData.push({ outputVar: value });
       this.setState({ outputData });
-      this.props.nodeInfo.outputData = outputData;
-      this.updateOutputPorts(outputData);
+      // this.updateOutputPorts(outputData);
     }
   };
 
@@ -175,6 +204,7 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
       <div className="node-script">
         {/* 脚本节点信息 */}
         <Form
+          ref={this.formRef as any}
           name="datasourceInfo"
           autoComplete="off"
           layout="vertical"
@@ -292,7 +322,7 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
                       onClick={() => {
                         const outputData = this.state.outputData;
                         outputData.splice(name, 1);
-                        this.updateOutputPorts(outputData);
+                        // this.updateOutputPorts(outputData);
                         return remove(name);
                       }}
                       style={{ color: '#147BD1' }}
@@ -323,6 +353,25 @@ export default class ScriptNodeInfo extends React.Component<any, any> {
               </>
             )}
           </Form.List>
+          <Form.Item style={{ marginTop: '20px' }}>
+            <Space>
+              <Button
+                type="primary"
+                onClick={() => {
+                  this.submit();
+                }}
+              >
+                保存
+              </Button>
+              <Button
+                onClick={() => {
+                  this.onReset();
+                }}
+              >
+                重置
+              </Button>
+            </Space>
+          </Form.Item>
         </Form>
         {/* 脚本编辑弹窗 */}
         <Modal

部分文件因为文件数量过多而无法显示