ronds-metadata 1.3.65 → 1.3.67

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,15 +22,10 @@ import { LinkOutlined, UploadOutlined, PlusOutlined } from '@ant-design/icons';
22
22
  import React from 'react';
23
23
  import Editable from '../../../Editable/index';
24
24
  import { MetadataService } from '../../../../framework/metadata/MetadataService';
25
- import { useAsyncMemo } from '../../../../framework/hooks/use-async-memo';
26
25
  import { deepClone } from '../../../../utils';
27
- import useObservable from '../../../../framework/rxjs-hooks/useObservable';
26
+ import { MetadataFormContext } from '../../interface';
28
27
  var SourceConfig = function SourceConfig(props) {
29
- var configType = props.configType,
30
- sourceHttp = props.sourceHttp,
31
- sourceEnums = props.sourceEnums,
32
- targetHttp = props.targetHttp,
33
- targetEnums = props.targetEnums;
28
+ var configType = props.configType;
34
29
  var isTarget = configType === 'target';
35
30
  var isSource = configType === 'source';
36
31
  var marginStyle = {
@@ -46,6 +41,33 @@ var SourceConfig = function SourceConfig(props) {
46
41
  _React$useState4 = _slicedToArray(_React$useState3, 2),
47
42
  defaultSource = _React$useState4[0],
48
43
  setDefaultSource = _React$useState4[1];
44
+ var _React$useContext = React.useContext(MetadataFormContext),
45
+ form = _React$useContext.form;
46
+ var dataSourceOpts = isSource ? [{
47
+ value: 'Kafka',
48
+ label: 'Kafka'
49
+ }, {
50
+ value: 'PgSql',
51
+ label: 'PgSql'
52
+ }, {
53
+ value: 'Minio',
54
+ label: 'Minio'
55
+ }, {
56
+ value: 'SqlServer',
57
+ label: 'SqlServer'
58
+ }] : [{
59
+ value: 'Cassandra',
60
+ label: 'Cassandra'
61
+ }, {
62
+ value: 'PgSql',
63
+ label: 'PgSql'
64
+ }, {
65
+ value: 'Minio',
66
+ label: 'Minio'
67
+ }, {
68
+ value: 'SqlServer',
69
+ label: 'SqlServer'
70
+ }];
49
71
  // kafka source
50
72
  var _React$useState5 = React.useState(),
51
73
  _React$useState6 = _slicedToArray(_React$useState5, 2),
@@ -140,73 +162,84 @@ var SourceConfig = function SourceConfig(props) {
140
162
  filePath = _React$useState26[0],
141
163
  setFilePath = _React$useState26[1];
142
164
  // http 调用接口
143
- var watchValueRef = React.useRef();
144
165
  var pageRef = React.useRef(1);
145
166
  var totalRef = React.useRef();
146
- var processSelectOptionsData = function processSelectOptionsData() {
147
- var _options = [];
148
- var _items = [];
149
- var _enum = deepClone(sourceEnums || targetEnums || []);
150
- _enum.forEach(function (p) {
151
- p.forEach(function (it) {
152
- var _it$key;
153
- var obj = {
154
- label: it.value,
155
- value: (_it$key = it === null || it === void 0 ? void 0 : it.key) !== null && _it$key !== void 0 ? _it$key : it === null || it === void 0 ? void 0 : it.value
156
- };
157
- _items.push(obj);
158
- });
159
- _options.push(_items);
160
- _items = [];
161
- });
162
- return _options;
163
- };
164
- var options = React.useMemo(function () {
165
- return processSelectOptionsData();
166
- }, [sourceEnums, targetEnums]);
167
167
  var getEnumDataByUrl = React.useCallback( /*#__PURE__*/function () {
168
168
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(http, pid, page) {
169
- var server, _url, res, _res, resGet;
169
+ var _res2, _res3, _res4;
170
+ var server, _url, source, levelTwo, res, watchValues, _res, resGet;
170
171
  return _regeneratorRuntime.wrap(function _callee$(_context) {
171
172
  while (1) switch (_context.prev = _context.next) {
172
173
  case 0:
173
174
  server = new MetadataService();
174
- _url = pid || pid === '' ? http.url.replace('{pid}', pid) : http.url;
175
- _url = page ? http.url.replace('{page}', page) : _url;
176
- if (watchValueRef.current) {
177
- if (typeof watchValueRef.current === 'string') {
178
- _url = _url.replace('{watch}', watchValueRef.current);
179
- }
175
+ _url = pid || pid === '' ? http === null || http === void 0 ? void 0 : http.url.replace('{pid}', pid) : http === null || http === void 0 ? void 0 : http.url;
176
+ _url = page ? http === null || http === void 0 ? void 0 : http.url.replace('{page}', page) : _url;
177
+ if (!((http === null || http === void 0 ? void 0 : http.watch) && !http.watch.includes(','))) {
178
+ _context.next = 11;
179
+ break;
180
+ }
181
+ source = form.getFieldsValue()[http.watch];
182
+ _url = _url.replace('{watch}', source);
183
+ _context.next = 8;
184
+ return server.GetEnumDataByUrl(_url, http === null || http === void 0 ? void 0 : http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body) ? _objectSpread(_objectSpread({}, JSON.parse(http === null || http === void 0 ? void 0 : http.body)), {
185
+ source: source
186
+ } || {}) : source);
187
+ case 8:
188
+ res = _context.sent;
189
+ _context.next = 23;
190
+ break;
191
+ case 11:
192
+ if (!((http === null || http === void 0 ? void 0 : http.watch) && http.watch.includes(','))) {
193
+ _context.next = 20;
194
+ break;
180
195
  }
181
- _context.next = 6;
182
- return server.GetEnumDataByUrl(_url, http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body) ? _objectSpread(_objectSpread({}, JSON.parse(http === null || http === void 0 ? void 0 : http.body)), watchValueRef.current || {}) : watchValueRef.current);
183
- case 6:
196
+ watchValues = http.watch.split(',');
197
+ source = form.getFieldsValue()[watchValues[0]];
198
+ levelTwo = form.getFieldsValue()[watchValues[1]];
199
+ _context.next = 17;
200
+ return server.GetEnumDataByUrl(_url, http === null || http === void 0 ? void 0 : http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body) ? _objectSpread(_objectSpread({}, JSON.parse(http === null || http === void 0 ? void 0 : http.body)), {
201
+ source: source,
202
+ levelTwo: levelTwo
203
+ } || {}) : {
204
+ source: source,
205
+ levelTwo: levelTwo
206
+ });
207
+ case 17:
184
208
  res = _context.sent;
185
- _res = (res === null || res === void 0 ? void 0 : res.total) ? res === null || res === void 0 ? void 0 : res.list : res;
186
- console.warn('======================== interface get ========================', _res);
187
- totalRef.current = res === null || res === void 0 ? void 0 : res.total;
209
+ _context.next = 23;
210
+ break;
211
+ case 20:
212
+ _context.next = 22;
213
+ return server.GetEnumDataByUrl(_url, http === null || http === void 0 ? void 0 : http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body) ? _objectSpread(_objectSpread({}, JSON.parse(http === null || http === void 0 ? void 0 : http.body)), {
214
+ source: source
215
+ } || {}) : source);
216
+ case 22:
217
+ res = _context.sent;
218
+ case 23:
219
+ _res = ((_res2 = res) === null || _res2 === void 0 ? void 0 : _res2.total) ? (_res3 = res) === null || _res3 === void 0 ? void 0 : _res3.list : res;
220
+ totalRef.current = (_res4 = res) === null || _res4 === void 0 ? void 0 : _res4.total;
188
221
  if (!(_res && _res.length > 0)) {
189
- _context.next = 22;
222
+ _context.next = 36;
190
223
  break;
191
224
  }
192
- if (!((http === null || http === void 0 ? void 0 : http.isCascader) && http.url.indexOf('{pid}') === -1)) {
193
- _context.next = 13;
225
+ if (!((http === null || http === void 0 ? void 0 : http.isCascader) && (http === null || http === void 0 ? void 0 : http.url.indexOf('{pid}')) === -1)) {
226
+ _context.next = 28;
194
227
  break;
195
228
  }
196
229
  return _context.abrupt("return", _res);
197
- case 13:
230
+ case 28:
198
231
  if (!(http === null || http === void 0 ? void 0 : http.isGroup)) {
199
- _context.next = 15;
232
+ _context.next = 30;
200
233
  break;
201
234
  }
202
235
  return _context.abrupt("return", _res);
203
- case 15:
236
+ case 30:
204
237
  if (!(http === null || http === void 0 ? void 0 : http.isTreeSelect)) {
205
- _context.next = 17;
238
+ _context.next = 32;
206
239
  break;
207
240
  }
208
241
  return _context.abrupt("return", _res);
209
- case 17:
242
+ case 32:
210
243
  resGet = _res.map(function (it) {
211
244
  if (http === null || http === void 0 ? void 0 : http.isCascader) {
212
245
  return {
@@ -215,7 +248,6 @@ var SourceConfig = function SourceConfig(props) {
215
248
  isLeaf: it['isLeaf'] ? it['isLeaf'] : false
216
249
  };
217
250
  } else {
218
- console.warn('======================== result ========================', it);
219
251
  return {
220
252
  value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
221
253
  label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
@@ -223,12 +255,11 @@ var SourceConfig = function SourceConfig(props) {
223
255
  };
224
256
  }
225
257
  });
226
- console.warn('========================== value =======================', resGet);
227
258
  return _context.abrupt("return", resGet);
228
- case 22:
259
+ case 36:
229
260
  console.warn("".concat(_url, " is not return success result"));
230
261
  return _context.abrupt("return", []);
231
- case 24:
262
+ case 38:
232
263
  case "end":
233
264
  return _context.stop();
234
265
  }
@@ -238,38 +269,124 @@ var SourceConfig = function SourceConfig(props) {
238
269
  return _ref.apply(this, arguments);
239
270
  };
240
271
  }(), []);
241
- var httpOptions = useAsyncMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
242
- var _httpOptions;
243
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
244
- while (1) switch (_context2.prev = _context2.next) {
245
- case 0:
246
- _httpOptions = (sourceHttp || targetHttp).map(function (it) {
247
- if (it && it.url) {
248
- getEnumDataByUrl(deepClone(it), '', (it === null || it === void 0 ? void 0 : it.isPagination) && pageRef.current).then(function (res) {
249
- return res;
250
- });
251
- }
252
- return [];
253
- });
254
- return _context2.abrupt("return", _httpOptions);
255
- case 2:
256
- case "end":
257
- return _context2.stop();
258
- }
259
- }, _callee2);
260
- })), [sourceHttp, targetHttp]);
261
- var myOptions = React.useMemo(function () {
262
- var _options = options;
263
- httpOptions && httpOptions.forEach(function (p, i) {
264
- if (p && p.length > 0) {
265
- _options[i] = p;
266
- }
267
- });
268
- return _options;
269
- }, [options, httpOptions]);
270
- useObservable(function (p) {
271
- // TODO 设置watch值
272
- }, []);
272
+ var getHttpOptions = /*#__PURE__*/function () {
273
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(httpValue) {
274
+ var valueOpts;
275
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
276
+ while (1) switch (_context2.prev = _context2.next) {
277
+ case 0:
278
+ _context2.next = 2;
279
+ return getEnumDataByUrl(deepClone(httpValue), '', (httpValue === null || httpValue === void 0 ? void 0 : httpValue.isPagination) && pageRef.current);
280
+ case 2:
281
+ valueOpts = _context2.sent;
282
+ return _context2.abrupt("return", valueOpts);
283
+ case 4:
284
+ case "end":
285
+ return _context2.stop();
286
+ }
287
+ }, _callee2);
288
+ }));
289
+ return function getHttpOptions(_x4) {
290
+ return _ref2.apply(this, arguments);
291
+ };
292
+ }();
293
+ var getDefaultHttpConfig4Source = function getDefaultHttpConfig4Source(val) {
294
+ switch (val) {
295
+ case 'Kafka':
296
+ return {
297
+ method: 'post',
298
+ body: '{"type":"Kafka","level":1}',
299
+ value: 'name',
300
+ key: 'config',
301
+ url: '/dataset-web/source/cascade/data/v2'
302
+ };
303
+ break;
304
+ default:
305
+ return null;
306
+ }
307
+ };
308
+ var getDefaultHttpConfig4Target = function getDefaultHttpConfig4Target(val) {
309
+ switch (val) {
310
+ case 'Cassandra':
311
+ return {
312
+ method: 'post',
313
+ body: '{"type":"Cassandra","level":1}',
314
+ value: 'name',
315
+ key: 'config',
316
+ url: '/dataset-web/source/cascade/data/v2'
317
+ };
318
+ break;
319
+ default:
320
+ return null;
321
+ }
322
+ };
323
+ // 来源选项值
324
+ var _React$useState27 = React.useState(),
325
+ _React$useState28 = _slicedToArray(_React$useState27, 2),
326
+ defaultSourceOpts = _React$useState28[0],
327
+ setDefaultSourceOpts = _React$useState28[1];
328
+ var topicHttp = {
329
+ method: 'post',
330
+ body: '{"type":"Kafka","level":2}',
331
+ value: 'name',
332
+ watch: 'defaultSource',
333
+ key: 'name',
334
+ url: '/dataset-web/source/cascade/data/v2'
335
+ };
336
+ var _React$useState29 = React.useState(),
337
+ _React$useState30 = _slicedToArray(_React$useState29, 2),
338
+ topicOpts = _React$useState30[0],
339
+ setTopicOpts = _React$useState30[1];
340
+ // 去向选项值
341
+ var keyspaceHttp = {
342
+ method: 'post',
343
+ body: '{"type":"Cassandra","level":2}',
344
+ value: 'name',
345
+ watch: 'defaultSource',
346
+ key: 'name',
347
+ url: '/dataset-web/source/cascade/data/v2'
348
+ };
349
+ var _React$useState31 = React.useState(),
350
+ _React$useState32 = _slicedToArray(_React$useState31, 2),
351
+ keyspaceOpts = _React$useState32[0],
352
+ setKeyspaceOpts = _React$useState32[1];
353
+ var dtnameHttp = {
354
+ method: 'post',
355
+ body: '{"type":"Cassandra","level":3}',
356
+ value: 'name',
357
+ watch: 'defaultSource,keyspace',
358
+ key: 'dfSourceId',
359
+ url: '/dataset-web/source/cascade/data/v2'
360
+ };
361
+ var _React$useState33 = React.useState(),
362
+ _React$useState34 = _slicedToArray(_React$useState33, 2),
363
+ dtnameOpts = _React$useState34[0],
364
+ setDtnameOpts = _React$useState34[1];
365
+ // onfunction
366
+ var onDataSourceChange = /*#__PURE__*/function () {
367
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(val) {
368
+ var _http;
369
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
370
+ while (1) switch (_context3.prev = _context3.next) {
371
+ case 0:
372
+ setSource(val);
373
+ _http = isSource ? getDefaultHttpConfig4Source(val) : getDefaultHttpConfig4Target(val);
374
+ _context3.t0 = setDefaultSourceOpts;
375
+ _context3.next = 5;
376
+ return getHttpOptions(_http);
377
+ case 5:
378
+ _context3.t1 = _context3.sent;
379
+ (0, _context3.t0)(_context3.t1);
380
+ case 7:
381
+ case "end":
382
+ return _context3.stop();
383
+ }
384
+ }, _callee3);
385
+ }));
386
+ return function onDataSourceChange(_x5) {
387
+ return _ref3.apply(this, arguments);
388
+ };
389
+ }();
273
390
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, {
274
391
  gutter: 16,
275
392
  style: marginStyle
@@ -281,22 +398,63 @@ var SourceConfig = function SourceConfig(props) {
281
398
  required: true
282
399
  }, /*#__PURE__*/React.createElement(_Select, {
283
400
  value: source,
284
- onChange: function onChange(val) {
285
- return setSource(val);
286
- },
287
- options: myOptions[0],
401
+ onChange: onDataSourceChange,
402
+ options: dataSourceOpts,
288
403
  allowClear: true
289
404
  }))), /*#__PURE__*/React.createElement(_Col, {
290
405
  span: 8
291
406
  }, /*#__PURE__*/React.createElement(FormItem, {
292
- name: tr('defaultSource'),
407
+ name: 'defaultSource',
293
408
  colon: false
294
409
  }, /*#__PURE__*/React.createElement(_Select, {
295
410
  value: defaultSource,
296
- onChange: function onChange(val) {
297
- return setDefaultSource(val);
298
- },
299
- options: myOptions[1],
411
+ onChange: ( /*#__PURE__*/function () {
412
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(val) {
413
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
414
+ while (1) switch (_context4.prev = _context4.next) {
415
+ case 0:
416
+ setDefaultSource(val);
417
+ if (!isSource) {
418
+ _context4.next = 13;
419
+ break;
420
+ }
421
+ _context4.t0 = source;
422
+ _context4.next = _context4.t0 === 'Kafka' ? 5 : 11;
423
+ break;
424
+ case 5:
425
+ _context4.t1 = setTopicOpts;
426
+ _context4.next = 8;
427
+ return getHttpOptions(topicHttp);
428
+ case 8:
429
+ _context4.t2 = _context4.sent;
430
+ (0, _context4.t1)(_context4.t2);
431
+ return _context4.abrupt("break", 11);
432
+ case 11:
433
+ _context4.next = 22;
434
+ break;
435
+ case 13:
436
+ _context4.t3 = source;
437
+ _context4.next = _context4.t3 === 'Cassandra' ? 16 : 22;
438
+ break;
439
+ case 16:
440
+ _context4.t4 = setKeyspaceOpts;
441
+ _context4.next = 19;
442
+ return getHttpOptions(keyspaceHttp);
443
+ case 19:
444
+ _context4.t5 = _context4.sent;
445
+ (0, _context4.t4)(_context4.t5);
446
+ return _context4.abrupt("break", 22);
447
+ case 22:
448
+ case "end":
449
+ return _context4.stop();
450
+ }
451
+ }, _callee4);
452
+ }));
453
+ return function (_x6) {
454
+ return _ref4.apply(this, arguments);
455
+ };
456
+ }()),
457
+ options: defaultSourceOpts,
300
458
  allowClear: true
