vap1 0.5.3 → 0.5.5
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/cems/admin/utils.js +0 -4
- package/components/SearchTool/SearchBar/ActionButtons.js +3 -16
- package/components/Tables/ApiTable.d.ts +1 -0
- package/components/Tables/ApiTableModal.d.ts +1 -0
- package/components/Tables/Components/ActionBar.js +0 -36
- package/components/Tables/Components/useTableContext.js +0 -1
- package/components/Tables/Util.d.ts +2 -2
- package/components/Tables/VTable.d.ts +1 -0
- package/components/Tables/VTable.js +0 -1
- package/components/Tables/index.d.ts +9 -1
- package/components/Trees/ActionTree.js +5 -1
- package/components/Trees/BaseTree.js +1 -1
- package/components/UForm/FormWrapper.js +5 -0
- package/components/UForm/UFormModal.js +2 -2
- package/components/UForm/_FieldType.js +2 -1
- package/components/UForm/index.d.ts +1 -1
- package/hooks/useModals.d.ts +1 -2
- package/index.d.ts +4 -1
- package/package.json +1 -1
- package/components/Tables/VTableBack.d.ts +0 -0
- package/components/Tables/VTableBack.js +0 -269
- package/deps/app-data/Const.d.ts +0 -71
- package/deps/app-data/Const.js +0 -54
- package/deps/app-data/SourceTable.d.ts +0 -0
- package/deps/app-data/SourceTable.js +0 -137
- package/deps/app-data/TimeConst.d.ts +0 -0
- package/deps/app-data/TimeConst.js +0 -58
- package/deps/app-data/useSource.d.ts +0 -22
- package/deps/app-data/useSource.js +0 -253
package/cems/admin/utils.js
CHANGED
|
@@ -73,16 +73,10 @@ var getIcon = function (icon) {
|
|
|
73
73
|
return icon;
|
|
74
74
|
};
|
|
75
75
|
var ActionButton = function (props) {
|
|
76
|
+
var btnParam = lodash_1.default.pick(props, ['type', 'danger', 'disabled']);
|
|
76
77
|
if (props.children && props.children.length > 0) {
|
|
77
|
-
var btnParam_1 = {};
|
|
78
|
-
if (lodash_1.default.has(props, 'type'))
|
|
79
|
-
btnParam_1.type = props.type;
|
|
80
|
-
if (props.danger)
|
|
81
|
-
btnParam_1.danger = true;
|
|
82
|
-
if (props.disabled)
|
|
83
|
-
btnParam_1.disabled = true;
|
|
84
78
|
if (lodash_1.default.isFunction(props.onClick))
|
|
85
|
-
|
|
79
|
+
btnParam.onClick = function (evt) { return utils_1.PageUtil.stopEvent(evt, props.onClick); };
|
|
86
80
|
var menus_1 = [];
|
|
87
81
|
props.children.map(function (item, key) {
|
|
88
82
|
if (item.roleCode && !utils_1.PageUtil.hasRole(item.roleCode))
|
|
@@ -104,20 +98,13 @@ var ActionButton = function (props) {
|
|
|
104
98
|
if (menus_1.length == 0)
|
|
105
99
|
return utils_1.Const.NONE;
|
|
106
100
|
return react_1.default.createElement(Dropdown_1.Dropdown, { menu: { items: menus_1 } },
|
|
107
|
-
react_1.default.createElement(Button_1.Button, __assign({},
|
|
101
|
+
react_1.default.createElement(Button_1.Button, __assign({}, btnParam),
|
|
108
102
|
props.label,
|
|
109
103
|
" ",
|
|
110
104
|
react_1.default.createElement(Icon_1.Icon, { type: "down" })));
|
|
111
105
|
}
|
|
112
|
-
var btnParam = {};
|
|
113
106
|
if (props.icon)
|
|
114
107
|
btnParam.icon = getIcon(props.icon);
|
|
115
|
-
if (lodash_1.default.has(props, 'type'))
|
|
116
|
-
btnParam.type = props.type;
|
|
117
|
-
if (props.disabled)
|
|
118
|
-
btnParam.disabled = true;
|
|
119
|
-
if (props.danger)
|
|
120
|
-
btnParam.danger = true;
|
|
121
108
|
if (props.confirm && props.disabled !== true) {
|
|
122
109
|
return react_1.default.createElement(Popconfirm_1.Popconfirm, { key: Math.floor(lodash_1.default.random() * 1000000) + '', trigger: "click", placement: "bottomLeft", onConfirm: props.onClick, title: lodash_1.default.isString(props.confirm) ? props.confirm : props.confirm() },
|
|
123
110
|
react_1.default.createElement(Button_1.Button, __assign({}, props.config, btnParam), props.label));
|
|
@@ -13,4 +13,5 @@ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index")
|
|
|
13
13
|
selectDisabled?: (record: any) => boolean;
|
|
14
14
|
actionBar?: Array<import("./Components/ActionBar").TableActionButton[]> | React.ReactNode;
|
|
15
15
|
autoLoad?: false;
|
|
16
|
+
fixHeader?: boolean;
|
|
16
17
|
} & Pick<ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & React.RefAttributes<ApiModel>>;
|
|
@@ -13,6 +13,7 @@ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").
|
|
|
13
13
|
selectDisabled?: (record: any) => boolean;
|
|
14
14
|
actionBar?: Array<import("./Components/ActionBar").TableActionButton[]> | React.ReactNode;
|
|
15
15
|
autoLoad?: false;
|
|
16
|
+
fixHeader?: boolean;
|
|
16
17
|
} & Pick<import("../../hooks/useApiBase").ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & Omit<import("antd/es/modal").ModalProps, "visible" | "onCancel" | "onOk"> & {
|
|
17
18
|
open?: boolean;
|
|
18
19
|
onOk?: (data?: import("../..").PlainObject) => void;
|
|
@@ -125,39 +125,3 @@ exports.BUTTON_IMPORT = BUTTON_IMPORT;
|
|
|
125
125
|
*/
|
|
126
126
|
var BUTTON_EXPORT = function (onClick, props) { return (__assign(__assign({ label: (0, i18n_1.txt)(_i18n_1.V.BTN_EXPORT), icon: 'export' }, props), { onClick: onClick })); };
|
|
127
127
|
exports.BUTTON_EXPORT = BUTTON_EXPORT;
|
|
128
|
-
// import { useLayoutEffect } from 'react';
|
|
129
|
-
// import { useUpdate } from '../../../hooks'
|
|
130
|
-
// type TableActionBar = {
|
|
131
|
-
// buttons: (TableActionButton | null | false)[],
|
|
132
|
-
// queryParam: PlainObject
|
|
133
|
-
// selectedRef: MutableRefObject<any>
|
|
134
|
-
// }
|
|
135
|
-
// export const ActionBar: FC<TableActionBar> = props => {
|
|
136
|
-
// const update = useUpdate();
|
|
137
|
-
// useLayoutEffect(() => {
|
|
138
|
-
// props.selectedRef.current.onSelected = () => {
|
|
139
|
-
// update();
|
|
140
|
-
// }
|
|
141
|
-
// }, [])
|
|
142
|
-
// const [selectedRowKeys, selectedObjects] = props.selectedRef.current.selected;
|
|
143
|
-
// const buttons = useMemo(() => {
|
|
144
|
-
// const btns = [];
|
|
145
|
-
// (props.buttons || []).map(btn => {
|
|
146
|
-
// if (btn === false) return;
|
|
147
|
-
// if (btn === null) {
|
|
148
|
-
// btns.push(null);
|
|
149
|
-
// return;
|
|
150
|
-
// }
|
|
151
|
-
// let sub = convertButton(btn, selectedRowKeys, selectedObjects, props.queryParam);
|
|
152
|
-
// if (_.isArray(btn.children) && btn.children.length > 0) {
|
|
153
|
-
// sub.children = [];
|
|
154
|
-
// btn.children.map(item => {
|
|
155
|
-
// sub.children.push(convertButton(item, selectedRowKeys, selectedObjects, props.queryParam))
|
|
156
|
-
// })
|
|
157
|
-
// }
|
|
158
|
-
// btns.push(sub);
|
|
159
|
-
// });
|
|
160
|
-
// return btns;
|
|
161
|
-
// }, [selectedRowKeys, props.buttons, props.queryParam])
|
|
162
|
-
// return <ActionButtons buttons={buttons} />
|
|
163
|
-
// }
|
|
@@ -108,7 +108,6 @@ var TableContextWrapper = function (props) {
|
|
|
108
108
|
var toRemove = new Set(diff);
|
|
109
109
|
return __assign(__assign({}, prev), { selectedRowKeys: prev.selectedRowKeys.filter(function (key) { return !toRemove.has(key); }), selectedObjects: prev.selectedObjects.filter(function (item) { return !toRemove.has(item[rowKey]); }) });
|
|
110
110
|
}); }, []);
|
|
111
|
-
// console.log(state)
|
|
112
111
|
return react_1.default.createElement(TableContext.Provider, { value: __assign(__assign({}, state), { setParam: setParam, setSelection: setSelection, initObjects: initObjects, reflushPage: reflushPage }) }, props.children);
|
|
113
112
|
};
|
|
114
113
|
exports.TableContextWrapper = TableContextWrapper;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
2
|
import type { BaseTableProps } from './index';
|
|
3
|
-
import type { ColumnProps as
|
|
3
|
+
import type { ColumnProps as ColumnType } from 'antd/es/table/interface';
|
|
4
4
|
export declare const convertColumns: (props: BaseTableProps, rank: {
|
|
5
5
|
ref: MutableRefObject<number>;
|
|
6
6
|
isRank?: boolean;
|
|
7
|
-
}) => Array<
|
|
7
|
+
}) => Array<ColumnType<any>>;
|
|
@@ -37,6 +37,7 @@ export declare const VTable: React.ForwardRefExoticComponent<import("./index").T
|
|
|
37
37
|
selectDisabled?: (record: any) => boolean;
|
|
38
38
|
actionBar?: Array<TableActionButton[]> | React.ReactNode;
|
|
39
39
|
autoLoad?: false;
|
|
40
|
+
fixHeader?: boolean;
|
|
40
41
|
} & {
|
|
41
42
|
/**
|
|
42
43
|
* 列表模型,可以使用系统提供的 useApi/useArray 等,也可自行实现列表模型
|
|
@@ -240,7 +240,6 @@ var _VTable = (0, react_1.forwardRef)(function (props) {
|
|
|
240
240
|
var VTableRoot = (0, react_1.forwardRef)(function (props, ref) {
|
|
241
241
|
var _a = props.model, isQuerying = _a.isQuerying, pageNo = _a.pageNo, pageSize = _a.pageSize, total = _a.total, totalAcc = _a.totalAcc, pageTo = _a.pageTo, query = _a.query, cost = _a.cost;
|
|
242
242
|
var _b = (0, useTableContext_1.useTableContext)(), selectedRowKeys = _b.selectedRowKeys, selectedObjects = _b.selectedObjects, param = _b.param, setSelection = _b.setSelection, setParam = _b.setParam;
|
|
243
|
-
// console.log(selectedRowKeys)
|
|
244
243
|
(0, react_1.useImperativeHandle)(ref, function () {
|
|
245
244
|
return {
|
|
246
245
|
clearSelected: function () { return setSelection([], []); },
|
|
@@ -59,6 +59,14 @@ export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' |
|
|
|
59
59
|
* 是否自动查询,默认为TRUE
|
|
60
60
|
*/
|
|
61
61
|
autoLoad?: false;
|
|
62
|
+
/**
|
|
63
|
+
* @experimental
|
|
64
|
+
* 说明: 1.5 版本才有此属性
|
|
65
|
+
* 2.0版本会自动锁定表头
|
|
66
|
+
* 1.5版本有问题: http://192.168.119.213:9999/vap2/why-not/#%E4%B8%BA%E4%BB%80%E4%B9%881-5%E7%89%88%E6%9C%AC%E7%9A%84vtable%E4%B8%8D%E6%94%AF%E6%8C%81%E9%94%81%E5%AE%9A%E8%A1%A8%E5%A4%B4
|
|
67
|
+
* 传此参数后,会试验性的计算,可能会有BUG
|
|
68
|
+
*/
|
|
69
|
+
fixHeader?: boolean;
|
|
62
70
|
};
|
|
63
71
|
import type { ApiTableProps } from './ApiTable';
|
|
64
72
|
export type ApiTable = ForwardRefExoticComponent<ApiTableProps & RefAttributes<ApiModel>> & TableDefined;
|
|
@@ -67,7 +75,7 @@ import type { VTableProps, VTableRef } from './VTable';
|
|
|
67
75
|
export type VTable = ForwardRefExoticComponent<VTableProps & RefAttributes<VTableRef>> & TableDefined;
|
|
68
76
|
export declare const VTable: VTable;
|
|
69
77
|
import type { STableProps } from './STable';
|
|
70
|
-
export type STable =
|
|
78
|
+
export type STable = ForwardRefExoticComponent<STableProps & RefAttributes<VTableRef>> & TableDefined;
|
|
71
79
|
export declare const STable: STable;
|
|
72
80
|
import type { TopTableProps } from './TopTable';
|
|
73
81
|
export type TopTable = ExoticComponent<TopTableProps> & TableDefined;
|
|
@@ -193,7 +193,11 @@ var _Actiontree = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
193
193
|
var treeData = treeState.treeData;
|
|
194
194
|
var node = lodash_1.default.get(treeData, nodePath);
|
|
195
195
|
if (node == null) {
|
|
196
|
-
|
|
196
|
+
if (props.canAddRoot != true) {
|
|
197
|
+
// message.error('No parent found')
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
addRoot(data, { pos: INSER_POS.AFTER, position: [] });
|
|
197
201
|
return;
|
|
198
202
|
}
|
|
199
203
|
add(data, { pos: INSER_POS.INNER, node: node, position: position });
|
|
@@ -117,7 +117,7 @@ var BaseTree = function (props) {
|
|
|
117
117
|
langs: null,
|
|
118
118
|
folderChecker: null,
|
|
119
119
|
};
|
|
120
|
-
if (props
|
|
120
|
+
if (lodash_1.default.has(props, 'rootCode'))
|
|
121
121
|
DEFAULT.rootCode = props.rootCode;
|
|
122
122
|
if (props.keyField)
|
|
123
123
|
DEFAULT.keyField = props.keyField;
|
|
@@ -71,6 +71,7 @@ var LAYOUTS = {
|
|
|
71
71
|
compress: [1080, 3, 9],
|
|
72
72
|
};
|
|
73
73
|
var COLS_SPLIT = 8;
|
|
74
|
+
// const FONT_SIZE = 12;
|
|
74
75
|
var getDefault = function (props) {
|
|
75
76
|
var _a, _b;
|
|
76
77
|
var isGroup = lodash_1.default.has(props.fields[0], 'fields');
|
|
@@ -88,6 +89,8 @@ var getDefault = function (props) {
|
|
|
88
89
|
}
|
|
89
90
|
_b = __read((col > COLS_SPLIT) ? LAYOUTS.common : LAYOUTS.simple, 3), width = _b[0], cols = _b[1], colMax = _b[2];
|
|
90
91
|
}
|
|
92
|
+
if (lodash_1.default.isNumber(props.width))
|
|
93
|
+
width = props.width;
|
|
91
94
|
return [isGroup, width, cols, colMax];
|
|
92
95
|
};
|
|
93
96
|
exports.getDefault = getDefault;
|
|
@@ -135,6 +138,8 @@ var getFormLayout = function (props, root) {
|
|
|
135
138
|
return [isGroup, cols, width, colMax, isInfo, isEdit, isAdd];
|
|
136
139
|
};
|
|
137
140
|
var getMaxTitleWidth = function (field) {
|
|
141
|
+
if (field.dataType == 'NONE')
|
|
142
|
+
return 0;
|
|
138
143
|
if (field.type && (0, _register_1.getUFormInput)(field.type).breakTitle)
|
|
139
144
|
return 0;
|
|
140
145
|
var title = null;
|
|
@@ -93,7 +93,7 @@ var UForm_1 = require("./UForm");
|
|
|
93
93
|
var utils_1 = require("../../utils");
|
|
94
94
|
var _i18n_1 = require("../_i18n");
|
|
95
95
|
var FormWrapper_1 = require("./FormWrapper");
|
|
96
|
-
var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'size'];
|
|
96
|
+
var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'size', 'width'];
|
|
97
97
|
var UFormModal = function (props) {
|
|
98
98
|
var ref = (0, react_1.useRef)(null);
|
|
99
99
|
var modalProps = {
|
|
@@ -208,7 +208,7 @@ var UFormModal = function (props) {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
return react_1.default.createElement(Modal_1.Modal, __assign({ maskClosable: utils_1.GLOBAL.CONFIG.FORM.maskClosable, destroyOnClose: true }, lodash_1.default.omit(props, FORM_FIELDS), { className: utils_1.StringUtil.className(['u-form-modal'], props.className), onCancel: function () { return props.onCancel(); } }, modalProps),
|
|
211
|
+
return react_1.default.createElement(Modal_1.Modal, __assign({ maskClosable: utils_1.GLOBAL.CONFIG.FORM.maskClosable, destroyOnClose: true, width: props.width }, lodash_1.default.omit(props, FORM_FIELDS), { className: utils_1.StringUtil.className(['u-form-modal'], props.className), onCancel: function () { return props.onCancel(); } }, modalProps),
|
|
212
212
|
react_1.default.createElement(UForm_1.UForm, __assign({}, lodash_1.default.pick(props, FORM_FIELDS), { ref: ref })));
|
|
213
213
|
};
|
|
214
214
|
exports.UFormModal = UFormModal;
|
|
@@ -74,6 +74,7 @@ exports._FieldType = [
|
|
|
74
74
|
'radio',
|
|
75
75
|
'radio-button',
|
|
76
76
|
'radio-with-more',
|
|
77
|
+
// 'segmented', 仅2.0
|
|
77
78
|
'checkbox',
|
|
78
79
|
'checkbox-with-all',
|
|
79
80
|
'icon',
|
|
@@ -115,6 +116,6 @@ exports._FieldType = [
|
|
|
115
116
|
'role',
|
|
116
117
|
'roles',
|
|
117
118
|
// CEMS 专用
|
|
118
|
-
// 'cems-org', // org 为2.0 专属
|
|
119
|
+
// 'cems-org', // cems-org 为2.0 专属
|
|
119
120
|
'cems-org-button',
|
|
120
121
|
];
|
|
@@ -312,7 +312,7 @@ export type UFromAction = ButtonProps & {
|
|
|
312
312
|
* 新版本 ModalProps 只支持 open 且必传,
|
|
313
313
|
* 不使用 deprecated 属性
|
|
314
314
|
*/
|
|
315
|
-
export type UModalProps = UFromProps & Omit<ModalProps, 'children'> & {
|
|
315
|
+
export type UModalProps = UFromProps & Omit<ModalProps, 'children' | 'width'> & {
|
|
316
316
|
/**
|
|
317
317
|
* open 为必填项,不使用废弃的 visable 属性
|
|
318
318
|
*/
|
package/hooks/useModals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UModalProps } from '../components/UForm';
|
|
2
2
|
import type { PlainObject } from "../basetype";
|
|
3
|
-
type ModalsState = {
|
|
3
|
+
export type ModalsState = {
|
|
4
4
|
modalProps: Pick<UModalProps, 'open' | 'onCancel' | 'data' | 'isEdit'>;
|
|
5
5
|
open: boolean;
|
|
6
6
|
isEdit: boolean;
|
|
@@ -37,4 +37,3 @@ export declare const useModals: () => {
|
|
|
37
37
|
showUpload: (extra?: any) => void;
|
|
38
38
|
showDetail: (data?: PlainObject, extra?: any) => void;
|
|
39
39
|
};
|
|
40
|
-
export {};
|
package/index.d.ts
CHANGED
|
@@ -165,5 +165,8 @@ export { Role, type RoleProps } from './components/_common/Role';
|
|
|
165
165
|
export { IAutoComplete, type IAutoCompleteProps } from './components/_common/AutoComplete';
|
|
166
166
|
export { PromiseLabel, type PromiseLabelProps } from './components/_common/PromiseLabel';
|
|
167
167
|
export type { Key, BaseTypes, PlainObject, BaseItem, BaseOption, PageProps, } from './basetype';
|
|
168
|
-
export type { ApiModel, ListModel } from './hooks/_list';
|
|
169
168
|
export type { Moment as Dayjs } from 'dayjs';
|
|
169
|
+
export type { FC, ForwardRefExoticComponent, ReactNode, PropsWithChildren, CSSProperties, RefAttributes, MutableRefObject, } from 'react';
|
|
170
|
+
export type { ModalsState } from './hooks/useModals';
|
|
171
|
+
export type { ApiModel, ListModel } from './hooks/_list';
|
|
172
|
+
export type { OpenState } from './hooks/useOpenState';
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.5.
|
|
1
|
+
{"name":"vap1","version":"0.5.5","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|
|
File without changes
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
// import _ from 'lodash';
|
|
2
|
-
// import React, { useEffect, useRef, useMemo, useLayoutEffect, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
-
// import { Table } from '../_adapt/Table'
|
|
4
|
-
// import { Empty } from "antd";
|
|
5
|
-
// import { ActionBar } from './Components/ActionBar';
|
|
6
|
-
// import { PageUtil, GLOBAL, StringUtil, i18n } from '../../utils';
|
|
7
|
-
// import { convertColumns } from './Util';
|
|
8
|
-
// // import { HighLight } from '../_common/HighLight';
|
|
9
|
-
// import { useUpdate, useFirstMountState } from '../../hooks';
|
|
10
|
-
// import { Box, useBox } from '../Box/Box';
|
|
11
|
-
// import type { MutableRefObject } from 'react';
|
|
12
|
-
// import type { BaseTableProps, TableColumn, TableColumnGroup } from './index';
|
|
13
|
-
// import type { TableProps, } from 'antd/es/table'
|
|
14
|
-
// import type { SorterResult, ColumnProps as ColumnsType } from 'antd/es/table/interface';
|
|
15
|
-
// import type { ListModel } from '../../hooks/_list';
|
|
16
|
-
// import type { PlainObject, Key } from '../../basetype';
|
|
17
|
-
// import type { BoxProps } from '../Box/Box'
|
|
18
|
-
// import type { SelectFunction } from './Components/ActionBar';;
|
|
19
|
-
// export type VTableRef = {
|
|
20
|
-
// getSelected: () => [Key[], PlainObject[]]
|
|
21
|
-
// getParams: () => PlainObject;
|
|
22
|
-
// clearSelected: () => void;
|
|
23
|
-
// }
|
|
24
|
-
// export const getHeightByTagName = (root: HTMLElement, tagName: string): number => {
|
|
25
|
-
// if (root == null) return 0;
|
|
26
|
-
// let els = root.getElementsByTagName(tagName);
|
|
27
|
-
// if (els.length) {
|
|
28
|
-
// return els[0].getBoundingClientRect().height;
|
|
29
|
-
// }
|
|
30
|
-
// return 0
|
|
31
|
-
// }
|
|
32
|
-
// /**
|
|
33
|
-
// * VTable 支持多种模型,内置模型有 API/DATA/STATIC,也支持模型规范的自定义模型
|
|
34
|
-
// */
|
|
35
|
-
// export type VTableProps = BaseTableProps & {
|
|
36
|
-
// /**
|
|
37
|
-
// * 列表模型,可以使用系统提供的 useApi/useArray 等,也可自行实现列表模型
|
|
38
|
-
// */
|
|
39
|
-
// model: ListModel
|
|
40
|
-
// /**
|
|
41
|
-
// * 默认选中的列,用于部分场景,可能会无效
|
|
42
|
-
// */
|
|
43
|
-
// defaultSelectedKeys?: (string | number)[]
|
|
44
|
-
// /**
|
|
45
|
-
// * 选中后变化
|
|
46
|
-
// */
|
|
47
|
-
// onSelectedChange?: (selectedRowKeys: Key[], selectedRows?: any[]) => void;
|
|
48
|
-
// }
|
|
49
|
-
// const _VTable = forwardRef((props: VTableProps, ref: MutableRefObject<SelectFunction>) => {
|
|
50
|
-
// const update = useUpdate();
|
|
51
|
-
// const { state, root, resize } = useBox();
|
|
52
|
-
// const inModal = useMemo(() => {
|
|
53
|
-
// if (root.current == null) return false;
|
|
54
|
-
// return root.current.parentElement.parentElement.classList.contains('ant-modal-body')
|
|
55
|
-
// || root.current.parentElement.parentElement.parentElement.classList.contains('ant-modal-body')
|
|
56
|
-
// || root.current.parentElement.parentElement.parentElement.parentElement.classList.contains('ant-modal-body');
|
|
57
|
-
// }, [])
|
|
58
|
-
// // const [scroll, setScroll] = useState<TableProps<PlainObject>['scroll']>(undefined);
|
|
59
|
-
// const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query, total } = props.model;
|
|
60
|
-
// let start = useRef(0);
|
|
61
|
-
// const tableProps: TableProps<PlainObject> = {}
|
|
62
|
-
// useEffect(() => {
|
|
63
|
-
// if (state.selected == null) return;
|
|
64
|
-
// if (_.isFunction(props.selectBar?.onSelect)) {
|
|
65
|
-
// let param = props.selectBar.onSelect(...state.selected);
|
|
66
|
-
// query({ ...props.default, ...param })
|
|
67
|
-
// }
|
|
68
|
-
// }, [state.selected]);
|
|
69
|
-
// // 更新页数
|
|
70
|
-
// useLayoutEffect(() => {
|
|
71
|
-
// start.current = pageSize * (pageNo - 1)
|
|
72
|
-
// // @ts-ignore
|
|
73
|
-
// if (props.model.mode == 'static') update();
|
|
74
|
-
// }, [pageSize, pageNo]);
|
|
75
|
-
// // 更新选中
|
|
76
|
-
// useLayoutEffect(() => {
|
|
77
|
-
// const diff = _.xor(ref.current.selected[0], list.map(item => item[rowKey]));
|
|
78
|
-
// if (diff.length > 0) {
|
|
79
|
-
// let toRemove = new Set(diff);
|
|
80
|
-
// ref.current.selected[0] = ref.current.selected[0].filter(key => !toRemove.has(key))
|
|
81
|
-
// ref.current.selected[1] = ref.current.selected[1].filter(item => !toRemove.has(item[rowKey]))
|
|
82
|
-
// ref.current.onSelected();
|
|
83
|
-
// }
|
|
84
|
-
// }, [list]);
|
|
85
|
-
// useLayoutEffect(() => {
|
|
86
|
-
// if (!isQuerying || !GLOBAL.CONFIG.TABLE.UNSELECT_ON_QUERY) return;
|
|
87
|
-
// if (ref.current.selected[0].length > 0) {
|
|
88
|
-
// ref.current.selected = [[], []];
|
|
89
|
-
// ref.current.onSelected();
|
|
90
|
-
// }
|
|
91
|
-
// }, [isQuerying])
|
|
92
|
-
// // 初始选中
|
|
93
|
-
// const isFristMounted = useFirstMountState();
|
|
94
|
-
// useLayoutEffect(() => {
|
|
95
|
-
// if (!isFristMounted) return;
|
|
96
|
-
// if (!_.isArray(props.defaultSelectedKeys) || props.defaultSelectedKeys.length == 0 || list.length == 0) return;
|
|
97
|
-
// const selectKeys = [];
|
|
98
|
-
// const selectObjs = [];
|
|
99
|
-
// for (let key of props.defaultSelectedKeys) {
|
|
100
|
-
// let obj = _.find(list, { [rowKey]: key });
|
|
101
|
-
// if (obj == null) continue;
|
|
102
|
-
// selectKeys.push(key)
|
|
103
|
-
// selectObjs.push(obj)
|
|
104
|
-
// }
|
|
105
|
-
// if (selectKeys.length > 0) {
|
|
106
|
-
// ref.current.selected[0] = selectKeys
|
|
107
|
-
// ref.current.selected[1] = selectObjs;
|
|
108
|
-
// ref.current.onSelected();
|
|
109
|
-
// update();
|
|
110
|
-
// }
|
|
111
|
-
// }, [isFristMounted])
|
|
112
|
-
// // 计算 clolum 及 高亮keyword
|
|
113
|
-
// const columns = useMemo<Array<ColumnsType<any>>>(() => convertColumns(props, { ref: start, isRank: false }), [props.columns])
|
|
114
|
-
// useLayoutEffect(() => {
|
|
115
|
-
// resize();
|
|
116
|
-
// }, [columns])
|
|
117
|
-
// useEffect(() => {
|
|
118
|
-
// if (props.autoLoad === false) return;
|
|
119
|
-
// // @ts-ignore
|
|
120
|
-
// if (props.model.mode == 'api-global' && total > 0) return;
|
|
121
|
-
// if (_.has(props.selectBar, 'config.mustSelect') && props.selectBar.config.mustSelect == true) return;
|
|
122
|
-
// query(props.default || {});
|
|
123
|
-
// }, []);
|
|
124
|
-
// // 更新高度 table 需要把 head 排除设置滚动
|
|
125
|
-
// // useEffect(() => {
|
|
126
|
-
// // if (inModal) {
|
|
127
|
-
// // setScroll({ x: true })
|
|
128
|
-
// // return;
|
|
129
|
-
// // }
|
|
130
|
-
// // if (props.scroll === null) return;
|
|
131
|
-
// // if (props.mode == undefined || props.mode == 'common') return;
|
|
132
|
-
// // let height = state?.height;
|
|
133
|
-
// // if (!height) return;
|
|
134
|
-
// // // VAP1.5 scroll table bug
|
|
135
|
-
// // root.current.style.height = height + 'px';
|
|
136
|
-
// // // setTimeout(() => {
|
|
137
|
-
// // // height -= getHeightByTagName(root.current, 'thead');
|
|
138
|
-
// // // setScroll({ y: Math.ceil(height), x: true })
|
|
139
|
-
// // // }, 2);
|
|
140
|
-
// // }, [state?.height]);
|
|
141
|
-
// // @ts-ignore
|
|
142
|
-
// const effectKey = props.model.effect;
|
|
143
|
-
// useEffect(() => {
|
|
144
|
-
// if (effectKey == null) return;
|
|
145
|
-
// let effectRow = effectKey;
|
|
146
|
-
// if (_.isString(effectKey) && _.startsWith(effectKey, '_')) effectRow = effectRow.substring(1);
|
|
147
|
-
// const trs = root.current.getElementsByClassName('ant-table-row');
|
|
148
|
-
// let size = trs.length;
|
|
149
|
-
// if (size <= 0) return;
|
|
150
|
-
// for (let i = 0; i < size; i++) {
|
|
151
|
-
// let tr = trs.item(i);
|
|
152
|
-
// let key = tr.getAttribute('data-row-key');
|
|
153
|
-
// if (key == effectRow) {
|
|
154
|
-
// if (tr.classList.contains('c-table-high')) {
|
|
155
|
-
// tr.classList.remove('c-table-high')
|
|
156
|
-
// }
|
|
157
|
-
// setTimeout(() => tr.classList.add('c-table-high'), 2)
|
|
158
|
-
// }
|
|
159
|
-
// }
|
|
160
|
-
// }, [effectKey]);
|
|
161
|
-
// if (props.select) {
|
|
162
|
-
// tableProps.rowSelection = {
|
|
163
|
-
// selectedRowKeys: ref.current.selected[0] as any[],
|
|
164
|
-
// onChange: (selectedRowKeys, selectedObjects) => {
|
|
165
|
-
// ref.current.selected = [selectedRowKeys, selectedObjects];
|
|
166
|
-
// ref.current.onSelected();
|
|
167
|
-
// update();
|
|
168
|
-
// if (props.onSelectedChange && _.isFunction(props.onSelectedChange)) {
|
|
169
|
-
// props.onSelectedChange(selectedRowKeys, selectedObjects)
|
|
170
|
-
// }
|
|
171
|
-
// },
|
|
172
|
-
// getCheckboxProps: record => {
|
|
173
|
-
// if (_.isFunction(props.selectDisabled)) return { disabled: props.selectDisabled(record) }
|
|
174
|
-
// if (!_.has(record, rowKey)) return { disabled: true }
|
|
175
|
-
// return { disabled: false };
|
|
176
|
-
// },
|
|
177
|
-
// }
|
|
178
|
-
// }
|
|
179
|
-
// return <Table
|
|
180
|
-
// rowKey={props.rowKey || rowKey}
|
|
181
|
-
// // scroll={scroll}
|
|
182
|
-
// // tableLayout="fixed"
|
|
183
|
-
// // showSorterTooltip={false}
|
|
184
|
-
// size={GLOBAL.CONFIG.TABLE.SIZE}
|
|
185
|
-
// locale={{ emptyText: <Empty style={{ marginTop: 24 }} /> }}
|
|
186
|
-
// {..._.omit(props, ['children'])}
|
|
187
|
-
// {...tableProps}
|
|
188
|
-
// className={StringUtil.className(['c-table'], props.className)}
|
|
189
|
-
// pagination={false}
|
|
190
|
-
// columns={columns}
|
|
191
|
-
// dataSource={list}
|
|
192
|
-
// loading={isQuerying}
|
|
193
|
-
// onChange={(x, y, field: SorterResult<any>) => {
|
|
194
|
-
// if (field.column) {
|
|
195
|
-
// orderBy(field.field as string, field.order == 'ascend' ? 'asc' : 'desc');
|
|
196
|
-
// } else {
|
|
197
|
-
// orderBy(null, 'desc');
|
|
198
|
-
// }
|
|
199
|
-
// }}
|
|
200
|
-
// />
|
|
201
|
-
// });
|
|
202
|
-
// export const VTable = forwardRef((props: VTableProps, ref: MutableRefObject<VTableRef>) => {
|
|
203
|
-
// const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
|
|
204
|
-
// const update = useUpdate();
|
|
205
|
-
// // 通过 ref 方式交互,后续扩展方法实现定制联页选择
|
|
206
|
-
// const selectedRef = useRef<SelectFunction>({ selected: [props.defaultSelectedKeys || [], []], onSelected: update });
|
|
207
|
-
// // 对外提供getSelected方法获取当前选择的数据
|
|
208
|
-
// useImperativeHandle(ref, () => {
|
|
209
|
-
// return {
|
|
210
|
-
// clearSelected() {
|
|
211
|
-
// selectedRef.current.selected = [[], []];
|
|
212
|
-
// selectedRef.current.onSelected();
|
|
213
|
-
// },
|
|
214
|
-
// getSelected() {
|
|
215
|
-
// return selectedRef.current.selected;
|
|
216
|
-
// },
|
|
217
|
-
// getParams: () => {
|
|
218
|
-
// return props.model.param;
|
|
219
|
-
// }
|
|
220
|
-
// }
|
|
221
|
-
// }, [param]);
|
|
222
|
-
// let boxProps: BoxProps = _.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
|
|
223
|
-
// if (props.searchBar) {
|
|
224
|
-
// boxProps.searchBar = {
|
|
225
|
-
// ...props.searchBar, disabled: isQuerying,
|
|
226
|
-
// onSearch: (data) => {
|
|
227
|
-
// let queryParam = _.extend({}, param, data)
|
|
228
|
-
// query(queryParam, true);
|
|
229
|
-
// selectedRef.current.selected = [[], []];
|
|
230
|
-
// selectedRef.current.onSelected();
|
|
231
|
-
// },
|
|
232
|
-
// }
|
|
233
|
-
// }
|
|
234
|
-
// if (props.actionBar) {
|
|
235
|
-
// if (_.isArray(props.actionBar)) {
|
|
236
|
-
// if (props.actionBar.length) {
|
|
237
|
-
// boxProps.actionBar = <ActionBar
|
|
238
|
-
// buttons={props.actionBar as any}
|
|
239
|
-
// queryParam={param}
|
|
240
|
-
// selectedRef={selectedRef}
|
|
241
|
-
// />
|
|
242
|
-
// }
|
|
243
|
-
// } else {
|
|
244
|
-
// boxProps.actionBar = props.actionBar;
|
|
245
|
-
// }
|
|
246
|
-
// }
|
|
247
|
-
// if (props.pagination !== false) {
|
|
248
|
-
// boxProps.pagination = {
|
|
249
|
-
// disabled: isQuerying,
|
|
250
|
-
// current: pageNo,
|
|
251
|
-
// pageSize: pageSize,
|
|
252
|
-
// total: total,
|
|
253
|
-
// cost: cost,
|
|
254
|
-
// totalAcc: totalAcc,
|
|
255
|
-
// onChange: pageTo,
|
|
256
|
-
// }
|
|
257
|
-
// if (props.pagination) {
|
|
258
|
-
// if (props.pagination.hideOnSinglePage) {
|
|
259
|
-
// boxProps.pagination.hideOnSinglePage = true;
|
|
260
|
-
// }
|
|
261
|
-
// if (props.pagination.className) {
|
|
262
|
-
// boxProps.pagination.className = props.pagination.className;
|
|
263
|
-
// }
|
|
264
|
-
// }
|
|
265
|
-
// }
|
|
266
|
-
// return <Box {...boxProps}>
|
|
267
|
-
// {/* <_VTable {..._.omit(props, ['className', 'style'])} ref={selectedRef} /> */}
|
|
268
|
-
// </Box>
|
|
269
|
-
// });
|
package/deps/app-data/Const.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export declare const API_PREFIX: string;
|
|
2
|
-
export declare const IMAGE_PREFIX: string;
|
|
3
|
-
export declare enum SOURCE_TYPE {
|
|
4
|
-
ELASTIC = 1,
|
|
5
|
-
MYSQL = 2,
|
|
6
|
-
DORIS = 5
|
|
7
|
-
}
|
|
8
|
-
export type FIELD_TYPE = 'keyword' | 'date' | 'long' | 'double' | 'text' | 'json' | 'object' | 'pic' | 'base64';
|
|
9
|
-
/**
|
|
10
|
-
* 数据源
|
|
11
|
-
*/
|
|
12
|
-
export type Source = {
|
|
13
|
-
/**
|
|
14
|
-
* 数据源ID
|
|
15
|
-
*/
|
|
16
|
-
id: number;
|
|
17
|
-
/**
|
|
18
|
-
* 数据源名称(表名称/索引名称)
|
|
19
|
-
*/
|
|
20
|
-
name: string;
|
|
21
|
-
/**
|
|
22
|
-
* 数据源标题
|
|
23
|
-
*/
|
|
24
|
-
title: string;
|
|
25
|
-
/**
|
|
26
|
-
* 数据源标题
|
|
27
|
-
*/
|
|
28
|
-
icon?: string;
|
|
29
|
-
/**
|
|
30
|
-
* 数据源时间字段
|
|
31
|
-
*/
|
|
32
|
-
timeField?: string;
|
|
33
|
-
/**
|
|
34
|
-
* 数据源类型
|
|
35
|
-
* 1 = Elastic Search
|
|
36
|
-
* 2 = MySQL
|
|
37
|
-
* 5 = Doris
|
|
38
|
-
*/
|
|
39
|
-
type: 1 | 2 | 5;
|
|
40
|
-
};
|
|
41
|
-
export type SourceField = {
|
|
42
|
-
/**
|
|
43
|
-
* 字段
|
|
44
|
-
*/
|
|
45
|
-
field: string;
|
|
46
|
-
/**
|
|
47
|
-
* 字段名称
|
|
48
|
-
*/
|
|
49
|
-
name: string;
|
|
50
|
-
/**
|
|
51
|
-
* 是否可排序
|
|
52
|
-
*/
|
|
53
|
-
sorter: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* 是否可被过滤
|
|
56
|
-
*/
|
|
57
|
-
filter: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* 是否可被 filter
|
|
60
|
-
*/
|
|
61
|
-
tag: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* 字段类型
|
|
64
|
-
*/
|
|
65
|
-
type: FIELD_TYPE;
|
|
66
|
-
/**
|
|
67
|
-
* 字段类型
|
|
68
|
-
*/
|
|
69
|
-
dict?: string;
|
|
70
|
-
};
|
|
71
|
-
export declare const getSourceByName: (sourceName: string, sources: Source[]) => Source;
|
package/deps/app-data/Const.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getSourceByName = exports.SOURCE_TYPE = exports.IMAGE_PREFIX = exports.API_PREFIX = void 0;
|
|
18
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
19
|
-
var PageUtil_1 = require("../../utils/PageUtil");
|
|
20
|
-
exports.API_PREFIX = (0, PageUtil_1.resolveURL)('/api-data');
|
|
21
|
-
exports.IMAGE_PREFIX = (0, PageUtil_1.resolveURL)('/data/images');
|
|
22
|
-
var SOURCE_TYPE;
|
|
23
|
-
(function (SOURCE_TYPE) {
|
|
24
|
-
SOURCE_TYPE[SOURCE_TYPE["ELASTIC"] = 1] = "ELASTIC";
|
|
25
|
-
SOURCE_TYPE[SOURCE_TYPE["MYSQL"] = 2] = "MYSQL";
|
|
26
|
-
SOURCE_TYPE[SOURCE_TYPE["DORIS"] = 5] = "DORIS";
|
|
27
|
-
})(SOURCE_TYPE || (exports.SOURCE_TYPE = SOURCE_TYPE = {}));
|
|
28
|
-
var getSourceByName = function (sourceName, sources) {
|
|
29
|
-
var e_1, _a;
|
|
30
|
-
var find = lodash_1.default.find(sources, { name: sourceName });
|
|
31
|
-
if (find)
|
|
32
|
-
return find;
|
|
33
|
-
var matched = [];
|
|
34
|
-
try {
|
|
35
|
-
for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
|
|
36
|
-
var source = sources_1_1.value;
|
|
37
|
-
var prefix = source.name.replace('-*', '').replace('*', '');
|
|
38
|
-
if (lodash_1.default.startsWith(sourceName, prefix)) {
|
|
39
|
-
matched.push(source);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
44
|
-
finally {
|
|
45
|
-
try {
|
|
46
|
-
if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
|
|
47
|
-
}
|
|
48
|
-
finally { if (e_1) throw e_1.error; }
|
|
49
|
-
}
|
|
50
|
-
if (matched.length == 0)
|
|
51
|
-
return { id: 0, title: sourceName, name: sourceName, type: 1 };
|
|
52
|
-
return lodash_1.default.orderBy(matched, function (item) { return item.name.length; }, 'desc')[0];
|
|
53
|
-
};
|
|
54
|
-
exports.getSourceByName = getSourceByName;
|
|
File without changes
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
// import _ from 'lodash';
|
|
3
|
-
// import { VTable } from '../../index';
|
|
4
|
-
// import { useDoLoad, useEffectFunction } from 'vap2/hooks';
|
|
5
|
-
// import { Const, Renders } from '../../utils';
|
|
6
|
-
// import { SOURCE_TYPE } from '../utils/Global';
|
|
7
|
-
// import { getColumns, getFieldBySourceField, getSourceFieldsById } from '../utils/SourceUtil';
|
|
8
|
-
// import { filtersToQuery, } from '../utils/ConvertUtil';
|
|
9
|
-
// import { generate, search, orderBy } from 'utils/ContentUtil';
|
|
10
|
-
// import type { BaseTableProps } from '../..//components/Tables';
|
|
11
|
-
// import type { ListModel } from '../../hooks/_list';
|
|
12
|
-
// import type { Dayjs } from 'dayjs';
|
|
13
|
-
// import type { PlainObject } from '../../basetype';
|
|
14
|
-
// export type SourceTableProps = Partial<Omit<BaseTableProps, 'searchBar' | 'selectBar'>> & {
|
|
15
|
-
// sourceId: number,
|
|
16
|
-
// startTime: Dayjs,
|
|
17
|
-
// endTime: Dayjs,
|
|
18
|
-
// searchFields?: string[]
|
|
19
|
-
// // columns?: []
|
|
20
|
-
// };
|
|
21
|
-
// const useSourceTable = (sourceId: number, startTime: Dayjs, endTime: Dayjs): ListModel => {
|
|
22
|
-
// const [state, setState] = useDoLoad({
|
|
23
|
-
// rowKey: '_id',
|
|
24
|
-
// list: [],
|
|
25
|
-
// isQuerying: false,
|
|
26
|
-
// cost: 0,
|
|
27
|
-
// pageNo: 1,
|
|
28
|
-
// pageSize: 15,
|
|
29
|
-
// total: 0,
|
|
30
|
-
// totalAcc: 0,
|
|
31
|
-
// param: {}
|
|
32
|
-
// });
|
|
33
|
-
// // source: number[], startTime: Dayjs, endTime: Dayjs, q: string, query: RequestQuery = {}, professor: boolean = false, agg: boolean = false, domain: string = null
|
|
34
|
-
// let lastQuery = useRef({
|
|
35
|
-
// sourceType: SOURCE_TYPE.ELASTIC,
|
|
36
|
-
// sourceId: [sourceId],
|
|
37
|
-
// startTime, endTime,
|
|
38
|
-
// segment: null, query: '',
|
|
39
|
-
// sort: null
|
|
40
|
-
// });
|
|
41
|
-
// const queryHook = useCallback(async (
|
|
42
|
-
// param: PlainObject,
|
|
43
|
-
// ) => {
|
|
44
|
-
// let filters: Filter[] = [];
|
|
45
|
-
// let fields = _.keys(param);
|
|
46
|
-
// for (let field of fields) {
|
|
47
|
-
// // getFieldBySourceField
|
|
48
|
-
// let value = _.trim(param[field]);
|
|
49
|
-
// if (value == null || value == '') continue;
|
|
50
|
-
// let col = await getFieldBySourceField(sourceId, field);
|
|
51
|
-
// if (col && col.type == 'keyword') {
|
|
52
|
-
// let filter = { field } as Filter;
|
|
53
|
-
// filter.oper = col.dict ? 'eq' : 'like';
|
|
54
|
-
// filter.value = param[field];
|
|
55
|
-
// filters.push(filter);
|
|
56
|
-
// }
|
|
57
|
-
// }
|
|
58
|
-
// let query = filtersToQuery(filters, sourceId);
|
|
59
|
-
// setState({ isQuerying: true })
|
|
60
|
-
// let resp = await generate(lastQuery.current.sourceId, lastQuery.current.startTime, lastQuery.current.endTime, '', query);
|
|
61
|
-
// lastQuery.current.sort = orderBy(lastQuery.current.sourceId[0]);
|
|
62
|
-
// lastQuery.current.query = resp.query;
|
|
63
|
-
// lastQuery.current.segment = resp.segment;
|
|
64
|
-
// // this.setState({ query: info.query, segment: info.segment, total: info.total, totalAcc: info.totalAcc }, () => {
|
|
65
|
-
// if (resp.total == 0) {
|
|
66
|
-
// setState({ isQuerying: false, list: [], total: 0, totalAcc: 0 })
|
|
67
|
-
// } else {
|
|
68
|
-
// setState({ isQuerying: false, total: resp.total, totalAcc: resp.totalAcc })
|
|
69
|
-
// pageTo(1)
|
|
70
|
-
// // this.toPage(1);
|
|
71
|
-
// }
|
|
72
|
-
// // })
|
|
73
|
-
// }, [state])
|
|
74
|
-
// const changeTime = () => {
|
|
75
|
-
// }
|
|
76
|
-
// const query = async (param: PlainObject, clean?: boolean) => {
|
|
77
|
-
// queryHook(param)
|
|
78
|
-
// }
|
|
79
|
-
// const pageTo = useCallback(async (pageNo: number, size?: number) => {
|
|
80
|
-
// const { sourceType, segment, query, sort } = lastQuery.current;
|
|
81
|
-
// let pageSize = size || state.pageSize;
|
|
82
|
-
// setState({ isQuerying: true })
|
|
83
|
-
// const resp = await search({
|
|
84
|
-
// sourceType, segment, query,
|
|
85
|
-
// sort,
|
|
86
|
-
// start: pageSize * (pageNo - 1),
|
|
87
|
-
// count: pageSize
|
|
88
|
-
// });
|
|
89
|
-
// setState({ isQuerying: false, list: resp.list, pageNo, pageSize })
|
|
90
|
-
// }, [state.pageSize])
|
|
91
|
-
// const _orderBy = async (order: string, by: 'asc' | 'desc') => {
|
|
92
|
-
// let sort = null;
|
|
93
|
-
// if (order) {
|
|
94
|
-
// sort = orderBy(lastQuery.current.sort, order, by != 'asc')
|
|
95
|
-
// }
|
|
96
|
-
// pageTo(1)
|
|
97
|
-
// }
|
|
98
|
-
// return { ...state, query, pageTo, orderBy: _orderBy, changeTime } as ListModel
|
|
99
|
-
// }
|
|
100
|
-
// export default (props: SourceTableProps) => {
|
|
101
|
-
// const model = useSourceTable(props.sourceId, props.startTime, props.endTime);
|
|
102
|
-
// const [config, setConfig] = useState({ columns: [] });
|
|
103
|
-
// useEffectFunction(async () => {
|
|
104
|
-
// let tableProps: BaseTableProps = { columns: [] }
|
|
105
|
-
// if (_.isArray(props.columns) && props.columns.length) {
|
|
106
|
-
// tableProps.columns = props.columns;
|
|
107
|
-
// } else {
|
|
108
|
-
// [tableProps.columns] = await getColumns([props.sourceId])
|
|
109
|
-
// }
|
|
110
|
-
// if (_.has(props, 'searchFields') && _.isArray(props.searchFields) && props.searchFields.length > 0) {
|
|
111
|
-
// const fields = await getSourceFieldsById(props.sourceId)
|
|
112
|
-
// tableProps.searchBar = { fields: [] }
|
|
113
|
-
// props.searchFields.map(item => {
|
|
114
|
-
// let field = _.find(fields, { field: item });
|
|
115
|
-
// if (field) {
|
|
116
|
-
// if (field.dict) {
|
|
117
|
-
// tableProps.searchBar.fields.push({ label: field.name, field: field.field, type: 'select', options: Renders.DictRender(field.dict).options() })
|
|
118
|
-
// } else if (field.type == 'keyword') {
|
|
119
|
-
// tableProps.searchBar.fields.push({ label: field.name, field: field.field, config: { like: true } })
|
|
120
|
-
// }
|
|
121
|
-
// }
|
|
122
|
-
// });
|
|
123
|
-
// }
|
|
124
|
-
// setConfig(tableProps);
|
|
125
|
-
// }, [props.columns]);
|
|
126
|
-
// useLayoutEffect(() => {
|
|
127
|
-
// model.query({});
|
|
128
|
-
// }, [])
|
|
129
|
-
// if (config.columns.length == 0) return Const.NONE;
|
|
130
|
-
// return <VTable
|
|
131
|
-
// model={model}
|
|
132
|
-
// {...config}
|
|
133
|
-
// mode={props.mode}
|
|
134
|
-
// rowKey='_id'
|
|
135
|
-
// autoLoad={false}
|
|
136
|
-
// />
|
|
137
|
-
// }
|
|
File without changes
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// import dayjs from 'dayjs';
|
|
2
|
-
// import _ from 'lodash';
|
|
3
|
-
// // import type { Dayjs } from 'mo';
|
|
4
|
-
// const _toStart = mnt => mnt.millisecond(0).second(0).minute(0).hour(0);
|
|
5
|
-
// const _toEnd = mnt => mnt.millisecond(999).second(59).minute(59).hour(23);
|
|
6
|
-
// const _TODAY = _toEnd(dayjs());
|
|
7
|
-
// type RangeOption = {
|
|
8
|
-
// value: string,
|
|
9
|
-
// label: string,
|
|
10
|
-
// range: [Dayjs, Dayjs] | (() => [Dayjs, Dayjs]),
|
|
11
|
-
// }
|
|
12
|
-
// export const DEFAULT_TIME_RANGE = '1011';
|
|
13
|
-
// export const TIME_OPTION: RangeOption[] = [
|
|
14
|
-
// { value: "1001", label: "今天", range: [_toStart(dayjs()), _TODAY] },
|
|
15
|
-
// { value: "1002", label: "本周", range: [_toStart(dayjs().startOf('week')), _TODAY] },
|
|
16
|
-
// { value: "1003", label: "本月", range: [_toStart(dayjs().startOf('month')), _TODAY] },
|
|
17
|
-
// { value: "1004", label: "本年", range: [_toStart(dayjs().startOf('year')), _TODAY] },
|
|
18
|
-
// { value: "1005", label: "最近15分钟", range: () => [dayjs().subtract(15, 'minutes'), dayjs()] },
|
|
19
|
-
// { value: "1006", label: "最近30分钟", range: () => [dayjs().subtract(30, 'minutes'), dayjs()] },
|
|
20
|
-
// { value: "1007", label: "最近1小时", range: () => [dayjs().subtract(1, 'hours'), dayjs()] },
|
|
21
|
-
// { value: "1008", label: "最近4小时", range: () => [dayjs().subtract(4, 'hours'), dayjs()] },
|
|
22
|
-
// { value: "1009", label: "最近12小时", range: () => [dayjs().subtract(12, 'hours'), dayjs()] },
|
|
23
|
-
// { value: "1010", label: "最近24小时", range: () => [dayjs().subtract(24, 'hours'), dayjs()] },
|
|
24
|
-
// { value: "1013", label: "最近3天", range: [_toStart(dayjs().subtract(3, 'days')), _TODAY] },
|
|
25
|
-
// { value: "1011", label: "最近7天", range: [_toStart(dayjs().subtract(7, 'days')), _TODAY] },
|
|
26
|
-
// { value: "1012", label: "最近30天", range: [_toStart(dayjs().subtract(30, 'days')), _TODAY] },
|
|
27
|
-
// { value: "1014", label: "最近60天", range: [_toStart(dayjs().subtract(60, 'days')), _TODAY] },
|
|
28
|
-
// { value: "1015", label: "最近90天", range: [_toStart(dayjs().subtract(90, 'days')), _TODAY] },
|
|
29
|
-
// { value: "1016", label: "最近6月", range: [_toStart(dayjs().subtract(6, 'months')), _TODAY] },
|
|
30
|
-
// { value: "1017", label: "最近1年", range: [_toStart(dayjs().subtract(1, 'years')), _TODAY] },
|
|
31
|
-
// ];
|
|
32
|
-
// export const TIME_MAP: Map<string, RangeOption> = new Map();
|
|
33
|
-
// TIME_OPTION.map(item => TIME_MAP.set(item.value, item));
|
|
34
|
-
// export const getRange = (id = DEFAULT_TIME_RANGE): [Dayjs, Dayjs] => {
|
|
35
|
-
// var opt = TIME_MAP.get(id);
|
|
36
|
-
// if (opt == null) {
|
|
37
|
-
// opt = TIME_MAP.get(DEFAULT_TIME_RANGE);
|
|
38
|
-
// }
|
|
39
|
-
// if (_.isFunction(opt.range)) {
|
|
40
|
-
// return opt.range();
|
|
41
|
-
// }
|
|
42
|
-
// return [opt.range[0].clone(), opt.range[1].clone()];
|
|
43
|
-
// }
|
|
44
|
-
// export const getTimeRange = (id = DEFAULT_TIME_RANGE): [string, string] => {
|
|
45
|
-
// let [start, end] = getRange(id);
|
|
46
|
-
// return [start.format('YYYY-MM-DD HH:mm:ss'), end.format('YYYY-MM-DD HH:mm:ss')]
|
|
47
|
-
// }
|
|
48
|
-
// export const getMomentRange = (id, def?: [Dayjs, Dayjs]): [Dayjs, Dayjs] => {
|
|
49
|
-
// if (id == null || id == 0 || id == '0') {
|
|
50
|
-
// if (_.isArray(def) && def.length == 2) {
|
|
51
|
-
// return def;
|
|
52
|
-
// }
|
|
53
|
-
// getRange(DEFAULT_TIME_RANGE);
|
|
54
|
-
// }
|
|
55
|
-
// return getRange(id);
|
|
56
|
-
// }
|
|
57
|
-
// export const DEFAULT_START = getRange()[0];
|
|
58
|
-
// export const DEFAULT_END = getRange()[1];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SOURCE_TYPE } from './Const';
|
|
2
|
-
import type { BaseOption } from '../../basetype';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import type { Source, SourceField } from './Const';
|
|
5
|
-
export declare const sourceTypeRender: (type: SOURCE_TYPE) => ReactNode;
|
|
6
|
-
export type UseDataSource = {
|
|
7
|
-
sourceLoading: boolean;
|
|
8
|
-
all: Source[];
|
|
9
|
-
sourceMap: Map<number, Source>;
|
|
10
|
-
nameMap: Map<string, number>;
|
|
11
|
-
es: Source[];
|
|
12
|
-
mysql: Source[];
|
|
13
|
-
doris: Source[];
|
|
14
|
-
sourceOptions: BaseOption[];
|
|
15
|
-
esOptions: BaseOption[];
|
|
16
|
-
mysqlOptions: BaseOption[];
|
|
17
|
-
dorisOptions: BaseOption[];
|
|
18
|
-
sourceIdRender: (id: number) => ReactNode;
|
|
19
|
-
sourceNameRender: (name: string) => ReactNode;
|
|
20
|
-
getSourceFiled: (sourceId: number) => Promise<SourceField[]>;
|
|
21
|
-
};
|
|
22
|
-
export declare const useSource: () => UseDataSource;
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
72
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
73
|
-
if (!m) return o;
|
|
74
|
-
var i = m.call(o), r, ar = [], e;
|
|
75
|
-
try {
|
|
76
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
77
|
-
}
|
|
78
|
-
catch (error) { e = { error: error }; }
|
|
79
|
-
finally {
|
|
80
|
-
try {
|
|
81
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
82
|
-
}
|
|
83
|
-
finally { if (e) throw e.error; }
|
|
84
|
-
}
|
|
85
|
-
return ar;
|
|
86
|
-
};
|
|
87
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
88
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
89
|
-
};
|
|
90
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
|
-
exports.useSource = exports.sourceTypeRender = void 0;
|
|
92
|
-
var react_1 = __importStar(require("react"));
|
|
93
|
-
var lodash_1 = __importDefault(require("lodash"));
|
|
94
|
-
var utils_1 = require("../../utils");
|
|
95
|
-
var Icon_1 = require("../../components/_adapt/Icon");
|
|
96
|
-
var hooks_1 = require("../../hooks");
|
|
97
|
-
var Const_1 = require("./Const");
|
|
98
|
-
var SOURCE_API = Const_1.API_PREFIX + '/source';
|
|
99
|
-
var sourceTypeRender = function (type) {
|
|
100
|
-
switch (type) {
|
|
101
|
-
case Const_1.SOURCE_TYPE.ELASTIC:
|
|
102
|
-
return react_1.default.createElement("img", { src: "".concat(Const_1.IMAGE_PREFIX, "/source-type/elastic-search.svg"), height: 20, width: 58, style: { verticalAlign: 'middle' } });
|
|
103
|
-
case Const_1.SOURCE_TYPE.MYSQL:
|
|
104
|
-
return react_1.default.createElement("img", { src: "".concat(Const_1.IMAGE_PREFIX, "/source-type/mysql.svg"), height: 20, width: 30, style: { verticalAlign: 'middle' } });
|
|
105
|
-
case Const_1.SOURCE_TYPE.DORIS:
|
|
106
|
-
return react_1.default.createElement("img", { src: "".concat(Const_1.IMAGE_PREFIX, "/source-type/doris.svg"), height: 20, width: 59, style: { verticalAlign: 'middle' } });
|
|
107
|
-
default:
|
|
108
|
-
return react_1.default.createElement("img", { src: "".concat(Const_1.IMAGE_PREFIX, "/source-type/elastic-search.svg"), height: 20, width: 58, style: { verticalAlign: 'middle' } });
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
exports.sourceTypeRender = sourceTypeRender;
|
|
112
|
-
utils_1.Ajax.SESSION(SOURCE_API);
|
|
113
|
-
var DEFAULT = {
|
|
114
|
-
sourceLoading: true,
|
|
115
|
-
all: [],
|
|
116
|
-
es: [],
|
|
117
|
-
mysql: [],
|
|
118
|
-
doris: [],
|
|
119
|
-
sourceOptions: [],
|
|
120
|
-
esOptions: [],
|
|
121
|
-
mysqlOptions: [],
|
|
122
|
-
dorisOptions: [],
|
|
123
|
-
nameMap: new Map(),
|
|
124
|
-
sourceMap: new Map(),
|
|
125
|
-
};
|
|
126
|
-
var useSource = function () {
|
|
127
|
-
var _a = __read((0, hooks_1.useGlobal)('DATA_SOURCE', DEFAULT, { share: true, }), 3), _b = _a[0], sourceLoading = _b.sourceLoading, all = _b.all, es = _b.es, mysql = _b.mysql, doris = _b.doris, sourceOptions = _b.sourceOptions, esOptions = _b.esOptions, mysqlOptions = _b.mysqlOptions, dorisOptions = _b.dorisOptions, sourceMap = _b.sourceMap, nameMap = _b.nameMap, setState = _a[1], loaded = _a[2];
|
|
128
|
-
var reflush = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
-
var resp, es, mysql, doris, all, sourceMap, nameMap, sourceOptions, esOptions, mysqlOptions, dorisOptions;
|
|
130
|
-
return __generator(this, function (_a) {
|
|
131
|
-
switch (_a.label) {
|
|
132
|
-
case 0:
|
|
133
|
-
if (loaded)
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
return [4 /*yield*/, utils_1.Ajax.GET(SOURCE_API)];
|
|
136
|
-
case 1:
|
|
137
|
-
resp = _a.sent();
|
|
138
|
-
es = [];
|
|
139
|
-
mysql = [];
|
|
140
|
-
doris = [];
|
|
141
|
-
all = [];
|
|
142
|
-
sourceMap = new Map();
|
|
143
|
-
nameMap = new Map();
|
|
144
|
-
if (resp.code == '0') {
|
|
145
|
-
resp.data.map(function (item) {
|
|
146
|
-
all.push(item);
|
|
147
|
-
sourceMap.set(item.id, item);
|
|
148
|
-
nameMap.set(item.name, item.id);
|
|
149
|
-
if (item.type == Const_1.SOURCE_TYPE.ELASTIC) {
|
|
150
|
-
es.push(item);
|
|
151
|
-
}
|
|
152
|
-
else if (item.type == Const_1.SOURCE_TYPE.MYSQL) {
|
|
153
|
-
mysql.push(item);
|
|
154
|
-
}
|
|
155
|
-
else if (item.type == Const_1.SOURCE_TYPE.DORIS) {
|
|
156
|
-
doris.push(item);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
sourceOptions = [], esOptions = [], mysqlOptions = [], dorisOptions = [];
|
|
161
|
-
all.map(function (item) {
|
|
162
|
-
var option = {
|
|
163
|
-
value: item.id,
|
|
164
|
-
label: react_1.default.createElement("span", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
|
|
165
|
-
react_1.default.createElement("span", { style: { alignItems: 'center', display: 'flex' } },
|
|
166
|
-
(0, exports.sourceTypeRender)(item.type),
|
|
167
|
-
" ",
|
|
168
|
-
react_1.default.createElement("b", { style: { marginLeft: 4 } }, item.title)),
|
|
169
|
-
react_1.default.createElement("i", null, item.name))
|
|
170
|
-
};
|
|
171
|
-
sourceOptions.push(option);
|
|
172
|
-
if (item.type == Const_1.SOURCE_TYPE.ELASTIC) {
|
|
173
|
-
esOptions.push(option);
|
|
174
|
-
}
|
|
175
|
-
else if (item.type == Const_1.SOURCE_TYPE.MYSQL) {
|
|
176
|
-
mysqlOptions.push(option);
|
|
177
|
-
}
|
|
178
|
-
else if (item.type == Const_1.SOURCE_TYPE.DORIS) {
|
|
179
|
-
dorisOptions.push(option);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
setState({ sourceLoading: false, nameMap: nameMap, all: all, es: es, mysql: mysql, doris: doris, sourceOptions: sourceOptions, sourceMap: sourceMap, esOptions: esOptions, mysqlOptions: mysqlOptions, dorisOptions: dorisOptions });
|
|
183
|
-
return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}); };
|
|
187
|
-
(0, hooks_1.useEffectFunction)(reflush);
|
|
188
|
-
var getSourceFiled = (0, react_1.useCallback)(function (sourceId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
-
var API, resp;
|
|
190
|
-
return __generator(this, function (_a) {
|
|
191
|
-
switch (_a.label) {
|
|
192
|
-
case 0:
|
|
193
|
-
API = "/api-data/source/field/".concat(sourceId);
|
|
194
|
-
utils_1.Ajax.SESSION(API);
|
|
195
|
-
return [4 /*yield*/, utils_1.Ajax.GET(API)];
|
|
196
|
-
case 1:
|
|
197
|
-
resp = _a.sent();
|
|
198
|
-
if (lodash_1.default.isArray(resp.data))
|
|
199
|
-
return [2 /*return*/, resp.data.filter(function (item) { return item.name != ''; })];
|
|
200
|
-
return [2 /*return*/, []];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}); }, []);
|
|
204
|
-
var sourceIdRender = (0, react_1.useCallback)(function (idStr, showIdx) {
|
|
205
|
-
if (showIdx === void 0) { showIdx = false; }
|
|
206
|
-
try {
|
|
207
|
-
var id = parseInt(idStr);
|
|
208
|
-
if (!sourceMap.has(id)) {
|
|
209
|
-
return '';
|
|
210
|
-
}
|
|
211
|
-
var source = sourceMap.get(id);
|
|
212
|
-
if (showIdx && source.title) {
|
|
213
|
-
return react_1.default.createElement("span", { style: { display: 'flex', alignItems: 'center', columnGap: 3 } },
|
|
214
|
-
source.icon && react_1.default.createElement(Icon_1.Icon, { type: source.icon }),
|
|
215
|
-
react_1.default.createElement("span", null,
|
|
216
|
-
source.title,
|
|
217
|
-
" ",
|
|
218
|
-
react_1.default.createElement("i", null,
|
|
219
|
-
"(",
|
|
220
|
-
source.name,
|
|
221
|
-
")")));
|
|
222
|
-
}
|
|
223
|
-
var txt = source.title || source.name;
|
|
224
|
-
return react_1.default.createElement("span", { style: { display: 'flex', alignItems: 'center', columnGap: 3 } },
|
|
225
|
-
source.icon && react_1.default.createElement(Icon_1.Icon, { type: source.icon }),
|
|
226
|
-
react_1.default.createElement("span", null, txt));
|
|
227
|
-
}
|
|
228
|
-
catch (_a) {
|
|
229
|
-
return utils_1.Const.NONE;
|
|
230
|
-
}
|
|
231
|
-
}, [sourceMap]);
|
|
232
|
-
var sourceNameRender = (0, react_1.useCallback)(function (sourceName) {
|
|
233
|
-
var source = (0, Const_1.getSourceByName)(sourceName, all);
|
|
234
|
-
return sourceIdRender(source.id);
|
|
235
|
-
}, [sourceMap]);
|
|
236
|
-
return {
|
|
237
|
-
sourceLoading: sourceLoading,
|
|
238
|
-
all: all,
|
|
239
|
-
sourceOptions: sourceOptions,
|
|
240
|
-
sourceMap: sourceMap,
|
|
241
|
-
nameMap: nameMap,
|
|
242
|
-
sourceIdRender: sourceIdRender,
|
|
243
|
-
sourceNameRender: sourceNameRender,
|
|
244
|
-
getSourceFiled: getSourceFiled,
|
|
245
|
-
es: es,
|
|
246
|
-
mysql: mysql,
|
|
247
|
-
doris: doris,
|
|
248
|
-
esOptions: esOptions,
|
|
249
|
-
mysqlOptions: mysqlOptions,
|
|
250
|
-
dorisOptions: dorisOptions,
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
exports.useSource = useSource;
|