@gridsuite/commons-ui 0.35.3 → 0.35.5
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/es/components/FlatParameters/FlatParameters.js +73 -2
- package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +3 -2
- package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +100 -0
- package/es/components/MultipleSelectionDialog/index.js +8 -0
- package/es/components/ReportViewer/filter-button.js +77 -0
- package/es/components/ReportViewer/log-table.js +20 -5
- package/es/components/ReportViewer/multi-select-list.js +56 -0
- package/es/components/ReportViewer/report-viewer.js +14 -1
- package/es/components/TopBar/TopBar.js +1 -1
- package/es/components/translations/flat-parameters-en.js +13 -0
- package/es/components/translations/flat-parameters-fr.js +13 -0
- package/es/components/translations/multiple-selection-dialog-en.js +13 -0
- package/es/components/translations/multiple-selection-dialog-fr.js +13 -0
- package/es/index.js +5 -0
- package/es/utils/ElementType.js +4 -4
- package/package.json +1 -1
|
@@ -10,8 +10,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import React, { useCallback, useState } from 'react';
|
|
13
|
-
import { Autocomplete, Chip, List, ListItem, MenuItem, Select, Switch, TextField, Tooltip, Typography, Divider } from '@mui/material';
|
|
13
|
+
import { Autocomplete, Chip, List, ListItem, MenuItem, Select, Switch, TextField, Tooltip, Typography, Divider, IconButton } from '@mui/material';
|
|
14
|
+
import TuneIcon from '@mui/icons-material/Tune';
|
|
14
15
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
16
|
+
import MultipleSelectionDialog from '../MultipleSelectionDialog/MultipleSelectionDialog';
|
|
15
17
|
var styles = {
|
|
16
18
|
paramList: {
|
|
17
19
|
width: '100%',
|
|
@@ -86,6 +88,8 @@ function longestCommonPrefix(stringList) {
|
|
|
86
88
|
* @param initValues {k:v}
|
|
87
89
|
* @param onChange (paramName, newValue, isInEdition)
|
|
88
90
|
* @param variant style variant for TextField, Autocomplete and Select parameter fields
|
|
91
|
+
* @param showSeparator if true, a separator is added between parameters
|
|
92
|
+
* @param selectionWithDialog {(param: {}) => boolean} if true, param with multiple options use dialog for selection
|
|
89
93
|
*/
|
|
90
94
|
export var FlatParameters = function FlatParameters(_ref) {
|
|
91
95
|
var paramsAsArray = _ref.paramsAsArray,
|
|
@@ -94,7 +98,11 @@ export var FlatParameters = function FlatParameters(_ref) {
|
|
|
94
98
|
_ref$variant = _ref.variant,
|
|
95
99
|
variant = _ref$variant === void 0 ? 'outlined' : _ref$variant,
|
|
96
100
|
_ref$showSeparator = _ref.showSeparator,
|
|
97
|
-
showSeparator = _ref$showSeparator === void 0 ? false : _ref$showSeparator
|
|
101
|
+
showSeparator = _ref$showSeparator === void 0 ? false : _ref$showSeparator,
|
|
102
|
+
_ref$selectionWithDia = _ref.selectionWithDialog,
|
|
103
|
+
selectionWithDialog = _ref$selectionWithDia === void 0 ? function (param) {
|
|
104
|
+
return false;
|
|
105
|
+
} : _ref$selectionWithDia;
|
|
98
106
|
var intl = useIntl();
|
|
99
107
|
var longestPrefix = longestCommonPrefix(paramsAsArray.map(function (m) {
|
|
100
108
|
return m.name;
|
|
@@ -107,12 +115,25 @@ export var FlatParameters = function FlatParameters(_ref) {
|
|
|
107
115
|
var _useState2 = useState(null),
|
|
108
116
|
inEditionParam = _useState2[0],
|
|
109
117
|
setInEditionParam = _useState2[1];
|
|
118
|
+
var _useState3 = useState(false),
|
|
119
|
+
openSelector = _useState3[0],
|
|
120
|
+
setOpenSelector = _useState3[1];
|
|
110
121
|
var getTranslatedValue = useCallback(function (prefix, value) {
|
|
111
122
|
return intl.formatMessage({
|
|
112
123
|
id: prefix + '.' + value,
|
|
113
124
|
defaultMessage: value
|
|
114
125
|
});
|
|
115
126
|
}, [intl]);
|
|
127
|
+
var getSelectionDialogName = useCallback(function (paramName) {
|
|
128
|
+
var defaultMessage = intl.formatMessage({
|
|
129
|
+
id: paramName,
|
|
130
|
+
defaultMessage: paramName.slice(prefix.length)
|
|
131
|
+
});
|
|
132
|
+
return intl.formatMessage({
|
|
133
|
+
id: paramName + '.selectionDialog.name',
|
|
134
|
+
defaultMessage: defaultMessage
|
|
135
|
+
});
|
|
136
|
+
}, [intl, prefix.length]);
|
|
116
137
|
var sortPossibleValues = useCallback(function (prefix, values) {
|
|
117
138
|
if (values == null) {
|
|
118
139
|
return [];
|
|
@@ -183,6 +204,21 @@ export var FlatParameters = function FlatParameters(_ref) {
|
|
|
183
204
|
var outputTransformFloatString = function outputTransformFloatString(value) {
|
|
184
205
|
return (value === null || value === void 0 ? void 0 : value.replace(',', '.')) || '';
|
|
185
206
|
};
|
|
207
|
+
var getStringListValue = function getStringListValue(allValues, selectValues) {
|
|
208
|
+
if (!selectValues || !selectValues.length) {
|
|
209
|
+
return intl.formatMessage({
|
|
210
|
+
id: 'flat_parameters/none'
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (selectValues.length === allValues.length) {
|
|
214
|
+
return intl.formatMessage({
|
|
215
|
+
id: 'flat_parameters/all'
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return intl.formatMessage({
|
|
219
|
+
id: 'flat_parameters/some'
|
|
220
|
+
});
|
|
221
|
+
};
|
|
186
222
|
var renderField = function renderField(param) {
|
|
187
223
|
var fieldValue = mixInitAndDefault(param);
|
|
188
224
|
switch (param.type) {
|
|
@@ -249,6 +285,41 @@ export var FlatParameters = function FlatParameters(_ref) {
|
|
|
249
285
|
});
|
|
250
286
|
case 'STRING_LIST':
|
|
251
287
|
if (param.possibleValues) {
|
|
288
|
+
var allOptions = sortPossibleValues(param.name, param.possibleValues).map(function (_ref2) {
|
|
289
|
+
var id = _ref2.id;
|
|
290
|
+
return id;
|
|
291
|
+
});
|
|
292
|
+
var withDialog = selectionWithDialog(param);
|
|
293
|
+
if (withDialog) {
|
|
294
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
|
|
295
|
+
value: getStringListValue(allOptions, fieldValue),
|
|
296
|
+
size: 'small',
|
|
297
|
+
variant: variant,
|
|
298
|
+
InputProps: {
|
|
299
|
+
readOnly: true,
|
|
300
|
+
endAdornment: /*#__PURE__*/React.createElement(IconButton, {
|
|
301
|
+
onClick: function onClick() {
|
|
302
|
+
return setOpenSelector(true);
|
|
303
|
+
}
|
|
304
|
+
}, /*#__PURE__*/React.createElement(TuneIcon, null))
|
|
305
|
+
}
|
|
306
|
+
}), /*#__PURE__*/React.createElement(MultipleSelectionDialog, {
|
|
307
|
+
options: allOptions,
|
|
308
|
+
titleId: getSelectionDialogName(param.name),
|
|
309
|
+
open: openSelector,
|
|
310
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
311
|
+
return getTranslatedValue(param.name, option);
|
|
312
|
+
},
|
|
313
|
+
selectedOptions: fieldValue,
|
|
314
|
+
handleClose: function handleClose() {
|
|
315
|
+
return setOpenSelector(false);
|
|
316
|
+
},
|
|
317
|
+
handleValidate: function handleValidate(selectedOptions) {
|
|
318
|
+
onFieldChange(selectedOptions, param);
|
|
319
|
+
setOpenSelector(false);
|
|
320
|
+
}
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
252
323
|
return /*#__PURE__*/React.createElement(Autocomplete, {
|
|
253
324
|
fullWidth: true,
|
|
254
325
|
multiple: true,
|
|
@@ -681,7 +681,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
681
681
|
key: {
|
|
682
682
|
dataKey: dataKey
|
|
683
683
|
}
|
|
684
|
-
})) : _this3.simpleHeaderRenderer(_extends({}, headerProps)));
|
|
684
|
+
})) : _this3.simpleHeaderRenderer(_extends({}, headerProps)), columns[columnIndex].extra && columns[columnIndex].extra);
|
|
685
685
|
};
|
|
686
686
|
};
|
|
687
687
|
_proto.render = function render() {
|
|
@@ -761,7 +761,8 @@ MuiVirtualizedTable.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
761
761
|
minWidth: PropTypes.number,
|
|
762
762
|
maxWidth: PropTypes.number,
|
|
763
763
|
unit: PropTypes.string,
|
|
764
|
-
fractionDigits: PropTypes.number
|
|
764
|
+
fractionDigits: PropTypes.number,
|
|
765
|
+
extra: PropTypes.element
|
|
765
766
|
})).isRequired,
|
|
766
767
|
enableExportCSV: PropTypes.bool,
|
|
767
768
|
exportCSVDataKeys: PropTypes.array,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Dialog, DialogContent, Divider } from '@mui/material';
|
|
9
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
12
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
15
|
+
import Button from '@mui/material/Button';
|
|
16
|
+
import Grid from '@mui/material/Grid';
|
|
17
|
+
var MultipleSelectionDialog = function MultipleSelectionDialog(_ref) {
|
|
18
|
+
var options = _ref.options,
|
|
19
|
+
selectedOptions = _ref.selectedOptions,
|
|
20
|
+
open = _ref.open,
|
|
21
|
+
getOptionLabel = _ref.getOptionLabel,
|
|
22
|
+
handleClose = _ref.handleClose,
|
|
23
|
+
handleValidate = _ref.handleValidate,
|
|
24
|
+
titleId = _ref.titleId;
|
|
25
|
+
var _useState = useState(selectedOptions !== null && selectedOptions !== void 0 ? selectedOptions : []),
|
|
26
|
+
selectedIds = _useState[0],
|
|
27
|
+
setSelectedIds = _useState[1];
|
|
28
|
+
var handleSelectAll = function handleSelectAll() {
|
|
29
|
+
if (selectedIds.length !== options.length) {
|
|
30
|
+
setSelectedIds(options);
|
|
31
|
+
} else {
|
|
32
|
+
setSelectedIds([]);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var handleOptionSelection = function handleOptionSelection(option) {
|
|
36
|
+
setSelectedIds(function (oldValues) {
|
|
37
|
+
if (oldValues.includes(option)) {
|
|
38
|
+
return oldValues.filter(function (o) {
|
|
39
|
+
return o !== option;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return [].concat(oldValues, [option]);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
return /*#__PURE__*/React.createElement(Dialog, {
|
|
46
|
+
open: open,
|
|
47
|
+
fullWidth: true,
|
|
48
|
+
maxWidth: 'lg'
|
|
49
|
+
}, /*#__PURE__*/React.createElement(DialogTitle, null, titleId), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Grid, {
|
|
50
|
+
container: true,
|
|
51
|
+
spacing: 2
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
53
|
+
item: true,
|
|
54
|
+
xs: 12
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Divider, null, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
56
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
57
|
+
id: 'multiple_selection_dialog/selectAll'
|
|
58
|
+
}),
|
|
59
|
+
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
60
|
+
checked: selectedIds.length === options.length,
|
|
61
|
+
indeterminate: selectedIds.length && selectedIds.length !== options.length,
|
|
62
|
+
onChange: handleSelectAll
|
|
63
|
+
})
|
|
64
|
+
}))), options.map(function (option, index) {
|
|
65
|
+
var _option$id;
|
|
66
|
+
var optionId = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option;
|
|
67
|
+
var label = getOptionLabel(option);
|
|
68
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
69
|
+
key: optionId
|
|
70
|
+
}, /*#__PURE__*/React.createElement(Grid, {
|
|
71
|
+
item: true,
|
|
72
|
+
xs: 4
|
|
73
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
74
|
+
label: label,
|
|
75
|
+
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
76
|
+
checked: selectedIds.includes(optionId),
|
|
77
|
+
onChange: function onChange() {
|
|
78
|
+
return handleOptionSelection(optionId);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
})), (index + 1) % 3 === 0 && /*#__PURE__*/React.createElement(Grid, {
|
|
82
|
+
item: true,
|
|
83
|
+
xs: 12,
|
|
84
|
+
key: index
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Divider, null)));
|
|
86
|
+
}))), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
87
|
+
onClick: function onClick() {
|
|
88
|
+
return handleClose();
|
|
89
|
+
}
|
|
90
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
91
|
+
id: 'multiple_selection_dialog/cancel'
|
|
92
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
93
|
+
onClick: function onClick() {
|
|
94
|
+
return handleValidate(selectedIds);
|
|
95
|
+
}
|
|
96
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
97
|
+
id: 'multiple_selection_dialog/validate'
|
|
98
|
+
}))));
|
|
99
|
+
};
|
|
100
|
+
export default MultipleSelectionDialog;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { default } from './MultipleSelectionDialog';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
4
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
|
+
*/
|
|
8
|
+
import React, { useMemo, useState } from 'react';
|
|
9
|
+
import { Box, IconButton } from '@mui/material';
|
|
10
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
11
|
+
import { MultiSelectList } from './multi-select-list';
|
|
12
|
+
var styles = {
|
|
13
|
+
notificationDot: {
|
|
14
|
+
height: '6px',
|
|
15
|
+
width: '6px',
|
|
16
|
+
backgroundColor: '#cc70a0',
|
|
17
|
+
borderRadius: '50%',
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
top: '5px',
|
|
20
|
+
left: '23px'
|
|
21
|
+
},
|
|
22
|
+
container: {
|
|
23
|
+
position: 'relative'
|
|
24
|
+
},
|
|
25
|
+
icon: {
|
|
26
|
+
width: '0.7em',
|
|
27
|
+
height: '0.7em'
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* FilterButton wraps a MultiSelectList with a button which has a visual indication to indicate when the user alters the default state of the list
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} selectedItems - It serves as the model and data of the Component each entry must be formatted as a pair of string and boolean. Each key will be displayed and the corresponding boolean is updated in function of its checkbox status
|
|
35
|
+
* @param {Function} setSelectedItems - Setter needed to update the list underlying data
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export var FilterButton = function FilterButton(_ref) {
|
|
39
|
+
var selectedItems = _ref.selectedItems,
|
|
40
|
+
setSelectedItems = _ref.setSelectedItems;
|
|
41
|
+
var _useState = useState(selectedItems),
|
|
42
|
+
initialState = _useState[0];
|
|
43
|
+
var _useState2 = useState(),
|
|
44
|
+
anchorEl = _useState2[0],
|
|
45
|
+
setAnchorEl = _useState2[1];
|
|
46
|
+
var handleClick = function handleClick(event) {
|
|
47
|
+
setAnchorEl(event.currentTarget);
|
|
48
|
+
};
|
|
49
|
+
var handleClose = function handleClose() {
|
|
50
|
+
setAnchorEl(null);
|
|
51
|
+
};
|
|
52
|
+
var handleChange = function handleChange(event) {
|
|
53
|
+
setSelectedItems(function (previousSelection) {
|
|
54
|
+
var _extends2;
|
|
55
|
+
return _extends({}, previousSelection, (_extends2 = {}, _extends2[event.target.name] = !selectedItems[event.target.name], _extends2));
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var isInitialStateModified = useMemo(function () {
|
|
59
|
+
return Object.keys(selectedItems).some(function (key) {
|
|
60
|
+
return initialState[key] !== selectedItems[key];
|
|
61
|
+
});
|
|
62
|
+
}, [initialState, selectedItems]);
|
|
63
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
64
|
+
sx: styles.container
|
|
65
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
66
|
+
onClick: handleClick
|
|
67
|
+
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
68
|
+
sx: styles.icon
|
|
69
|
+
}), isInitialStateModified && /*#__PURE__*/React.createElement(Box, {
|
|
70
|
+
sx: styles.notificationDot
|
|
71
|
+
})), /*#__PURE__*/React.createElement(MultiSelectList, {
|
|
72
|
+
selectedItems: selectedItems,
|
|
73
|
+
handleChange: handleChange,
|
|
74
|
+
handleClose: handleClose,
|
|
75
|
+
anchor: anchorEl
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
|
-
import React, { memo, useEffect, useState } from 'react';
|
|
7
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
8
8
|
import { useIntl } from 'react-intl';
|
|
9
9
|
import TableCell from '@mui/material/TableCell';
|
|
10
10
|
import { styled } from '@mui/system';
|
|
11
11
|
import MuiVirtualizedTable from '../MuiVirtualizedTable';
|
|
12
12
|
import { useTheme } from '@mui/material/styles';
|
|
13
|
-
|
|
13
|
+
import { FilterButton } from './filter-button';
|
|
14
|
+
var SEVERITY_COLUMN_FIXED_WIDTH = 115;
|
|
14
15
|
var styles = {
|
|
15
16
|
flexContainer: {
|
|
16
17
|
display: 'flex',
|
|
@@ -34,7 +35,9 @@ var styles = {
|
|
|
34
35
|
var VirtualizedTable = styled(MuiVirtualizedTable)(styles);
|
|
35
36
|
var LogTable = function LogTable(_ref) {
|
|
36
37
|
var logs = _ref.logs,
|
|
37
|
-
onRowClick = _ref.onRowClick
|
|
38
|
+
onRowClick = _ref.onRowClick,
|
|
39
|
+
selectedSeverity = _ref.selectedSeverity,
|
|
40
|
+
setSelectedSeverity = _ref.setSelectedSeverity;
|
|
38
41
|
var intl = useIntl();
|
|
39
42
|
var theme = useTheme();
|
|
40
43
|
var _useState = useState(-1),
|
|
@@ -60,7 +63,11 @@ var LogTable = function LogTable(_ref) {
|
|
|
60
63
|
dataKey: 'severity',
|
|
61
64
|
maxWidth: SEVERITY_COLUMN_FIXED_WIDTH,
|
|
62
65
|
minWidth: SEVERITY_COLUMN_FIXED_WIDTH,
|
|
63
|
-
cellRenderer: severityCellRender
|
|
66
|
+
cellRenderer: severityCellRender,
|
|
67
|
+
extra: /*#__PURE__*/React.createElement(FilterButton, {
|
|
68
|
+
selectedItems: selectedSeverity,
|
|
69
|
+
setSelectedItems: setSelectedSeverity
|
|
70
|
+
})
|
|
64
71
|
}, {
|
|
65
72
|
label: intl.formatMessage({
|
|
66
73
|
id: 'report_viewer/message'
|
|
@@ -100,6 +107,13 @@ var LogTable = function LogTable(_ref) {
|
|
|
100
107
|
useEffect(function () {
|
|
101
108
|
setSelectedRowIndex(-1);
|
|
102
109
|
}, [logs]);
|
|
110
|
+
var filter = useCallback(function (row) {
|
|
111
|
+
return row.severity && Object.entries(selectedSeverity).some(function (_ref2) {
|
|
112
|
+
var key = _ref2[0],
|
|
113
|
+
value = _ref2[1];
|
|
114
|
+
return key === row.severity && value;
|
|
115
|
+
});
|
|
116
|
+
}, [selectedSeverity]);
|
|
103
117
|
return (
|
|
104
118
|
/*#__PURE__*/
|
|
105
119
|
//TODO do we need to useMemo/useCallback these props to avoid rerenders ?
|
|
@@ -108,7 +122,8 @@ var LogTable = function LogTable(_ref) {
|
|
|
108
122
|
rows: generateTableRows(),
|
|
109
123
|
sortable: false,
|
|
110
124
|
onRowClick: handleRowClick,
|
|
111
|
-
rowStyle: rowStyleFormat
|
|
125
|
+
rowStyle: rowStyleFormat,
|
|
126
|
+
filter: filter
|
|
112
127
|
})
|
|
113
128
|
);
|
|
114
129
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import Menu from '@mui/material/Menu';
|
|
9
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
10
|
+
import { Checkbox, FormControlLabel } from '@mui/material';
|
|
11
|
+
var styles = {
|
|
12
|
+
label: {
|
|
13
|
+
width: '100%',
|
|
14
|
+
margin: 0
|
|
15
|
+
},
|
|
16
|
+
menuItem: {
|
|
17
|
+
padding: '0 10px 0 0'
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* MultiSelectList allows to manipulate an object where each keys are associated to a boolean in order to determine which are the ones the user wants to select
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} selectedItems - It serves as the model and data of the Component each entry must be formatted as a pair of string and boolean. Each key will be displayed and the corresponding boolean is updated in function of its checkbox status
|
|
25
|
+
* @param {Function} handleChange - Allows to customise the behaviour on selection change
|
|
26
|
+
* @param {Function} handleClose - Allows to customise the behaviour when the menu is closing
|
|
27
|
+
* @param {Object} anchor - Determines where the menu will appear on screen
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export var MultiSelectList = function MultiSelectList(_ref) {
|
|
31
|
+
var selectedItems = _ref.selectedItems,
|
|
32
|
+
handleChange = _ref.handleChange,
|
|
33
|
+
handleClose = _ref.handleClose,
|
|
34
|
+
anchor = _ref.anchor;
|
|
35
|
+
var open = Boolean(anchor);
|
|
36
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
37
|
+
open: open,
|
|
38
|
+
onClose: handleClose,
|
|
39
|
+
anchorEl: anchor
|
|
40
|
+
}, Object.entries(selectedItems).map(function (_ref2) {
|
|
41
|
+
var key = _ref2[0],
|
|
42
|
+
value = _ref2[1];
|
|
43
|
+
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
44
|
+
sx: styles.menuItem,
|
|
45
|
+
key: key
|
|
46
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
47
|
+
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
48
|
+
checked: value,
|
|
49
|
+
onChange: handleChange,
|
|
50
|
+
name: key
|
|
51
|
+
}),
|
|
52
|
+
label: key,
|
|
53
|
+
sx: styles.label
|
|
54
|
+
}));
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
@@ -14,6 +14,7 @@ import LogReport from './log-report';
|
|
|
14
14
|
import Grid from '@mui/material/Grid';
|
|
15
15
|
import LogTable from './log-table';
|
|
16
16
|
import ReportTreeViewContext from './report-tree-view-context';
|
|
17
|
+
import LogReportItem from './log-report-item';
|
|
17
18
|
var MAX_SUB_REPORTS = 500;
|
|
18
19
|
var styles = {
|
|
19
20
|
treeView: {
|
|
@@ -43,6 +44,16 @@ export default function ReportViewer(_ref) {
|
|
|
43
44
|
var rootReport = useRef(null);
|
|
44
45
|
var allReports = useRef({});
|
|
45
46
|
var treeView = useRef(null);
|
|
47
|
+
var defaultSeverityFilter = useMemo(function () {
|
|
48
|
+
var filterConfig = {};
|
|
49
|
+
Object.values(LogReportItem.SEVERITY).forEach(function (severity) {
|
|
50
|
+
filterConfig[severity.name] = true;
|
|
51
|
+
});
|
|
52
|
+
return filterConfig;
|
|
53
|
+
}, []);
|
|
54
|
+
var _useState5 = useState(defaultSeverityFilter),
|
|
55
|
+
selectedSeverity = _useState5[0],
|
|
56
|
+
setSelectedSeverity = _useState5[1];
|
|
46
57
|
var createReporterItem = useCallback(function (logReport) {
|
|
47
58
|
allReports.current[logReport.getId()] = logReport;
|
|
48
59
|
if (logReport.getSubReports().length > maxSubReports) {
|
|
@@ -149,6 +160,8 @@ export default function ReportViewer(_ref) {
|
|
|
149
160
|
}
|
|
150
161
|
}, /*#__PURE__*/React.createElement(LogTable, {
|
|
151
162
|
logs: logs,
|
|
152
|
-
onRowClick: onRowClick
|
|
163
|
+
onRowClick: onRowClick,
|
|
164
|
+
selectedSeverity: selectedSeverity,
|
|
165
|
+
setSelectedSeverity: setSelectedSeverity
|
|
153
166
|
})));
|
|
154
167
|
}
|
|
@@ -260,7 +260,7 @@ var TopBar = function TopBar(_ref2) {
|
|
|
260
260
|
useEffect(function () {
|
|
261
261
|
if (user && withElementsSearch && !searchDisabled) {
|
|
262
262
|
var openSearch = function openSearch(e) {
|
|
263
|
-
if (e.ctrlKey && e.
|
|
263
|
+
if (e.ctrlKey && e.key === 'F') {
|
|
264
264
|
e.preventDefault();
|
|
265
265
|
setDialogSearchOpen(true);
|
|
266
266
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var flat_parameters_en = {
|
|
9
|
+
'flat_parameters/none': 'None',
|
|
10
|
+
'flat_parameters/some': 'Some',
|
|
11
|
+
'flat_parameters/all': 'All'
|
|
12
|
+
};
|
|
13
|
+
export default flat_parameters_en;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var flat_parameters_fr = {
|
|
9
|
+
'flat_parameters/none': 'Aucune',
|
|
10
|
+
'flat_parameters/some': 'Quelques-unes',
|
|
11
|
+
'flat_parameters/all': 'Toutes'
|
|
12
|
+
};
|
|
13
|
+
export default flat_parameters_fr;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var multiple_selection_dialog_en = {
|
|
9
|
+
'multiple_selection_dialog/cancel': 'Cancel',
|
|
10
|
+
'multiple_selection_dialog/validate': 'Validate',
|
|
11
|
+
'multiple_selection_dialog/selectAll': 'Select all'
|
|
12
|
+
};
|
|
13
|
+
export default multiple_selection_dialog_en;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023, RTE (http://www.rte-france.com)
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var multiple_selection_dialog_fr = {
|
|
9
|
+
'multiple_selection_dialog/cancel': 'Annuler',
|
|
10
|
+
'multiple_selection_dialog/validate': 'Valider',
|
|
11
|
+
'multiple_selection_dialog/selectAll': 'Tout sélectionner'
|
|
12
|
+
};
|
|
13
|
+
export default multiple_selection_dialog_fr;
|
package/es/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { default as ReportViewerDialog } from './components/ReportViewerDialog';
|
|
|
16
16
|
export { default as OverflowableText } from './components/OverflowableText';
|
|
17
17
|
export { default as ElementSearchDialog } from './components/ElementSearchDialog';
|
|
18
18
|
export { default as FlatParameters } from './components/FlatParameters';
|
|
19
|
+
export { default as MultipleSelectionDialog } from './components/MultipleSelectionDialog';
|
|
19
20
|
export { EQUIPMENT_TYPE, getEquipmentsInfosForSearchBar, equipmentStyles } from './utils/EquipmentType';
|
|
20
21
|
export { initializeAuthenticationDev, initializeAuthenticationProd, logout, dispatchUser, getPreLoginPath } from './utils/AuthService';
|
|
21
22
|
export { elementType, getFileIcon } from './utils/ElementType';
|
|
@@ -38,6 +39,10 @@ export { default as equipment_search_en } from './components/translations/equipm
|
|
|
38
39
|
export { default as equipment_search_fr } from './components/translations/equipment-search-fr';
|
|
39
40
|
export { default as card_error_boundary_en } from './components/translations/card-error-boundary-en';
|
|
40
41
|
export { default as card_error_boundary_fr } from './components/translations/card-error-boundary-fr';
|
|
42
|
+
export { default as flat_parameters_en } from './components/translations/flat-parameters-en';
|
|
43
|
+
export { default as flat_parameters_fr } from './components/translations/flat-parameters-fr';
|
|
44
|
+
export { default as multiple_selection_dialog_en } from './components/translations/multiple-selection-dialog-en';
|
|
45
|
+
export { default as multiple_selection_dialog_fr } from './components/translations/multiple-selection-dialog-fr';
|
|
41
46
|
export { TagRenderer } from './components/ElementSearchDialog';
|
|
42
47
|
export { EquipmentItem } from './components/ElementSearchDialog/equipment-item';
|
|
43
48
|
export { default as CardErrorBoundary } from './components/CardErrorBoundary';
|
package/es/utils/ElementType.js
CHANGED
|
@@ -14,19 +14,19 @@ export var elementType = {
|
|
|
14
14
|
FILTER: 'FILTER',
|
|
15
15
|
CONTINGENCY_LIST: 'CONTINGENCY_LIST'
|
|
16
16
|
};
|
|
17
|
-
export function getFileIcon(type,
|
|
17
|
+
export function getFileIcon(type, style) {
|
|
18
18
|
switch (type) {
|
|
19
19
|
case elementType.STUDY:
|
|
20
20
|
return /*#__PURE__*/React.createElement(LibraryBooksOutlinedIcon, {
|
|
21
|
-
|
|
21
|
+
sx: style
|
|
22
22
|
});
|
|
23
23
|
case elementType.CONTINGENCY_LIST:
|
|
24
24
|
return /*#__PURE__*/React.createElement(OfflineBoltIcon, {
|
|
25
|
-
|
|
25
|
+
sx: style
|
|
26
26
|
});
|
|
27
27
|
case elementType.FILTER:
|
|
28
28
|
return /*#__PURE__*/React.createElement(ArticleIcon, {
|
|
29
|
-
|
|
29
|
+
sx: style
|
|
30
30
|
});
|
|
31
31
|
case elementType.DIRECTORY:
|
|
32
32
|
// to easily use in TreeView we do not give icons for directories
|