ronds-metadata 1.3.4 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ import 'monaco-editor/esm/vs/basic-languages/pgsql/pgsql.contribution.js';
2
+ interface ICodeEditProps {
3
+ value?: string;
4
+ theme?: 'light' | 'vs-dark';
5
+ mode?: 'javascript' | 'python' | 'pgsql';
6
+ width?: string | number;
7
+ height?: string | number;
8
+ /**
9
+ * 联想提示说明
10
+ */
11
+ extraDico?: any[];
12
+ /**
13
+ * 编辑框输入值改变回调
14
+ */
15
+ onChange?: (txt: string) => void;
16
+ }
17
+ declare const CodeEdit: (props: ICodeEditProps) => JSX.Element;
18
+ export default CodeEdit;
@@ -0,0 +1,143 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ /*
5
+ * @Author: wangxian
6
+ * @Date: 2023-09-08 10:02:20
7
+ * @LastEditTime: 2023-09-08 18:47:50
8
+ */
9
+ import Editor, { useMonaco } from '@monaco-editor/react';
10
+ import React from 'react';
11
+ // 引入所需的语言库
12
+ import 'monaco-editor/esm/vs/basic-languages/pgsql/pgsql.contribution.js';
13
+ var CodeEdit = function CodeEdit(props) {
14
+ var value = props.value,
15
+ width = props.width,
16
+ height = props.height,
17
+ _props$theme = props.theme,
18
+ theme = _props$theme === void 0 ? 'light' : _props$theme,
19
+ _props$mode = props.mode,
20
+ mode = _props$mode === void 0 ? 'javascript' : _props$mode,
21
+ onChange = props.onChange;
22
+ var editorRef = React.useRef(null);
23
+ var monaco = useMonaco();
24
+ var initSuggestion = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
25
+ var l, _yield$import, conf, language;
26
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
27
+ while (1) switch (_context.prev = _context.next) {
28
+ case 0:
29
+ // 动态导入 pgsql 模块
30
+ l = {};
31
+ if (!(mode === 'pgsql')) {
32
+ _context.next = 8;
33
+ break;
34
+ }
35
+ _context.next = 4;
36
+ return import('monaco-editor/esm/vs/basic-languages/pgsql/pgsql.js');
37
+ case 4:
38
+ _yield$import = _context.sent;
39
+ conf = _yield$import.conf;
40
+ language = _yield$import.language;
41
+ l = language;
42
+ case 8:
43
+ if (mode === 'python') {
44
+ l = {
45
+ keywords: ['signal'],
46
+ operators: ['add'],
47
+ builtinFunctions: ['alarm', 'plot']
48
+ };
49
+ }
50
+ monaco.languages.registerCompletionItemProvider(mode, {
51
+ provideCompletionItems: function provideCompletionItems(model, position) {
52
+ var _l, _l2, _l3;
53
+ // 获取原有的提示项
54
+ // const suggestions = monaco.languages.provideCompletionItems(model, position).suggestions;
55
+ var word = model.getWordUntilPosition(position);
56
+ var range = {
57
+ startLineNumber: position.lineNumber,
58
+ endLineNumber: position.lineNumber,
59
+ startColumn: word.startColumn,
60
+ endColumn: word.endColumn
61
+ };
62
+ var keyword = (((_l = l) === null || _l === void 0 ? void 0 : _l.keywords) || []).map(function (item) {
63
+ return {
64
+ insertText: item,
65
+ kind: monaco.languages.CompletionItemKind.Keyword,
66
+ label: item,
67
+ range: range
68
+ };
69
+ });
70
+ var operator = (((_l2 = l) === null || _l2 === void 0 ? void 0 : _l2.operators) || []).map(function (item) {
71
+ return {
72
+ insertText: item,
73
+ kind: monaco.languages.CompletionItemKind.Method,
74
+ label: item,
75
+ range: range
76
+ };
77
+ });
78
+ var fnc = (((_l3 = l) === null || _l3 === void 0 ? void 0 : _l3.builtinFunctions) || []).map(function (item) {
79
+ return {
80
+ insertText: item,
81
+ kind: monaco.languages.CompletionItemKind.Function,
82
+ label: item,
83
+ range: range
84
+ };
85
+ });
86
+ return {
87
+ suggestions: [].concat(_toConsumableArray(keyword), _toConsumableArray(operator), _toConsumableArray(fnc))
88
+ };
89
+ },
90
+ triggerCharacters: ['$', '.', '=', ':'] // 触发提示的字符 可以定义多个
91
+ });
92
+ case 10:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }, _callee);
97
+ })), [monaco]);
98
+ var initHighlight = React.useCallback(function () {
99
+ monaco.languages.setMonarchTokensProvider(mode, {
100
+ ignoreCase: true,
101
+ tokenizer: {
102
+ root: [[/plot/, {
103
+ token: 'keyword'
104
+ }], [/alarm/, {
105
+ token: 'keyword'
106
+ }], [/add/, {
107
+ token: 'keyword'
108
+ }], [/signal/, {
109
+ token: 'string.escape'
110
+ }]]
111
+ }
112
+ });
113
+ }, [monaco]);
114
+ React.useEffect(function () {
115
+ if (monaco) {
116
+ initHighlight();
117
+ initSuggestion();
118
+ }
119
+ }, [monaco, value, initSuggestion]);
120
+ var onEditorChange = function onEditorChange(data) {
121
+ initHighlight();
122
+ onChange && onChange(data);
123
+ };
124
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Editor, {
125
+ width: width || '100%',
126
+ height: height || '100%',
127
+ theme: theme,
128
+ defaultLanguage: mode,
129
+ defaultValue: value
130
+ // beforeMount={onEditorWillMount}
131
+ ,
132
+ onMount: function onMount(editor) {
133
+ editorRef.current = editor;
134
+ },
135
+ options: {
136
+ readOnly: false,
137
+ automaticLayout: true,
138
+ wordWrap: 'on'
139
+ },
140
+ onChange: onEditorChange
141
+ }));
142
+ };
143
+ export default CodeEdit;
@@ -0,0 +1,5 @@
1
+ interface ILineChartProps {
2
+ data: any[];
3
+ }
4
+ declare const LineChart: (props: ILineChartProps) => JSX.Element;
5
+ export default LineChart;
@@ -0,0 +1,70 @@
1
+ import { Line } from '@antv/g2plot';
2
+ import React from 'react';
3
+ import { transXYData } from './utils';
4
+ var LineChart = function LineChart(props) {
5
+ var data = props.data;
6
+ var containerRef = React.useRef();
7
+ var plotRef = React.useRef();
8
+ React.useEffect(function () {
9
+ var line = new Line(containerRef.current, {
10
+ data: [],
11
+ xField: 'x',
12
+ yField: 'y',
13
+ annotations: [
14
+ // 低于中位数颜色变化
15
+ {
16
+ type: 'regionFilter',
17
+ start: ['min', 15],
18
+ end: ['max', 'max'],
19
+ color: '#F4664A'
20
+ }, {
21
+ type: 'text',
22
+ position: ['min', 15],
23
+ content: '报警阈值',
24
+ offsetY: -4,
25
+ style: {
26
+ textBaseline: 'bottom'
27
+ }
28
+ }, {
29
+ type: 'line',
30
+ start: ['min', 15],
31
+ end: ['max', 15],
32
+ style: {
33
+ stroke: '#F4664A',
34
+ lineDash: [2, 2]
35
+ }
36
+ }],
37
+ seriesField: 'name',
38
+ xAxis: {
39
+ type: 'time'
40
+ },
41
+ interactions: [{
42
+ type: 'brush',
43
+ cfg: {
44
+ enabled: false,
45
+ type: 'x-rect'
46
+ }
47
+ }]
48
+ });
49
+ plotRef.current = line;
50
+ line.on('brushselected', function (ev) {
51
+ var selectedData = ev.selected;
52
+
53
+ // 在这里处理选中的数据范围
54
+ });
55
+
56
+ line.render();
57
+ }, []);
58
+ React.useEffect(function () {
59
+ var _data = transXYData(data);
60
+ plotRef.current.changeData(_data);
61
+ }, [data]);
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
63
+ ref: containerRef,
64
+ style: {
65
+ width: '100%',
66
+ height: '100%'
67
+ }
68
+ }));
69
+ };
70
+ export default LineChart;
@@ -0,0 +1,4 @@
1
+ interface IDataMineProps {
2
+ }
3
+ declare const DataMine: (props: IDataMineProps) => JSX.Element;
4
+ export default DataMine;
@@ -0,0 +1,157 @@
1
+ import "antd/es/divider/style";
2
+ import _Divider from "antd/es/divider";
3
+ import "antd/es/button/style";
4
+ import _Button from "antd/es/button";
5
+ import "antd/es/collapse/style";
6
+ import _Collapse from "antd/es/collapse";
7
+ import "antd/es/tabs/style";
8
+ import _Tabs from "antd/es/tabs";
9
+ import "antd/es/tree/style";
10
+ import _Tree from "antd/es/tree";
11
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
+ import "antd/es/date-picker/style";
13
+ import _DatePicker from "antd/es/date-picker";
14
+ /*
15
+ * @Author: wangxian
16
+ * @Date: 2023-09-08 14:44:29
17
+ * @LastEditTime: 2023-09-12 17:08:41
18
+ */
19
+ import { PlusOutlined, CaretUpOutlined, CaretRightOutlined, DownOutlined } from '@ant-design/icons';
20
+ import CodeEdit from '../CodeEdit';
21
+ import { transCode2Graph } from './utils';
22
+ import LineChart from './Line';
23
+ import { SIGNAL, TREEDATA } from './utils';
24
+ import React from 'react';
25
+ import Split from '../Split';
26
+ var RangePicker = _DatePicker.RangePicker;
27
+ var DataMine = function DataMine(props) {
28
+ var value = "s1 = signal('\u6E29\u5EA61')\ns2 = signal('\u6E29\u5EA63')\ns3 = add(s1,s2)\n\nalarm(s3).over(15).level(3).des('\u6E29\u5EA6\u65F6\u5E8F\u62A5\u8B66')\n\nplot(s3)";
29
+ // const [sigValue, setSigValue] = React.useState<string[]>([]);
30
+ var _React$useState = React.useState([SIGNAL[0], SIGNAL[2]]),
31
+ _React$useState2 = _slicedToArray(_React$useState, 2),
32
+ sigChartData = _React$useState2[0],
33
+ setSigChartData = _React$useState2[1];
34
+ // React.useEffect(() => {
35
+ // const _sigChartData = [];
36
+ // for (let i = 0; i < sigValue.length; i++) {
37
+ // const _data = SIGNAL.find((it) => it.id === sigValue[i]);
38
+ // _sigChartData.push(_data);
39
+ // }
40
+ // setSigChartData([..._sigChartData]);
41
+ // }, [sigValue]);
42
+ var onChange = function onChange(txt) {};
43
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Split, {
44
+ sizes: [15, 85],
45
+ gutterSize: 5
46
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Tabs, {
47
+ defaultActiveKey: "item-1"
48
+ }, /*#__PURE__*/React.createElement(_Tabs.TabPane, {
49
+ tab: "\u8BBE\u5907\u6811",
50
+ key: "item-1"
51
+ }, /*#__PURE__*/React.createElement(_Tree, {
52
+ showLine: true,
53
+ switcherIcon: /*#__PURE__*/React.createElement(DownOutlined, null),
54
+ defaultExpandedKeys: ['0-0-0'],
55
+ onSelect: function onSelect() {},
56
+ treeData: TREEDATA
57
+ })), /*#__PURE__*/React.createElement(_Tabs.TabPane, {
58
+ tab: "\u6A21\u578B\u5E93",
59
+ key: "item-2"
60
+ }, /*#__PURE__*/React.createElement(_Collapse, {
61
+ accordion: true,
62
+ defaultActiveKey: 1
63
+ }, /*#__PURE__*/React.createElement(_Collapse.Panel, {
64
+ header: "add-\u52A0 ",
65
+ key: "1"
66
+ }, /*#__PURE__*/React.createElement("p", null, "add(\u4FE1\u53F71\uFF0C\u4FE1\u53F72) \u4E24\u4E2A\u4FE1\u53F7\u76F8\u52A0"), /*#__PURE__*/React.createElement("p", null, "\u793A\u4F8B"), /*#__PURE__*/React.createElement("p", null, "s3 = add(s1,s2)")), /*#__PURE__*/React.createElement(_Collapse.Panel, {
67
+ header: "alarm-\u81EA\u5B9A\u4E49\u62A5\u8B66",
68
+ key: "2"
69
+ }, /*#__PURE__*/React.createElement("p", null, "2223")), /*#__PURE__*/React.createElement(_Collapse.Panel, {
70
+ header: "signal-\u4FE1\u53F7",
71
+ key: "3"
72
+ }, /*#__PURE__*/React.createElement("p", null, "2223")))))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
73
+ icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
74
+ style: {
75
+ marginBottom: '10px'
76
+ },
77
+ size: "small",
78
+ type: "link",
79
+ onClick: function onClick() {
80
+ transCode2Graph(value);
81
+ }
82
+ }, "\u4FE1\u53F7"), /*#__PURE__*/React.createElement(_Button, {
83
+ icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
84
+ style: {
85
+ marginBottom: '10px'
86
+ },
87
+ size: "small",
88
+ type: "link",
89
+ onClick: function onClick() {
90
+ transCode2Graph(value);
91
+ }
92
+ }, "\u4EE3\u7801"), /*#__PURE__*/React.createElement(_Divider, {
93
+ type: "vertical"
94
+ }), /*#__PURE__*/React.createElement(_Button, {
95
+ style: {
96
+ marginBottom: '10px'
97
+ },
98
+ size: "small",
99
+ type: "link",
100
+ onClick: function onClick() {
101
+ transCode2Graph(value);
102
+ }
103
+ }, "\u89E3\u6790\u6210\u56FE\u7ED3\u6784")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
104
+ style: {
105
+ display: 'flex',
106
+ marginBottom: '10px'
107
+ }
108
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
109
+ type: "link",
110
+ icon: /*#__PURE__*/React.createElement(CaretUpOutlined, null)
111
+ })), /*#__PURE__*/React.createElement("div", {
112
+ style: {
113
+ padding: '10px',
114
+ border: '1px solid #ccc',
115
+ flex: 1
116
+ }
117
+ }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", {
118
+ style: {
119
+ width: '100%',
120
+ height: '200px'
121
+ }
122
+ }, /*#__PURE__*/React.createElement(LineChart, {
123
+ data: sigChartData
124
+ }))))), /*#__PURE__*/React.createElement("div", {
125
+ style: {
126
+ marginBottom: '10px'
127
+ }
128
+ }, /*#__PURE__*/React.createElement("div", {
129
+ style: {
130
+ display: 'flex'
131
+ }
132
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
133
+ type: "link",
134
+ icon: /*#__PURE__*/React.createElement(CaretRightOutlined, null)
135
+ })), /*#__PURE__*/React.createElement("div", {
136
+ style: {
137
+ padding: '10px',
138
+ border: '1px solid #ccc',
139
+ flex: 1,
140
+ position: 'relative'
141
+ }
142
+ }, /*#__PURE__*/React.createElement(CodeEdit, {
143
+ value: value,
144
+ height: '140px',
145
+ mode: "python",
146
+ onChange: onChange
147
+ }))), /*#__PURE__*/React.createElement("div", {
148
+ style: {
149
+ width: '100%',
150
+ height: '200px',
151
+ padding: '10px'
152
+ }
153
+ }, /*#__PURE__*/React.createElement(LineChart, {
154
+ data: [SIGNAL[1]]
155
+ }))))));
156
+ };
157
+ export default DataMine;
@@ -0,0 +1,39 @@
1
+ export declare const SIGNAL: {
2
+ id: string;
3
+ name: string;
4
+ x: number[];
5
+ y: number[];
6
+ }[];
7
+ export declare const TREEDATA: {
8
+ title: string;
9
+ key: string;
10
+ children: {
11
+ title: string;
12
+ key: string;
13
+ children: {
14
+ title: string;
15
+ key: string;
16
+ }[];
17
+ }[];
18
+ }[];
19
+ export declare const FNC: ({
20
+ id: string;
21
+ name: string;
22
+ method?: undefined;
23
+ } | {
24
+ id: string;
25
+ name: string;
26
+ method: ({
27
+ code: string;
28
+ name: string;
29
+ value: number;
30
+ } | {
31
+ code: string;
32
+ name: string;
33
+ value: string;
34
+ })[];
35
+ })[];
36
+ export declare const transCode2Graph: (code: string) => void;
37
+ export declare const getArg: (txt: string) => string;
38
+ export declare const getFnc: (txt: string) => string;
39
+ export declare const transXYData: (data: any[]) => any[];