301
459
  }))), /*#__PURE__*/React.createElement(_Col, {
302
460
  span: 8
@@ -321,7 +479,7 @@ var SourceConfig = function SourceConfig(props) {
321
479
  onChange: function onChange(val) {
322
480
  return setTopics(val);
323
481
  },
324
- options: myOptions[2],
482
+ options: topicOpts,
325
483
  mode: "multiple",
326
484
  allowClear: true
327
485
  }))), /*#__PURE__*/React.createElement(_Col, {
@@ -335,7 +493,13 @@ var SourceConfig = function SourceConfig(props) {
335
493
  onChange: function onChange(val) {
336
494
  return setAutoOffsetReset(val);
337
495
  },
338
- options: myOptions[3],
496
+ options: [{
497
+ value: 'earliest',
498
+ label: 'earliest'
499
+ }, {
500
+ value: 'latest',
501
+ label: 'latest'
502
+ }],
339
503
  allowClear: true
340
504
  })))), /*#__PURE__*/React.createElement(_Row, {
341
505
  gutter: 16,
@@ -366,7 +530,7 @@ var SourceConfig = function SourceConfig(props) {
366
530
  onChange: function onChange(val) {
367
531
  return setDbname(val);
368
532
  },
369
- options: myOptions[4],
533
+ options: [],
370
534
  allowClear: true
371
535
  }))), /*#__PURE__*/React.createElement(_Col, {
372
536
  span: 8
@@ -379,7 +543,7 @@ var SourceConfig = function SourceConfig(props) {
379
543
  onChange: function onChange(val) {
380
544
  return setSchema(val);
381
545
  },
382
- options: myOptions[5],
546
+ options: [],
383
547
  allowClear: true
384
548
  })))), /*#__PURE__*/React.createElement(_Row, {
385
549
  gutter: 16,
@@ -461,10 +625,29 @@ var SourceConfig = function SourceConfig(props) {
461
625
  required: true
462
626
  }, /*#__PURE__*/React.createElement(_Select, {
463
627
  value: keyspace,
464
- onChange: function onChange(val) {
465
- return setKeyspace(val);
466
- },
467
- options: myOptions[2],
628
+ onChange: ( /*#__PURE__*/function () {
629
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(val) {
630
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
631
+ while (1) switch (_context5.prev = _context5.next) {
632
+ case 0:
633
+ setKeyspace(val);
634
+ _context5.t0 = setDtnameOpts;
635
+ _context5.next = 4;
636
+ return getHttpOptions(dtnameHttp);
637
+ case 4:
638
+ _context5.t1 = _context5.sent;
639
+ (0, _context5.t0)(_context5.t1);
640
+ case 6:
641
+ case "end":
642
+ return _context5.stop();
643
+ }
644
+ }, _callee5);
645
+ }));
646
+ return function (_x7) {
647
+ return _ref5.apply(this, arguments);
648
+ };
649
+ }()),
650
+ options: keyspaceOpts,
468
651
  allowClear: true
