@perses-dev/logs-table-plugin 0.2.0-beta.0 → 0.2.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/__mf/js/{LogsTable.6980b2d9.js → LogsTable.2781dfd7.js} +3 -3
- package/__mf/js/async/1117.0a72bc85.js +2 -0
- package/__mf/js/async/1129.e0f0503a.js +7 -0
- package/__mf/js/async/1240.1a0b69fc.js +1 -0
- package/__mf/js/async/304.d0edd380.js +37 -0
- package/__mf/js/async/392.2e457deb.js +2 -0
- package/__mf/js/async/3982.ab5d25af.js +1 -0
- package/__mf/js/async/6034.130a9e6d.js +22 -0
- package/__mf/js/async/648.0ddef36d.js +1 -0
- package/__mf/js/async/7445.28262ec0.js +110 -0
- package/__mf/js/async/8542.1802a06b.js +1 -0
- package/__mf/js/async/8608.4e8b55b4.js +1 -0
- package/__mf/js/async/8859.f8f648fc.js +1 -0
- package/__mf/js/async/9293.7e278959.js +2 -0
- package/__mf/js/async/__federation_expose_LogsTable.f2d6f7ad.js +1 -0
- package/__mf/js/async/lib-router.04411383.js +2 -0
- package/__mf/js/async/{lib-router.318cb64e.js.LICENSE.txt → lib-router.04411383.js.LICENSE.txt} +3 -3
- package/__mf/js/{main.029df708.js → main.76fc2531.js} +3 -3
- package/lib/LogsTable.d.ts.map +1 -1
- package/lib/LogsTable.js +6 -1
- package/lib/LogsTable.js.map +1 -1
- package/lib/LogsTableComponent.d.ts.map +1 -1
- package/lib/LogsTableComponent.js +13 -9
- package/lib/LogsTableComponent.js.map +1 -1
- package/lib/LogsTableItemSelectionActionsEditor.d.ts +4 -0
- package/lib/LogsTableItemSelectionActionsEditor.d.ts.map +1 -0
- package/lib/LogsTableItemSelectionActionsEditor.js +36 -0
- package/lib/LogsTableItemSelectionActionsEditor.js.map +1 -0
- package/lib/LogsTablePanel.js +1 -1
- package/lib/LogsTablePanel.js.map +1 -1
- package/lib/LogsTableSettingsEditor.js +2 -2
- package/lib/LogsTableSettingsEditor.js.map +1 -1
- package/lib/bootstrap.js +1 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/LogsTable.js +6 -1
- package/lib/cjs/LogsTableComponent.js +12 -8
- package/lib/cjs/LogsTableItemSelectionActionsEditor.js +44 -0
- package/lib/cjs/LogsTablePanel.js +1 -1
- package/lib/cjs/LogsTableSettingsEditor.js +1 -1
- package/lib/cjs/bootstrap.js +1 -1
- package/lib/cjs/components/EmptyLogsState.js +1 -1
- package/lib/cjs/components/LogRow/LogDetailsTable.js +1 -1
- package/lib/cjs/components/LogRow/LogRow.js +260 -13
- package/lib/cjs/components/LogRow/LogTimestamp.js +1 -1
- package/lib/cjs/components/LogRow/LogsStyles.js +9 -7
- package/lib/cjs/components/LogRow/index.js +1 -1
- package/lib/cjs/components/LogsList.js +1 -1
- package/lib/cjs/components/VirtualizedLogsList.js +502 -19
- package/lib/cjs/components/hooks/useExpandedRows.js +1 -1
- package/lib/cjs/components/hooks/useSeverity.js +47 -0
- package/lib/cjs/components/utils.js +78 -0
- package/lib/cjs/env.d.js +1 -1
- package/lib/cjs/getPluginModule.js +12 -0
- package/lib/cjs/index-federation.js +1 -1
- package/lib/cjs/index.js +12 -0
- package/lib/cjs/model.js +1 -1
- package/lib/cjs/setup-tests.js +1 -1
- package/lib/cjs/test/mock-query-results.js +60 -3
- package/lib/cjs/utils/copyHelpers.js +70 -0
- package/lib/components/EmptyLogsState.js +1 -1
- package/lib/components/EmptyLogsState.js.map +1 -1
- package/lib/components/LogRow/LogDetailsTable.js +1 -1
- package/lib/components/LogRow/LogDetailsTable.js.map +1 -1
- package/lib/components/LogRow/LogRow.d.ts +4 -1
- package/lib/components/LogRow/LogRow.d.ts.map +1 -1
- package/lib/components/LogRow/LogRow.js +262 -15
- package/lib/components/LogRow/LogRow.js.map +1 -1
- package/lib/components/LogRow/LogTimestamp.js +1 -1
- package/lib/components/LogRow/LogTimestamp.js.map +1 -1
- package/lib/components/LogRow/LogsStyles.d.ts +3 -0
- package/lib/components/LogRow/LogsStyles.d.ts.map +1 -1
- package/lib/components/LogRow/LogsStyles.js +9 -7
- package/lib/components/LogRow/LogsStyles.js.map +1 -1
- package/lib/components/LogRow/index.js +1 -1
- package/lib/components/LogRow/index.js.map +1 -1
- package/lib/components/LogsList.js +1 -1
- package/lib/components/LogsList.js.map +1 -1
- package/lib/components/VirtualizedLogsList.d.ts.map +1 -1
- package/lib/components/VirtualizedLogsList.js +463 -21
- package/lib/components/VirtualizedLogsList.js.map +1 -1
- package/lib/components/hooks/useExpandedRows.js +1 -1
- package/lib/components/hooks/useExpandedRows.js.map +1 -1
- package/lib/components/hooks/useSeverity.d.ts +3 -0
- package/lib/components/hooks/useSeverity.d.ts.map +1 -0
- package/lib/components/hooks/useSeverity.js +39 -0
- package/lib/components/hooks/useSeverity.js.map +1 -0
- package/lib/components/utils.d.ts +5 -0
- package/lib/components/utils.d.ts.map +1 -0
- package/lib/components/utils.js +62 -0
- package/lib/components/utils.js.map +1 -0
- package/lib/env.d.js +1 -1
- package/lib/env.d.js.map +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +12 -0
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index-federation.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -1
- package/lib/model.d.ts +4 -1
- package/lib/model.d.ts.map +1 -1
- package/lib/model.js +1 -1
- package/lib/model.js.map +1 -1
- package/lib/setup-tests.js +1 -1
- package/lib/setup-tests.js.map +1 -1
- package/lib/test/mock-query-results.d.ts +1 -0
- package/lib/test/mock-query-results.d.ts.map +1 -1
- package/lib/test/mock-query-results.js +57 -3
- package/lib/test/mock-query-results.js.map +1 -1
- package/lib/utils/copyHelpers.d.ts +28 -0
- package/lib/utils/copyHelpers.d.ts.map +1 -0
- package/lib/utils/copyHelpers.js +56 -0
- package/lib/utils/copyHelpers.js.map +1 -0
- package/mf-manifest.json +30 -30
- package/mf-stats.json +35 -32
- package/package.json +5 -5
- package/__mf/js/async/1117.921746cb.js +0 -2
- package/__mf/js/async/1939.46722505.js +0 -1
- package/__mf/js/async/392.ffb0729b.js +0 -2
- package/__mf/js/async/580.9e16464c.js +0 -110
- package/__mf/js/async/5997.f6b3408c.js +0 -2
- package/__mf/js/async/6600.884fc0ad.js +0 -22
- package/__mf/js/async/6916.3d24109f.js +0 -7
- package/__mf/js/async/7417.39d13c6a.js +0 -1
- package/__mf/js/async/8252.88cd9656.js +0 -1
- package/__mf/js/async/8294.dac3426d.js +0 -37
- package/__mf/js/async/8535.20f8a453.js +0 -1
- package/__mf/js/async/9558.692edca6.js +0 -1
- package/__mf/js/async/9890.b97f395d.js +0 -1
- package/__mf/js/async/__federation_expose_LogsTable.6f8b33f4.js +0 -1
- package/__mf/js/async/lib-router.318cb64e.js +0 -2
- /package/__mf/js/async/{1117.921746cb.js.LICENSE.txt → 1117.0a72bc85.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6916.3d24109f.js.LICENSE.txt → 1129.e0f0503a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.ffb0729b.js.LICENSE.txt → 392.2e457deb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6600.884fc0ad.js.LICENSE.txt → 6034.130a9e6d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{580.9e16464c.js.LICENSE.txt → 7445.28262ec0.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -21,20 +21,217 @@ Object.defineProperty(exports, "VirtualizedLogsList", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _react = /*#__PURE__*/
|
|
24
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
|
+
const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
|
|
26
27
|
const _reactvirtuoso = require("react-virtuoso");
|
|
27
|
-
const
|
|
28
|
+
const _components = require("@perses-dev/components");
|
|
29
|
+
const _dashboards = require("@perses-dev/dashboards");
|
|
30
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
31
|
+
const _copyHelpers = require("../utils/copyHelpers");
|
|
32
|
+
const _LogRow = require("./LogRow");
|
|
28
33
|
function _interop_require_default(obj) {
|
|
29
34
|
return obj && obj.__esModule ? obj : {
|
|
30
35
|
default: obj
|
|
31
36
|
};
|
|
32
37
|
}
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
39
|
+
if (typeof WeakMap !== "function") return null;
|
|
40
|
+
var cacheBabelInterop = new WeakMap();
|
|
41
|
+
var cacheNodeInterop = new WeakMap();
|
|
42
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
43
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
44
|
+
})(nodeInterop);
|
|
45
|
+
}
|
|
46
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
47
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
51
|
+
return {
|
|
52
|
+
default: obj
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
56
|
+
if (cache && cache.has(obj)) {
|
|
57
|
+
return cache.get(obj);
|
|
58
|
+
}
|
|
59
|
+
var newObj = {
|
|
60
|
+
__proto__: null
|
|
61
|
+
};
|
|
62
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
63
|
+
for(var key in obj){
|
|
64
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
65
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
66
|
+
if (desc && (desc.get || desc.set)) {
|
|
67
|
+
Object.defineProperty(newObj, key, desc);
|
|
68
|
+
} else {
|
|
69
|
+
newObj[key] = obj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
newObj.default = obj;
|
|
74
|
+
if (cache) {
|
|
75
|
+
cache.set(obj, newObj);
|
|
76
|
+
}
|
|
77
|
+
return newObj;
|
|
78
|
+
}
|
|
79
|
+
const PERSES_LOGSTABLE_HINTS_DISMISSED = 'PERSES_LOGSTABLE_HINTS_DISMISSED';
|
|
80
|
+
const COPY_TOAST_DURATION_MS = 5000;
|
|
81
|
+
// Detect Mac for keyboard shortcuts display
|
|
82
|
+
const isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent);
|
|
33
83
|
const VirtualizedLogsList = ({ logs, spec, expandedRows, onToggleExpand })=>{
|
|
34
84
|
const theme = (0, _material.useTheme)();
|
|
85
|
+
const [selectedRows, setSelectedRows] = (0, _react.useState)(new Set());
|
|
86
|
+
const [lastSelectedIndex, setLastSelectedIndex] = (0, _react.useState)(null);
|
|
87
|
+
const selectedRowsRef = (0, _react.useRef)(selectedRows);
|
|
88
|
+
const [copyPopoverAnchor, setCopyPopoverAnchor] = (0, _react.useState)(null);
|
|
89
|
+
const [lastCopiedFormat, setLastCopiedFormat] = (0, _react.useState)('full');
|
|
90
|
+
const [lastCopiedCount, setLastCopiedCount] = (0, _react.useState)(0);
|
|
91
|
+
const copyPopoverTimerRef = (0, _react.useRef)(null);
|
|
92
|
+
const [isHintsDismissed, setIsHintsDismissed] = (0, _react.useState)(()=>{
|
|
93
|
+
try {
|
|
94
|
+
return localStorage.getItem(PERSES_LOGSTABLE_HINTS_DISMISSED) === 'true';
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const selectionEnabled = spec.selection?.enabled ?? false;
|
|
100
|
+
const { setSelection, clearSelection } = (0, _components.useSelection)();
|
|
101
|
+
const allVariables = (0, _pluginsystem.useAllVariableValues)();
|
|
102
|
+
const itemActionsConfig = spec.actions ? spec.actions : undefined;
|
|
103
|
+
const itemActionsListConfig = itemActionsConfig?.enabled && itemActionsConfig.displayWithItem ? itemActionsConfig.actionsList : [];
|
|
104
|
+
const { getItemActionButtons, confirmDialog } = (0, _dashboards.useSelectionItemActions)({
|
|
105
|
+
actions: itemActionsListConfig,
|
|
106
|
+
variableState: allVariables
|
|
107
|
+
});
|
|
108
|
+
(0, _react.useEffect)(()=>{
|
|
109
|
+
selectedRowsRef.current = selectedRows;
|
|
110
|
+
}, [
|
|
111
|
+
selectedRows
|
|
112
|
+
]);
|
|
113
|
+
// Sync local selection state with context when selection is enabled
|
|
114
|
+
(0, _react.useEffect)(()=>{
|
|
115
|
+
if (!selectionEnabled) return;
|
|
116
|
+
if (selectedRows.size === 0) {
|
|
117
|
+
clearSelection();
|
|
118
|
+
} else {
|
|
119
|
+
const selectionItems = Array.from(selectedRows).map((index)=>{
|
|
120
|
+
const log = logs[index];
|
|
121
|
+
return log ? {
|
|
122
|
+
id: index,
|
|
123
|
+
item: log
|
|
124
|
+
} : null;
|
|
125
|
+
}).filter((entry)=>entry !== null);
|
|
126
|
+
setSelection(selectionItems);
|
|
127
|
+
}
|
|
128
|
+
}, [
|
|
129
|
+
selectedRows,
|
|
130
|
+
logs,
|
|
131
|
+
selectionEnabled,
|
|
132
|
+
setSelection,
|
|
133
|
+
clearSelection
|
|
134
|
+
]);
|
|
135
|
+
const handleDismissHints = (0, _react.useCallback)(()=>{
|
|
136
|
+
setIsHintsDismissed(true);
|
|
137
|
+
try {
|
|
138
|
+
localStorage.setItem(PERSES_LOGSTABLE_HINTS_DISMISSED, 'true');
|
|
139
|
+
} catch {
|
|
140
|
+
// Ignore localStorage errors
|
|
141
|
+
}
|
|
142
|
+
}, []);
|
|
143
|
+
const showCopyPopover = (0, _react.useCallback)((format = 'full', count)=>{
|
|
144
|
+
// Show toast at bottom-right corner
|
|
145
|
+
const x = window.innerWidth - 32;
|
|
146
|
+
const y = window.innerHeight - 32;
|
|
147
|
+
setCopyPopoverAnchor({
|
|
148
|
+
x,
|
|
149
|
+
y
|
|
150
|
+
});
|
|
151
|
+
setLastCopiedFormat(format);
|
|
152
|
+
setLastCopiedCount(count);
|
|
153
|
+
// Clear existing timer
|
|
154
|
+
if (copyPopoverTimerRef.current) {
|
|
155
|
+
window.clearTimeout(copyPopoverTimerRef.current);
|
|
156
|
+
}
|
|
157
|
+
// Auto-dismiss after configured duration
|
|
158
|
+
copyPopoverTimerRef.current = window.setTimeout(()=>{
|
|
159
|
+
setCopyPopoverAnchor(null);
|
|
160
|
+
}, COPY_TOAST_DURATION_MS);
|
|
161
|
+
}, []);
|
|
162
|
+
const handleCloseCopyPopover = (0, _react.useCallback)(()=>{
|
|
163
|
+
if (copyPopoverTimerRef.current) {
|
|
164
|
+
window.clearTimeout(copyPopoverTimerRef.current);
|
|
165
|
+
}
|
|
166
|
+
setCopyPopoverAnchor(null);
|
|
167
|
+
}, []);
|
|
168
|
+
const handleCopyInFormat = (0, _react.useCallback)(async (format)=>{
|
|
169
|
+
const selectedLogs = Array.from(selectedRowsRef.current).sort((a, b)=>a - b).map((index)=>logs[index]).filter((log)=>log !== undefined);
|
|
170
|
+
let text;
|
|
171
|
+
if (format === 'message') {
|
|
172
|
+
text = selectedLogs.map(_copyHelpers.formatLogMessage).join('\n');
|
|
173
|
+
} else if (format === 'json') {
|
|
174
|
+
text = JSON.stringify(selectedLogs, null, 2);
|
|
175
|
+
} else {
|
|
176
|
+
text = (0, _copyHelpers.formatLogEntries)(selectedLogs);
|
|
177
|
+
}
|
|
178
|
+
await navigator.clipboard.writeText(text);
|
|
179
|
+
showCopyPopover(format, selectedLogs.length);
|
|
180
|
+
}, [
|
|
181
|
+
logs,
|
|
182
|
+
showCopyPopover
|
|
183
|
+
]);
|
|
184
|
+
const handleRowSelect = (0, _react.useCallback)((index, event)=>{
|
|
185
|
+
if (event.shiftKey) {
|
|
186
|
+
// Prevent text selection during shift-click
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
window.getSelection()?.removeAllRanges();
|
|
189
|
+
if (lastSelectedIndex !== null) {
|
|
190
|
+
// Range selection: select all rows between anchor and current
|
|
191
|
+
const start = Math.min(lastSelectedIndex, index);
|
|
192
|
+
const end = Math.max(lastSelectedIndex, index);
|
|
193
|
+
const newSelection = new Set();
|
|
194
|
+
for(let i = start; i <= end; i++){
|
|
195
|
+
newSelection.add(i);
|
|
196
|
+
}
|
|
197
|
+
setSelectedRows(newSelection);
|
|
198
|
+
} else {
|
|
199
|
+
// No anchor set: just select this row and set as anchor
|
|
200
|
+
const newSelection = new Set([
|
|
201
|
+
index
|
|
202
|
+
]);
|
|
203
|
+
setSelectedRows(newSelection);
|
|
204
|
+
setLastSelectedIndex(index);
|
|
205
|
+
}
|
|
206
|
+
} else if (event.ctrlKey || event.metaKey) {
|
|
207
|
+
// Prevent text selection during cmd/ctrl-click
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
window.getSelection()?.removeAllRanges();
|
|
210
|
+
// Toggle individual row (additive selection)
|
|
211
|
+
const newSelection = new Set(selectedRows);
|
|
212
|
+
if (newSelection.has(index)) {
|
|
213
|
+
newSelection.delete(index);
|
|
214
|
+
} else {
|
|
215
|
+
newSelection.add(index);
|
|
216
|
+
}
|
|
217
|
+
setSelectedRows(newSelection);
|
|
218
|
+
setLastSelectedIndex(index);
|
|
219
|
+
} else {
|
|
220
|
+
// Plain click: set as anchor for future shift-clicks
|
|
221
|
+
// Don't prevent default to allow text selection
|
|
222
|
+
setLastSelectedIndex(index);
|
|
223
|
+
}
|
|
224
|
+
}, [
|
|
225
|
+
selectedRows,
|
|
226
|
+
lastSelectedIndex
|
|
227
|
+
]);
|
|
35
228
|
const renderLogRow = (index)=>{
|
|
36
229
|
const log = logs[index];
|
|
37
230
|
if (!log) return null;
|
|
231
|
+
const itemActionButtons = itemActionsListConfig?.length ? getItemActionButtons({
|
|
232
|
+
id: index,
|
|
233
|
+
data: log
|
|
234
|
+
}) : [];
|
|
38
235
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_LogRow.LogRow, {
|
|
39
236
|
isExpandable: spec.enableDetails,
|
|
40
237
|
log: log,
|
|
@@ -42,23 +239,309 @@ const VirtualizedLogsList = ({ logs, spec, expandedRows, onToggleExpand })=>{
|
|
|
42
239
|
isExpanded: expandedRows.has(index),
|
|
43
240
|
onToggle: onToggleExpand,
|
|
44
241
|
allowWrap: spec.allowWrap,
|
|
45
|
-
showTime: spec.showTime
|
|
242
|
+
showTime: spec.showTime,
|
|
243
|
+
isSelected: selectedRows.has(index),
|
|
244
|
+
onSelect: handleRowSelect,
|
|
245
|
+
itemActionButtons: itemActionButtons
|
|
46
246
|
});
|
|
47
247
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
248
|
+
const handleCopy = (e)=>{
|
|
249
|
+
const selection = window.getSelection();
|
|
250
|
+
const hasTextSelection = selection && selection.rangeCount > 0 && selection.toString().length > 0;
|
|
251
|
+
// If user has text selected, let browser handle it normally
|
|
252
|
+
if (hasTextSelection) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// If rows are selected, copy those
|
|
256
|
+
const currentSelectedRows = selectedRowsRef.current;
|
|
257
|
+
if (currentSelectedRows.size > 0) {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
const selectedLogs = Array.from(currentSelectedRows).sort((a, b)=>a - b).map((index)=>logs[index]).filter((log)=>log !== undefined);
|
|
260
|
+
const formattedText = (0, _copyHelpers.formatLogEntries)(selectedLogs);
|
|
261
|
+
e.clipboardData.setData('text/plain', formattedText);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
// Keyboard shortcuts for selection
|
|
265
|
+
(0, _react.useEffect)(()=>{
|
|
266
|
+
const handleKeyDown = async (e)=>{
|
|
267
|
+
// Cmd/Ctrl+A: Select all logs
|
|
268
|
+
if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
const allIndices = new Set(logs.map((_, index)=>index));
|
|
271
|
+
setSelectedRows(allIndices);
|
|
272
|
+
if (logs.length > 0) {
|
|
273
|
+
setLastSelectedIndex(logs.length - 1);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Cmd/Ctrl+C: Copy selected rows
|
|
277
|
+
if ((e.metaKey || e.ctrlKey) && e.key === 'c') {
|
|
278
|
+
const selection = window.getSelection();
|
|
279
|
+
const hasTextSelection = selection && selection.rangeCount > 0 && selection.toString().length > 0;
|
|
280
|
+
// Only handle if we have selected rows and no text selection
|
|
281
|
+
if (selectedRowsRef.current.size > 0 && !hasTextSelection) {
|
|
282
|
+
e.preventDefault();
|
|
283
|
+
const selectedLogs = Array.from(selectedRowsRef.current).sort((a, b)=>a - b).map((index)=>logs[index]).filter((log)=>log !== undefined);
|
|
284
|
+
const formattedText = (0, _copyHelpers.formatLogEntries)(selectedLogs);
|
|
285
|
+
await navigator.clipboard.writeText(formattedText);
|
|
286
|
+
showCopyPopover('full', selectedLogs.length);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Escape: Clear selection
|
|
290
|
+
if (e.key === 'Escape' && selectedRows.size > 0) {
|
|
291
|
+
setSelectedRows(new Set());
|
|
292
|
+
setLastSelectedIndex(null);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
296
|
+
return ()=>{
|
|
297
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
298
|
+
};
|
|
299
|
+
}, [
|
|
300
|
+
logs,
|
|
301
|
+
selectedRows,
|
|
302
|
+
showCopyPopover
|
|
303
|
+
]);
|
|
304
|
+
// Cleanup timer on unmount
|
|
305
|
+
(0, _react.useEffect)(()=>{
|
|
306
|
+
return ()=>{
|
|
307
|
+
if (copyPopoverTimerRef.current) {
|
|
308
|
+
window.clearTimeout(copyPopoverTimerRef.current);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}, []);
|
|
312
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
313
|
+
children: [
|
|
314
|
+
confirmDialog,
|
|
315
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
316
|
+
sx: {
|
|
317
|
+
height: '100%',
|
|
318
|
+
backgroundColor: theme.palette.background.default,
|
|
319
|
+
overflow: 'hidden',
|
|
320
|
+
boxShadow: theme.shadows[1],
|
|
321
|
+
display: 'flex',
|
|
322
|
+
flexDirection: 'column'
|
|
323
|
+
},
|
|
324
|
+
onCopy: handleCopy,
|
|
325
|
+
children: [
|
|
326
|
+
!isHintsDismissed && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
327
|
+
sx: {
|
|
328
|
+
px: 2,
|
|
329
|
+
py: 0.75,
|
|
330
|
+
fontSize: '12px',
|
|
331
|
+
color: theme.palette.text.secondary,
|
|
332
|
+
backgroundColor: theme.palette.background.paper,
|
|
333
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
334
|
+
display: 'flex',
|
|
335
|
+
alignItems: 'center',
|
|
336
|
+
gap: 2,
|
|
337
|
+
flexShrink: 0
|
|
338
|
+
},
|
|
339
|
+
children: [
|
|
340
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
341
|
+
sx: {
|
|
342
|
+
display: 'flex',
|
|
343
|
+
alignItems: 'center',
|
|
344
|
+
gap: 2,
|
|
345
|
+
flex: 1
|
|
346
|
+
},
|
|
347
|
+
children: [
|
|
348
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
349
|
+
component: "span",
|
|
350
|
+
sx: {
|
|
351
|
+
opacity: 0.8
|
|
352
|
+
},
|
|
353
|
+
children: [
|
|
354
|
+
isMac ? '⌘' : 'Ctrl',
|
|
355
|
+
"+Click to select"
|
|
356
|
+
]
|
|
357
|
+
}),
|
|
358
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
359
|
+
component: "span",
|
|
360
|
+
sx: {
|
|
361
|
+
opacity: 0.6
|
|
362
|
+
},
|
|
363
|
+
children: "•"
|
|
364
|
+
}),
|
|
365
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
366
|
+
component: "span",
|
|
367
|
+
sx: {
|
|
368
|
+
opacity: 0.8
|
|
369
|
+
},
|
|
370
|
+
children: "Shift+Click for range"
|
|
371
|
+
}),
|
|
372
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
373
|
+
component: "span",
|
|
374
|
+
sx: {
|
|
375
|
+
opacity: 0.6
|
|
376
|
+
},
|
|
377
|
+
children: "•"
|
|
378
|
+
}),
|
|
379
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
380
|
+
component: "span",
|
|
381
|
+
sx: {
|
|
382
|
+
opacity: 0.8
|
|
383
|
+
},
|
|
384
|
+
children: [
|
|
385
|
+
isMac ? '⌘' : 'Ctrl',
|
|
386
|
+
"+C to copy"
|
|
387
|
+
]
|
|
388
|
+
}),
|
|
389
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
390
|
+
component: "span",
|
|
391
|
+
sx: {
|
|
392
|
+
opacity: 0.6
|
|
393
|
+
},
|
|
394
|
+
children: "•"
|
|
395
|
+
}),
|
|
396
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
397
|
+
component: "span",
|
|
398
|
+
sx: {
|
|
399
|
+
opacity: 0.8
|
|
400
|
+
},
|
|
401
|
+
children: "Esc to clear"
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
}),
|
|
405
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
406
|
+
size: "small",
|
|
407
|
+
onClick: handleDismissHints,
|
|
408
|
+
sx: {
|
|
409
|
+
opacity: 0.6,
|
|
410
|
+
'&:hover': {
|
|
411
|
+
opacity: 1
|
|
412
|
+
},
|
|
413
|
+
padding: 0.5
|
|
414
|
+
},
|
|
415
|
+
"aria-label": "Dismiss hints",
|
|
416
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {
|
|
417
|
+
sx: {
|
|
418
|
+
fontSize: '16px'
|
|
419
|
+
}
|
|
420
|
+
})
|
|
421
|
+
})
|
|
422
|
+
]
|
|
423
|
+
}),
|
|
424
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactvirtuoso.Virtuoso, {
|
|
425
|
+
style: {
|
|
426
|
+
height: '100%',
|
|
427
|
+
flexGrow: 1
|
|
428
|
+
},
|
|
429
|
+
initialItemCount: spec.showAll ? logs.length : undefined,
|
|
430
|
+
totalCount: logs.length,
|
|
431
|
+
itemContent: renderLogRow
|
|
432
|
+
}),
|
|
433
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Popover, {
|
|
434
|
+
open: Boolean(copyPopoverAnchor),
|
|
435
|
+
anchorReference: "anchorPosition",
|
|
436
|
+
anchorPosition: copyPopoverAnchor ? {
|
|
437
|
+
top: copyPopoverAnchor.y,
|
|
438
|
+
left: copyPopoverAnchor.x
|
|
439
|
+
} : undefined,
|
|
440
|
+
onClose: handleCloseCopyPopover,
|
|
441
|
+
disableScrollLock: true,
|
|
442
|
+
disableAutoFocus: true,
|
|
443
|
+
disableRestoreFocus: true,
|
|
444
|
+
disableEnforceFocus: true,
|
|
445
|
+
anchorOrigin: {
|
|
446
|
+
vertical: 'bottom',
|
|
447
|
+
horizontal: 'right'
|
|
448
|
+
},
|
|
449
|
+
transformOrigin: {
|
|
450
|
+
vertical: 'bottom',
|
|
451
|
+
horizontal: 'right'
|
|
452
|
+
},
|
|
453
|
+
slotProps: {
|
|
454
|
+
paper: {
|
|
455
|
+
sx: {
|
|
456
|
+
px: 2,
|
|
457
|
+
py: 1.5,
|
|
458
|
+
boxShadow: theme.shadows[8],
|
|
459
|
+
borderRadius: 2,
|
|
460
|
+
pointerEvents: 'auto'
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
sx: {
|
|
465
|
+
pointerEvents: 'none'
|
|
466
|
+
},
|
|
467
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
468
|
+
sx: {
|
|
469
|
+
display: 'flex',
|
|
470
|
+
alignItems: 'center',
|
|
471
|
+
gap: 2
|
|
472
|
+
},
|
|
473
|
+
children: [
|
|
474
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
475
|
+
sx: {
|
|
476
|
+
fontSize: '14px',
|
|
477
|
+
color: theme.palette.text.primary,
|
|
478
|
+
fontWeight: 500,
|
|
479
|
+
display: 'flex',
|
|
480
|
+
alignItems: 'center',
|
|
481
|
+
gap: 0.5
|
|
482
|
+
},
|
|
483
|
+
children: [
|
|
484
|
+
"✓ Copied ",
|
|
485
|
+
lastCopiedCount,
|
|
486
|
+
" ",
|
|
487
|
+
lastCopiedCount === 1 ? 'log' : 'logs',
|
|
488
|
+
" as",
|
|
489
|
+
' ',
|
|
490
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
491
|
+
component: "span",
|
|
492
|
+
sx: {
|
|
493
|
+
color: theme.palette.primary.main,
|
|
494
|
+
minWidth: '60px',
|
|
495
|
+
display: 'inline-block'
|
|
496
|
+
},
|
|
497
|
+
children: lastCopiedFormat === 'full' ? 'Full' : lastCopiedFormat === 'message' ? 'Message' : 'JSON'
|
|
498
|
+
})
|
|
499
|
+
]
|
|
500
|
+
}),
|
|
501
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ButtonGroup, {
|
|
502
|
+
size: "small",
|
|
503
|
+
variant: "outlined",
|
|
504
|
+
children: [
|
|
505
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
506
|
+
onClick: ()=>handleCopyInFormat('full'),
|
|
507
|
+
sx: {
|
|
508
|
+
fontSize: '12px',
|
|
509
|
+
textTransform: 'none',
|
|
510
|
+
minWidth: '52px',
|
|
511
|
+
fontWeight: lastCopiedFormat === 'full' ? 600 : 400,
|
|
512
|
+
bgcolor: lastCopiedFormat === 'full' ? theme.palette.action.selected : 'transparent'
|
|
513
|
+
},
|
|
514
|
+
children: "Full"
|
|
515
|
+
}),
|
|
516
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
517
|
+
onClick: ()=>handleCopyInFormat('message'),
|
|
518
|
+
sx: {
|
|
519
|
+
fontSize: '12px',
|
|
520
|
+
textTransform: 'none',
|
|
521
|
+
minWidth: '74px',
|
|
522
|
+
fontWeight: lastCopiedFormat === 'message' ? 600 : 400,
|
|
523
|
+
bgcolor: lastCopiedFormat === 'message' ? theme.palette.action.selected : 'transparent'
|
|
524
|
+
},
|
|
525
|
+
children: "Message"
|
|
526
|
+
}),
|
|
527
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
528
|
+
onClick: ()=>handleCopyInFormat('json'),
|
|
529
|
+
sx: {
|
|
530
|
+
fontSize: '12px',
|
|
531
|
+
textTransform: 'none',
|
|
532
|
+
minWidth: '52px',
|
|
533
|
+
fontWeight: lastCopiedFormat === 'json' ? 600 : 400,
|
|
534
|
+
bgcolor: lastCopiedFormat === 'json' ? theme.palette.action.selected : 'transparent'
|
|
535
|
+
},
|
|
536
|
+
children: "JSON"
|
|
537
|
+
})
|
|
538
|
+
]
|
|
539
|
+
})
|
|
540
|
+
]
|
|
541
|
+
})
|
|
542
|
+
})
|
|
543
|
+
]
|
|
544
|
+
})
|
|
545
|
+
]
|
|
63
546
|
});
|
|
64
547
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useSeverityColor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return useSeverityColor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _utils = require("../utils");
|
|
25
|
+
const useSeverityColor = (log)=>{
|
|
26
|
+
const theme = (0, _material.useTheme)();
|
|
27
|
+
if (!log) {
|
|
28
|
+
return theme.palette.text.secondary;
|
|
29
|
+
}
|
|
30
|
+
const severity = (0, _utils.getSeverity)(log);
|
|
31
|
+
switch(severity){
|
|
32
|
+
case 'critical':
|
|
33
|
+
return theme.palette.error.dark;
|
|
34
|
+
case 'error':
|
|
35
|
+
return theme.palette.error.main;
|
|
36
|
+
case 'warning':
|
|
37
|
+
return theme.palette.warning.main;
|
|
38
|
+
case 'info':
|
|
39
|
+
return theme.palette.info.main;
|
|
40
|
+
case 'debug':
|
|
41
|
+
return theme.palette.primary.main;
|
|
42
|
+
case 'trace':
|
|
43
|
+
return theme.palette.grey[500];
|
|
44
|
+
default:
|
|
45
|
+
return theme.palette.text.secondary;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get getSeverity () {
|
|
25
|
+
return getSeverity;
|
|
26
|
+
},
|
|
27
|
+
get severityAbbreviations () {
|
|
28
|
+
return severityAbbreviations;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const severityAbbreviations = {
|
|
32
|
+
critical: [
|
|
33
|
+
'critical',
|
|
34
|
+
'emerg',
|
|
35
|
+
'fatal',
|
|
36
|
+
'alert',
|
|
37
|
+
'crit'
|
|
38
|
+
],
|
|
39
|
+
error: [
|
|
40
|
+
'error',
|
|
41
|
+
'err',
|
|
42
|
+
'eror'
|
|
43
|
+
],
|
|
44
|
+
debug: [
|
|
45
|
+
'debug',
|
|
46
|
+
'dbug'
|
|
47
|
+
],
|
|
48
|
+
info: [
|
|
49
|
+
'info',
|
|
50
|
+
'inf',
|
|
51
|
+
'information',
|
|
52
|
+
'notice'
|
|
53
|
+
],
|
|
54
|
+
trace: [
|
|
55
|
+
'trace'
|
|
56
|
+
],
|
|
57
|
+
warning: [
|
|
58
|
+
'warn',
|
|
59
|
+
'warning'
|
|
60
|
+
],
|
|
61
|
+
unknown: [
|
|
62
|
+
'unknown'
|
|
63
|
+
],
|
|
64
|
+
other: [
|
|
65
|
+
''
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
const getSeverity = (log)=>{
|
|
69
|
+
const level = log.labels?.level?.toLowerCase();
|
|
70
|
+
if (level) {
|
|
71
|
+
for (const [severity, abbreviations] of Object.entries(severityAbbreviations)){
|
|
72
|
+
if (abbreviations.some((abbr)=>abbr && level.includes(abbr))) {
|
|
73
|
+
return severity;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return 'unknown';
|
|
78
|
+
};
|