vap1 0.5.4 → 0.5.7
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/components/Box/Box.d.ts +4 -0
- package/components/Box/Box.js +17 -7
- package/components/Box/SelectBar.d.ts +1 -4
- package/components/Box/SelectBar.js +3 -6
- package/components/Lists/Grid/index.js +0 -1
- package/components/SearchTool/SearchBar/ActionButtons.js +3 -16
- package/components/SearchTool/SearchBar/ByKeyword.js +1 -1
- 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.js +4 -2
- package/components/Trees/ActionTree.js +5 -1
- package/components/Trees/BaseTree.js +1 -1
- package/components/Trees/STree.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/package.json +1 -1
- package/utils/Global.d.ts +5 -0
- package/utils/Global.js +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
|
@@ -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;
|