@gingkoo/pandora-metabase 0.0.1-alpha.1 → 0.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,93 +1,79 @@
1
- # pandora-sql
2
-
3
-
4
-
5
- ## Getting started
6
-
7
- To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
-
9
- Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
-
11
- ## Add your files
12
-
13
- - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
- - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
1
+ # Pandora-SQL 使用指南
2
+
3
+ ## 功能概述
4
+
5
+ `Pandora-SQL` 是一个用于动态生成 SQL 查询的工具库,支持通过可视化界面配置表结构、字段及查询逻辑。
6
+
7
+ ### 主要功能
8
+
9
+ - **动态获取表字段**:使用 `getTableColumns` 方法可以动态获取指定表的最新字段信息,并且可以通过设置 `isCacheColumns=true` 来启用缓存机制(默认开启),减少重复请求。
10
+ - **可视化 SQL 构建**:通过 `MetaBase` 组件,用户能够以图形化的方式构建 SQL 查询,支持多种元数据类型,如 `MetaData`, `MetaJoin`, `MetaFilter` 等。
11
+ - **灵活扩展**:提供了丰富的接口和类型定义,便于根据具体需求进行定制和扩展。
12
+
13
+ ### 类型定义
14
+
15
+ ```ts
16
+ export type MetaListType =
17
+ | MetaData
18
+ | MetaJoin
19
+ | MetaCustom
20
+ | MetaFilter
21
+ | MetaSummarize
22
+ | MetaSort
23
+ | MetaLimit;
24
+
25
+ export interface MetaData_TableType {
26
+ name: string; // 表名
27
+ alias: string; // 别名
28
+ }
29
+
30
+ export interface MetaData_ColumnsType {
31
+ name: string; // 字段名
32
+ name_zh: string; // 字段中文名称
33
+ database_type: SQL_COLUMN_TYPE | string; // 数据库中的字段类型
34
+ special_type: SpecialType | string; // 特殊类型,如主键、外键等
35
+ select: boolean; // 是否在查询中选中该字段
36
+ }
37
+
38
+ export type InitColumnsType = Omit<MetaData_ColumnsType, 'select'>;
39
+
40
+ export interface MetaBaseProps {
41
+ loading?: boolean; // 加载状态
42
+ value?: MetaListType[]; // 当前组件的值,用于回显数据
43
+ tableData?: MetaData_TableType[]; // 包含表别名的数据
44
+ showExecute?: boolean; // 是否显示执行按钮,默认为true
45
+ onExecute?: (params: MetaListType[]) => void; // 点击执行按钮时的回调函数
46
+ isCacheColumns?: boolean; // 是否启用列缓存,默认为true
47
+ getTableColumns?: (tableName: string) => Promise<InitColumnsType[]>; // 动态获取表列的方法
48
+ onChange?: (val: MetaListType[]) => void; // 当选择改变时触发的回调函数
49
+ }
15
50
 
16
51
  ```
17
- cd existing_repo
18
- git remote add origin http://git.server.gingkoo/frontend/pandora/pandora-components/pandora-sql.git
19
- git branch -M main
20
- git push -uf origin main
21
- ```
22
-
23
- ## Integrate with your tools
24
-
25
- - [ ] [Set up project integrations](http://git.server.gingkoo/frontend/pandora/pandora-components/pandora-sql/-/settings/integrations)
26
-
27
- ## Collaborate with your team
28
-
29
- - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
- - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
- - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
- - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
- - [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
-
35
- ## Test and Deploy
36
-
37
- Use the built-in continuous integration in GitLab.
38
-
39
- - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
- - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
- - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
- - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
- - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
-
45
- ***
46
-
47
- # Editing this README
48
-
49
- When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
-
51
- ## Suggestions for a good README
52
-
53
- Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54
-
55
- ## Name
56
- Choose a self-explaining name for your project.
57
-
58
- ## Description
59
- Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
60
-
61
- ## Badges
62
- On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
63
-
64
- ## Visuals
65
- Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
66
-
67
- ## Installation
68
- Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
69
-
70
- ## Usage
71
- Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
72
-
73
- ## Support
74
- Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
75
-
76
- ## Roadmap
77
- If you have ideas for releases in the future, it is a good idea to list them in the README.
78
-
79
- ## Contributing
80
- State if you are open to contributions and what your requirements are for accepting them.
81
-
82
- For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
83
-
84
- You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
85
-
86
- ## Authors and acknowledgment
87
- Show your appreciation to those who have contributed to the project.
88
-
89
- ## License
90
- For open source projects, say how it is licensed.
91
52
 
92
- ## Project status
93
- If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
53
+ ## 代码示例
54
+
55
+ ```tsx
56
+ const [table, setTable] = useState([]);
57
+ const [value, setValue] = useState<MetaListType[]>([]);
58
+
59
+ <MetaBase
60
+ value={value}
61
+ tableData={table}
62
+ onChange={setValue}
63
+ getTableColumns={async (name: string) => {
64
+ let data: MetaData_ColumnsType[] = [
65
+ {
66
+ database_type: 'STRING',
67
+ name: 'C_RSV5',
68
+ select: true,
69
+ special_type: '',
70
+ name_zh: '备用字段(项目组可使用)',
71
+ },
72
+ ];
73
+ return data;
74
+ }}
75
+ onExecute={(v) => {
76
+ console.log(v);
77
+ }}
78
+ />
79
+ ```
package/lib/es/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  /**
2
- * @gingkoo/pandora-metabase v0.0.1-alpha.1
2
+ * @gingkoo/pandora-metabase v0.0.1-alpha.2
3
3
  */
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import * as React from 'react';
6
6
  import React__default, { forwardRef, useRef, useImperativeHandle, useEffect, useState, useMemo } from 'react';
7
7
  import cx from 'classnames';
8
- import { DatePicker, Menu, Dropdown, Button, Input, Tooltip, InputNumber } from '@gingkoo/pandora';
9
- import { DownArrow, Loading } from '@gingkoo/pandora-icons';
8
+ import { DatePicker, Menu, Dropdown, Button, Input, Tooltip, InputNumber, Spinner } from '@gingkoo/pandora';
10
9
  import Styled from 'styled-components';
11
10
  import _$2 from 'underscore';
12
11
  import ReactDOM from 'react-dom';
@@ -14,6 +13,7 @@ import ReactDOMServer from 'react-dom/server';
14
13
  import cloneDeep from 'lodash/cloneDeep';
15
14
  import { configure, makeAutoObservable } from 'mobx';
16
15
  import 'mobx-react';
16
+ import { DownArrow } from '@gingkoo/pandora-icons';
17
17
  import moment from 'dayjs';
18
18
 
19
19
  function styleInject(css, ref) {
@@ -5541,7 +5541,7 @@ const MetaBase = props => {
5541
5541
  loading,
5542
5542
  showExecute = true,
5543
5543
  onExecute,
5544
- isCacheColumns,
5544
+ isCacheColumns = true,
5545
5545
  value,
5546
5546
  tableData: _tableData,
5547
5547
  getTableColumns,
@@ -5694,10 +5694,13 @@ const MetaBase = props => {
5694
5694
  }
5695
5695
  return false;
5696
5696
  }, [metaList]);
5697
- if (loading) return null;
5698
- return (
5699
- // @ts-ignore
5700
- jsx(VisualBox, {
5697
+ // if (loading) return null;
5698
+ return jsx(Spinner, {
5699
+ loading: loading,
5700
+ style: {
5701
+ display: 'block'
5702
+ },
5703
+ children: jsx(VisualBox, {
5701
5704
  ref: popupContainer,
5702
5705
  children: jsxs("div", {
5703
5706
  className: 'sqb',
@@ -5726,8 +5729,9 @@ const MetaBase = props => {
5726
5729
  })
5727
5730
  }), showExecute && jsx(Button, {
5728
5731
  type: 'primary',
5732
+ loading: loading,
5729
5733
  className: `sqb-btn`,
5730
- icon: loading ? jsx(Loading, {}) : null,
5734
+ // icon={loading ? <Spinner /> : null}
5731
5735
  disabled: loading,
5732
5736
  onClick: () => {
5733
5737
  onExecute?.(metaList);
@@ -5749,7 +5753,7 @@ const MetaBase = props => {
5749
5753
  })]
5750
5754
  })
5751
5755
  })
5752
- );
5756
+ });
5753
5757
  };
5754
5758
 
5755
5759
  export { MetaBase };