@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.
Files changed (180) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/{lib → dist}/client/index.d.ts +1 -0
  4. package/dist/client/index.js +3234 -0
  5. package/{lib → dist}/index.d.ts +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/locale/en-US.js +26 -0
  8. package/{src/locale/es-ES.ts → dist/locale/es-ES.js} +22 -18
  9. package/dist/locale/fr-FR.js +5 -0
  10. package/dist/locale/ja-JP.js +5 -0
  11. package/dist/locale/pt-BR.js +26 -0
  12. package/dist/locale/ru-RU.js +5 -0
  13. package/dist/locale/tr-TR.js +5 -0
  14. package/dist/locale/zh-CN.js +65 -0
  15. package/dist/node_modules/json5/dist/index.js +1737 -0
  16. package/dist/node_modules/json5/dist/index.min.js +1 -0
  17. package/dist/node_modules/json5/lib/cli.js +152 -0
  18. package/dist/node_modules/json5/lib/index.d.ts +4 -0
  19. package/dist/node_modules/json5/lib/index.js +1 -0
  20. package/dist/node_modules/json5/lib/parse.d.ts +15 -0
  21. package/dist/node_modules/json5/lib/parse.js +1114 -0
  22. package/dist/node_modules/json5/lib/register.js +13 -0
  23. package/dist/node_modules/json5/lib/require.js +4 -0
  24. package/dist/node_modules/json5/lib/stringify.d.ts +89 -0
  25. package/dist/node_modules/json5/lib/stringify.js +261 -0
  26. package/dist/node_modules/json5/lib/unicode.d.ts +3 -0
  27. package/dist/node_modules/json5/lib/unicode.js +4 -0
  28. package/dist/node_modules/json5/lib/util.d.ts +5 -0
  29. package/dist/node_modules/json5/lib/util.js +35 -0
  30. package/dist/node_modules/json5/package.json +1 -0
  31. package/dist/server/actions/chartsQueries.js +57 -0
  32. package/dist/server/actions/index.js +2 -0
  33. package/dist/server/collections/chartsQueries.js +30 -0
  34. package/dist/server/index.js +11 -0
  35. package/dist/server/plugin.js +66 -0
  36. package/dist/server/query.js +39 -0
  37. package/dist/server/shared/index.js +5 -0
  38. package/package.json +17 -28
  39. package/server.d.ts +2 -3
  40. package/server.js +1 -1
  41. package/lib/client/ChartBlockEngine.js +0 -146
  42. package/lib/client/ChartBlockEngineDesigner.js +0 -293
  43. package/lib/client/ChartBlockInitializer.js +0 -263
  44. package/lib/client/ChartQueryBlockInitializer.js +0 -191
  45. package/lib/client/ChartQueryMetadataProvider.js +0 -91
  46. package/lib/client/DataSetPreviewTable.js +0 -113
  47. package/lib/client/Icons.js +0 -210
  48. package/lib/client/chartRenderComponents/index.js +0 -20
  49. package/lib/client/hooks/index.js +0 -38
  50. package/lib/client/index.js +0 -143
  51. package/lib/client/locale/index.js +0 -37
  52. package/lib/client/select/CustomSelect.js +0 -148
  53. package/lib/client/select/ReadPretty.js +0 -77
  54. package/lib/client/select/index.js +0 -27
  55. package/lib/client/select/shared.js +0 -66
  56. package/lib/client/settings/AddNewQuery.js +0 -270
  57. package/lib/client/settings/ConfigureFields.js +0 -39
  58. package/lib/client/settings/QueriesTable.js +0 -77
  59. package/lib/client/settings/queryTypes.js +0 -77
  60. package/lib/client/settings/schemas/chartsQueries.js +0 -353
  61. package/lib/client/templates/AreaTemplate.js +0 -81
  62. package/lib/client/templates/BarTemplate.js +0 -98
  63. package/lib/client/templates/ColumnTemplate.js +0 -98
  64. package/lib/client/templates/FunnelTemplate.js +0 -82
  65. package/lib/client/templates/LineTemplate.js +0 -89
  66. package/lib/client/templates/PieTemplate.js +0 -87
  67. package/lib/client/templates/RadarTemplate.js +0 -88
  68. package/lib/client/templates/ScatterTemplate.js +0 -107
  69. package/lib/client/templates/TableTemplate.js +0 -54
  70. package/lib/client/templates/index.js +0 -25
  71. package/lib/client/utils.js +0 -50
  72. package/lib/index.js +0 -13
  73. package/lib/locale/en-US.js +0 -29
  74. package/lib/locale/es-ES.js +0 -59
  75. package/lib/locale/fr-FR.js +0 -8
  76. package/lib/locale/ja-JP.js +0 -8
  77. package/lib/locale/pt-BR.js +0 -29
  78. package/lib/locale/ru-RU.js +0 -8
  79. package/lib/locale/tr-TR.js +0 -8
  80. package/lib/locale/zh-CN.js +0 -68
  81. package/lib/server/actions/chartsQueries.js +0 -89
  82. package/lib/server/actions/index.js +0 -1
  83. package/lib/server/collections/chartsQueries.js +0 -33
  84. package/lib/server/index.js +0 -13
  85. package/lib/server/plugin.js +0 -106
  86. package/lib/server/query.js +0 -71
  87. package/lib/server/shared/index.js +0 -8
  88. package/src/client/ChartBlockEngine.tsx +0 -121
  89. package/src/client/ChartBlockEngineDesigner.tsx +0 -248
  90. package/src/client/ChartBlockInitializer.tsx +0 -223
  91. package/src/client/ChartQueryBlockInitializer.tsx +0 -156
  92. package/src/client/ChartQueryMetadataProvider.tsx +0 -64
  93. package/src/client/DataSetPreviewTable.tsx +0 -71
  94. package/src/client/Icons.tsx +0 -99
  95. package/src/client/chartRenderComponents/index.ts +0 -7
  96. package/src/client/hooks/index.ts +0 -19
  97. package/src/client/index.tsx +0 -115
  98. package/src/client/locale/index.ts +0 -18
  99. package/src/client/select/CustomSelect.tsx +0 -126
  100. package/src/client/select/ReadPretty.tsx +0 -39
  101. package/src/client/select/index.md +0 -31
  102. package/src/client/select/index.ts +0 -2
  103. package/src/client/select/shared.ts +0 -37
  104. package/src/client/settings/AddNewQuery.tsx +0 -176
  105. package/src/client/settings/ConfigureFields.tsx +0 -18
  106. package/src/client/settings/QueriesTable.tsx +0 -26
  107. package/src/client/settings/queryTypes.ts +0 -65
  108. package/src/client/settings/schemas/chartsQueries.ts +0 -319
  109. package/src/client/templates/AreaTemplate.tsx +0 -64
  110. package/src/client/templates/BarTemplate.tsx +0 -80
  111. package/src/client/templates/ColumnTemplate.tsx +0 -81
  112. package/src/client/templates/FunnelTemplate.tsx +0 -65
  113. package/src/client/templates/LineTemplate.tsx +0 -72
  114. package/src/client/templates/PieTemplate.tsx +0 -68
  115. package/src/client/templates/RadarTemplate.tsx +0 -71
  116. package/src/client/templates/ScatterTemplate.tsx +0 -90
  117. package/src/client/templates/TableTemplate.tsx +0 -48
  118. package/src/client/templates/index.ts +0 -21
  119. package/src/client/utils.ts +0 -39
  120. package/src/index.ts +0 -1
  121. package/src/locale/en-US.ts +0 -23
  122. package/src/locale/fr-FR.ts +0 -1
  123. package/src/locale/ja-JP.ts +0 -1
  124. package/src/locale/pt-BR.ts +0 -23
  125. package/src/locale/ru-RU.ts +0 -1
  126. package/src/locale/tr-TR.ts +0 -1
  127. package/src/locale/zh-CN.ts +0 -64
  128. package/src/server/actions/chartsQueries.ts +0 -49
  129. package/src/server/actions/index.ts +0 -0
  130. package/src/server/collections/.gitkeep +0 -0
  131. package/src/server/collections/chartsQueries.ts +0 -26
  132. package/src/server/index.ts +0 -1
  133. package/src/server/plugin.ts +0 -61
  134. package/src/server/query.ts +0 -39
  135. package/src/server/shared/index.ts +0 -2
  136. /package/{lib → dist}/client/ChartBlockEngine.d.ts +0 -0
  137. /package/{lib → dist}/client/ChartBlockEngineDesigner.d.ts +0 -0
  138. /package/{lib → dist}/client/ChartBlockInitializer.d.ts +0 -0
  139. /package/{lib → dist}/client/ChartQueryBlockInitializer.d.ts +0 -0
  140. /package/{lib → dist}/client/ChartQueryMetadataProvider.d.ts +0 -0
  141. /package/{lib → dist}/client/DataSetPreviewTable.d.ts +0 -0
  142. /package/{lib → dist}/client/Icons.d.ts +0 -0
  143. /package/{lib → dist}/client/chartRenderComponents/index.d.ts +0 -0
  144. /package/{lib → dist}/client/hooks/index.d.ts +0 -0
  145. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  146. /package/{lib → dist}/client/select/CustomSelect.d.ts +0 -0
  147. /package/{lib → dist}/client/select/ReadPretty.d.ts +0 -0
  148. /package/{lib → dist}/client/select/index.d.ts +0 -0
  149. /package/{lib → dist}/client/select/shared.d.ts +0 -0
  150. /package/{lib → dist}/client/settings/AddNewQuery.d.ts +0 -0
  151. /package/{lib → dist}/client/settings/ConfigureFields.d.ts +0 -0
  152. /package/{lib → dist}/client/settings/QueriesTable.d.ts +0 -0
  153. /package/{lib → dist}/client/settings/queryTypes.d.ts +0 -0
  154. /package/{lib → dist}/client/settings/schemas/chartsQueries.d.ts +0 -0
  155. /package/{lib → dist}/client/templates/AreaTemplate.d.ts +0 -0
  156. /package/{lib → dist}/client/templates/BarTemplate.d.ts +0 -0
  157. /package/{lib → dist}/client/templates/ColumnTemplate.d.ts +0 -0
  158. /package/{lib → dist}/client/templates/FunnelTemplate.d.ts +0 -0
  159. /package/{lib → dist}/client/templates/LineTemplate.d.ts +0 -0
  160. /package/{lib → dist}/client/templates/PieTemplate.d.ts +0 -0
  161. /package/{lib → dist}/client/templates/RadarTemplate.d.ts +0 -0
  162. /package/{lib → dist}/client/templates/ScatterTemplate.d.ts +0 -0
  163. /package/{lib → dist}/client/templates/TableTemplate.d.ts +0 -0
  164. /package/{lib → dist}/client/templates/index.d.ts +0 -0
  165. /package/{lib → dist}/client/utils.d.ts +0 -0
  166. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  167. /package/{lib → dist}/locale/es-ES.d.ts +0 -0
  168. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  169. /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
  170. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  171. /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
  172. /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
  173. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  174. /package/{lib → dist}/server/actions/chartsQueries.d.ts +0 -0
  175. /package/{lib → dist}/server/actions/index.d.ts +0 -0
  176. /package/{lib → dist}/server/collections/chartsQueries.d.ts +0 -0
  177. /package/{lib → dist}/server/index.d.ts +0 -0
  178. /package/{lib → dist}/server/plugin.d.ts +0 -0
  179. /package/{lib → dist}/server/query.d.ts +0 -0
  180. /package/{lib → dist}/server/shared/index.d.ts +0 -0
