@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,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {};
8
- exports.default = _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {};
8
- exports.default = _default;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- Edit: 'Editar',
9
- Delete: 'Delete',
10
- Cancel: 'Cancelar',
11
- Submit: 'Enviar',
12
- Actions: 'Ações',
13
- Title: 'Titulo',
14
- Enable: 'Ativo',
15
- 'SAML manager': 'Gerenciador SAML',
16
- 'SAML Providers': 'Provedores SAML',
17
- 'Redirect url': 'URL de redirecionamento',
18
- 'SP entity id': 'ID de entidade do provedor de serviço (SP)',
19
- 'Add provider': 'Adicionar',
20
- 'Edit provider': 'Editar',
21
- 'Client id': 'ID do cliente',
22
- 'Entity id or issuer': 'ID de entidade ou emissor',
23
- 'Login Url': 'URL de login',
24
- 'Public cert': 'Certificado público',
25
- 'Delete provider': 'Excluir',
26
- 'Are you sure you want to delete it?': 'Tem certeza de que deseja excluí-lo?',
27
- 'Sign in button name, which will be displayed on the sign in page': 'Nome do botão de login, que será exibido na página de login'
28
- };
29
- exports.default = _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {};
8
- exports.default = _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {};
8
- exports.default = _default;
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- Edit: '编辑',
9
- Delete: '删除',
10
- Cancel: '取消',
11
- Submit: '提交',
12
- Actions: '操作',
13
- Title: '名称',
14
- Enable: '启用',
15
- Chart: '图表',
16
- Charts: '图表',
17
- Queries: '查询列表',
18
- 'Select chart query': '选择图表数据',
19
- 'Select query data': '选择查询数据',
20
- Type: '类型',
21
- 'Chart type': '图表类型',
22
- 'Chart title': '图表标题',
23
- 'Basic charts': '基础图表',
24
- 'More charts': '更多图表',
25
- 'Chart config': '图表配置',
26
- 'Add query': '添加查询',
27
- 'Edit query': '编辑查询',
28
- 'Invalid JSON format,must be an object array.': '无效的JSON格式,必须是对象数组。',
29
- Area: '面积图',
30
- Bar: '条形图',
31
- Column: '柱状图',
32
- Funnel: '漏斗图',
33
- Line: '折线图',
34
- Pie: '饼图',
35
- Radar: '雷达图',
36
- Scatter: '散点图',
37
- 'Edit chart block': '编辑图表区块',
38
- 'Chart preview': '图表预览',
39
- 'Delete queries': '删除查询列表',
40
- 'Delete query': '删除查询',
41
- 'Add chart query': '添加图表查询',
42
- 'Add SQL query': '添加SQL查询',
43
- 'Add JSON query': '添加JSON查询',
44
- 'Data preview': '数据预览',
45
- 'Category axis / Dimension': '类别轴 / 维度',
46
- 'Value axis / Metrics': '值轴 / 度量',
47
- 'JSON config': 'JSON 配置',
48
- 'Json config references': 'JSON配置参考',
49
- 'Create chart block': '创建图表区块',
50
- 'Invalid JSON format': '无效的JSON格式',
51
- 'Json config references: ': 'JSON配置参考: ',
52
- 'Sector Angle / Metric': '扇形角 / 度量',
53
- 'Sector label / Dimensional': '扇形标签 / 维度',
54
- 'Color legend / Dimensional': '颜色系列 / 维度',
55
- 'Funnel Layer Width/Metrics': '漏斗层宽度 / 度量',
56
- 'Branch Tags/Dimensions': '分支标签 / 维度',
57
- 'Branch Length/Metrics': '分支长度 / 度量',
58
- 'Please check the chart config': '请检查图表配置',
59
- '1 「time」or 「Ordered Noun」 field,1 「Numerical」 field,1 「Unordered Noun」 field (optional)': '1 个「时间」或「有序名词」字段,1 个「数值」字段,1 个「无序名词」字段(可选)',
60
- '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0~ 1 「unordered noun」': '1 个「时间」或「有序名词」字段,1 个「数值」字段,0 ~ 1 个「无序名词」',
61
- '1 「time」 or 「ordered noun」 field, 1 「value」 field, 0 to 1 「unordered noun」': '1 个「时间」或「有序名词」字段,1 个「数值」字段,0 ~ 1 个「无序名词」',
62
- '1 「Unordered Noun」 field, 1 「Numeric」 field': '1 个「无序名词」字段,1 个「数值」字段',
63
- '1 「Time」 or 「Order Noun」 field, 1 「Value」 field': '1 个「时间」或「有序名词」字段,1 个「数值」字段',
64
- '1~ 2 「Unordered Noun」 fields, 1 「Numeric」 field': '1 ~ 2 个「无序名词」字段,1 个「数值」字段',
65
- '1 「Numeric」 field, 0~ 1 「Unordered Noun」 field': '1 个「数值」字段,0 ~ 1 个「无序名词」字段',
66
- 'Chart (Old)': '图表 (旧)'
67
- };
68
- exports.default = _default;
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.validate = exports.listMetadata = exports.getData = void 0;
7
- function _json() {
8
- const data = _interopRequireDefault(require("json5"));
9
- _json = function _json() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- var _query = require("../query");
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
- const getData = /*#__PURE__*/function () {
19
- var _ref = _asyncToGenerator(function* (ctx, next) {
20
- const filterByTk = ctx.action.params.filterByTk;
21
- const r = ctx.db.getRepository('chartsQueries');
22
- try {
23
- const instance = yield r.findOne({
24
- filterByTk
25
- });
26
- const result = yield _query.query[instance.type](instance.options, {
27
- db: ctx.db,
28
- skipError: true
29
- });
30
- if (typeof result === 'string') {
31
- ctx.body = _json().default.parse(result);
32
- } else {
33
- ctx.body = result;
34
- }
35
- } catch (error) {
36
- ctx.body = [];
37
- ctx.logger.info('chartsQueries', error);
38
- }
39
- return next();
40
- });
41
- return function getData(_x, _x2) {
42
- return _ref.apply(this, arguments);
43
- };
44
- }();
45
- exports.getData = getData;
46
- const validate = /*#__PURE__*/function () {
47
- var _ref2 = _asyncToGenerator(function* (ctx, next) {
48
- const values = ctx.action.params.values;
49
- ctx.body = {
50
- errorMessage: ''
51
- };
52
- try {
53
- yield _query.query.sql(values, {
54
- db: ctx.db,
55
- validateSQL: true
56
- });
57
- } catch (error) {
58
- ctx.body = {
59
- errorMessage: error.message
60
- };
61
- }
62
- return next();
63
- });
64
- return function validate(_x3, _x4) {
65
- return _ref2.apply(this, arguments);
66
- };
67
- }();
68
- exports.validate = validate;
69
- const listMetadata = /*#__PURE__*/function () {
70
- var _ref3 = _asyncToGenerator(function* (ctx, next) {
71
- const r = ctx.db.getRepository('chartsQueries');
72
- const items = yield r.find({
73
- sort: '-id'
74
- });
75
- ctx.body = items.map(item => {
76
- return {
77
- id: item.id,
78
- title: item.title,
79
- type: item.type,
80
- fields: item.fields
81
- };
82
- });
83
- return next();
84
- });
85
- return function listMetadata(_x5, _x6) {
86
- return _ref3.apply(this, arguments);
87
- };
88
- }();
89
- exports.listMetadata = listMetadata;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- function _database() {
8
- const data = require("@nocobase/database");
9
- _database = function _database() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- var _default = (0, _database().defineCollection)({
15
- namespace: 'charts.chartsQueries',
16
- duplicator: 'optional',
17
- name: 'chartsQueries',
18
- fields: [{
19
- name: 'title',
20
- type: 'string'
21
- }, {
22
- name: 'type',
23
- type: 'string'
24
- }, {
25
- name: 'options',
26
- type: 'json'
27
- }, {
28
- name: 'fields',
29
- type: 'json',
30
- defaultValue: []
31
- }]
32
- });
33
- exports.default = _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function get() {
9
- return _plugin.default;
10
- }
11
- });
12
- var _plugin = _interopRequireDefault(require("./plugin"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,106 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.ChartsPlugin = void 0;
7
- function _server() {
8
- const data = require("@nocobase/server");
9
- _server = function _server() {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _json() {
15
- const data = _interopRequireDefault(require("json5"));
16
- _json = function _json() {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _path() {
22
- const data = require("path");
23
- _path = function _path() {
24
- return data;
25
- };
26
- return data;
27
- }
28
- var _chartsQueries = require("./actions/chartsQueries");
29
- var _query = require("./query");
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
32
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
33
- class ChartsPlugin extends _server().Plugin {
34
- constructor(...args) {
35
- var _this;
36
- super(...args);
37
- _this = this;
38
- this.syncFields = /*#__PURE__*/function () {
39
- var _ref = _asyncToGenerator(function* (instance, {
40
- transaction
41
- }) {
42
- var _data2;
43
- const _data = yield _query.query[instance.type](instance.options, {
44
- db: _this.db,
45
- transaction,
46
- validateSQL: true
47
- });
48
- let data;
49
- if (typeof _data === 'string') {
50
- data = _json().default.parse(_data);
51
- } else {
52
- data = _data;
53
- }
54
- const d = Array.isArray(data) ? (_data2 = data) === null || _data2 === void 0 ? void 0 : _data2[0] : data;
55
- const fields = Object.keys(d || {}).map(f => {
56
- return {
57
- name: f
58
- };
59
- });
60
- instance.set('fields', fields);
61
- });
62
- return function (_x, _x2) {
63
- return _ref.apply(this, arguments);
64
- };
65
- }();
66
- }
67
- afterAdd() {}
68
- beforeLoad() {
69
- this.app.db.on('chartsQueries.beforeCreate', this.syncFields);
70
- this.app.db.on('chartsQueries.beforeUpdate', this.syncFields);
71
- }
72
- load() {
73
- var _this2 = this;
74
- return _asyncToGenerator(function* () {
75
- yield _this2.db.import({
76
- directory: (0, _path().resolve)(__dirname, 'collections')
77
- });
78
- _this2.app.resourcer.registerActionHandlers({
79
- 'chartsQueries:getData': _chartsQueries.getData,
80
- 'chartsQueries:listMetadata': _chartsQueries.listMetadata,
81
- 'chartsQueries:validate': _chartsQueries.validate
82
- });
83
- _this2.app.acl.registerSnippet({
84
- name: 'pm.charts.queries',
85
- actions: ['chartsQueries:*']
86
- });
87
- _this2.app.acl.allow('chartsQueries', 'getData', 'loggedIn');
88
- _this2.app.acl.allow('chartsQueries', 'listMetadata', 'loggedIn');
89
- })();
90
- }
91
- install(options) {
92
- return _asyncToGenerator(function* () {})();
93
- }
94
- afterEnable() {
95
- return _asyncToGenerator(function* () {})();
96
- }
97
- afterDisable() {
98
- return _asyncToGenerator(function* () {})();
99
- }
100
- remove() {
101
- return _asyncToGenerator(function* () {})();
102
- }
103
- }
104
- exports.ChartsPlugin = ChartsPlugin;
105
- var _default = ChartsPlugin;
106
- exports.default = _default;
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.query = exports.default = void 0;
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
- const query = {
16
- api: function () {
17
- var _api = _asyncToGenerator(function* (options) {
18
- return [];
19
- });
20
- function api(_x) {
21
- return _api.apply(this, arguments);
22
- }
23
- return api;
24
- }(),
25
- json: function () {
26
- var _json = _asyncToGenerator(function* (options) {
27
- return options.data || [];
28
- });
29
- function json(_x2) {
30
- return _json.apply(this, arguments);
31
- }
32
- return json;
33
- }(),
34
- sql: function () {
35
- var _sql = _asyncToGenerator(function* (options, {
36
- db,
37
- transaction,
38
- skipError,
39
- validateSQL
40
- }) {
41
- try {
42
- // 分号截取,只取第一段
43
- const sql = options.sql.trim().split(';').shift();
44
- if (!sql) {
45
- throw new Error('SQL is empty');
46
- }
47
- if (!/^select/i.test(sql) && !/^with([\s\S]+)select([\s\S]+)/i.test(sql)) {
48
- throw new Error('Only select query allowed');
49
- }
50
- const _yield$db$sequelize$q = yield db.sequelize.query(sql, {
51
- transaction
52
- }),
53
- _yield$db$sequelize$q2 = _slicedToArray(_yield$db$sequelize$q, 1),
54
- data = _yield$db$sequelize$q2[0];
55
- return data;
56
- } catch (error) {
57
- if (skipError) {
58
- return [];
59
- }
60
- throw error;
61
- }
62
- });
63
- function sql(_x3, _x4) {
64
- return _sql.apply(this, arguments);
65
- }
66
- return sql;
67
- }()
68
- };
69
- exports.query = query;
70
- var _default = query;
71
- exports.default = _default;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.choicesTypeInterfaceArray = void 0;
7
- const choicesTypeInterfaceArray = ['radioGroup', 'select'];
8
- exports.choicesTypeInterfaceArray = choicesTypeInterfaceArray;
@@ -1,121 +0,0 @@
1
- import { useCompile, useRequest } from '@nocobase/client';
2
- import { Empty, Spin } from 'antd';
3
- import JSON5 from 'json5';
4
- import React, { useEffect, useState } from 'react';
5
- import { ChartBlockEngineDesigner } from './ChartBlockEngineDesigner';
6
- import chartRenderComponentsMap from './chartRenderComponents';
7
- import { lang } from './locale';
8
- import { templates } from './templates';
9
-
10
- export interface IQueryConfig {
11
- id: number;
12
- }
13
- export interface IChartConfig {
14
- type: string;
15
- template: string;
16
- metric: string;
17
- dimension: string;
18
- category?: string;
19
- [key: string]: any;
20
- }
21
-
22
- export interface ChartBlockEngineMetaData {
23
- query: IQueryConfig;
24
- chart: IChartConfig;
25
- }
26
-
27
- const ChartRenderComponent = ({
28
- chartBlockEngineMetaData,
29
- }: {
30
- chartBlockEngineMetaData: ChartBlockEngineMetaData;
31
- }): JSX.Element => {
32
- const compile = useCompile();
33
- const chartType = chartBlockEngineMetaData.chart.type;
34
- const renderComponent = templates.get(chartType)?.renderComponent;
35
- const RenderComponent = chartRenderComponentsMap.get(renderComponent); //G2Plot | Echarts | D3 |Table
36
- const chartConfig = chartBlockEngineMetaData.chart;
37
- const { loading, dataSet, error } = useGetDataSet(chartBlockEngineMetaData.query.id);
38
-
39
- const [currentConfig, setCurrentConfig] = useState<IChartConfig>({} as any);
40
-
41
- useEffect(() => {
42
- setCurrentConfig(chartConfig);
43
- }, [JSON.stringify(chartConfig)]);
44
-
45
- if (error) {
46
- return (
47
- <>
48
- <Empty description={<span>{`May be this chart block's query data has been deleted,please check!`}</span>} />
49
- </>
50
- );
51
- }
52
-
53
- if (currentConfig.type !== chartConfig.type) {
54
- return <></>;
55
- }
56
-
57
- switch (renderComponent) {
58
- case 'G2Plot': {
59
- const finalChartOptions = templates.get(chartType)?.defaultChartOptions;
60
- let template;
61
- try {
62
- template = JSON5.parse(chartConfig?.template);
63
- } catch (e) {
64
- template = {};
65
- }
66
- const config = compile(
67
- {
68
- ...finalChartOptions,
69
- ...template,
70
- data: dataSet,
71
- },
72
- { ...chartConfig, category: chartConfig?.category ?? '' },
73
- );
74
- if (config && chartConfig) {
75
- const { dimension, metric, category } = chartConfig;
76
- if (!metric || !dimension) {
77
- return <>{lang('Please check the chart config')}</>;
78
- }
79
- }
80
- return <>{loading ? <Spin /> : <RenderComponent plot={chartConfig.type} config={config} />}</>;
81
- }
82
- }
83
- return <></>;
84
- };
85
-
86
- export const useGetDataSet = (chartQueryId: number) => {
87
- const { data, loading, error } = useRequest<{
88
- data: any;
89
- }>({
90
- url: `/chartsQueries:getData/${chartQueryId}`,
91
- });
92
- const dataSet = data?.data;
93
- return {
94
- loading,
95
- dataSet: dataSet,
96
- error,
97
- };
98
- };
99
-
100
- const ChartBlockEngine = ({ chartBlockEngineMetaData }: { chartBlockEngineMetaData: ChartBlockEngineMetaData }) => {
101
- let renderComponent;
102
- const chartType = chartBlockEngineMetaData?.chart?.type;
103
-
104
- if (chartType) {
105
- renderComponent = templates.get(chartType)?.renderComponent;
106
- }
107
-
108
- if (!chartType || !renderComponent) {
109
- return <>{lang('Please check the chart config')}</>;
110
- }
111
-
112
- return (
113
- <>
114
- <ChartRenderComponent chartBlockEngineMetaData={chartBlockEngineMetaData} />
115
- </>
116
- );
117
- };
118
-
119
- ChartBlockEngine.Designer = ChartBlockEngineDesigner;
120
-
121
- export { ChartBlockEngine };