ronds-metadata 1.3.58 → 1.3.60

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,7 +33,7 @@ import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
33
33
  import { MetadataService } from '../../../framework/metadata/MetadataService';
34
34
  import SparkSqlTable from './plugin/SparkSqlTable';
35
35
  import MapTable from './plugin/MapTable';
36
- import IconButton from './plugin/IconButton';
36
+ import SourceConfig from './plugin/SourceConfig';
37
37
  var TextArea = _Input.TextArea;
38
38
  function Index(props) {
39
39
  var _extraInfo$addonAfter7;
@@ -195,8 +195,8 @@ function Index(props) {
195
195
  return /*#__PURE__*/React.createElement(SparkSqlTable, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.sparkSqlTable);
196
196
  case 'mapTable':
197
197
  return /*#__PURE__*/React.createElement(MapTable, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mapTable);
198
- case 'iconButton':
199
- return /*#__PURE__*/React.createElement(IconButton, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.iconButton);
198
+ case 'sourceConfig':
199
+ return /*#__PURE__*/React.createElement(SourceConfig, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.sourceConfig);
200
200
  default:
201
201
  return /*#__PURE__*/React.createElement(_Input, {
202
202
  addonAfter: ((_extraInfo$addonAfter2 = extraInfo.addonAfter) === null || _extraInfo$addonAfter2 === void 0 ? void 0 : _extraInfo$addonAfter2.key) ? /*#__PURE__*/React.createElement(_Form.Item, {
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface ISourceConfigProps {
3
+ configType?: string;
4
+ }
5
+ declare const SourceConfig: (props: ISourceConfigProps) => React.JSX.Element;
6
+ export default SourceConfig;
@@ -0,0 +1,397 @@
1
+ import "antd/es/form/style";
2
+ import _Form from "antd/es/form";
3
+ import "antd/es/upload/style";
4
+ import _Upload from "antd/es/upload";
5
+ import "antd/es/input/style";
6
+ import _Input from "antd/es/input";
7
+ import "antd/es/button/style";
8
+ import _Button from "antd/es/button";
9
+ import "antd/es/select/style";
10
+ import _Select from "antd/es/select";
11
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
12
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
13
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
+ import { tr } from '@/framework/locale';
15
+ import { LinkOutlined, UploadOutlined, PlusOutlined } from '@ant-design/icons';
16
+ import React from 'react';
17
+ import Editable from '@/comps/Editable';
18
+ var SourceConfig = function SourceConfig(props) {
19
+ var configType = props.configType;
20
+ var isTarget = configType === 'target';
21
+ var isSource = configType === 'source';
22
+ var sourceOpts = isTarget ? [{
23
+ value: 'Cassandra',
24
+ label: 'Cassandra'
25
+ }, {
26
+ value: 'PgSql',
27
+ label: 'PgSql'
28
+ }, {
29
+ value: 'Minio',
30
+ label: 'Minio'
31
+ }, {
32
+ value: 'SqlServer',
33
+ label: 'SqlServer'
34
+ }] : [{
35
+ value: 'Kafka',
36
+ label: 'Kafka'
37
+ }, {
38
+ value: 'PgSql',
39
+ label: 'PgSql'
40
+ }, {
41
+ value: 'Minio',
42
+ label: 'Minio'
43
+ }, {
44
+ value: 'SqlServer',
45
+ label: 'SqlServer'
46
+ }];
47
+ var _React$useState = React.useState(),
48
+ _React$useState2 = _slicedToArray(_React$useState, 2),
49
+ source = _React$useState2[0],
50
+ setSource = _React$useState2[1];
51
+ var _React$useState3 = React.useState(),
52
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
53
+ defaultSource = _React$useState4[0],
54
+ setDefaultSource = _React$useState4[1];
55
+ // kafka source
56
+ var _React$useState5 = React.useState(),
57
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
58
+ autoOffsetReset = _React$useState6[0],
59
+ setAutoOffsetReset = _React$useState6[1];
60
+ var _React$useState7 = React.useState(),
61
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
62
+ batchDuration = _React$useState8[0],
63
+ setBatchDuration = _React$useState8[1];
64
+ var strategyOpts = [{
65
+ value: 'earliest',
66
+ label: 'earliest'
67
+ }, {
68
+ value: 'latest',
69
+ label: 'latest'
70
+ }];
71
+ // sql source
72
+ var _React$useState9 = React.useState(),
73
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
74
+ fetchSize = _React$useState10[0],
75
+ setFetchSize = _React$useState10[1];
76
+ var _React$useState11 = React.useState(),
77
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
78
+ sql = _React$useState12[0],
79
+ setSql = _React$useState12[1];
80
+ // minio source
81
+ var streamRef = React.useRef();
82
+ var columns = [{
83
+ title: 'sheetName',
84
+ key: 'sheetName',
85
+ dataIndex: 'sheetName',
86
+ editable: true,
87
+ type: 'text'
88
+ }, {
89
+ title: 'header',
90
+ key: 'header',
91
+ dataIndex: 'header',
92
+ editable: true,
93
+ type: 'text'
94
+ }];
95
+ var _React$useState13 = React.useState([]),
96
+ _React$useState14 = _slicedToArray(_React$useState13, 2),
97
+ list = _React$useState14[0],
98
+ setList = _React$useState14[1];
99
+ var listRef = React.useRef([]);
100
+ var onAddRow = function onAddRow() {
101
+ var _list = listRef.current;
102
+ var newRow = {
103
+ sheetName: '',
104
+ header: ''
105
+ };
106
+ _list.push(newRow);
107
+ streamRef.current.next({
108
+ type: 'editRowKey',
109
+ payload: {
110
+ _rowKey_: _list.length - 1
111
+ }
112
+ });
113
+ setList(_toConsumableArray(_list));
114
+ listRef.current = _list;
115
+ };
116
+ var onRowConfirm = function onRowConfirm(record) {
117
+ var _list = listRef.current;
118
+ _list[record.rowIdx] = _objectSpread(_objectSpread({}, _list[record.rowIdx]), record.allValues);
119
+ setList(_toConsumableArray(_list));
120
+ listRef.current = _list;
121
+ };
122
+ var onRowDelete = function onRowDelete(record) {
123
+ var _list = listRef.current;
124
+ _list.splice(record._rowKey_, 1);
125
+ setList(_toConsumableArray(_list));
126
+ listRef.current = _list;
127
+ };
128
+ // cassandra target
129
+ var _React$useState15 = React.useState(),
130
+ _React$useState16 = _slicedToArray(_React$useState15, 2),
131
+ keyspace = _React$useState16[0],
132
+ setKeyspace = _React$useState16[1];
133
+ var _React$useState17 = React.useState(),
134
+ _React$useState18 = _slicedToArray(_React$useState17, 2),
135
+ dtname = _React$useState18[0],
136
+ setDtname = _React$useState18[1];
137
+ // pgsql target
138
+ var _React$useState19 = React.useState(),
139
+ _React$useState20 = _slicedToArray(_React$useState19, 2),
140
+ schema = _React$useState20[0],
141
+ setSchema = _React$useState20[1];
142
+ var _React$useState21 = React.useState(),
143
+ _React$useState22 = _slicedToArray(_React$useState21, 2),
144
+ dbname = _React$useState22[0],
145
+ setDbname = _React$useState22[1];
146
+ // minio target
147
+ var _React$useState23 = React.useState(),
148
+ _React$useState24 = _slicedToArray(_React$useState23, 2),
149
+ filePath = _React$useState24[0],
150
+ setFilePath = _React$useState24[1];
151
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
152
+ style: {
153
+ display: 'flex'
154
+ }
155
+ }, /*#__PURE__*/React.createElement(FormItem, {
156
+ label: tr('数据源'),
157
+ name: 'dataSource',
158
+ required: true
159
+ }, /*#__PURE__*/React.createElement(_Select, {
160
+ options: sourceOpts,
161
+ value: source,
162
+ onChange: function onChange(val) {
163
+ return setSource(val);
164
+ },
165
+ allowClear: true
166
+ })), /*#__PURE__*/React.createElement(FormItem, {
167
+ name: tr('defaultSource'),
168
+ colon: false
169
+ }, /*#__PURE__*/React.createElement(_Select, {
170
+ value: defaultSource,
171
+ onChange: function onChange(val) {
172
+ return setDefaultSource(val);
173
+ },
174
+ allowClear: true
175
+ })), /*#__PURE__*/React.createElement(FormItem, {
176
+ colon: false
177
+ }, /*#__PURE__*/React.createElement(_Button, {
178
+ className: "ml-2",
179
+ type: "link",
180
+ icon: /*#__PURE__*/React.createElement(LinkOutlined, null),
181
+ onClick: function onClick() {}
182
+ }, tr('测试连接')))), isSource && source === 'Kafka' && /*#__PURE__*/React.createElement("div", {
183
+ style: {
184
+ display: 'flex'
185
+ }
186
+ }, /*#__PURE__*/React.createElement(FormItem, {
187
+ label: tr('消费策略'),
188
+ name: 'autoOffsetReset',
189
+ required: true
190
+ }, /*#__PURE__*/React.createElement(_Select, {
191
+ options: strategyOpts,
192
+ value: autoOffsetReset,
193
+ onChange: function onChange(val) {
194
+ return setAutoOffsetReset(val);
195
+ },
196
+ allowClear: true
197
+ })), /*#__PURE__*/React.createElement(FormItem, {
198
+ label: tr('批间隔'),
199
+ name: 'batchDuration',
200
+ required: true
201
+ }, /*#__PURE__*/React.createElement(_Input, {
202
+ value: batchDuration,
203
+ onChange: function onChange(e) {
204
+ var _e$target;
205
+ return setBatchDuration(e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
206
+ }
207
+ }))), isSource && (source === 'PgSql' || source === 'SqlServer') && /*#__PURE__*/React.createElement("div", {
208
+ style: {
209
+ display: 'flex'
210
+ }
211
+ }, /*#__PURE__*/React.createElement(FormItem, {
212
+ label: 'fetch size',
213
+ name: 'fetchSize',
214
+ required: true
215
+ }, /*#__PURE__*/React.createElement(_Input, {
216
+ value: fetchSize,
217
+ onChange: function onChange(e) {
218
+ var _e$target2;
219
+ return setFetchSize(e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.value);
220
+ }
221
+ })), /*#__PURE__*/React.createElement(FormItem, {
222
+ label: 'sql',
223
+ name: 'sql',
224
+ required: true
225
+ }, /*#__PURE__*/React.createElement(_Input, {
226
+ value: sql,
227
+ onChange: function onChange(e) {
228
+ var _e$target3;
229
+ return setSql(e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.value);
230
+ }
231
+ }))), isSource && source === 'Minio' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormItem, {
232
+ label: tr('上传文件'),
233
+ name: 'filepath',
234
+ required: true
235
+ }, /*#__PURE__*/React.createElement(_Upload, {
236
+ customRequest: function customRequest(options) {
237
+ setTimeout(function () {
238
+ options.onSuccess();
239
+ }, 1000);
240
+ }
241
+ }, /*#__PURE__*/React.createElement(_Button, {
242
+ icon: /*#__PURE__*/React.createElement(UploadOutlined, null)
243
+ }, tr('上传'))))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormItem, {
244
+ label: tr('文件信息'),
245
+ name: 'headers'
246
+ }, /*#__PURE__*/React.createElement(Editable, {
247
+ type: "single",
248
+ columns: columns,
249
+ dataSource: list,
250
+ onRowConfirm: onRowConfirm,
251
+ onRowDelete: onRowDelete,
252
+ getStreamInstance: function getStreamInstance(stream) {
253
+ return streamRef.current = stream;
254
+ },
255
+ onRowClick: function onRowClick(record) {}
256
+ }), /*#__PURE__*/React.createElement(_Button, {
257
+ type: "dashed",
258
+ onClick: onAddRow,
259
+ style: {
260
+ width: '100%',
261
+ marginTop: '2px'
262
+ }
263
+ }, tr('添加一行'))))), isTarget && source === 'Cassandra' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FormItem, {
264
+ label: tr('键空间'),
265
+ name: 'keyspace',
266
+ required: true
267
+ }, /*#__PURE__*/React.createElement(_Select, {
268
+ value: keyspace,
269
+ onChange: function onChange(val) {
270
+ return setKeyspace(val);
271
+ },
272
+ allowClear: true
273
+ })), /*#__PURE__*/React.createElement("div", {
274
+ style: {
275
+ display: 'flex'
276
+ }
277
+ }, /*#__PURE__*/React.createElement(FormItem, {
278
+ label: tr('数据表'),
279
+ name: 'dtname',
280
+ required: true
281
+ }, /*#__PURE__*/React.createElement(_Select, {
282
+ value: dtname,
283
+ onChange: function onChange(val) {
284
+ return setDtname(val);
285
+ },
286
+ allowClear: true
287
+ })), /*#__PURE__*/React.createElement(FormItem, {
288
+ colon: false
289
+ }, /*#__PURE__*/React.createElement(_Button, {
290
+ className: "ml-2",
291
+ type: "link",
292
+ icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
293
+ onClick: function onClick() {}
294
+ }, tr('手动建表'))))), isTarget && (source === 'PgSql' || source === 'SqlServer') && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
295
+ style: {
296
+ display: 'flex'
297
+ }
298
+ }, /*#__PURE__*/React.createElement(FormItem, {
299
+ label: 'schema',
300
+ name: 'schema',
301
+ required: true
302
+ }, /*#__PURE__*/React.createElement(_Select, {
303
+ value: schema,
304
+ onChange: function onChange(val) {
305
+ return setSchema(val);
306
+ },
307
+ allowClear: true
308
+ })), /*#__PURE__*/React.createElement(FormItem, {
309
+ label: tr('数据库'),
310
+ name: 'dbname',
311
+ required: true
312
+ }, /*#__PURE__*/React.createElement(_Select, {
313
+ value: dbname,
314
+ onChange: function onChange(val) {
315
+ return setDbname(val);
316
+ },
317
+ allowClear: true
318
+ }))), /*#__PURE__*/React.createElement("div", {
319
+ style: {
320
+ display: 'flex'
321
+ }
322
+ }, /*#__PURE__*/React.createElement(FormItem, {
323
+ label: tr('数据表'),
324
+ name: 'dtname',
325
+ required: true
326
+ }, /*#__PURE__*/React.createElement(_Select, {
327
+ value: dtname,
328
+ onChange: function onChange(val) {
329
+ return setDtname(val);
330
+ },
331
+ allowClear: true
332
+ })), /*#__PURE__*/React.createElement(FormItem, {
333
+ colon: false
334
+ }, /*#__PURE__*/React.createElement(_Button, {
335
+ className: "ml-2",
336
+ type: "link",
337
+ icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
338
+ onClick: function onClick() {}
339
+ }, tr('手动建表'))))), isTarget && source === 'Minio' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, {
340
+ label: tr('文件路径'),
341
+ name: 'filepath',
342
+ required: true
343
+ }, /*#__PURE__*/React.createElement(_Input, {
344
+ value: filePath,
345
+ onChange: function onChange(e) {
346
+ return setFilePath(e.target.value);
347
+ }
348
+ }))));
349
+ };
350
+ export default SourceConfig;
351
+ var FormItem = function FormItem(props) {
352
+ var color = props.color,
353
+ _props$labelSpan = props.labelSpan,
354
+ labelSpan = _props$labelSpan === void 0 ? 0 : _props$labelSpan,
355
+ _props$layout = props.layout,
356
+ layout = _props$layout === void 0 ? 'horizontal' : _props$layout,
357
+ name = props.name,
358
+ label = props.label,
359
+ colon = props.colon,
360
+ help = props.help,
361
+ tooltip = props.tooltip,
362
+ _props$required = props.required,
363
+ required = _props$required === void 0 ? false : _props$required,
364
+ children = props.children,
365
+ _props$wrapperSpan = props.wrapperSpan,
366
+ wrapperSpan = _props$wrapperSpan === void 0 ? 3 : _props$wrapperSpan;
367
+ return /*#__PURE__*/React.createElement(_Form.Item, {
368
+ style: {
369
+ flex: 1,
370
+ paddingRight: '10px'
371
+ },
372
+ label: /*#__PURE__*/React.createElement("span", {
373
+ style: color ? {
374
+ color: color
375
+ } : {}
376
+ }, tr(label)),
377
+ labelCol: labelSpan && layout === 'horizontal' ? {
378
+ flex: "0 0 ".concat(labelSpan * 100 / 24, "%"),
379
+ offset: 0
380
+ } : undefined,
381
+ wrapperCol: labelSpan && wrapperSpan && layout === 'horizontal' ? {
382
+ style: {
383
+ width: "".concat((wrapperSpan - labelSpan) * 100 / 24, "%")
384
+ },
385
+ flex: "0 0 ".concat((wrapperSpan - labelSpan) * 100 / 24, "%"),
386
+ offset: 0
387
+ } : undefined,
388
+ name: name,
389
+ rules: [{
390
+ required: required,
391
+ message: "".concat(tr('请输入'), " ").concat(tr(label))
392
+ }],
393
+ help: tr(help),
394
+ tooltip: tr(tooltip),
395
+ colon: colon
396
+ }, children);
397
+ };