wenay-react2 1.0.39 → 1.0.40
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/lib/common/src/components/Dnd/FloatingWindow.d.ts +29 -12
- package/lib/common/src/components/Dnd/FloatingWindow.js +100 -91
- package/lib/common/src/components/Menu/RightMenu.d.ts +28 -1
- package/lib/common/src/components/Menu/RightMenu.js +62 -35
- package/lib/common/src/components/Modal/LeftModal.js +5 -4
- package/lib/common/src/components/Modal/Modal.js +8 -7
- package/lib/common/src/components/ParamsEditor.d.ts +15 -0
- package/lib/common/src/components/ParamsEditor.js +45 -18
- package/lib/common/src/components/Settings/SettingsDialog.d.ts +68 -6
- package/lib/common/src/components/Settings/SettingsDialog.js +61 -12
- package/lib/common/src/components/Toolbar/Toolbar.js +64 -19
- package/lib/common/src/components/UiSlot/UiSlot.js +5 -4
- package/lib/common/src/grid/columnState/columnState.js +8 -6
- package/lib/common/src/hooks/useKeyboard.js +4 -3
- package/lib/common/src/logs/logs.d.ts +13 -133
- package/lib/common/src/logs/logs.js +20 -39
- package/lib/common/src/logs/logsContext.d.ts +26 -0
- package/lib/common/src/logs/logsContext.js +25 -20
- package/lib/common/src/logs/logsController.d.ts +88 -0
- package/lib/common/src/logs/logsController.js +54 -0
- package/lib/common/src/logs/miniLogs.d.ts +69 -3
- package/lib/common/src/logs/miniLogs.js +70 -15
- package/lib/common/src/menu/menu.d.ts +15 -3
- package/lib/common/src/menu/menu.js +81 -17
- package/lib/common/src/menu/menuMouse.d.ts +18 -0
- package/lib/common/src/menu/menuMouse.js +43 -1
- package/lib/common/src/utils/memoryStore.d.ts +1 -10
- package/lib/common/src/utils/searchHistory.js +4 -3
- package/package.json +49 -49
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { createUpdateApi } from "../../updateBy";
|
|
3
3
|
import { listen as createListen } from "wenay-common2";
|
|
4
4
|
export const keyboardState = {
|
|
5
5
|
key: ""
|
|
6
6
|
};
|
|
7
|
+
const keyboardStateApi = createUpdateApi(keyboardState);
|
|
7
8
|
const [emitKeyDown, keyboardListen] = createListen();
|
|
8
9
|
export const keyboard = {
|
|
9
10
|
get key() { return keyboardState.key; },
|
|
@@ -11,7 +12,7 @@ export const keyboard = {
|
|
|
11
12
|
get() { return keyboardState.key; },
|
|
12
13
|
clear() {
|
|
13
14
|
keyboardState.key = "";
|
|
14
|
-
|
|
15
|
+
keyboardStateApi.render();
|
|
15
16
|
emitKeyDown("", undefined);
|
|
16
17
|
},
|
|
17
18
|
reset() {
|
|
@@ -38,7 +39,7 @@ export function useKeyboard(options = {}) {
|
|
|
38
39
|
if (!(event instanceof KeyboardEvent))
|
|
39
40
|
return;
|
|
40
41
|
keyboardState.key = event.key;
|
|
41
|
-
|
|
42
|
+
keyboardStateApi.render();
|
|
42
43
|
emitKeyDown(event.key, event);
|
|
43
44
|
onKeyDownRef.current?.(event.key, event);
|
|
44
45
|
};
|
|
@@ -1,92 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
txt: string;
|
|
7
|
-
};
|
|
8
|
-
declare const getSettingLogs: () => {
|
|
9
|
-
minVarLogs: {
|
|
10
|
-
name: string;
|
|
11
|
-
range: {
|
|
12
|
-
min: number;
|
|
13
|
-
max: number;
|
|
14
|
-
step: number;
|
|
15
|
-
};
|
|
16
|
-
value: number;
|
|
17
|
-
};
|
|
18
|
-
minVarMessage: {
|
|
19
|
-
name: string;
|
|
20
|
-
range: {
|
|
21
|
-
min: number;
|
|
22
|
-
max: number;
|
|
23
|
-
step: number;
|
|
24
|
-
};
|
|
25
|
-
value: number;
|
|
26
|
-
};
|
|
27
|
-
timeShow: {
|
|
28
|
-
name: string;
|
|
29
|
-
range: {
|
|
30
|
-
min: number;
|
|
31
|
-
max: number;
|
|
32
|
-
step: number;
|
|
33
|
-
};
|
|
34
|
-
value: number;
|
|
35
|
-
};
|
|
36
|
-
show: {
|
|
37
|
-
name: string;
|
|
38
|
-
value: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export declare function getLogsApi<T extends object = {}>(setting: {
|
|
42
|
-
limit?: number;
|
|
43
|
-
limitPer: number;
|
|
44
|
-
varMin?: number;
|
|
45
|
-
}): {
|
|
46
|
-
addLogs(a: LogInput<T>): void;
|
|
1
|
+
import { getSettingLogs, type LogEntry, type LogsApiOptions } from "./logsController";
|
|
2
|
+
export { createLogsController, createLogsControllerState, getSettingLogs, } from "./logsController";
|
|
3
|
+
export type { CreateLogsControllerOptions, LogsApiOptions, LogsController, LogsControllerState, LogsFullState, LogsMiniState, } from "./logsController";
|
|
4
|
+
export declare function getLogsApi<T extends object = {}>(setting: LogsApiOptions): {
|
|
5
|
+
addLogs: (input: import("./logsController").LogInput<T>) => LogEntry<T>;
|
|
47
6
|
params: {
|
|
48
|
-
def:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
range: {
|
|
52
|
-
min: number;
|
|
53
|
-
max: number;
|
|
54
|
-
step: number;
|
|
55
|
-
};
|
|
56
|
-
value: number;
|
|
57
|
-
};
|
|
58
|
-
minVarMessage: {
|
|
59
|
-
name: string;
|
|
60
|
-
range: {
|
|
61
|
-
min: number;
|
|
62
|
-
max: number;
|
|
63
|
-
step: number;
|
|
64
|
-
};
|
|
65
|
-
value: number;
|
|
66
|
-
};
|
|
67
|
-
timeShow: {
|
|
68
|
-
name: string;
|
|
69
|
-
range: {
|
|
70
|
-
min: number;
|
|
71
|
-
max: number;
|
|
72
|
-
step: number;
|
|
73
|
-
};
|
|
74
|
-
value: number;
|
|
75
|
-
};
|
|
76
|
-
show: {
|
|
77
|
-
name: string;
|
|
78
|
-
value: boolean;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
get(): {
|
|
82
|
-
minVarLogs: number;
|
|
83
|
-
minVarMessage: number;
|
|
84
|
-
timeShow: number;
|
|
85
|
-
show: boolean;
|
|
86
|
-
} & {
|
|
87
|
-
readonly [key: number]: void;
|
|
88
|
-
};
|
|
89
|
-
set(a: Params.SimpleParams<ReturnType<typeof getSettingLogs>>): void;
|
|
7
|
+
def: typeof getSettingLogs;
|
|
8
|
+
get(): import("./logsController").LogsSettings;
|
|
9
|
+
set(settings: import("./logsController").LogsSettings): void;
|
|
90
10
|
};
|
|
91
11
|
React: {
|
|
92
12
|
Setting: typeof InputSettingLogs;
|
|
@@ -95,55 +15,16 @@ export declare function getLogsApi<T extends object = {}>(setting: {
|
|
|
95
15
|
};
|
|
96
16
|
};
|
|
97
17
|
export declare const logsApi: {
|
|
98
|
-
addLogs(
|
|
18
|
+
addLogs: (input: {
|
|
99
19
|
id: string;
|
|
100
20
|
var?: number;
|
|
101
21
|
time: Date;
|
|
102
22
|
txt: string;
|
|
103
|
-
})
|
|
23
|
+
}) => LogEntry<{}>;
|
|
104
24
|
params: {
|
|
105
|
-
def:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
range: {
|
|
109
|
-
min: number;
|
|
110
|
-
max: number;
|
|
111
|
-
step: number;
|
|
112
|
-
};
|
|
113
|
-
value: number;
|
|
114
|
-
};
|
|
115
|
-
minVarMessage: {
|
|
116
|
-
name: string;
|
|
117
|
-
range: {
|
|
118
|
-
min: number;
|
|
119
|
-
max: number;
|
|
120
|
-
step: number;
|
|
121
|
-
};
|
|
122
|
-
value: number;
|
|
123
|
-
};
|
|
124
|
-
timeShow: {
|
|
125
|
-
name: string;
|
|
126
|
-
range: {
|
|
127
|
-
min: number;
|
|
128
|
-
max: number;
|
|
129
|
-
step: number;
|
|
130
|
-
};
|
|
131
|
-
value: number;
|
|
132
|
-
};
|
|
133
|
-
show: {
|
|
134
|
-
name: string;
|
|
135
|
-
value: boolean;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
get(): {
|
|
139
|
-
minVarLogs: number;
|
|
140
|
-
minVarMessage: number;
|
|
141
|
-
timeShow: number;
|
|
142
|
-
show: boolean;
|
|
143
|
-
} & {
|
|
144
|
-
readonly [key: number]: void;
|
|
145
|
-
};
|
|
146
|
-
set(a: Params.SimpleParams<ReturnType<typeof getSettingLogs>>): void;
|
|
25
|
+
def: typeof getSettingLogs;
|
|
26
|
+
get(): import("./logsController").LogsSettings;
|
|
27
|
+
set(settings: import("./logsController").LogsSettings): void;
|
|
147
28
|
};
|
|
148
29
|
React: {
|
|
149
30
|
Setting: typeof InputSettingLogs;
|
|
@@ -163,4 +44,3 @@ export declare function MessageEventLogs({ zIndex }: {
|
|
|
163
44
|
export declare function LogsPage({ update }: {
|
|
164
45
|
update?: number;
|
|
165
46
|
}): import("react/jsx-runtime").JSX.Element;
|
|
166
|
-
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AgGridReact } from "ag-grid-react";
|
|
3
2
|
import { useCallback, useEffect, useRef } from "react";
|
|
4
3
|
import { copyToClipboard, Params, timeLocalToStr_hhmmss } from "wenay-common2";
|
|
5
4
|
import { renderBy, updateBy } from "../../updateBy";
|
|
@@ -7,6 +6,9 @@ import { contextMenu } from "../menu/menuMouse";
|
|
|
7
6
|
import { memoryGetOrCreate } from "../utils/memoryStore";
|
|
8
7
|
import { ParamsEditor } from "../components/ParamsEditor";
|
|
9
8
|
import { logDividerGradient, logSeverityBackground, logStyleTokens } from "./logStyles";
|
|
9
|
+
import { AgGridTable, colDefCentered } from "../grid/agGrid4";
|
|
10
|
+
import { createLogsController, createLogsControllerState, getSettingLogs, } from "./logsController";
|
|
11
|
+
export { createLogsController, createLogsControllerState, getSettingLogs, } from "./logsController";
|
|
10
12
|
const cashLogs = new Map();
|
|
11
13
|
const datumConst = {
|
|
12
14
|
map: cashLogs,
|
|
@@ -14,39 +16,25 @@ const datumConst = {
|
|
|
14
16
|
const datumMiniConst = {
|
|
15
17
|
last: []
|
|
16
18
|
};
|
|
17
|
-
const getSettingLogs = () => ({
|
|
18
|
-
minVarLogs: { name: "min. importance for notifications", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
19
|
-
minVarMessage: { name: "min. importance for log table", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
20
|
-
timeShow: { name: "screen display time", range: { min: 1, max: 20, step: 1 }, value: 2 },
|
|
21
|
-
show: { name: "show", value: true }
|
|
22
|
-
});
|
|
23
19
|
const settingLogs = { params: Params.GetSimpleParams(getSettingLogs()) };
|
|
20
|
+
const logGridDefaultColDef = { ...colDefCentered, wrapText: true };
|
|
24
21
|
// varMin - minimum importance
|
|
25
22
|
export function getLogsApi(setting) {
|
|
26
23
|
const datum = memoryGetOrCreate("settingLogs", settingLogs);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
const controller = createLogsController({
|
|
25
|
+
options: setting,
|
|
26
|
+
state: createLogsControllerState({
|
|
27
|
+
full: datumConst,
|
|
28
|
+
mini: datumMiniConst,
|
|
29
|
+
settings: datum,
|
|
30
|
+
}),
|
|
31
|
+
onFullChange: () => renderBy(datumConst),
|
|
32
|
+
onMiniChange: () => renderBy(datumMiniConst),
|
|
33
|
+
onSettingsChange: () => renderBy(datum),
|
|
34
|
+
});
|
|
33
35
|
return {
|
|
34
|
-
addLogs
|
|
35
|
-
|
|
36
|
-
addToArr(datumMiniConst.last, item, setting.limit ?? 50);
|
|
37
|
-
addToArr(datumConst.map.get(a.id) ?? datumConst.map.set(a.id, []).get(a.id), item, setting.limitPer);
|
|
38
|
-
renderBy(datumConst);
|
|
39
|
-
renderBy(datumMiniConst);
|
|
40
|
-
},
|
|
41
|
-
params: {
|
|
42
|
-
def: getSettingLogs,
|
|
43
|
-
get() { return datum.params; },
|
|
44
|
-
set(a) {
|
|
45
|
-
datum.params = a;
|
|
46
|
-
renderBy(datumMiniConst);
|
|
47
|
-
renderBy(datumConst);
|
|
48
|
-
},
|
|
49
|
-
},
|
|
36
|
+
addLogs: controller.addLogs,
|
|
37
|
+
params: controller.params,
|
|
50
38
|
React: {
|
|
51
39
|
Setting: InputSettingLogs,
|
|
52
40
|
Message: MessageEventLogs,
|
|
@@ -136,7 +124,7 @@ export function PageLogs({ update }) {
|
|
|
136
124
|
width: 150,
|
|
137
125
|
},
|
|
138
126
|
];
|
|
139
|
-
return _jsx("div", { className: "maxSize", children: _jsx(
|
|
127
|
+
return _jsx("div", { className: "maxSize", children: _jsx(AgGridTable
|
|
140
128
|
// className = "ag-theme-alpine-dark ag-theme-alpine2" // ag-theme-alpine-dark3
|
|
141
129
|
, {
|
|
142
130
|
// className = "ag-theme-alpine-dark ag-theme-alpine2" // ag-theme-alpine-dark3
|
|
@@ -153,18 +141,11 @@ export function PageLogs({ update }) {
|
|
|
153
141
|
});
|
|
154
142
|
}
|
|
155
143
|
}, onSortChanged: (e) => {
|
|
156
|
-
}, defaultColDef: {
|
|
157
|
-
headerClass: () => ("gridTable-header"),
|
|
158
|
-
resizable: true,
|
|
159
|
-
cellStyle: { textAlign: "center" },
|
|
160
|
-
sortable: true,
|
|
161
|
-
filter: true,
|
|
162
|
-
wrapText: true,
|
|
163
|
-
}, headerHeight: 30, rowHeight: 26, autoSizePadding: 1, rowData: rowData, columnDefs: columns, onCellMouseDown: (e) => {
|
|
144
|
+
}, defaultColDef: logGridDefaultColDef, headerHeight: 30, rowHeight: 26, autoSizePadding: 1, rowData: rowData, columnDefs: columns, onCellMouseDown: (e) => {
|
|
164
145
|
if (e.event instanceof MouseEvent && e.event.button == 2) {
|
|
165
146
|
contextMenu.openAt(e.event, [
|
|
166
147
|
{
|
|
167
|
-
name: "copy", onClick: () => { copyToClipboard(e.value); }
|
|
148
|
+
name: "copy", actionKey: "logs.copyCell", onClick: () => { copyToClipboard(e.value); }
|
|
168
149
|
}
|
|
169
150
|
]);
|
|
170
151
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ColDef, GridReadyEvent } from 'ag-grid-community';
|
|
2
3
|
/** -----------------------------
|
|
3
4
|
* 1. Log types
|
|
4
5
|
* -----------------------------
|
|
@@ -42,7 +43,32 @@ export declare function useLogsContext(): LogsContextValue;
|
|
|
42
43
|
* (PageLogs equivalent)
|
|
43
44
|
* -----------------------------
|
|
44
45
|
*/
|
|
46
|
+
export type LogsTableController = {
|
|
47
|
+
logs: LogEntry[];
|
|
48
|
+
minVarLogs: number;
|
|
49
|
+
gridRef: React.MutableRefObject<GridReadyEvent | null>;
|
|
50
|
+
columnDefs: ColDef[];
|
|
51
|
+
defaultColDef: ColDef;
|
|
52
|
+
onGridReady(params: GridReadyEvent): void;
|
|
53
|
+
};
|
|
54
|
+
export declare function useLogsTableController(): LogsTableController;
|
|
45
55
|
export declare function LogsTable(): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
/** -----------------------------
|
|
57
|
+
* 7. LogsNotifications component
|
|
58
|
+
* (MessageEventLogs equivalent)
|
|
59
|
+
* -----------------------------
|
|
60
|
+
*/
|
|
61
|
+
export interface NotificationItem {
|
|
62
|
+
id: number;
|
|
63
|
+
log: LogEntry;
|
|
64
|
+
}
|
|
65
|
+
export type LogsNotificationsController = {
|
|
66
|
+
showMessages: boolean;
|
|
67
|
+
setShowMessages(value: boolean): void;
|
|
68
|
+
notifications: NotificationItem[];
|
|
69
|
+
visibleNotifications: NotificationItem[];
|
|
70
|
+
};
|
|
71
|
+
export declare function useLogsNotificationsController(): LogsNotificationsController;
|
|
46
72
|
export declare function LogsNotifications(): import("react/jsx-runtime").JSX.Element;
|
|
47
73
|
/** -----------------------------
|
|
48
74
|
* 8. LogsSettings component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { AgGridTable, colDefCentered } from '../grid/agGrid4';
|
|
4
4
|
import { logDividerGradient, logSeverityBackground, logStyleTokens } from './logStyles';
|
|
5
5
|
/** -----------------------------
|
|
6
6
|
* 2. memoryGetOrCreate function -
|
|
@@ -93,15 +93,9 @@ export function useLogsContext() {
|
|
|
93
93
|
}
|
|
94
94
|
return ctx;
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
* 6. LogsTable component
|
|
98
|
-
* (PageLogs equivalent)
|
|
99
|
-
* -----------------------------
|
|
100
|
-
*/
|
|
101
|
-
export function LogsTable() {
|
|
96
|
+
export function useLogsTableController() {
|
|
102
97
|
const { logs, minVarLogs } = useLogsContext();
|
|
103
98
|
const gridRef = useRef(null);
|
|
104
|
-
// Column definitions
|
|
105
99
|
const columnDefs = useMemo(() => [
|
|
106
100
|
{
|
|
107
101
|
field: 'time',
|
|
@@ -126,12 +120,9 @@ export function LogsTable() {
|
|
|
126
120
|
}
|
|
127
121
|
], []);
|
|
128
122
|
const defaultColDef = useMemo(() => ({
|
|
129
|
-
|
|
130
|
-
sortable: true,
|
|
131
|
-
filter: true,
|
|
123
|
+
...colDefCentered,
|
|
132
124
|
wrapText: true,
|
|
133
125
|
}), []);
|
|
134
|
-
// Watch minVarLogs and configure the AG Grid filter
|
|
135
126
|
useEffect(() => {
|
|
136
127
|
if (gridRef.current?.api) {
|
|
137
128
|
if (minVarLogs > 0) {
|
|
@@ -148,14 +139,19 @@ export function LogsTable() {
|
|
|
148
139
|
}
|
|
149
140
|
}
|
|
150
141
|
}, [minVarLogs]);
|
|
142
|
+
const onGridReady = useCallback((params) => {
|
|
143
|
+
gridRef.current = params;
|
|
144
|
+
params.api.sizeColumnsToFit();
|
|
145
|
+
}, []);
|
|
146
|
+
return { logs, minVarLogs, gridRef, columnDefs, defaultColDef, onGridReady };
|
|
147
|
+
}
|
|
148
|
+
export function LogsTable() {
|
|
149
|
+
const table = useLogsTableController();
|
|
151
150
|
return (
|
|
152
151
|
// <div className="ag-theme-alpine-dark" style={{ width: '100%', height: '100%' }}>
|
|
153
|
-
_jsx("div", { style: { width: '100%', height: '100%' }, children: _jsx(
|
|
154
|
-
gridRef.current = params;
|
|
155
|
-
params.api.sizeColumnsToFit();
|
|
156
|
-
}, rowData: logs, columnDefs: columnDefs, defaultColDef: defaultColDef, headerHeight: 30, rowHeight: 26 }) }));
|
|
152
|
+
_jsx("div", { style: { width: '100%', height: '100%' }, children: _jsx(AgGridTable, { onGridReady: table.onGridReady, rowData: table.logs, columnDefs: table.columnDefs, defaultColDef: table.defaultColDef, headerHeight: 30, rowHeight: 26 }) }));
|
|
157
153
|
}
|
|
158
|
-
export function
|
|
154
|
+
export function useLogsNotificationsController() {
|
|
159
155
|
const { logs, minVarMessage, timeShow, showMessages, setShowMessages } = useLogsContext();
|
|
160
156
|
const [notifications, setNotifications] = useState([]);
|
|
161
157
|
const counterRef = useRef(0);
|
|
@@ -183,13 +179,22 @@ export function LogsNotifications() {
|
|
|
183
179
|
timersRef.current.add(timer);
|
|
184
180
|
}, [logs, minVarMessage, timeShow]);
|
|
185
181
|
useEffect(() => () => { timersRef.current.forEach(clearTimeout); }, []);
|
|
186
|
-
|
|
182
|
+
return {
|
|
183
|
+
showMessages,
|
|
184
|
+
setShowMessages,
|
|
185
|
+
notifications,
|
|
186
|
+
visibleNotifications: notifications.slice(0, 10),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export function LogsNotifications() {
|
|
190
|
+
const controller = useLogsNotificationsController();
|
|
191
|
+
if (!controller.showMessages) {
|
|
187
192
|
// If popups are hidden, show only "log"
|
|
188
193
|
return (_jsx("div", { style: { position: 'absolute', right: 10, top: 10, zIndex: 999 }, children: _jsx("div", { style: {
|
|
189
194
|
background: logStyleTokens.toggleOffBg,
|
|
190
195
|
padding: '6px 10px',
|
|
191
196
|
cursor: 'pointer'
|
|
192
|
-
}, onClick: () => setShowMessages(true), children: "log" }) }));
|
|
197
|
+
}, onClick: () => controller.setShowMessages(true), children: "log" }) }));
|
|
193
198
|
}
|
|
194
199
|
// Otherwise render the current notification list
|
|
195
200
|
return (_jsxs("div", { style: { position: 'absolute', right: 10, top: 10, zIndex: 999 }, children: [_jsx("div", { style: {
|
|
@@ -197,7 +202,7 @@ export function LogsNotifications() {
|
|
|
197
202
|
fontSize: '20px',
|
|
198
203
|
padding: '6px 10px',
|
|
199
204
|
cursor: 'pointer'
|
|
200
|
-
}, onClick: () => setShowMessages(false), children: "X" }), _jsx("div", { children:
|
|
205
|
+
}, onClick: () => controller.setShowMessages(false), children: "X" }), _jsx("div", { children: controller.visibleNotifications.map(({ id, log }) => (_jsxs("div", { className: "testAnime example-exit", style: {
|
|
201
206
|
width: 200,
|
|
202
207
|
color: logStyleTokens.text,
|
|
203
208
|
marginTop: 10,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Params } from "wenay-common2";
|
|
2
|
+
export type LogInput<T extends object = {}> = T & {
|
|
3
|
+
id: string;
|
|
4
|
+
var?: number;
|
|
5
|
+
time: Date;
|
|
6
|
+
txt: string;
|
|
7
|
+
};
|
|
8
|
+
export type LogEntry<T extends object = {}> = LogInput<T> & {
|
|
9
|
+
num: number;
|
|
10
|
+
};
|
|
11
|
+
export type LogsApiOptions = {
|
|
12
|
+
limit?: number;
|
|
13
|
+
limitPer: number;
|
|
14
|
+
varMin?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const getSettingLogs: () => {
|
|
17
|
+
minVarLogs: {
|
|
18
|
+
name: string;
|
|
19
|
+
range: {
|
|
20
|
+
min: number;
|
|
21
|
+
max: number;
|
|
22
|
+
step: number;
|
|
23
|
+
};
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
minVarMessage: {
|
|
27
|
+
name: string;
|
|
28
|
+
range: {
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
step: number;
|
|
32
|
+
};
|
|
33
|
+
value: number;
|
|
34
|
+
};
|
|
35
|
+
timeShow: {
|
|
36
|
+
name: string;
|
|
37
|
+
range: {
|
|
38
|
+
min: number;
|
|
39
|
+
max: number;
|
|
40
|
+
step: number;
|
|
41
|
+
};
|
|
42
|
+
value: number;
|
|
43
|
+
};
|
|
44
|
+
show: {
|
|
45
|
+
name: string;
|
|
46
|
+
value: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type LogsSettingsDefinition = ReturnType<typeof getSettingLogs>;
|
|
50
|
+
export type LogsSettings = Params.SimpleParams<LogsSettingsDefinition>;
|
|
51
|
+
export type LogsFullState<T extends object = {}> = {
|
|
52
|
+
map: Map<string, LogEntry<T>[]>;
|
|
53
|
+
};
|
|
54
|
+
export type LogsMiniState<T extends object = {}> = {
|
|
55
|
+
last: LogEntry<T>[];
|
|
56
|
+
};
|
|
57
|
+
export type LogsSettingsState = {
|
|
58
|
+
params: LogsSettings;
|
|
59
|
+
};
|
|
60
|
+
export type LogsControllerState<T extends object = {}> = {
|
|
61
|
+
full: LogsFullState<T>;
|
|
62
|
+
mini: LogsMiniState<T>;
|
|
63
|
+
settings: LogsSettingsState;
|
|
64
|
+
};
|
|
65
|
+
export type LogsControllerEvents = {
|
|
66
|
+
onFullChange?: () => void;
|
|
67
|
+
onMiniChange?: () => void;
|
|
68
|
+
onSettingsChange?: () => void;
|
|
69
|
+
};
|
|
70
|
+
export type CreateLogsControllerOptions<T extends object = {}> = LogsControllerEvents & {
|
|
71
|
+
options: LogsApiOptions;
|
|
72
|
+
state?: LogsControllerState<T>;
|
|
73
|
+
};
|
|
74
|
+
export type LogsController<T extends object = {}> = {
|
|
75
|
+
state: LogsControllerState<T>;
|
|
76
|
+
options: LogsApiOptions;
|
|
77
|
+
addLogs(input: LogInput<T>): LogEntry<T>;
|
|
78
|
+
getRows(): LogEntry<T>[];
|
|
79
|
+
getMiniRows(): LogEntry<T>[];
|
|
80
|
+
getLatest(): LogEntry<T> | undefined;
|
|
81
|
+
params: {
|
|
82
|
+
def: typeof getSettingLogs;
|
|
83
|
+
get(): LogsSettings;
|
|
84
|
+
set(settings: LogsSettings): void;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export declare function createLogsControllerState<T extends object = {}>(state?: Partial<LogsControllerState<T>>): LogsControllerState<T>;
|
|
88
|
+
export declare function createLogsController<T extends object = {}>({ options, state, onFullChange, onMiniChange, onSettingsChange, }: CreateLogsControllerOptions<T>): LogsController<T>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Params } from "wenay-common2";
|
|
2
|
+
export const getSettingLogs = () => ({
|
|
3
|
+
minVarLogs: { name: "min. importance for notifications", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
4
|
+
minVarMessage: { name: "min. importance for log table", range: { min: 0, max: 25, step: 1 }, value: 0 },
|
|
5
|
+
timeShow: { name: "screen display time", range: { min: 1, max: 20, step: 1 }, value: 2 },
|
|
6
|
+
show: { name: "show", value: true }
|
|
7
|
+
});
|
|
8
|
+
function addToArr(arr, data, limit) {
|
|
9
|
+
arr.unshift(data);
|
|
10
|
+
if (arr.length > limit)
|
|
11
|
+
arr.length = limit;
|
|
12
|
+
}
|
|
13
|
+
export function createLogsControllerState(state = {}) {
|
|
14
|
+
return {
|
|
15
|
+
full: state.full ?? { map: new Map() },
|
|
16
|
+
mini: state.mini ?? { last: [] },
|
|
17
|
+
settings: state.settings ?? { params: Params.GetSimpleParams(getSettingLogs()) },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function createLogsController({ options, state = createLogsControllerState(), onFullChange, onMiniChange, onSettingsChange, }) {
|
|
21
|
+
let num = 0;
|
|
22
|
+
return {
|
|
23
|
+
state,
|
|
24
|
+
options,
|
|
25
|
+
addLogs(input) {
|
|
26
|
+
const item = { ...input, num: num++ };
|
|
27
|
+
addToArr(state.mini.last, item, options.limit ?? 50);
|
|
28
|
+
const perId = state.full.map.get(input.id) ?? state.full.map.set(input.id, []).get(input.id);
|
|
29
|
+
addToArr(perId, item, options.limitPer);
|
|
30
|
+
onFullChange?.();
|
|
31
|
+
onMiniChange?.();
|
|
32
|
+
return item;
|
|
33
|
+
},
|
|
34
|
+
getRows() {
|
|
35
|
+
return [...state.full.map.values()].flat();
|
|
36
|
+
},
|
|
37
|
+
getMiniRows() {
|
|
38
|
+
return state.mini.last.slice();
|
|
39
|
+
},
|
|
40
|
+
getLatest() {
|
|
41
|
+
return state.mini.last[0];
|
|
42
|
+
},
|
|
43
|
+
params: {
|
|
44
|
+
def: getSettingLogs,
|
|
45
|
+
get() { return state.settings.params; },
|
|
46
|
+
set(settings) {
|
|
47
|
+
state.settings.params = settings;
|
|
48
|
+
onSettingsChange?.();
|
|
49
|
+
onMiniChange?.();
|
|
50
|
+
onFullChange?.();
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1,5 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CellMouseDownEvent, ColDef, GridApi, GridPreDestroyedEvent, GridReadyEvent } from "ag-grid-community";
|
|
3
|
+
import { type AgGridTableProps } from "../grid/agGrid4";
|
|
4
|
+
export declare const miniLogsColumnDefs: ({
|
|
5
|
+
field: string;
|
|
6
|
+
sort: "desc";
|
|
7
|
+
width: number;
|
|
8
|
+
valueFormatter: (e: import("ag-grid-community").ValueFormatterParams<any, any, any>) => any;
|
|
9
|
+
wrapText?: undefined;
|
|
10
|
+
autoHeight?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
field: string;
|
|
13
|
+
width: number;
|
|
14
|
+
sort?: undefined;
|
|
15
|
+
valueFormatter?: undefined;
|
|
16
|
+
wrapText?: undefined;
|
|
17
|
+
autoHeight?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
field: string;
|
|
20
|
+
wrapText: true;
|
|
21
|
+
autoHeight: true;
|
|
22
|
+
width: number;
|
|
23
|
+
sort?: undefined;
|
|
24
|
+
valueFormatter?: undefined;
|
|
25
|
+
})[];
|
|
26
|
+
export declare const miniLogsDefaultColDef: {
|
|
27
|
+
wrapText: true;
|
|
28
|
+
headerClass: () => string;
|
|
29
|
+
resizable: true;
|
|
30
|
+
cellStyle: {
|
|
31
|
+
textAlign: string;
|
|
32
|
+
};
|
|
33
|
+
sortable: true;
|
|
34
|
+
filter: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type UseMiniLogsTableOptions<T = any> = {
|
|
3
37
|
data: T[];
|
|
4
38
|
onClick?: (e: CellMouseDownEvent<T>) => any;
|
|
5
|
-
|
|
39
|
+
columnDefs?: ColDef<T>[];
|
|
40
|
+
defaultColDef?: ColDef<T>;
|
|
41
|
+
};
|
|
42
|
+
export type MiniLogsTableController<T = any> = {
|
|
43
|
+
rows: T[];
|
|
44
|
+
columns: ColDef<T>[];
|
|
45
|
+
columnDefs: ColDef<T>[];
|
|
46
|
+
defaultColDef: ColDef<T>;
|
|
47
|
+
apiRef: React.RefObject<GridApi<T> | null>;
|
|
48
|
+
fit: () => boolean;
|
|
49
|
+
getApi: () => GridApi<T> | null;
|
|
50
|
+
withApi: <R>(fn: (api: GridApi<T>) => R) => R | undefined;
|
|
51
|
+
onGridReady: (e: GridReadyEvent<T>) => void;
|
|
52
|
+
onGridPreDestroyed: (e: GridPreDestroyedEvent<T>) => void;
|
|
53
|
+
onCellMouseDown: (e: CellMouseDownEvent<T>) => void;
|
|
54
|
+
props: AgGridTableProps<T>;
|
|
55
|
+
tableProps: AgGridTableProps<T>;
|
|
56
|
+
gridProps: AgGridTableProps<T>;
|
|
57
|
+
};
|
|
58
|
+
export type MiniLogsController<T = any> = MiniLogsTableController<T>;
|
|
59
|
+
export type MiniLogsViewProps<T = any> = {
|
|
60
|
+
controller: MiniLogsTableController<T>;
|
|
61
|
+
className?: string;
|
|
62
|
+
style?: React.CSSProperties;
|
|
63
|
+
};
|
|
64
|
+
export type MiniLogsTableProps<T = any> = UseMiniLogsTableOptions<T> & {
|
|
65
|
+
className?: string;
|
|
66
|
+
style?: React.CSSProperties;
|
|
67
|
+
};
|
|
68
|
+
export declare function useMiniLogsTable<T = any>(options: UseMiniLogsTableOptions<T>): MiniLogsTableController<T>;
|
|
69
|
+
export declare function MiniLogsView<T = any>({ controller, className, style }: MiniLogsViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare function MiniLogsTable<T = any>({ className, style, ...options }: MiniLogsTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
export declare function MiniLogs<T = any>(props: MiniLogsTableProps<T>): import("react/jsx-runtime").JSX.Element;
|