@@ -1,23 +0,0 @@
1
- export default {
2
- Edit: 'Editar',
3
- Delete: 'Delete',
4
- Cancel: 'Cancelar',
5
- Submit: 'Enviar',
6
- Actions: 'Ações',
7
- Title: 'Titulo',
8
- Enable: 'Ativo',
9
- 'SAML manager': 'Gerenciador SAML',
10
- 'SAML Providers': 'Provedores SAML',
11
- 'Redirect url': 'URL de redirecionamento',
12
- 'SP entity id': 'ID de entidade do provedor de serviço (SP)',
13
- 'Add provider': 'Adicionar',
14
- 'Edit provider': 'Editar',
15
- 'Client id': 'ID do cliente',
16
- 'Entity id or issuer': 'ID de entidade ou emissor',
17
- 'Login Url': 'URL de login',
18
- 'Public cert': 'Certificado público',
19
- 'Delete provider': 'Excluir',
20
- 'Are you sure you want to delete it?': 'Tem certeza de que deseja excluí-lo?',
21
- 'Sign in button name, which will be displayed on the sign in page':
22
- 'Nome do botão de login, que será exibido na página de login',
23
- };
@@ -1 +0,0 @@
1
- export default {};
@@ -1 +0,0 @@
1
- export default {};
@@ -1,64 +0,0 @@
1
- export default {
2
- Edit: '编辑',
3
- Delete: '删除',
4
- Cancel: '取消',
5
- Submit: '提交',
6
- Actions: '操作',
7
- Title: '名称',
8
- Enable: '启用',
9
- Chart: '图表',
10
- Charts: '图表',
11
- Queries: '查询列表',
12
- 'Select chart query': '选择图表数据',
13
- 'Select query data': '选择查询数据',
14
- Type: '类型',
15
- 'Chart type': '图表类型',
16
- 'Chart title': '图表标题',
17
- 'Basic charts': '基础图表',
18
- 'More charts': '更多图表',
19
- 'Chart config': '图表配置',
20
- 'Add query': '添加查询',
21
- 'Edit query': '编辑查询',
22
- 'Invalid JSON format,must be an object array.': '无效的JSON格式,必须是对象数组。',
23
- Area: '面积图',
24
- Bar: '条形图',
25
- Column: '柱状图',
26
- Funnel: '漏斗图',
27
- Line: '折线图',
28
- Pie: '饼图',
29
- Radar: '雷达图',
30
- Scatter: '散点图',
31
- 'Edit chart block': '编辑图表区块',
32
- 'Chart preview': '图表预览',
33
- 'Delete queries': '删除查询列表',
34
- 'Delete query': '删除查询',
35
- 'Add chart query': '添加图表查询',
36
- 'Add SQL query': '添加SQL查询',
37
- 'Add JSON query': '添加JSON查询',
38
- 'Data preview': '数据预览',
39
- 'Category axis / Dimension': '类别轴 / 维度',
40
- 'Value axis / Metrics': '值轴 / 度量',
41
- 'JSON config': 'JSON 配置',
42
- 'Json config references': 'JSON配置参考',
43
- 'Create chart block': '创建图表区块',
44
- 'Invalid JSON format': '无效的JSON格式',
45
- 'Json config references: ': 'JSON配置参考: ',
46
- 'Sector Angle / Metric': '扇形角 / 度量',
47
- 'Sector label / Dimensional': '扇形标签 / 维度',
48
- 'Color legend / Dimensional': '颜色系列 / 维度',
49
- 'Funnel Layer Width/Metrics': '漏斗层宽度 / 度量',
50
- 'Branch Tags/Dimensions': '分支标签 / 维度',
51
- 'Branch Length/Metrics': '分支长度 / 度量',
52
- 'Please check the chart config': '请检查图表配置',
53
- '1 「time」or 「Ordered Noun」 field,1 「Numerical」 field,1 「Unordered Noun」 field (optional)':
54
- '1 个「时间」或「有序名词」字段,1 个「数值」字段,1 个「无序名词」字段(可选)',
55
- '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0~ 1 「unordered noun」':
56
- '1 个「时间」或「有序名词」字段,1 个「数值」字段,0 ~ 1 个「无序名词」',
57
- '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0 to 1 「unordered noun」':
58
- '1 个「时间」或「有序名词」字段,1 个「数值」字段,0 ~ 1 个「无序名词」',
59
- '1 「Unordered Noun」 field, 1 「Numeric」 field': '1 个「无序名词」字段,1 个「数值」字段',
60
- '1 「Time」 or 「Order Noun」 field, 1 「Value」 field': '1 个「时间」或「有序名词」字段,1 个「数值」字段',
61
- '1~ 2 「Unordered Noun」 fields, 1 「Numeric」 field': '1 ~ 2 个「无序名词」字段,1 个「数值」字段',
62
- '1 「Numeric」 field, 0~ 1 「Unordered Noun」 field': '1 个「数值」字段,0 ~ 1 个「无序名词」字段',
63
- 'Chart (Old)': '图表 (旧)',
64
- };
@@ -1,49 +0,0 @@
1
- import JSON5 from 'json5';
2
- import { query } from '../query';
3
-
4
- export const getData = async (ctx, next) => {
5
- const { filterByTk } = ctx.action.params;
6
- const r = ctx.db.getRepository('chartsQueries');
7
- try {
8
- const instance = await r.findOne({ filterByTk });
9
- const result = await query[instance.type](instance.options, { db: ctx.db, skipError: true });
10
- if (typeof result === 'string') {
11
- ctx.body = JSON5.parse(result);
12
- } else {
13
- ctx.body = result;
14
- }
15
- } catch (error) {
16
- ctx.body = [];
17
- ctx.logger.info('chartsQueries', error);
18
- }
19
- return next();
20
- };
21
-
22
- export const validate = async (ctx, next) => {
23
- const { values } = ctx.action.params;
24
- ctx.body = {
25
- errorMessage: '',
26
- };
27
- try {
28
- await query.sql(values, { db: ctx.db, validateSQL: true });
29
- } catch (error) {
30
- ctx.body = {
31
- errorMessage: error.message,
32
- };
33
- }
34
- return next();
35
- };
36
-
37
- export const listMetadata = async (ctx, next) => {
38
- const r = ctx.db.getRepository('chartsQueries');
39
- const items = await r.find({ sort: '-id' });
40
- ctx.body = items.map((item) => {
41
- return {
42
- id: item.id,
43
- title: item.title,
44
- type: item.type,
45
- fields: item.fields,
46
- };
47
- });
48
- return next();
49
- };
File without changes
File without changes
@@ -1,26 +0,0 @@
1
- import { defineCollection } from '@nocobase/database';
2
-
3
- export default defineCollection({
4
- namespace: 'charts.chartsQueries',
5
- duplicator: 'optional',
6
- name: 'chartsQueries',
7
- fields: [
8
- {
9
- name: 'title',
10
- type: 'string',
11
- },
12
- {
13
- name: 'type',
14
- type: 'string',
15
- },
16
- {
17
- name: 'options',
18
- type: 'json',
19
- },
20
- {
21
- name: 'fields',
22
- type: 'json',
23
- defaultValue: [],
24
- },
25
- ],
26
- });
@@ -1 +0,0 @@
1
- export { default } from './plugin';
@@ -1,61 +0,0 @@
1
- import { InstallOptions, Plugin } from '@nocobase/server';
2
- import JSON5 from 'json5';
3
- import { resolve } from 'path';
4
- import { getData, listMetadata, validate } from './actions/chartsQueries';
5
- import { query } from './query';
6
-
7
- export class ChartsPlugin extends Plugin {
8
- syncFields = async (instance, { transaction }) => {
9
- const _data = await query[instance.type](instance.options, { db: this.db, transaction, validateSQL: true });
10
- let data;
11
- if (typeof _data === 'string') {
12
- data = JSON5.parse(_data);
13
- } else {
14
- data = _data;
15
- }
16
- const d = Array.isArray(data) ? data?.[0] : data;
17
- const fields = Object.keys(d || {}).map((f) => {
18
- return {
19
- name: f,
20
- };
21
- });
22
- instance.set('fields', fields);
23
- };
24
-
25
- afterAdd() {}
26
-
27
- beforeLoad() {
28
- this.app.db.on('chartsQueries.beforeCreate', this.syncFields);
29
- this.app.db.on('chartsQueries.beforeUpdate', this.syncFields);
30
- }
31
-
32
- async load() {
33
- await this.db.import({
34
- directory: resolve(__dirname, 'collections'),
35
- });
36
-
37
- this.app.resourcer.registerActionHandlers({
38
- 'chartsQueries:getData': getData,
39
- 'chartsQueries:listMetadata': listMetadata,
40
- 'chartsQueries:validate': validate,
41
- });
42
-
43
- this.app.acl.registerSnippet({
44
- name: 'pm.charts.queries',
45
- actions: ['chartsQueries:*'],
46
- });
47
-
48
- this.app.acl.allow('chartsQueries', 'getData', 'loggedIn');
49
- this.app.acl.allow('chartsQueries', 'listMetadata', 'loggedIn');
50
- }
51
-
52
- async install(options?: InstallOptions) {}
53
-
54
- async afterEnable() {}
55
-
56
- async afterDisable() {}
57
-
58
- async remove() {}
59
- }
60
-
61
- export default ChartsPlugin;
@@ -1,39 +0,0 @@
1
- import { Database } from '@nocobase/database';
2
-
3
- export const query = {
4
- api: async (options) => {
5
- return [];
6
- },
7
- json: async (options) => {
8
- return options.data || [];
9
- },
10
- sql: async (
11
- options,
12
- {
13
- db,
14
- transaction,
15
- skipError,
16
- validateSQL,
17
- }: { db: Database; transaction?: any; skipError?: boolean; validateSQL?: boolean },
18
- ) => {
19
- try {
20
- // 分号截取,只取第一段
21
- const sql: string = options.sql.trim().split(';').shift();
22
- if (!sql) {
23
- throw new Error('SQL is empty');
24
- }
25
- if (!/^select/i.test(sql) && !/^with([\s\S]+)select([\s\S]+)/i.test(sql)) {
26
- throw new Error('Only select query allowed');
27
- }
28
- const [data] = await db.sequelize.query(sql, { transaction });
29
- return data;
30
- } catch (error) {
31
- if (skipError) {
32
- return [];
33
- }
34
- throw error;
35
- }
36
- },
37
- };
38
-
39
- export default query;
@@ -1,2 +0,0 @@
1
- const choicesTypeInterfaceArray = ['radioGroup', 'select'];
2
- export { choicesTypeInterfaceArray };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes