@nocobase/plugin-charts 0.11.1-alpha.5 → 0.12.0-alpha.1
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/client.d.ts +2 -3
- package/client.js +1 -1
- package/{lib → dist}/client/index.d.ts +1 -0
- package/dist/client/index.js +3234 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +26 -0
- package/{src/locale/es-ES.ts → dist/locale/es-ES.js} +22 -18
- package/dist/locale/fr-FR.js +5 -0
- package/dist/locale/ja-JP.js +5 -0
- package/dist/locale/pt-BR.js +26 -0
- package/dist/locale/ru-RU.js +5 -0
- package/dist/locale/tr-TR.js +5 -0
- package/dist/locale/zh-CN.js +65 -0
- package/dist/node_modules/json5/dist/index.js +1737 -0
- package/dist/node_modules/json5/dist/index.min.js +1 -0
- package/dist/node_modules/json5/lib/cli.js +152 -0
- package/dist/node_modules/json5/lib/index.d.ts +4 -0
- package/dist/node_modules/json5/lib/index.js +1 -0
- package/dist/node_modules/json5/lib/parse.d.ts +15 -0
- package/dist/node_modules/json5/lib/parse.js +1114 -0
- package/dist/node_modules/json5/lib/register.js +13 -0
- package/dist/node_modules/json5/lib/require.js +4 -0
- package/dist/node_modules/json5/lib/stringify.d.ts +89 -0
- package/dist/node_modules/json5/lib/stringify.js +261 -0
- package/dist/node_modules/json5/lib/unicode.d.ts +3 -0
- package/dist/node_modules/json5/lib/unicode.js +4 -0
- package/dist/node_modules/json5/lib/util.d.ts +5 -0
- package/dist/node_modules/json5/lib/util.js +35 -0
- package/dist/node_modules/json5/package.json +1 -0
- package/dist/server/actions/chartsQueries.js +57 -0
- package/dist/server/actions/index.js +2 -0
- package/dist/server/collections/chartsQueries.js +30 -0
- package/dist/server/index.js +11 -0
- package/dist/server/plugin.js +66 -0
- package/dist/server/query.js +39 -0
- package/dist/server/shared/index.js +5 -0
- package/package.json +17 -28
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/ChartBlockEngine.js +0 -146
- package/lib/client/ChartBlockEngineDesigner.js +0 -293
- package/lib/client/ChartBlockInitializer.js +0 -263
- package/lib/client/ChartQueryBlockInitializer.js +0 -191
- package/lib/client/ChartQueryMetadataProvider.js +0 -91
- package/lib/client/DataSetPreviewTable.js +0 -113
- package/lib/client/Icons.js +0 -210
- package/lib/client/chartRenderComponents/index.js +0 -20
- package/lib/client/hooks/index.js +0 -38
- package/lib/client/index.js +0 -143
- package/lib/client/locale/index.js +0 -37
- package/lib/client/select/CustomSelect.js +0 -148
- package/lib/client/select/ReadPretty.js +0 -77
- package/lib/client/select/index.js +0 -27
- package/lib/client/select/shared.js +0 -66
- package/lib/client/settings/AddNewQuery.js +0 -270
- package/lib/client/settings/ConfigureFields.js +0 -39
- package/lib/client/settings/QueriesTable.js +0 -77
- package/lib/client/settings/queryTypes.js +0 -77
- package/lib/client/settings/schemas/chartsQueries.js +0 -353
- package/lib/client/templates/AreaTemplate.js +0 -81
- package/lib/client/templates/BarTemplate.js +0 -98
- package/lib/client/templates/ColumnTemplate.js +0 -98
- package/lib/client/templates/FunnelTemplate.js +0 -82
- package/lib/client/templates/LineTemplate.js +0 -89
- package/lib/client/templates/PieTemplate.js +0 -87
- package/lib/client/templates/RadarTemplate.js +0 -88
- package/lib/client/templates/ScatterTemplate.js +0 -107
- package/lib/client/templates/TableTemplate.js +0 -54
- package/lib/client/templates/index.js +0 -25
- package/lib/client/utils.js +0 -50
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -29
- package/lib/locale/es-ES.js +0 -59
- package/lib/locale/fr-FR.js +0 -8
- package/lib/locale/ja-JP.js +0 -8
- package/lib/locale/pt-BR.js +0 -29
- package/lib/locale/ru-RU.js +0 -8
- package/lib/locale/tr-TR.js +0 -8
- package/lib/locale/zh-CN.js +0 -68
- package/lib/server/actions/chartsQueries.js +0 -89
- package/lib/server/actions/index.js +0 -1
- package/lib/server/collections/chartsQueries.js +0 -33
- package/lib/server/index.js +0 -13
- package/lib/server/plugin.js +0 -106
- package/lib/server/query.js +0 -71
- package/lib/server/shared/index.js +0 -8
- package/src/client/ChartBlockEngine.tsx +0 -121
- package/src/client/ChartBlockEngineDesigner.tsx +0 -248
- package/src/client/ChartBlockInitializer.tsx +0 -223
- package/src/client/ChartQueryBlockInitializer.tsx +0 -156
- package/src/client/ChartQueryMetadataProvider.tsx +0 -64
- package/src/client/DataSetPreviewTable.tsx +0 -71
- package/src/client/Icons.tsx +0 -99
- package/src/client/chartRenderComponents/index.ts +0 -7
- package/src/client/hooks/index.ts +0 -19
- package/src/client/index.tsx +0 -115
- package/src/client/locale/index.ts +0 -18
- package/src/client/select/CustomSelect.tsx +0 -126
- package/src/client/select/ReadPretty.tsx +0 -39
- package/src/client/select/index.md +0 -31
- package/src/client/select/index.ts +0 -2
- package/src/client/select/shared.ts +0 -37
- package/src/client/settings/AddNewQuery.tsx +0 -176
- package/src/client/settings/ConfigureFields.tsx +0 -18
- package/src/client/settings/QueriesTable.tsx +0 -26
- package/src/client/settings/queryTypes.ts +0 -65
- package/src/client/settings/schemas/chartsQueries.ts +0 -319
- package/src/client/templates/AreaTemplate.tsx +0 -64
- package/src/client/templates/BarTemplate.tsx +0 -80
- package/src/client/templates/ColumnTemplate.tsx +0 -81
- package/src/client/templates/FunnelTemplate.tsx +0 -65
- package/src/client/templates/LineTemplate.tsx +0 -72
- package/src/client/templates/PieTemplate.tsx +0 -68
- package/src/client/templates/RadarTemplate.tsx +0 -71
- package/src/client/templates/ScatterTemplate.tsx +0 -90
- package/src/client/templates/TableTemplate.tsx +0 -48
- package/src/client/templates/index.ts +0 -21
- package/src/client/utils.ts +0 -39
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -23
- package/src/locale/fr-FR.ts +0 -1
- package/src/locale/ja-JP.ts +0 -1
- package/src/locale/pt-BR.ts +0 -23
- package/src/locale/ru-RU.ts +0 -1
- package/src/locale/tr-TR.ts +0 -1
- package/src/locale/zh-CN.ts +0 -64
- package/src/server/actions/chartsQueries.ts +0 -49
- package/src/server/actions/index.ts +0 -0
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/chartsQueries.ts +0 -26
- package/src/server/index.ts +0 -1
- package/src/server/plugin.ts +0 -61
- package/src/server/query.ts +0 -39
- package/src/server/shared/index.ts +0 -2
- /package/{lib → dist}/client/ChartBlockEngine.d.ts +0 -0
- /package/{lib → dist}/client/ChartBlockEngineDesigner.d.ts +0 -0
- /package/{lib → dist}/client/ChartBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/ChartQueryBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/ChartQueryMetadataProvider.d.ts +0 -0
- /package/{lib → dist}/client/DataSetPreviewTable.d.ts +0 -0
- /package/{lib → dist}/client/Icons.d.ts +0 -0
- /package/{lib → dist}/client/chartRenderComponents/index.d.ts +0 -0
- /package/{lib → dist}/client/hooks/index.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/select/CustomSelect.d.ts +0 -0
- /package/{lib → dist}/client/select/ReadPretty.d.ts +0 -0
- /package/{lib → dist}/client/select/index.d.ts +0 -0
- /package/{lib → dist}/client/select/shared.d.ts +0 -0
- /package/{lib → dist}/client/settings/AddNewQuery.d.ts +0 -0
- /package/{lib → dist}/client/settings/ConfigureFields.d.ts +0 -0
- /package/{lib → dist}/client/settings/QueriesTable.d.ts +0 -0
- /package/{lib → dist}/client/settings/queryTypes.d.ts +0 -0
- /package/{lib → dist}/client/settings/schemas/chartsQueries.d.ts +0 -0
- /package/{lib → dist}/client/templates/AreaTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/BarTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/ColumnTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/FunnelTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/LineTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/PieTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/RadarTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/ScatterTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/TableTemplate.d.ts +0 -0
- /package/{lib → dist}/client/templates/index.d.ts +0 -0
- /package/{lib → dist}/client/utils.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/es-ES.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
- /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
- /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/actions/chartsQueries.d.ts +0 -0
- /package/{lib → dist}/server/actions/index.d.ts +0 -0
- /package/{lib → dist}/server/collections/chartsQueries.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
- /package/{lib → dist}/server/query.d.ts +0 -0
- /package/{lib → dist}/server/shared/index.d.ts +0 -0
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { DownOutlined, PlusOutlined } from '@ant-design/icons';
|
|
2
|
-
import { createForm } from '@formily/core';
|
|
3
|
-
import { ISchema, useForm } from '@formily/react';
|
|
4
|
-
import { uid } from '@formily/shared';
|
|
5
|
-
import {
|
|
6
|
-
ActionContextProvider,
|
|
7
|
-
SchemaComponent,
|
|
8
|
-
useActionContext,
|
|
9
|
-
useRecord,
|
|
10
|
-
useResourceActionContext,
|
|
11
|
-
useResourceContext,
|
|
12
|
-
} from '@nocobase/client';
|
|
13
|
-
import { Button, Dropdown, MenuProps } from 'antd';
|
|
14
|
-
import React, { useMemo, useState } from 'react';
|
|
15
|
-
import { useChartQueryMetadataContext } from '../ChartQueryMetadataProvider';
|
|
16
|
-
import { lang } from '../locale';
|
|
17
|
-
import { getQueryTypeSchema } from './queryTypes';
|
|
18
|
-
|
|
19
|
-
const useCreateAction = () => {
|
|
20
|
-
const { setVisible } = useActionContext();
|
|
21
|
-
const form = useForm();
|
|
22
|
-
const { refresh } = useResourceActionContext();
|
|
23
|
-
const { resource } = useResourceContext();
|
|
24
|
-
const ctx = useChartQueryMetadataContext();
|
|
25
|
-
return {
|
|
26
|
-
async run() {
|
|
27
|
-
await form.submit();
|
|
28
|
-
await resource.create({ values: form.values });
|
|
29
|
-
setVisible(false);
|
|
30
|
-
await form.reset();
|
|
31
|
-
refresh();
|
|
32
|
-
ctx.refresh();
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const useUpdateAction = () => {
|
|
38
|
-
const { setVisible } = useActionContext();
|
|
39
|
-
const form = useForm();
|
|
40
|
-
const { refresh } = useResourceActionContext();
|
|
41
|
-
const { resource, targetKey } = useResourceContext();
|
|
42
|
-
const { [targetKey]: filterByTk } = useRecord();
|
|
43
|
-
const ctx = useChartQueryMetadataContext();
|
|
44
|
-
return {
|
|
45
|
-
async run() {
|
|
46
|
-
await form.submit();
|
|
47
|
-
await resource.update({ filterByTk, values: form.values });
|
|
48
|
-
setVisible(false);
|
|
49
|
-
await form.reset();
|
|
50
|
-
refresh();
|
|
51
|
-
ctx.refresh();
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const useCloseAction = () => {
|
|
57
|
-
const { setVisible } = useActionContext();
|
|
58
|
-
return {
|
|
59
|
-
async run() {
|
|
60
|
-
setVisible(false);
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const getSchema = (initialValue, { form, isNewRecord }) => {
|
|
66
|
-
const type = initialValue.type;
|
|
67
|
-
const schema: ISchema = {
|
|
68
|
-
type: 'void',
|
|
69
|
-
name: uid(),
|
|
70
|
-
'x-component': 'Action.Drawer',
|
|
71
|
-
'x-decorator': 'Form',
|
|
72
|
-
'x-decorator-props': {
|
|
73
|
-
form,
|
|
74
|
-
// initialValue: JSON.parse(JSON.stringify(initialValue)),
|
|
75
|
-
},
|
|
76
|
-
title: isNewRecord ? lang('Add query') : lang('Edit query'),
|
|
77
|
-
properties: {
|
|
78
|
-
title: {
|
|
79
|
-
title: lang('Title'),
|
|
80
|
-
required: true,
|
|
81
|
-
'x-component': 'Input',
|
|
82
|
-
'x-decorator': 'FormItem',
|
|
83
|
-
},
|
|
84
|
-
options: getQueryTypeSchema(type),
|
|
85
|
-
footer: {
|
|
86
|
-
type: 'void',
|
|
87
|
-
'x-component': 'Action.Drawer.Footer',
|
|
88
|
-
properties: {
|
|
89
|
-
cancel: {
|
|
90
|
-
'x-component': 'Action',
|
|
91
|
-
title: lang('Cancel'),
|
|
92
|
-
'x-component-props': {
|
|
93
|
-
useAction: '{{ useCloseAction }}',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
submit: {
|
|
97
|
-
'x-component': 'Action',
|
|
98
|
-
title: lang('Submit'),
|
|
99
|
-
'x-component-props': {
|
|
100
|
-
type: 'primary',
|
|
101
|
-
useAction: '{{ useSubmitAction }}',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
return schema;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const AddNewQuery = () => {
|
|
112
|
-
const [visible, setVisible] = useState(false);
|
|
113
|
-
const [schema, setSchema] = useState({});
|
|
114
|
-
const form = useMemo(() => createForm(), []);
|
|
115
|
-
|
|
116
|
-
const menu = useMemo<MenuProps>(() => {
|
|
117
|
-
return {
|
|
118
|
-
onClick: (info) => {
|
|
119
|
-
setVisible(true);
|
|
120
|
-
form.setValues({ type: info.key });
|
|
121
|
-
setSchema(getSchema({ type: info.key }, { form, isNewRecord: true }));
|
|
122
|
-
},
|
|
123
|
-
items: [
|
|
124
|
-
{
|
|
125
|
-
key: 'json',
|
|
126
|
-
label: 'JSON',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
key: 'sql',
|
|
130
|
-
label: 'SQL',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
key: 'api',
|
|
134
|
-
label: 'API',
|
|
135
|
-
disabled: true,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
key: 'collection',
|
|
139
|
-
label: 'Collection',
|
|
140
|
-
disabled: true,
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
};
|
|
144
|
-
}, [form]);
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<ActionContextProvider value={{ visible, setVisible }}>
|
|
148
|
-
<Dropdown menu={menu}>
|
|
149
|
-
<Button icon={<PlusOutlined />} type={'primary'}>
|
|
150
|
-
{lang('Add query')} <DownOutlined />
|
|
151
|
-
</Button>
|
|
152
|
-
</Dropdown>
|
|
153
|
-
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useCreateAction }} />
|
|
154
|
-
</ActionContextProvider>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const EditQuery = () => {
|
|
159
|
-
const [visible, setVisible] = useState(false);
|
|
160
|
-
const record = useRecord();
|
|
161
|
-
const form = useMemo(() => createForm(), []);
|
|
162
|
-
const schema = getSchema(record, { form, isNewRecord: false });
|
|
163
|
-
return (
|
|
164
|
-
<ActionContextProvider value={{ visible, setVisible }}>
|
|
165
|
-
<a
|
|
166
|
-
onClick={() => {
|
|
167
|
-
form.setValues(record);
|
|
168
|
-
setVisible(true);
|
|
169
|
-
}}
|
|
170
|
-
>
|
|
171
|
-
{lang('Edit')}
|
|
172
|
-
</a>
|
|
173
|
-
<SchemaComponent schema={schema} scope={{ useCloseAction, useSubmitAction: useUpdateAction }} />
|
|
174
|
-
</ActionContextProvider>
|
|
175
|
-
);
|
|
176
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useRecord } from '@nocobase/client';
|
|
2
|
-
import { Table } from 'antd';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
export const ConfigureFields = () => {
|
|
6
|
-
const record = useRecord();
|
|
7
|
-
return (
|
|
8
|
-
<Table
|
|
9
|
-
columns={[
|
|
10
|
-
{
|
|
11
|
-
title: '字段标识',
|
|
12
|
-
dataIndex: 'name',
|
|
13
|
-
},
|
|
14
|
-
]}
|
|
15
|
-
dataSource={record.fields || []}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SchemaComponent } from '@nocobase/client';
|
|
2
|
-
import { Card } from 'antd';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { AddNewQuery, EditQuery } from './AddNewQuery';
|
|
6
|
-
import { ConfigureFields } from './ConfigureFields';
|
|
7
|
-
import {
|
|
8
|
-
chartsQueriesSchema,
|
|
9
|
-
useDestroyAllSelectedQueriesAction,
|
|
10
|
-
useDestroyQueryItemAction,
|
|
11
|
-
} from './schemas/chartsQueries';
|
|
12
|
-
import JSON5 from 'json5';
|
|
13
|
-
|
|
14
|
-
export const QueriesTable = () => {
|
|
15
|
-
const [visible, setVisible] = useState(false);
|
|
16
|
-
const { t } = useTranslation();
|
|
17
|
-
return (
|
|
18
|
-
<Card bordered={false}>
|
|
19
|
-
<SchemaComponent
|
|
20
|
-
scope={{ JSON5, useDestroyQueryItemAction, useDestroyAllSelectedQueriesAction }}
|
|
21
|
-
schema={chartsQueriesSchema}
|
|
22
|
-
components={{ AddNewQuery, EditQuery, ConfigureFields }}
|
|
23
|
-
/>
|
|
24
|
-
</Card>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ISchema } from '@formily/react';
|
|
2
|
-
import { lodash } from '@nocobase/utils/client';
|
|
3
|
-
|
|
4
|
-
export const json: ISchema = {
|
|
5
|
-
type: 'object',
|
|
6
|
-
properties: {
|
|
7
|
-
data: {
|
|
8
|
-
title: 'JSON',
|
|
9
|
-
required: true,
|
|
10
|
-
'x-component': 'Input.TextArea',
|
|
11
|
-
'x-validator': { json5: true },
|
|
12
|
-
'x-component-props': {
|
|
13
|
-
autoSize: {
|
|
14
|
-
maxRows: 20,
|
|
15
|
-
minRows: 10,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
'x-decorator': 'FormItem',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const sql: ISchema = {
|
|
24
|
-
type: 'object',
|
|
25
|
-
properties: {
|
|
26
|
-
sql: {
|
|
27
|
-
title: 'SQL',
|
|
28
|
-
required: true,
|
|
29
|
-
'x-component': 'Input.TextArea',
|
|
30
|
-
'x-decorator': 'FormItem',
|
|
31
|
-
'x-validator': {
|
|
32
|
-
triggerType: 'onBlur',
|
|
33
|
-
validator: '{{validateSQL}}',
|
|
34
|
-
},
|
|
35
|
-
'x-component-props': {
|
|
36
|
-
autoSize: {
|
|
37
|
-
maxRows: 20,
|
|
38
|
-
minRows: 10,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const api: ISchema = {
|
|
46
|
-
type: 'object',
|
|
47
|
-
properties: {
|
|
48
|
-
api: {
|
|
49
|
-
title: 'API',
|
|
50
|
-
required: true,
|
|
51
|
-
'x-component': 'Input',
|
|
52
|
-
'x-decorator': 'FormItem',
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const types = {
|
|
58
|
-
json,
|
|
59
|
-
sql,
|
|
60
|
-
api,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const getQueryTypeSchema = (type) => {
|
|
64
|
-
return lodash.cloneDeep(types[type]);
|
|
65
|
-
};
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { ISchema } from '@formily/react';
|
|
2
|
-
import { uid } from '@formily/shared';
|
|
3
|
-
import {
|
|
4
|
-
useActionContext,
|
|
5
|
-
useRecord,
|
|
6
|
-
useRequest,
|
|
7
|
-
useResourceActionContext,
|
|
8
|
-
useResourceContext,
|
|
9
|
-
} from '@nocobase/client';
|
|
10
|
-
import { useChartQueryMetadataContext } from '../../ChartQueryMetadataProvider';
|
|
11
|
-
|
|
12
|
-
const collection = {
|
|
13
|
-
name: 'chartsQueries',
|
|
14
|
-
fields: [
|
|
15
|
-
{
|
|
16
|
-
type: 'integer',
|
|
17
|
-
name: 'title',
|
|
18
|
-
interface: 'input',
|
|
19
|
-
uiSchema: {
|
|
20
|
-
title: '{{t("Title",{ns:"charts"})}}',
|
|
21
|
-
type: 'string',
|
|
22
|
-
'x-component': 'Input',
|
|
23
|
-
required: true,
|
|
24
|
-
} as ISchema,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: 'string',
|
|
28
|
-
name: 'type',
|
|
29
|
-
interface: 'select',
|
|
30
|
-
uiSchema: {
|
|
31
|
-
title: '{{t("Type",{ns:"charts"})}}',
|
|
32
|
-
type: 'string',
|
|
33
|
-
'x-component': 'Select',
|
|
34
|
-
required: true,
|
|
35
|
-
enum: [
|
|
36
|
-
{ label: '{{t("API")}}', value: 'api' },
|
|
37
|
-
{ label: '{{t("SQL")}}', value: 'sql' },
|
|
38
|
-
{ label: '{{t("JSON")}}', value: 'json' },
|
|
39
|
-
],
|
|
40
|
-
} as ISchema,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const useDestroyQueryItemAction = () => {
|
|
46
|
-
const ctx = useChartQueryMetadataContext();
|
|
47
|
-
const { refresh } = useResourceActionContext();
|
|
48
|
-
const { resource, targetKey } = useResourceContext();
|
|
49
|
-
const { [targetKey]: filterByTk } = useRecord();
|
|
50
|
-
return {
|
|
51
|
-
async run() {
|
|
52
|
-
await resource.destroy({ filterByTk });
|
|
53
|
-
refresh();
|
|
54
|
-
ctx.refresh();
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const useDestroyAllSelectedQueriesAction = () => {
|
|
60
|
-
const ctx = useChartQueryMetadataContext();
|
|
61
|
-
const { state, setState, refresh } = useResourceActionContext();
|
|
62
|
-
const { resource, targetKey } = useResourceContext();
|
|
63
|
-
return {
|
|
64
|
-
async run() {
|
|
65
|
-
await resource.destroy({
|
|
66
|
-
filterByTk: state?.selectedRowKeys || [],
|
|
67
|
-
});
|
|
68
|
-
setState?.({ selectedRowKeys: [] });
|
|
69
|
-
refresh();
|
|
70
|
-
ctx.refresh();
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const chartsQueriesSchema: ISchema = {
|
|
76
|
-
type: 'object',
|
|
77
|
-
properties: {
|
|
78
|
-
[uid()]: {
|
|
79
|
-
type: 'void',
|
|
80
|
-
'x-decorator': 'ResourceActionProvider',
|
|
81
|
-
'x-decorator-props': {
|
|
82
|
-
collection,
|
|
83
|
-
resourceName: 'chartsQueries',
|
|
84
|
-
request: {
|
|
85
|
-
resource: 'chartsQueries',
|
|
86
|
-
action: 'list',
|
|
87
|
-
params: {
|
|
88
|
-
pageSize: 50,
|
|
89
|
-
sort: ['-id'],
|
|
90
|
-
appends: [],
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
'x-component': 'CollectionProvider',
|
|
95
|
-
'x-component-props': {
|
|
96
|
-
collection,
|
|
97
|
-
},
|
|
98
|
-
properties: {
|
|
99
|
-
actions: {
|
|
100
|
-
type: 'void',
|
|
101
|
-
'x-component': 'ActionBar',
|
|
102
|
-
'x-component-props': {
|
|
103
|
-
style: {
|
|
104
|
-
marginBottom: 16,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
properties: {
|
|
108
|
-
delete: {
|
|
109
|
-
type: 'void',
|
|
110
|
-
title: '{{ t("Delete") }}',
|
|
111
|
-
'x-component': 'Action',
|
|
112
|
-
'x-component-props': {
|
|
113
|
-
useAction: '{{ useDestroyAllSelectedQueriesAction }}',
|
|
114
|
-
confirm: {
|
|
115
|
-
title: '{{t("Delete queries",{ns:"charts"})}}',
|
|
116
|
-
content: "{{t('Are you sure you want to delete it?')}}",
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
create: {
|
|
121
|
-
type: 'void',
|
|
122
|
-
title: '{{t("Add query")}}',
|
|
123
|
-
'x-component': 'AddNewQuery',
|
|
124
|
-
'x-component-props': {
|
|
125
|
-
type: 'primary',
|
|
126
|
-
},
|
|
127
|
-
properties: {
|
|
128
|
-
drawer: {
|
|
129
|
-
type: 'void',
|
|
130
|
-
'x-component': 'Action.Drawer',
|
|
131
|
-
'x-decorator': 'Form',
|
|
132
|
-
'x-decorator-props': {
|
|
133
|
-
useValues(options) {
|
|
134
|
-
const ctx = useActionContext();
|
|
135
|
-
return useRequest(
|
|
136
|
-
() =>
|
|
137
|
-
Promise.resolve({
|
|
138
|
-
data: {
|
|
139
|
-
name: `s_${uid()}`,
|
|
140
|
-
},
|
|
141
|
-
}),
|
|
142
|
-
{ ...options, refreshDeps: [ctx.visible] },
|
|
143
|
-
);
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
title: '{{t("Add query",{ns:"charts"})}}',
|
|
147
|
-
properties: {
|
|
148
|
-
title: {
|
|
149
|
-
'x-component': 'CollectionField',
|
|
150
|
-
'x-decorator': 'FormItem',
|
|
151
|
-
},
|
|
152
|
-
type: {
|
|
153
|
-
'x-component': 'CollectionField',
|
|
154
|
-
'x-decorator': 'FormItem',
|
|
155
|
-
},
|
|
156
|
-
footer: {
|
|
157
|
-
type: 'void',
|
|
158
|
-
'x-component': 'Action.Drawer.Footer',
|
|
159
|
-
properties: {
|
|
160
|
-
cancel: {
|
|
161
|
-
title: '{{t("Cancel",{ns:"charts"})}}',
|
|
162
|
-
'x-component': 'Action',
|
|
163
|
-
'x-component-props': {
|
|
164
|
-
useAction: '{{ cm.useCancelAction }}',
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
submit: {
|
|
168
|
-
title: '{{t("Submit",{ns:"charts"})}}',
|
|
169
|
-
'x-component': 'Action',
|
|
170
|
-
'x-component-props': {
|
|
171
|
-
type: 'primary',
|
|
172
|
-
useAction: '{{ cm.useCreateAction }}',
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
table: {
|
|
184
|
-
type: 'void',
|
|
185
|
-
'x-uid': 'input',
|
|
186
|
-
'x-component': 'Table.Void',
|
|
187
|
-
'x-component-props': {
|
|
188
|
-
rowKey: 'id',
|
|
189
|
-
rowSelection: {
|
|
190
|
-
type: 'checkbox',
|
|
191
|
-
},
|
|
192
|
-
useDataSource: '{{ cm.useDataSourceFromRAC }}',
|
|
193
|
-
},
|
|
194
|
-
properties: {
|
|
195
|
-
title: {
|
|
196
|
-
type: 'void',
|
|
197
|
-
'x-decorator': 'Table.Column.Decorator',
|
|
198
|
-
'x-component': 'Table.Column',
|
|
199
|
-
properties: {
|
|
200
|
-
title: {
|
|
201
|
-
type: 'number',
|
|
202
|
-
'x-component': 'CollectionField',
|
|
203
|
-
'x-read-pretty': true,
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
type: {
|
|
208
|
-
type: 'void',
|
|
209
|
-
'x-decorator': 'Table.Column.Decorator',
|
|
210
|
-
'x-component': 'Table.Column',
|
|
211
|
-
properties: {
|
|
212
|
-
type: {
|
|
213
|
-
type: 'string',
|
|
214
|
-
'x-component': 'CollectionField',
|
|
215
|
-
'x-read-pretty': true,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
actions: {
|
|
220
|
-
type: 'void',
|
|
221
|
-
title: '{{t("Actions")}}',
|
|
222
|
-
'x-component': 'Table.Column',
|
|
223
|
-
properties: {
|
|
224
|
-
actions: {
|
|
225
|
-
type: 'void',
|
|
226
|
-
'x-component': 'Space',
|
|
227
|
-
'x-component-props': {
|
|
228
|
-
split: '|',
|
|
229
|
-
},
|
|
230
|
-
properties: {
|
|
231
|
-
fields: {
|
|
232
|
-
type: 'void',
|
|
233
|
-
title: '{{t("Configure fields")}}',
|
|
234
|
-
'x-component': 'Action.Link',
|
|
235
|
-
'x-component-props': {
|
|
236
|
-
type: 'primary',
|
|
237
|
-
},
|
|
238
|
-
properties: {
|
|
239
|
-
drawer: {
|
|
240
|
-
type: 'void',
|
|
241
|
-
'x-component': 'Action.Drawer',
|
|
242
|
-
title: '{{t("Configure fields")}}',
|
|
243
|
-
properties: {
|
|
244
|
-
configure: {
|
|
245
|
-
type: 'void',
|
|
246
|
-
'x-component': 'ConfigureFields',
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
update: {
|
|
253
|
-
type: 'void',
|
|
254
|
-
title: '{{t("Edit")}}',
|
|
255
|
-
'x-component': 'EditQuery',
|
|
256
|
-
'x-component-props': {
|
|
257
|
-
type: 'primary',
|
|
258
|
-
},
|
|
259
|
-
properties: {
|
|
260
|
-
drawer: {
|
|
261
|
-
type: 'void',
|
|
262
|
-
'x-component': 'Action.Drawer',
|
|
263
|
-
'x-decorator': 'Form',
|
|
264
|
-
'x-decorator-props': {
|
|
265
|
-
useValues: '{{ cm.useValuesFromRecord }}',
|
|
266
|
-
},
|
|
267
|
-
title: '{{t("Edit")}}',
|
|
268
|
-
properties: {
|
|
269
|
-
title: {
|
|
270
|
-
'x-component': 'CollectionField',
|
|
271
|
-
'x-decorator': 'FormItem',
|
|
272
|
-
},
|
|
273
|
-
footer: {
|
|
274
|
-
type: 'void',
|
|
275
|
-
'x-component': 'Action.Drawer.Footer',
|
|
276
|
-
properties: {
|
|
277
|
-
cancel: {
|
|
278
|
-
title: '{{t("Cancel",{ns:"charts"})}}',
|
|
279
|
-
'x-component': 'Action',
|
|
280
|
-
'x-component-props': {
|
|
281
|
-
useAction: '{{ cm.useCancelAction }}',
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
submit: {
|
|
285
|
-
title: '{{t("Submit",{ns:"charts"})}}',
|
|
286
|
-
'x-component': 'Action',
|
|
287
|
-
'x-component-props': {
|
|
288
|
-
type: 'primary',
|
|
289
|
-
useAction: '{{ cm.useUpdateAction }}',
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
delete: {
|
|
299
|
-
type: 'void',
|
|
300
|
-
title: '{{ t("Delete") }}',
|
|
301
|
-
'x-component': 'Action.Link',
|
|
302
|
-
'x-component-props': {
|
|
303
|
-
confirm: {
|
|
304
|
-
title: '{{t("Delete query",{ns:"charts"})}}',
|
|
305
|
-
content: "{{t('Are you sure you want to delete it?')}}",
|
|
306
|
-
},
|
|
307
|
-
useAction: '{{ useDestroyQueryItemAction }}',
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import JSON5 from 'json5';
|
|
2
|
-
|
|
3
|
-
const chartConfig = {
|
|
4
|
-
yField: '{{metric}}',
|
|
5
|
-
xField: '{{dimension}}',
|
|
6
|
-
seriesField: '{{category}}',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const areaTemplate = {
|
|
10
|
-
description: '1 「time」or 「Ordered Noun」 field,1 「Numerical」 field,1 「Unordered Noun」 field (optional)',
|
|
11
|
-
type: 'Area',
|
|
12
|
-
title: 'Area',
|
|
13
|
-
iconId: 'icon-area',
|
|
14
|
-
group: 2,
|
|
15
|
-
renderComponent: 'G2Plot',
|
|
16
|
-
defaultChartOptions: chartConfig,
|
|
17
|
-
configurableProperties: {
|
|
18
|
-
type: 'void',
|
|
19
|
-
properties: {
|
|
20
|
-
dimension: {
|
|
21
|
-
required: true,
|
|
22
|
-
type: 'string',
|
|
23
|
-
title: '{{t("Category axis / Dimension",{ns:"charts"})}}',
|
|
24
|
-
'x-decorator': 'FormItem',
|
|
25
|
-
'x-component': 'Select',
|
|
26
|
-
enum: '{{dataSource}}',
|
|
27
|
-
},
|
|
28
|
-
metric: {
|
|
29
|
-
required: true,
|
|
30
|
-
type: 'string',
|
|
31
|
-
title: '{{t("Value axis / Metrics",{ns:"charts"})}}',
|
|
32
|
-
'x-decorator': 'FormItem',
|
|
33
|
-
'x-component': 'Select',
|
|
34
|
-
enum: '{{dataSource}}',
|
|
35
|
-
},
|
|
36
|
-
category: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
title: '{{t("Color legend / Dimensional",{ns:"charts"})}}',
|
|
39
|
-
'x-decorator': 'FormItem',
|
|
40
|
-
'x-component': 'Select',
|
|
41
|
-
enum: '{{dataSource}}',
|
|
42
|
-
},
|
|
43
|
-
jsonConfig: {
|
|
44
|
-
type: 'void',
|
|
45
|
-
'x-component': 'div',
|
|
46
|
-
properties: {
|
|
47
|
-
template: {
|
|
48
|
-
required: true,
|
|
49
|
-
title: '{{t("JSON config",{ns:"charts"})}}',
|
|
50
|
-
type: 'string',
|
|
51
|
-
default: JSON5.stringify(chartConfig, null, 2),
|
|
52
|
-
'x-decorator': 'FormItem',
|
|
53
|
-
'x-component': 'Input.TextArea',
|
|
54
|
-
'x-component-props': {
|
|
55
|
-
autoSize: { minRows: 8, maxRows: 16 },
|
|
56
|
-
},
|
|
57
|
-
description: '{{jsonConfigDesc("Area | G2Plot","https://g2plot.antv.antgroup.com/api/plots/area")}}',
|
|
58
|
-
'x-validator': { json5: true },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
};
|