@nocobase/plugin-charts 0.11.1-alpha.4 → 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,263 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Options = exports.ChartBlockInitializer = void 0;
|
|
7
|
-
function _antdV() {
|
|
8
|
-
const data = require("@formily/antd-v5");
|
|
9
|
-
_antdV = function _antdV() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _react() {
|
|
15
|
-
const data = require("@formily/react");
|
|
16
|
-
_react = function _react() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _client() {
|
|
22
|
-
const data = require("@nocobase/client");
|
|
23
|
-
_client = function _client() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _antd() {
|
|
29
|
-
const data = require("antd");
|
|
30
|
-
_antd = function _antd() {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _json() {
|
|
36
|
-
const data = _interopRequireDefault(require("json5"));
|
|
37
|
-
_json = function _json() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
function _react2() {
|
|
43
|
-
const data = _interopRequireWildcard(require("react"));
|
|
44
|
-
_react2 = function _react2() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
var _ChartBlockEngineDesigner = require("./ChartBlockEngineDesigner");
|
|
50
|
-
var _ChartQueryBlockInitializer = require("./ChartQueryBlockInitializer");
|
|
51
|
-
var _DataSetPreviewTable = _interopRequireDefault(require("./DataSetPreviewTable"));
|
|
52
|
-
var _locale = require("./locale");
|
|
53
|
-
var _templates = require("./templates");
|
|
54
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
55
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
56
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
57
|
-
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); } }
|
|
58
|
-
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); }); }; }
|
|
59
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
60
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
61
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
62
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
63
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
64
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
65
|
-
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."); }
|
|
66
|
-
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); }
|
|
67
|
-
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; }
|
|
68
|
-
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; } }
|
|
69
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
70
|
-
const Options = (0, _react().observer)(props => {
|
|
71
|
-
const form = (0, _react().useForm)();
|
|
72
|
-
const field = (0, _react().useField)();
|
|
73
|
-
const _useState = (0, _react2().useState)(new (_react().Schema)({})),
|
|
74
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
75
|
-
s = _useState2[0],
|
|
76
|
-
setSchema = _useState2[1];
|
|
77
|
-
const _useState3 = (0, _react2().useState)(form.values.type),
|
|
78
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
79
|
-
chartType = _useState4[0],
|
|
80
|
-
setChartType = _useState4[1];
|
|
81
|
-
(0, _react2().useEffect)(() => {
|
|
82
|
-
var _form$values, _form$values2;
|
|
83
|
-
// form.clearFormGraph('options.*');
|
|
84
|
-
setChartType(form === null || form === void 0 ? void 0 : (_form$values = form.values) === null || _form$values === void 0 ? void 0 : _form$values.type);
|
|
85
|
-
if (chartType !== (form === null || form === void 0 ? void 0 : (_form$values2 = form.values) === null || _form$values2 === void 0 ? void 0 : _form$values2.type)) {
|
|
86
|
-
form.clearFormGraph('options.*');
|
|
87
|
-
}
|
|
88
|
-
if (form.values.type) {
|
|
89
|
-
const template = _templates.templates.get(form.values.type);
|
|
90
|
-
setSchema(new (_react().Schema)(template.configurableProperties || {}));
|
|
91
|
-
}
|
|
92
|
-
}, [form.values.type]);
|
|
93
|
-
return _react2().default.createElement(_react().RecursionField, {
|
|
94
|
-
schema: s
|
|
95
|
-
});
|
|
96
|
-
}, {
|
|
97
|
-
displayName: 'Options'
|
|
98
|
-
});
|
|
99
|
-
exports.Options = Options;
|
|
100
|
-
const ChartBlockInitializer = props => {
|
|
101
|
-
const insert = props.insert;
|
|
102
|
-
const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
|
|
103
|
-
const api = (0, _client().useAPIClient)();
|
|
104
|
-
const compile = (0, _client().useCompile)();
|
|
105
|
-
const _useGlobalTheme = (0, _client().useGlobalTheme)(),
|
|
106
|
-
theme = _useGlobalTheme.theme;
|
|
107
|
-
return _react2().default.createElement(_ChartQueryBlockInitializer.ChartQueryBlockInitializer, _objectSpread(_objectSpread({}, props), {}, {
|
|
108
|
-
componentType: 'Charts',
|
|
109
|
-
onCreateBlockSchema: function () {
|
|
110
|
-
var _onCreateBlockSchema = _asyncToGenerator(function* ({
|
|
111
|
-
item: chartQueryMetadata
|
|
112
|
-
}) {
|
|
113
|
-
const dataSource = chartQueryMetadata === null || chartQueryMetadata === void 0 ? void 0 : chartQueryMetadata.fields.map(field => {
|
|
114
|
-
return {
|
|
115
|
-
label: field.name,
|
|
116
|
-
value: field.name
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
const values = yield (0, _client().FormDialog)({
|
|
120
|
-
okText: compile('{{t("Submit")}}'),
|
|
121
|
-
title: (0, _locale.lang)('Create chart block'),
|
|
122
|
-
width: 1200,
|
|
123
|
-
bodyStyle: {
|
|
124
|
-
background: 'var(--nb-box-bg)',
|
|
125
|
-
maxHeight: '65vh',
|
|
126
|
-
overflow: 'auto'
|
|
127
|
-
}
|
|
128
|
-
}, function Com() {
|
|
129
|
-
var _chartBlockEngineMeta, _chartBlockEngineMeta2;
|
|
130
|
-
const form = (0, _react().useForm)();
|
|
131
|
-
const _useState5 = (0, _react2().useState)(null),
|
|
132
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
133
|
-
chartBlockEngineMetaData = _useState6[0],
|
|
134
|
-
setChartBlockEngineMetaData = _useState6[1];
|
|
135
|
-
(0, _react2().useEffect)(() => {
|
|
136
|
-
const chartBlockEngineMetaData = {
|
|
137
|
-
query: {
|
|
138
|
-
id: chartQueryMetadata === null || chartQueryMetadata === void 0 ? void 0 : chartQueryMetadata.id
|
|
139
|
-
},
|
|
140
|
-
chart: form.values //TODO
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
setChartBlockEngineMetaData(chartBlockEngineMetaData);
|
|
144
|
-
}, [form.values.type]);
|
|
145
|
-
return _react2().default.createElement(_client().APIClientProvider, {
|
|
146
|
-
apiClient: api
|
|
147
|
-
}, _react2().default.createElement(_client().SchemaComponentOptions, {
|
|
148
|
-
scope: options.scope,
|
|
149
|
-
components: _objectSpread({}, options.components)
|
|
150
|
-
}, _react2().default.createElement("section", {
|
|
151
|
-
className: (0, _client().css)`
|
|
152
|
-
display: flex;
|
|
153
|
-
gap: 24px;
|
|
154
|
-
`
|
|
155
|
-
}, _react2().default.createElement(_antd().Card, {
|
|
156
|
-
title: (0, _locale.lang)('Chart config'),
|
|
157
|
-
size: 'default',
|
|
158
|
-
className: (0, _client().css)`
|
|
159
|
-
flex: 1;
|
|
160
|
-
`
|
|
161
|
-
}, _react2().default.createElement(_client().FormProvider, {
|
|
162
|
-
form: form
|
|
163
|
-
}, _react2().default.createElement(_antdV().FormLayout, {
|
|
164
|
-
layout: 'vertical'
|
|
165
|
-
}, _react2().default.createElement(_client().SchemaComponent, {
|
|
166
|
-
scope: {
|
|
167
|
-
dataSource,
|
|
168
|
-
JSON5: _json().default,
|
|
169
|
-
jsonConfigDesc: _ChartBlockEngineDesigner.jsonConfigDesc
|
|
170
|
-
},
|
|
171
|
-
components: {
|
|
172
|
-
Options
|
|
173
|
-
},
|
|
174
|
-
schema: {
|
|
175
|
-
properties: {
|
|
176
|
-
// title: {
|
|
177
|
-
// title: lang('Chart title'),
|
|
178
|
-
// 'x-component': 'Input',
|
|
179
|
-
// 'x-decorator': 'FormItem',
|
|
180
|
-
// },
|
|
181
|
-
type: {
|
|
182
|
-
title: (0, _locale.lang)('Chart type'),
|
|
183
|
-
required: true,
|
|
184
|
-
'x-component': 'CustomSelect',
|
|
185
|
-
'x-decorator': 'FormItem',
|
|
186
|
-
enum: [..._templates.templates.values()].map(template => {
|
|
187
|
-
return {
|
|
188
|
-
title: template.title,
|
|
189
|
-
key: template.type,
|
|
190
|
-
description: template.description,
|
|
191
|
-
group: template.group,
|
|
192
|
-
iconId: template.iconId
|
|
193
|
-
};
|
|
194
|
-
})
|
|
195
|
-
},
|
|
196
|
-
options: {
|
|
197
|
-
type: 'void',
|
|
198
|
-
'x-component': 'Options'
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
})))), _react2().default.createElement("div", {
|
|
203
|
-
className: (0, _client().css)`
|
|
204
|
-
flex: 1;
|
|
205
|
-
min-width: 600px;
|
|
206
|
-
`
|
|
207
|
-
}, _react2().default.createElement(_antd().Card, {
|
|
208
|
-
size: 'default',
|
|
209
|
-
title: (0, _locale.lang)('Chart preview')
|
|
210
|
-
}, chartBlockEngineMetaData && _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_client().SchemaComponent, {
|
|
211
|
-
schema: {
|
|
212
|
-
properties: {
|
|
213
|
-
chartPreview: {
|
|
214
|
-
type: 'void',
|
|
215
|
-
'x-decorator': 'CardItem',
|
|
216
|
-
'x-component': 'ChartBlockEngine',
|
|
217
|
-
'x-component-props': {
|
|
218
|
-
chartBlockEngineMetaData
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}))), _react2().default.createElement(_antd().Card, {
|
|
224
|
-
size: 'default',
|
|
225
|
-
title: (0, _locale.lang)('Data preview'),
|
|
226
|
-
className: (0, _client().css)`
|
|
227
|
-
margin-top: 24px;
|
|
228
|
-
overflow: scroll;
|
|
229
|
-
`
|
|
230
|
-
}, (chartBlockEngineMetaData === null || chartBlockEngineMetaData === void 0 ? void 0 : (_chartBlockEngineMeta = chartBlockEngineMetaData.query) === null || _chartBlockEngineMeta === void 0 ? void 0 : _chartBlockEngineMeta.id) && _react2().default.createElement(_DataSetPreviewTable.default, {
|
|
231
|
-
queryId: chartBlockEngineMetaData === null || chartBlockEngineMetaData === void 0 ? void 0 : (_chartBlockEngineMeta2 = chartBlockEngineMetaData.query) === null || _chartBlockEngineMeta2 === void 0 ? void 0 : _chartBlockEngineMeta2.id,
|
|
232
|
-
fields: chartQueryMetadata === null || chartQueryMetadata === void 0 ? void 0 : chartQueryMetadata.fields
|
|
233
|
-
}))))));
|
|
234
|
-
}, theme).open({
|
|
235
|
-
initialValues: {}
|
|
236
|
-
});
|
|
237
|
-
if (values) {
|
|
238
|
-
const chartBlockEngineMetaData = {
|
|
239
|
-
query: {
|
|
240
|
-
id: chartQueryMetadata.id
|
|
241
|
-
},
|
|
242
|
-
chart: values
|
|
243
|
-
};
|
|
244
|
-
insert({
|
|
245
|
-
type: 'void',
|
|
246
|
-
title: values === null || values === void 0 ? void 0 : values.title,
|
|
247
|
-
'x-designer': 'ChartBlockEngine.Designer',
|
|
248
|
-
'x-decorator': 'CardItem',
|
|
249
|
-
'x-component': 'ChartBlockEngine',
|
|
250
|
-
'x-component-props': {
|
|
251
|
-
chartBlockEngineMetaData
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
function onCreateBlockSchema(_x2) {
|
|
257
|
-
return _onCreateBlockSchema.apply(this, arguments);
|
|
258
|
-
}
|
|
259
|
-
return onCreateBlockSchema;
|
|
260
|
-
}()
|
|
261
|
-
}));
|
|
262
|
-
};
|
|
263
|
-
exports.ChartBlockInitializer = ChartBlockInitializer;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ChartQueryBlockInitializer = void 0;
|
|
7
|
-
function _icons() {
|
|
8
|
-
const data = require("@ant-design/icons");
|
|
9
|
-
_icons = function _icons() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _antdV() {
|
|
15
|
-
const data = require("@formily/antd-v5");
|
|
16
|
-
_antdV = function _antdV() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _react() {
|
|
22
|
-
const data = require("@formily/react");
|
|
23
|
-
_react = function _react() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _client() {
|
|
29
|
-
const data = require("@nocobase/client");
|
|
30
|
-
_client = function _client() {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _client2() {
|
|
36
|
-
const data = require("@nocobase/utils/client");
|
|
37
|
-
_client2 = function _client2() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
|
-
function _react2() {
|
|
43
|
-
const data = _interopRequireWildcard(require("react"));
|
|
44
|
-
_react2 = function _react2() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
var _ChartQueryMetadataProvider = require("./ChartQueryMetadataProvider");
|
|
50
|
-
var _locale = require("./locale");
|
|
51
|
-
var _queryTypes = require("./settings/queryTypes");
|
|
52
|
-
const _excluded = ["templateWrap", "onCreateBlockSchema", "componentType", "createBlockSchema", "insert"];
|
|
53
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
54
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
55
|
-
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); } }
|
|
56
|
-
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); }); }; }
|
|
57
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
58
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
59
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
60
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
61
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
62
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
63
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
64
|
-
const ChartQueryBlockInitializer = props => {
|
|
65
|
-
const templateWrap = props.templateWrap,
|
|
66
|
-
onCreateBlockSchema = props.onCreateBlockSchema,
|
|
67
|
-
componentType = props.componentType,
|
|
68
|
-
createBlockSchema = props.createBlockSchema,
|
|
69
|
-
insert = props.insert,
|
|
70
|
-
others = _objectWithoutProperties(props, _excluded);
|
|
71
|
-
const _useContext = (0, _react2().useContext)(_client().SchemaInitializerButtonContext),
|
|
72
|
-
setVisible = _useContext.setVisible;
|
|
73
|
-
const apiClient = (0, _client().useAPIClient)();
|
|
74
|
-
const ctx = (0, _ChartQueryMetadataProvider.useChartQueryMetadataContext)();
|
|
75
|
-
const options = (0, _react2().useContext)(_react().SchemaOptionsContext);
|
|
76
|
-
const _useGlobalTheme = (0, _client().useGlobalTheme)(),
|
|
77
|
-
theme = _useGlobalTheme.theme;
|
|
78
|
-
const onAddQuery = (0, _react2().useCallback)(info => {
|
|
79
|
-
(0, _client().FormDialog)({
|
|
80
|
-
sql: (0, _locale.lang)('Add SQL query'),
|
|
81
|
-
json: (0, _locale.lang)('Add JSON query')
|
|
82
|
-
}[info.key], () => {
|
|
83
|
-
return _react2().default.createElement("div", null, _react2().default.createElement(_client().SchemaComponentOptions, {
|
|
84
|
-
scope: options.scope,
|
|
85
|
-
components: _objectSpread({}, options.components)
|
|
86
|
-
}, _react2().default.createElement(_antdV().FormLayout, {
|
|
87
|
-
layout: 'vertical'
|
|
88
|
-
}, _react2().default.createElement(_client().SchemaComponent, {
|
|
89
|
-
schema: {
|
|
90
|
-
type: 'object',
|
|
91
|
-
properties: {
|
|
92
|
-
title: {
|
|
93
|
-
title: (0, _locale.lang)('Title'),
|
|
94
|
-
required: true,
|
|
95
|
-
'x-component': 'Input',
|
|
96
|
-
'x-decorator': 'FormItem'
|
|
97
|
-
},
|
|
98
|
-
options: (0, _queryTypes.getQueryTypeSchema)(info.key)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}))));
|
|
102
|
-
}, theme).open({
|
|
103
|
-
initialValues: {
|
|
104
|
-
type: info.key
|
|
105
|
-
}
|
|
106
|
-
}).then( /*#__PURE__*/function () {
|
|
107
|
-
var _ref = _asyncToGenerator(function* (values) {
|
|
108
|
-
try {
|
|
109
|
-
var _apiClient$resource;
|
|
110
|
-
if ((_apiClient$resource = apiClient.resource('chartsQueries')) !== null && _apiClient$resource !== void 0 && _apiClient$resource.create) {
|
|
111
|
-
const _yield$apiClient$reso = yield apiClient.resource('chartsQueries').create({
|
|
112
|
-
values
|
|
113
|
-
}),
|
|
114
|
-
data = _yield$apiClient$reso.data;
|
|
115
|
-
const items = yield ctx.refresh();
|
|
116
|
-
const item = items.find(item => {
|
|
117
|
-
var _data$data;
|
|
118
|
-
return item.id === (data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.id);
|
|
119
|
-
});
|
|
120
|
-
onCreateBlockSchema({
|
|
121
|
-
item
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
setVisible(false);
|
|
125
|
-
} catch (err) {
|
|
126
|
-
(0, _client2().error)(err);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return function (_x) {
|
|
130
|
-
return _ref.apply(this, arguments);
|
|
131
|
-
};
|
|
132
|
-
}()).catch(err => {
|
|
133
|
-
(0, _client2().error)(err);
|
|
134
|
-
});
|
|
135
|
-
}, [apiClient, ctx, onCreateBlockSchema, options.components, options.scope, setVisible]);
|
|
136
|
-
const items = (0, _react2().useMemo)(() => {
|
|
137
|
-
const defaultItems = [{
|
|
138
|
-
type: 'itemGroup',
|
|
139
|
-
title: (0, _locale.lang)('Select query data'),
|
|
140
|
-
children: []
|
|
141
|
-
}];
|
|
142
|
-
const chartQueryMetadata = ctx.data;
|
|
143
|
-
if (chartQueryMetadata && Array.isArray(chartQueryMetadata)) {
|
|
144
|
-
const item1 = chartQueryMetadata.length > 0 ? {
|
|
145
|
-
type: 'itemGroup',
|
|
146
|
-
title: '{{t("Select chart query", {ns: "charts"})}}',
|
|
147
|
-
children: chartQueryMetadata
|
|
148
|
-
} : null;
|
|
149
|
-
const item2 = chartQueryMetadata.length > 0 ? {
|
|
150
|
-
type: 'divider'
|
|
151
|
-
} : null;
|
|
152
|
-
return [item1, item2, {
|
|
153
|
-
type: 'subMenu',
|
|
154
|
-
title: (0, _locale.lang)('Add chart query'),
|
|
155
|
-
// component: AddChartQuery,
|
|
156
|
-
children: [{
|
|
157
|
-
key: 'sql',
|
|
158
|
-
type: 'item',
|
|
159
|
-
title: 'SQL',
|
|
160
|
-
onClick: onAddQuery
|
|
161
|
-
}, {
|
|
162
|
-
key: 'json',
|
|
163
|
-
type: 'item',
|
|
164
|
-
title: 'JSON',
|
|
165
|
-
onClick: onAddQuery
|
|
166
|
-
}]
|
|
167
|
-
}].filter(Boolean);
|
|
168
|
-
}
|
|
169
|
-
return defaultItems;
|
|
170
|
-
}, [ctx.data, onAddQuery]);
|
|
171
|
-
return _react2().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({
|
|
172
|
-
icon: _react2().default.createElement(_icons().TableOutlined, null)
|
|
173
|
-
}, others), {}, {
|
|
174
|
-
onClick: function () {
|
|
175
|
-
var _onClick = _asyncToGenerator(function* ({
|
|
176
|
-
item
|
|
177
|
-
}) {
|
|
178
|
-
onCreateBlockSchema({
|
|
179
|
-
item
|
|
180
|
-
});
|
|
181
|
-
setVisible(false);
|
|
182
|
-
});
|
|
183
|
-
function onClick(_x2) {
|
|
184
|
-
return _onClick.apply(this, arguments);
|
|
185
|
-
}
|
|
186
|
-
return onClick;
|
|
187
|
-
}(),
|
|
188
|
-
items: items
|
|
189
|
-
}));
|
|
190
|
-
};
|
|
191
|
-
exports.ChartQueryBlockInitializer = ChartQueryBlockInitializer;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useChartQueryMetadataContext = exports.ChartQueryMetadataProvider = exports.ChartQueryMetadataContext = void 0;
|
|
7
|
-
function _client() {
|
|
8
|
-
const data = require("@nocobase/client");
|
|
9
|
-
_client = function _client() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _antd() {
|
|
15
|
-
const data = require("antd");
|
|
16
|
-
_antd = function _antd() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _react() {
|
|
22
|
-
const data = _interopRequireWildcard(require("react"));
|
|
23
|
-
_react = function _react() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
function _reactRouterDom() {
|
|
29
|
-
const data = require("react-router-dom");
|
|
30
|
-
_reactRouterDom = function _reactRouterDom() {
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
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); } }
|
|
38
|
-
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); }); }; }
|
|
39
|
-
const ChartQueryMetadataContext = (0, _react().createContext)({
|
|
40
|
-
refresh: () => {},
|
|
41
|
-
data: []
|
|
42
|
-
});
|
|
43
|
-
exports.ChartQueryMetadataContext = ChartQueryMetadataContext;
|
|
44
|
-
const ChartQueryMetadataProvider = props => {
|
|
45
|
-
var _service$data;
|
|
46
|
-
const api = (0, _client().useAPIClient)();
|
|
47
|
-
const options = {
|
|
48
|
-
resource: 'chartsQueries',
|
|
49
|
-
action: 'listMetadata',
|
|
50
|
-
params: {
|
|
51
|
-
paginate: false,
|
|
52
|
-
sort: ['-id']
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const location = (0, _reactRouterDom().useLocation)();
|
|
56
|
-
const service = (0, _client().useRequest)(options, {
|
|
57
|
-
manual: true
|
|
58
|
-
});
|
|
59
|
-
const isAdminPage = location.pathname.startsWith('/admin');
|
|
60
|
-
const token = api.auth.getToken() || '';
|
|
61
|
-
(0, _react().useEffect)(() => {
|
|
62
|
-
if (isAdminPage && token) {
|
|
63
|
-
service.run();
|
|
64
|
-
}
|
|
65
|
-
}, [isAdminPage, token]);
|
|
66
|
-
const refresh = /*#__PURE__*/function () {
|
|
67
|
-
var _ref = _asyncToGenerator(function* () {
|
|
68
|
-
const _yield$api$request = yield api.request(options),
|
|
69
|
-
data = _yield$api$request.data;
|
|
70
|
-
service.mutate(data);
|
|
71
|
-
return (data === null || data === void 0 ? void 0 : data.data) || [];
|
|
72
|
-
});
|
|
73
|
-
return function refresh() {
|
|
74
|
-
return _ref.apply(this, arguments);
|
|
75
|
-
};
|
|
76
|
-
}();
|
|
77
|
-
if (service.loading) {
|
|
78
|
-
return _react().default.createElement(_antd().Spin, null);
|
|
79
|
-
}
|
|
80
|
-
return _react().default.createElement(ChartQueryMetadataContext.Provider, {
|
|
81
|
-
value: {
|
|
82
|
-
refresh,
|
|
83
|
-
data: (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.data
|
|
84
|
-
}
|
|
85
|
-
}, props.children);
|
|
86
|
-
};
|
|
87
|
-
exports.ChartQueryMetadataProvider = ChartQueryMetadataProvider;
|
|
88
|
-
const useChartQueryMetadataContext = () => {
|
|
89
|
-
return (0, _react().useContext)(ChartQueryMetadataContext);
|
|
90
|
-
};
|
|
91
|
-
exports.useChartQueryMetadataContext = useChartQueryMetadataContext;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
function _client() {
|
|
8
|
-
const data = require("@nocobase/client");
|
|
9
|
-
_client = function _client() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _antd() {
|
|
15
|
-
const data = require("antd");
|
|
16
|
-
_antd = function _antd() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _react() {
|
|
22
|
-
const data = _interopRequireDefault(require("react"));
|
|
23
|
-
_react = function _react() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
var _ChartBlockEngine = require("./ChartBlockEngine");
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
31
|
-
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); }
|
|
32
|
-
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; }
|
|
33
|
-
var _default = ({
|
|
34
|
-
queryId,
|
|
35
|
-
fields
|
|
36
|
-
}) => {
|
|
37
|
-
const _useGetDataSet = (0, _ChartBlockEngine.useGetDataSet)(queryId),
|
|
38
|
-
dataSet = _useGetDataSet.dataSet,
|
|
39
|
-
loading = _useGetDataSet.loading,
|
|
40
|
-
error = _useGetDataSet.error;
|
|
41
|
-
const columns = {};
|
|
42
|
-
if (fields) {
|
|
43
|
-
var _iterator = _createForOfIteratorHelper(fields),
|
|
44
|
-
_step;
|
|
45
|
-
try {
|
|
46
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
|
-
const field = _step.value;
|
|
48
|
-
columns[field.name] = {
|
|
49
|
-
type: 'void',
|
|
50
|
-
title: field.name,
|
|
51
|
-
'x-component': 'TableV2.Column',
|
|
52
|
-
'x-component-props': {
|
|
53
|
-
// width: 200,
|
|
54
|
-
},
|
|
55
|
-
properties: {
|
|
56
|
-
[field.name]: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
'x-component': 'Input',
|
|
59
|
-
'x-read-pretty': true
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
} catch (err) {
|
|
65
|
-
_iterator.e(err);
|
|
66
|
-
} finally {
|
|
67
|
-
_iterator.f();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const schema = {
|
|
71
|
-
type: 'void',
|
|
72
|
-
properties: {
|
|
73
|
-
input: {
|
|
74
|
-
type: 'array',
|
|
75
|
-
'x-component': 'TableV2',
|
|
76
|
-
'x-component-props': {
|
|
77
|
-
scroll: {
|
|
78
|
-
y: 300
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
default: dataSet,
|
|
82
|
-
properties: columns
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
if (error) {
|
|
87
|
-
return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Empty, {
|
|
88
|
-
description: _react().default.createElement("span", null, "May be this chart block's query data has been deleted,please check!")
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
if (loading) return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Spin, null));
|
|
92
|
-
//对dataset中引用类型数据类型进行序列化处理
|
|
93
|
-
dataSet.forEach(item => {
|
|
94
|
-
for (const key in item) {
|
|
95
|
-
if (item[key] && item[key] instanceof Object) {
|
|
96
|
-
item[key] = JSON.stringify(item[key]);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return _react().default.createElement(_client().SchemaComponentProvider, {
|
|
101
|
-
scope: {
|
|
102
|
-
dataSet
|
|
103
|
-
},
|
|
104
|
-
components: {
|
|
105
|
-
TableV2: _client().TableV2,
|
|
106
|
-
Input: _client().Input,
|
|
107
|
-
FormItem: _client().FormItem
|
|
108
|
-
}
|
|
109
|
-
}, _react().default.createElement(_client().SchemaComponent, {
|
|
110
|
-
schema: schema
|
|
111
|
-
}));
|
|
112
|
-
};
|
|
113
|
-
exports.default = _default;
|