plugin-elastic-report 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client-v2.d.ts +2 -2
- package/client-v2.js +1 -1
- package/client.d.ts +2 -2
- package/client.js +1 -1
- package/{ai → dist/ai}/skills/elastic-report/SKILLS.md +52 -34
- package/dist/client-v2/851.35e416bfb3fb565f.js +10 -0
- package/dist/client-v2/877.81b10beb7b7f4bd7.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +2 -1
- package/dist/locale/en-US.json +213 -198
- package/dist/locale/vi-VN.json +213 -198
- package/dist/locale/zh-CN.json +213 -198
- package/dist/node_modules/@elastic/elasticsearch/package.json +1 -1
- package/dist/server/mcp/ElasticReportToolCatalog.js +6 -4
- package/dist/server/plugin.js +4 -4
- package/dist/server/report-block-tools.js +340 -0
- package/dist/server/services/ElasticReportService.js +12 -6
- package/dist/shared/constants.js +9 -0
- package/package.json +2 -3
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/src/ai/skills/elastic-report/SKILLS.md +52 -0
- package/src/client/index.tsx +34 -34
- package/src/client/workflow-instructions.tsx +44 -44
- package/src/client-v2/__tests__/elastic-report.test.tsx +879 -791
- package/src/client-v2/__tests__/kql-autocomplete.test.ts +178 -178
- package/src/client-v2/api.ts +320 -320
- package/src/client-v2/bus/DashboardFilterBus.ts +212 -212
- package/src/client-v2/components/ElasticBasicCharts.tsx +652 -652
- package/src/client-v2/components/ElasticFilterBar.tsx +372 -372
- package/src/client-v2/components/ElasticKqlInput.tsx +421 -421
- package/src/client-v2/components/ElasticReportBlock.tsx +306 -306
- package/src/client-v2/components/ElasticReportRenderer.tsx +1257 -1257
- package/src/client-v2/components/HighlightText.tsx +50 -50
- package/src/client-v2/components/ReportSelect.tsx +85 -85
- package/src/client-v2/index.tsx +14 -14
- package/src/client-v2/locale.ts +23 -23
- package/src/client-v2/models/ElasticFilterBarBlockModel.tsx +115 -115
- package/src/client-v2/models/ElasticReportBlockModel.tsx +118 -118
- package/src/client-v2/pages/ElasticReportManager.tsx +1453 -1453
- package/src/client-v2/plugin.tsx +107 -72
- package/src/client-v2/report-destination.tsx +126 -0
- package/src/client-v2/utils/kqlAutocomplete.ts +861 -861
- package/src/client-v2/workflow/instructions.tsx +149 -149
- package/src/index.ts +11 -11
- package/src/locale/en-US.json +213 -198
- package/src/locale/vi-VN.json +213 -198
- package/src/locale/zh-CN.json +213 -198
- package/src/server/__tests__/ai-blocks.integration.test.ts +292 -0
- package/src/server/__tests__/query-compiler.test.ts +620 -620
- package/src/server/__tests__/report-mcp-acl.integration.test.ts +645 -645
- package/src/server/acl-guard.ts +194 -194
- package/src/server/collections/es-report-data-views.ts +64 -64
- package/src/server/collections/es-reports.ts +80 -80
- package/src/server/index.ts +15 -15
- package/src/server/mcp/ElasticReportMcpServer.ts +391 -391
- package/src/server/mcp/ElasticReportToolCatalog.ts +667 -663
- package/src/server/plugin.ts +599 -599
- package/src/server/report-block-tools.ts +400 -0
- package/src/server/services/ElasticReportService.ts +494 -486
- package/src/server/services/ElasticsearchConnectionService.ts +728 -728
- package/src/server/services/ReportExportService.ts +282 -282
- package/src/server/services/ReportQueryCompiler.ts +1552 -1552
- package/src/server/workflow/ElasticReportQueryInstruction.ts +124 -124
- package/src/shared/constants.ts +39 -36
- package/src/shared/types.ts +272 -272
- package/dist/client-v2/851.142c93fc6d666b28.js +0 -10
- package/dist/client-v2/877.f4095a3dbcadf98f.js +0 -10
- package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv +0 -15
- package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv.cmd +0 -7
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { HIGHLIGHT_POST_TAG, HIGHLIGHT_PRE_TAG } from '../../shared/constants';
|
|
11
|
-
import React from 'react';
|
|
12
|
-
|
|
13
|
-
export interface HighlightTextProps {
|
|
14
|
-
text: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Safely render Elasticsearch highlight snippets with semantic `<mark>` tags
|
|
19
|
-
* without ever invoking `dangerouslySetInnerHTML`.
|
|
20
|
-
*/
|
|
21
|
-
export const HighlightText: React.FC<HighlightTextProps> = ({ text }) => {
|
|
22
|
-
if (!text || !text.includes(HIGHLIGHT_PRE_TAG)) {
|
|
23
|
-
return <>{text}</>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const segments: React.ReactNode[] = [];
|
|
27
|
-
let cursor = 0;
|
|
28
|
-
let keyIdx = 0;
|
|
29
|
-
|
|
30
|
-
while (cursor < text.length) {
|
|
31
|
-
const startIdx = text.indexOf(HIGHLIGHT_PRE_TAG, cursor);
|
|
32
|
-
if (startIdx === -1) {
|
|
33
|
-
segments.push(text.slice(cursor));
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
if (startIdx > cursor) {
|
|
37
|
-
segments.push(text.slice(cursor, startIdx));
|
|
38
|
-
}
|
|
39
|
-
const contentStart = startIdx + HIGHLIGHT_PRE_TAG.length;
|
|
40
|
-
const endIdx = text.indexOf(HIGHLIGHT_POST_TAG, contentStart);
|
|
41
|
-
if (endIdx === -1) {
|
|
42
|
-
segments.push(text.slice(contentStart));
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
segments.push(<mark key={`hl-${keyIdx++}`}>{text.slice(contentStart, endIdx)}</mark>);
|
|
46
|
-
cursor = endIdx + HIGHLIGHT_POST_TAG.length;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return <>{segments}</>;
|
|
50
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { HIGHLIGHT_POST_TAG, HIGHLIGHT_PRE_TAG } from '../../shared/constants';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
export interface HighlightTextProps {
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Safely render Elasticsearch highlight snippets with semantic `<mark>` tags
|
|
19
|
+
* without ever invoking `dangerouslySetInnerHTML`.
|
|
20
|
+
*/
|
|
21
|
+
export const HighlightText: React.FC<HighlightTextProps> = ({ text }) => {
|
|
22
|
+
if (!text || !text.includes(HIGHLIGHT_PRE_TAG)) {
|
|
23
|
+
return <>{text}</>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const segments: React.ReactNode[] = [];
|
|
27
|
+
let cursor = 0;
|
|
28
|
+
let keyIdx = 0;
|
|
29
|
+
|
|
30
|
+
while (cursor < text.length) {
|
|
31
|
+
const startIdx = text.indexOf(HIGHLIGHT_PRE_TAG, cursor);
|
|
32
|
+
if (startIdx === -1) {
|
|
33
|
+
segments.push(text.slice(cursor));
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (startIdx > cursor) {
|
|
37
|
+
segments.push(text.slice(cursor, startIdx));
|
|
38
|
+
}
|
|
39
|
+
const contentStart = startIdx + HIGHLIGHT_PRE_TAG.length;
|
|
40
|
+
const endIdx = text.indexOf(HIGHLIGHT_POST_TAG, contentStart);
|
|
41
|
+
if (endIdx === -1) {
|
|
42
|
+
segments.push(text.slice(contentStart));
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
segments.push(<mark key={`hl-${keyIdx++}`}>{text.slice(contentStart, endIdx)}</mark>);
|
|
46
|
+
cursor = endIdx + HIGHLIGHT_POST_TAG.length;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return <>{segments}</>;
|
|
50
|
+
};
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { useApp } from '@nocobase/client-v2';
|
|
11
|
-
import { useFlowEngine } from '@nocobase/flow-engine';
|
|
12
|
-
import { Select, Tag, type SelectProps } from 'antd';
|
|
13
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
14
|
-
import type { EsReportRecord, ID } from '../../shared/types';
|
|
15
|
-
import { fetchPublishedReports, type ApiClientLike } from '../api';
|
|
16
|
-
import { useT } from '../locale';
|
|
17
|
-
|
|
18
|
-
export const ReportSelect: React.FC<SelectProps<ID>> = (props) => {
|
|
19
|
-
const { style, ...restProps } = props;
|
|
20
|
-
const t = useT();
|
|
21
|
-
const app = useApp();
|
|
22
|
-
const flowEngine = useFlowEngine();
|
|
23
|
-
const api = ((app as { apiClient?: unknown } | undefined)?.apiClient ??
|
|
24
|
-
(flowEngine as { context?: { api?: unknown } } | undefined)?.context?.api) as ApiClientLike;
|
|
25
|
-
const [reports, setReports] = useState<EsReportRecord[]>([]);
|
|
26
|
-
const [loading, setLoading] = useState(false);
|
|
27
|
-
|
|
28
|
-
const loadReports = useCallback(
|
|
29
|
-
async (search?: string) => {
|
|
30
|
-
if (!api) return;
|
|
31
|
-
setLoading(true);
|
|
32
|
-
try {
|
|
33
|
-
const list = await fetchPublishedReports(api, search);
|
|
34
|
-
setReports(list);
|
|
35
|
-
} catch {
|
|
36
|
-
setReports([]);
|
|
37
|
-
} finally {
|
|
38
|
-
setLoading(false);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
[api],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
loadReports();
|
|
46
|
-
}, [loadReports]);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div style={{ width: '100%', maxWidth: '100%', minWidth: 0 }}>
|
|
50
|
-
<Select
|
|
51
|
-
{...restProps}
|
|
52
|
-
popupMatchSelectWidth={true}
|
|
53
|
-
style={{ width: '100%', maxWidth: '100%', minWidth: 0, ...style }}
|
|
54
|
-
loading={loading}
|
|
55
|
-
showSearch
|
|
56
|
-
allowClear
|
|
57
|
-
placeholder={t('Select report')}
|
|
58
|
-
optionFilterProp="label"
|
|
59
|
-
options={reports.map((report) => ({
|
|
60
|
-
value: report.id,
|
|
61
|
-
label: `${report.title} (${report.visualization.toUpperCase()})`,
|
|
62
|
-
report,
|
|
63
|
-
}))}
|
|
64
|
-
optionRender={(option) => {
|
|
65
|
-
const item = (option.data as { report?: EsReportRecord }).report;
|
|
66
|
-
if (!item) return option.label;
|
|
67
|
-
return (
|
|
68
|
-
<div
|
|
69
|
-
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8, minWidth: 0 }}
|
|
70
|
-
>
|
|
71
|
-
<span
|
|
72
|
-
style={{ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
73
|
-
>
|
|
74
|
-
{item.title}
|
|
75
|
-
</span>
|
|
76
|
-
<Tag color="blue" style={{ marginInlineEnd: 0, flexShrink: 0 }}>
|
|
77
|
-
{item.visualization.toUpperCase()}
|
|
78
|
-
</Tag>
|
|
79
|
-
</div>
|
|
80
|
-
);
|
|
81
|
-
}}
|
|
82
|
-
/>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useApp } from '@nocobase/client-v2';
|
|
11
|
+
import { useFlowEngine } from '@nocobase/flow-engine';
|
|
12
|
+
import { Select, Tag, type SelectProps } from 'antd';
|
|
13
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
14
|
+
import type { EsReportRecord, ID } from '../../shared/types';
|
|
15
|
+
import { fetchPublishedReports, type ApiClientLike } from '../api';
|
|
16
|
+
import { useT } from '../locale';
|
|
17
|
+
|
|
18
|
+
export const ReportSelect: React.FC<SelectProps<ID>> = (props) => {
|
|
19
|
+
const { style, ...restProps } = props;
|
|
20
|
+
const t = useT();
|
|
21
|
+
const app = useApp();
|
|
22
|
+
const flowEngine = useFlowEngine();
|
|
23
|
+
const api = ((app as { apiClient?: unknown } | undefined)?.apiClient ??
|
|
24
|
+
(flowEngine as { context?: { api?: unknown } } | undefined)?.context?.api) as ApiClientLike;
|
|
25
|
+
const [reports, setReports] = useState<EsReportRecord[]>([]);
|
|
26
|
+
const [loading, setLoading] = useState(false);
|
|
27
|
+
|
|
28
|
+
const loadReports = useCallback(
|
|
29
|
+
async (search?: string) => {
|
|
30
|
+
if (!api) return;
|
|
31
|
+
setLoading(true);
|
|
32
|
+
try {
|
|
33
|
+
const list = await fetchPublishedReports(api, search);
|
|
34
|
+
setReports(list);
|
|
35
|
+
} catch {
|
|
36
|
+
setReports([]);
|
|
37
|
+
} finally {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[api],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
loadReports();
|
|
46
|
+
}, [loadReports]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div style={{ width: '100%', maxWidth: '100%', minWidth: 0 }}>
|
|
50
|
+
<Select
|
|
51
|
+
{...restProps}
|
|
52
|
+
popupMatchSelectWidth={true}
|
|
53
|
+
style={{ width: '100%', maxWidth: '100%', minWidth: 0, ...style }}
|
|
54
|
+
loading={loading}
|
|
55
|
+
showSearch
|
|
56
|
+
allowClear
|
|
57
|
+
placeholder={t('Select report')}
|
|
58
|
+
optionFilterProp="label"
|
|
59
|
+
options={reports.map((report) => ({
|
|
60
|
+
value: report.id,
|
|
61
|
+
label: `${report.title} (${report.visualization.toUpperCase()})`,
|
|
62
|
+
report,
|
|
63
|
+
}))}
|
|
64
|
+
optionRender={(option) => {
|
|
65
|
+
const item = (option.data as { report?: EsReportRecord }).report;
|
|
66
|
+
if (!item) return option.label;
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8, minWidth: 0 }}
|
|
70
|
+
>
|
|
71
|
+
<span
|
|
72
|
+
style={{ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}
|
|
73
|
+
>
|
|
74
|
+
{item.title}
|
|
75
|
+
</span>
|
|
76
|
+
<Tag color="blue" style={{ marginInlineEnd: 0, flexShrink: 0 }}>
|
|
77
|
+
{item.visualization.toUpperCase()}
|
|
78
|
+
</Tag>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
};
|
package/src/client-v2/index.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export { PluginElasticReportClient, default } from './plugin';
|
|
11
|
-
export * from './models/ElasticReportBlockModel';
|
|
12
|
-
export * from './components/ElasticReportBlock';
|
|
13
|
-
export * from './components/ElasticReportRenderer';
|
|
14
|
-
export * from './components/ReportSelect';
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { PluginElasticReportClient, default } from './plugin';
|
|
11
|
+
export * from './models/ElasticReportBlockModel';
|
|
12
|
+
export * from './components/ElasticReportBlock';
|
|
13
|
+
export * from './components/ElasticReportRenderer';
|
|
14
|
+
export * from './components/ReportSelect';
|
package/src/client-v2/locale.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { tExpr as flowTExpr, useFlowEngine } from '@nocobase/flow-engine';
|
|
11
|
-
import { PLUGIN_NAME } from '../shared/constants';
|
|
12
|
-
|
|
13
|
-
export const NAMESPACE = PLUGIN_NAME;
|
|
14
|
-
|
|
15
|
-
export function useT() {
|
|
16
|
-
const engine = useFlowEngine();
|
|
17
|
-
return (key: string, options?: Record<string, unknown>) =>
|
|
18
|
-
engine.context.t(key, { ns: [NAMESPACE, 'client'], ...options });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function tExpr(key: string) {
|
|
22
|
-
return flowTExpr(key, { ns: [NAMESPACE, 'client'] });
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { tExpr as flowTExpr, useFlowEngine } from '@nocobase/flow-engine';
|
|
11
|
+
import { PLUGIN_NAME } from '../shared/constants';
|
|
12
|
+
|
|
13
|
+
export const NAMESPACE = PLUGIN_NAME;
|
|
14
|
+
|
|
15
|
+
export function useT() {
|
|
16
|
+
const engine = useFlowEngine();
|
|
17
|
+
return (key: string, options?: Record<string, unknown>) =>
|
|
18
|
+
engine.context.t(key, { ns: [NAMESPACE, 'client'], ...options });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function tExpr(key: string) {
|
|
22
|
+
return flowTExpr(key, { ns: [NAMESPACE, 'client'] });
|
|
23
|
+
}
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { BlockModel } from '@nocobase/client-v2';
|
|
11
|
-
import React from 'react';
|
|
12
|
-
import type { ID } from '../../shared/types';
|
|
13
|
-
import { resolveFlowRootScopeId } from '../bus/DashboardFilterBus';
|
|
14
|
-
import { ElasticFilterBar } from '../components/ElasticFilterBar';
|
|
15
|
-
import { tExpr } from '../locale';
|
|
16
|
-
|
|
17
|
-
export interface ElasticFilterBarBlockModelProps {
|
|
18
|
-
referenceReportId?: ID;
|
|
19
|
-
filterFieldsCsv?: string;
|
|
20
|
-
showGlobalKql?: boolean;
|
|
21
|
-
showGlobalTimeRange?: boolean;
|
|
22
|
-
syncGroup?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class ElasticFilterBarBlockModel extends BlockModel {
|
|
26
|
-
declare props: ElasticFilterBarBlockModelProps;
|
|
27
|
-
|
|
28
|
-
renderComponent() {
|
|
29
|
-
const scopeKey = resolveFlowRootScopeId(
|
|
30
|
-
this as unknown as { uid?: string; parent?: unknown },
|
|
31
|
-
this.props.syncGroup,
|
|
32
|
-
);
|
|
33
|
-
return (
|
|
34
|
-
<ElasticFilterBar
|
|
35
|
-
scopeKey={scopeKey}
|
|
36
|
-
referenceReportId={this.props.referenceReportId}
|
|
37
|
-
filterFieldsCsv={this.props.filterFieldsCsv ?? ''}
|
|
38
|
-
showGlobalKql={this.props.showGlobalKql !== false}
|
|
39
|
-
showGlobalTimeRange={this.props.showGlobalTimeRange !== false}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ElasticFilterBarBlockModel.define({
|
|
46
|
-
label: tExpr('Elastic Filter Bar'),
|
|
47
|
-
createModelOptions: { use: 'ElasticFilterBarBlockModel' },
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
ElasticFilterBarBlockModel.registerFlow({
|
|
51
|
-
key: 'elasticFilterBarBlockSettings',
|
|
52
|
-
title: tExpr('Elastic filter bar settings'),
|
|
53
|
-
on: 'beforeRender',
|
|
54
|
-
steps: {
|
|
55
|
-
editFilterBar: {
|
|
56
|
-
title: tExpr('Elastic filter bar settings'),
|
|
57
|
-
uiMode: {
|
|
58
|
-
type: 'dialog',
|
|
59
|
-
props: {
|
|
60
|
-
width: 520,
|
|
61
|
-
style: { maxWidth: 'calc(100vw - 32px)' },
|
|
62
|
-
centered: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
uiSchema: {
|
|
66
|
-
referenceReportId: {
|
|
67
|
-
title: tExpr('Report'),
|
|
68
|
-
'x-decorator': 'FormItem',
|
|
69
|
-
'x-component': 'ElasticReportSelect',
|
|
70
|
-
},
|
|
71
|
-
filterFieldsCsv: {
|
|
72
|
-
title: tExpr('Filter Fields (comma-separated, e.g. service, region)'),
|
|
73
|
-
type: 'string',
|
|
74
|
-
'x-decorator': 'FormItem',
|
|
75
|
-
'x-component': 'Input',
|
|
76
|
-
},
|
|
77
|
-
showGlobalKql: {
|
|
78
|
-
title: tExpr('Show global KQL input'),
|
|
79
|
-
type: 'boolean',
|
|
80
|
-
'x-decorator': 'FormItem',
|
|
81
|
-
'x-component': 'Switch',
|
|
82
|
-
},
|
|
83
|
-
showGlobalTimeRange: {
|
|
84
|
-
title: tExpr('Show global time range'),
|
|
85
|
-
type: 'boolean',
|
|
86
|
-
'x-decorator': 'FormItem',
|
|
87
|
-
'x-component': 'Switch',
|
|
88
|
-
},
|
|
89
|
-
syncGroup: {
|
|
90
|
-
title: tExpr('Sync Group'),
|
|
91
|
-
type: 'string',
|
|
92
|
-
'x-decorator': 'FormItem',
|
|
93
|
-
'x-component': 'Input',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
defaultParams: {
|
|
97
|
-
showGlobalKql: true,
|
|
98
|
-
showGlobalTimeRange: true,
|
|
99
|
-
filterFieldsCsv: '',
|
|
100
|
-
syncGroup: '',
|
|
101
|
-
},
|
|
102
|
-
handler(ctx, params) {
|
|
103
|
-
ctx.model.setProps({
|
|
104
|
-
referenceReportId: params.referenceReportId,
|
|
105
|
-
filterFieldsCsv: typeof params.filterFieldsCsv === 'string' ? params.filterFieldsCsv : '',
|
|
106
|
-
showGlobalKql: params.showGlobalKql !== false,
|
|
107
|
-
showGlobalTimeRange: params.showGlobalTimeRange !== false,
|
|
108
|
-
syncGroup: typeof params.syncGroup === 'string' ? params.syncGroup : '',
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
export default ElasticFilterBarBlockModel;
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { BlockModel } from '@nocobase/client-v2';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { ID } from '../../shared/types';
|
|
13
|
+
import { resolveFlowRootScopeId } from '../bus/DashboardFilterBus';
|
|
14
|
+
import { ElasticFilterBar } from '../components/ElasticFilterBar';
|
|
15
|
+
import { tExpr } from '../locale';
|
|
16
|
+
|
|
17
|
+
export interface ElasticFilterBarBlockModelProps {
|
|
18
|
+
referenceReportId?: ID;
|
|
19
|
+
filterFieldsCsv?: string;
|
|
20
|
+
showGlobalKql?: boolean;
|
|
21
|
+
showGlobalTimeRange?: boolean;
|
|
22
|
+
syncGroup?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class ElasticFilterBarBlockModel extends BlockModel {
|
|
26
|
+
declare props: ElasticFilterBarBlockModelProps;
|
|
27
|
+
|
|
28
|
+
renderComponent() {
|
|
29
|
+
const scopeKey = resolveFlowRootScopeId(
|
|
30
|
+
this as unknown as { uid?: string; parent?: unknown },
|
|
31
|
+
this.props.syncGroup,
|
|
32
|
+
);
|
|
33
|
+
return (
|
|
34
|
+
<ElasticFilterBar
|
|
35
|
+
scopeKey={scopeKey}
|
|
36
|
+
referenceReportId={this.props.referenceReportId}
|
|
37
|
+
filterFieldsCsv={this.props.filterFieldsCsv ?? ''}
|
|
38
|
+
showGlobalKql={this.props.showGlobalKql !== false}
|
|
39
|
+
showGlobalTimeRange={this.props.showGlobalTimeRange !== false}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ElasticFilterBarBlockModel.define({
|
|
46
|
+
label: tExpr('Elastic Filter Bar'),
|
|
47
|
+
createModelOptions: { use: 'ElasticFilterBarBlockModel' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
ElasticFilterBarBlockModel.registerFlow({
|
|
51
|
+
key: 'elasticFilterBarBlockSettings',
|
|
52
|
+
title: tExpr('Elastic filter bar settings'),
|
|
53
|
+
on: 'beforeRender',
|
|
54
|
+
steps: {
|
|
55
|
+
editFilterBar: {
|
|
56
|
+
title: tExpr('Elastic filter bar settings'),
|
|
57
|
+
uiMode: {
|
|
58
|
+
type: 'dialog',
|
|
59
|
+
props: {
|
|
60
|
+
width: 520,
|
|
61
|
+
style: { maxWidth: 'calc(100vw - 32px)' },
|
|
62
|
+
centered: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
uiSchema: {
|
|
66
|
+
referenceReportId: {
|
|
67
|
+
title: tExpr('Report'),
|
|
68
|
+
'x-decorator': 'FormItem',
|
|
69
|
+
'x-component': 'ElasticReportSelect',
|
|
70
|
+
},
|
|
71
|
+
filterFieldsCsv: {
|
|
72
|
+
title: tExpr('Filter Fields (comma-separated, e.g. service, region)'),
|
|
73
|
+
type: 'string',
|
|
74
|
+
'x-decorator': 'FormItem',
|
|
75
|
+
'x-component': 'Input',
|
|
76
|
+
},
|
|
77
|
+
showGlobalKql: {
|
|
78
|
+
title: tExpr('Show global KQL input'),
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
'x-decorator': 'FormItem',
|
|
81
|
+
'x-component': 'Switch',
|
|
82
|
+
},
|
|
83
|
+
showGlobalTimeRange: {
|
|
84
|
+
title: tExpr('Show global time range'),
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
'x-decorator': 'FormItem',
|
|
87
|
+
'x-component': 'Switch',
|
|
88
|
+
},
|
|
89
|
+
syncGroup: {
|
|
90
|
+
title: tExpr('Sync Group'),
|
|
91
|
+
type: 'string',
|
|
92
|
+
'x-decorator': 'FormItem',
|
|
93
|
+
'x-component': 'Input',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
defaultParams: {
|
|
97
|
+
showGlobalKql: true,
|
|
98
|
+
showGlobalTimeRange: true,
|
|
99
|
+
filterFieldsCsv: '',
|
|
100
|
+
syncGroup: '',
|
|
101
|
+
},
|
|
102
|
+
handler(ctx, params) {
|
|
103
|
+
ctx.model.setProps({
|
|
104
|
+
referenceReportId: params.referenceReportId,
|
|
105
|
+
filterFieldsCsv: typeof params.filterFieldsCsv === 'string' ? params.filterFieldsCsv : '',
|
|
106
|
+
showGlobalKql: params.showGlobalKql !== false,
|
|
107
|
+
showGlobalTimeRange: params.showGlobalTimeRange !== false,
|
|
108
|
+
syncGroup: typeof params.syncGroup === 'string' ? params.syncGroup : '',
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export default ElasticFilterBarBlockModel;
|