469
652
  }))), /*#__PURE__*/React.createElement(_Col, {
470
653
  span: 8
@@ -477,7 +660,7 @@ var SourceConfig = function SourceConfig(props) {
477
660
  onChange: function onChange(val) {
478
661
  return setDtname(val);
479
662
  },
480
- options: myOptions[3],
663
+ options: dtnameOpts,
481
664
  allowClear: true
482
665
  }))), /*#__PURE__*/React.createElement(_Col, {
483
666
  span: 8
@@ -502,7 +685,7 @@ var SourceConfig = function SourceConfig(props) {
502
685
  onChange: function onChange(val) {
503
686
  return setDbname(val);
504
687
  },
505
- options: myOptions[4],
688
+ options: [],
506
689
  allowClear: true
507
690
  }))), /*#__PURE__*/React.createElement(_Col, {
508
691
  span: 8
@@ -515,7 +698,7 @@ var SourceConfig = function SourceConfig(props) {
515
698
  onChange: function onChange(val) {
516
699
  return setSchema(val);
517
700
  },
518
- options: myOptions[5],
701
+ options: [],
519
702
  allowClear: true
520
703
  })))), /*#__PURE__*/React.createElement(_Row, {
521
704
  gutter: 16,
@@ -531,7 +714,7 @@ var SourceConfig = function SourceConfig(props) {
531
714
  onChange: function onChange(val) {
532
715
  return setDtname(val);
533
716
  },
534
- options: myOptions[6],
717
+ options: [],
535
718
  allowClear: true
536
719
  }))), /*#__PURE__*/React.createElement(_Col, {
537
720
  span: 8
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface ISourceConfigNewProps {
3
+ configType: string;
4
+ sourceHttp?: any[];
5
+ sourceEnums?: any[];
6
+ targetHttp?: any[];
7
+ targetEnums?: any[];
8
+ }
9
+ declare const SourceConfigNew: (props: ISourceConfigNewProps) => React.JSX.Element;
10
+ export default SourceConfigNew;