@gridsuite/commons-ui 0.23.0 → 0.25.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/lib/components/ElementSearchDialog/element-search-dialog.js +20 -20
- package/lib/components/ElementSearchDialog/equipment-item.js +5 -3
- package/lib/components/MuiVirtualizedTable/MuiVirtualizedTable.js +12 -3
- package/lib/components/OverflowableText/overflowable-text.js +6 -4
- package/lib/components/ReportViewer/log-table.js +1 -0
- package/lib/components/TopBar/TopBar.js +9 -3
- package/lib/components/TreeViewFinder/TreeViewFinder.js +8 -5
- package/lib/components/translations/card-error-boundary-en.js +7 -0
- package/lib/components/translations/card-error-boundary-fr.js +7 -0
- package/lib/components/translations/element-search-en.js +7 -0
- package/lib/components/translations/element-search-fr.js +7 -0
- package/lib/components/translations/equipment-search-en.js +7 -0
- package/lib/components/translations/equipment-search-fr.js +7 -0
- package/lib/components/translations/login-en.js +7 -0
- package/lib/components/translations/login-fr.js +7 -0
- package/lib/components/translations/report-viewer-en.js +7 -0
- package/lib/components/translations/report-viewer-fr.js +7 -0
- package/lib/components/translations/table-en.js +7 -0
- package/lib/components/translations/table-fr.js +7 -0
- package/lib/components/translations/top-bar-en.js +7 -0
- package/lib/components/translations/top-bar-fr.js +7 -0
- package/lib/components/translations/treeview-finder-en.js +7 -0
- package/lib/components/translations/treeview-finder-fr.js +7 -0
- package/lib/hooks/useImportExportParams.js +155 -0
- package/lib/index.js +5 -1
- package/lib/utils/AuthService.js +9 -0
- package/package.json +1 -1
|
@@ -31,23 +31,20 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
|
31
31
|
onSearchTermChange = props.onSearchTermChange,
|
|
32
32
|
onSelectionChange = props.onSelectionChange,
|
|
33
33
|
elementsFound = props.elementsFound,
|
|
34
|
-
renderElement = props.renderElement
|
|
34
|
+
renderElement = props.renderElement,
|
|
35
|
+
searchTermDisabled = props.searchTermDisabled,
|
|
36
|
+
initialSearchTerm = props.initialSearchTerm;
|
|
35
37
|
|
|
36
|
-
var _useState = (0, _react.useState)(
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
var _useState = (0, _react.useState)(false),
|
|
39
|
+
expanded = _useState[0],
|
|
40
|
+
setExpanded = _useState[1];
|
|
39
41
|
|
|
40
42
|
var _useState2 = (0, _react.useState)(false),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var _useState3 = (0, _react.useState)(false),
|
|
45
|
-
loading = _useState3[0],
|
|
46
|
-
setLoading = _useState3[1];
|
|
43
|
+
loading = _useState2[0],
|
|
44
|
+
setLoading = _useState2[1];
|
|
47
45
|
|
|
48
46
|
(0, _react.useEffect)(function () {
|
|
49
47
|
setLoading(false);
|
|
50
|
-
setElements(elementsFound);
|
|
51
48
|
}, [elementsFound]);
|
|
52
49
|
|
|
53
50
|
var handleSearchTermChange = function handleSearchTermChange(term) {
|
|
@@ -56,14 +53,12 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
|
56
53
|
onSearchTermChange(term);
|
|
57
54
|
setExpanded(true);
|
|
58
55
|
} else {
|
|
59
|
-
setElements([]);
|
|
60
56
|
setExpanded(false);
|
|
61
57
|
}
|
|
62
58
|
};
|
|
63
59
|
|
|
64
60
|
var handleClose = (0, _react.useCallback)(function () {
|
|
65
61
|
setExpanded(false);
|
|
66
|
-
setElements([]);
|
|
67
62
|
onClose();
|
|
68
63
|
}, [onClose]);
|
|
69
64
|
return /*#__PURE__*/_react["default"].createElement(_material.Dialog, {
|
|
@@ -76,15 +71,14 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
|
76
71
|
id: "element-search",
|
|
77
72
|
forcePopupIcon: false,
|
|
78
73
|
open: expanded,
|
|
79
|
-
onOpen: function onOpen() {
|
|
80
|
-
setElements([]);
|
|
81
|
-
},
|
|
82
74
|
onClose: function onClose() {
|
|
83
75
|
setExpanded(false);
|
|
84
76
|
},
|
|
85
77
|
fullWidth: true,
|
|
86
78
|
onInputChange: function onInputChange(_event, value) {
|
|
87
|
-
|
|
79
|
+
if (!searchTermDisabled) {
|
|
80
|
+
handleSearchTermChange(value);
|
|
81
|
+
}
|
|
88
82
|
},
|
|
89
83
|
onChange: function onChange(_event, newValue) {
|
|
90
84
|
return onSelectionChange(newValue);
|
|
@@ -95,7 +89,7 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
|
95
89
|
isOptionEqualToValue: function isOptionEqualToValue(option, value) {
|
|
96
90
|
return option.id === value.id;
|
|
97
91
|
},
|
|
98
|
-
options:
|
|
92
|
+
options: loading ? [] : elementsFound,
|
|
99
93
|
loading: loading,
|
|
100
94
|
autoHighlight: true,
|
|
101
95
|
noOptionsText: intl.formatMessage({
|
|
@@ -122,7 +116,11 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
|
|
|
122
116
|
}), params.InputProps.startAdornment)
|
|
123
117
|
})
|
|
124
118
|
}));
|
|
125
|
-
}
|
|
119
|
+
},
|
|
120
|
+
defaultValue: searchTermDisabled ? {
|
|
121
|
+
label: initialSearchTerm
|
|
122
|
+
} : null,
|
|
123
|
+
disabled: searchTermDisabled
|
|
126
124
|
})));
|
|
127
125
|
};
|
|
128
126
|
|
|
@@ -133,7 +131,9 @@ ElementSearchDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
133
131
|
onSearchTermChange: _propTypes["default"].func.isRequired,
|
|
134
132
|
onSelectionChange: _propTypes["default"].func.isRequired,
|
|
135
133
|
elementsFound: _propTypes["default"].array.isRequired,
|
|
136
|
-
renderElement: _propTypes["default"].func.isRequired
|
|
134
|
+
renderElement: _propTypes["default"].func.isRequired,
|
|
135
|
+
searchTermDisabled: _propTypes["default"].bool,
|
|
136
|
+
initialSearchTerm: _propTypes["default"].string
|
|
137
137
|
} : {};
|
|
138
138
|
var _default = ElementSearchDialog;
|
|
139
139
|
exports["default"] = _default;
|
|
@@ -19,7 +19,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _EquipmentType = require("../../utils/EquipmentType");
|
|
21
21
|
|
|
22
|
-
var _excluded = ["inputValue", "suffixRenderer", "element"];
|
|
22
|
+
var _excluded = ["inputValue", "suffixRenderer", "element", "showsJustText"];
|
|
23
23
|
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
25
|
|
|
@@ -32,6 +32,8 @@ var EquipmentItem = function EquipmentItem(_ref) {
|
|
|
32
32
|
_ref$suffixRenderer = _ref.suffixRenderer,
|
|
33
33
|
suffixRenderer = _ref$suffixRenderer === void 0 ? _index.TagRenderer : _ref$suffixRenderer,
|
|
34
34
|
element = _ref.element,
|
|
35
|
+
_ref$showsJustText = _ref.showsJustText,
|
|
36
|
+
showsJustText = _ref$showsJustText === void 0 ? false : _ref$showsJustText,
|
|
35
37
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
36
38
|
|
|
37
39
|
var matches = (0, _match["default"])(element.label, inputValue, {
|
|
@@ -45,7 +47,7 @@ var EquipmentItem = function EquipmentItem(_ref) {
|
|
|
45
47
|
key: element.key
|
|
46
48
|
}, props), /*#__PURE__*/_react["default"].createElement("div", {
|
|
47
49
|
className: props.classes.equipmentOption
|
|
48
|
-
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
50
|
+
}, !showsJustText && /*#__PURE__*/_react["default"].createElement("span", {
|
|
49
51
|
className: (0, _clsx["default"])(props.classes.equipmentTag, props.classes.equipmentTypeTag)
|
|
50
52
|
}, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
51
53
|
id: _EquipmentType.EQUIPMENT_TYPE[element.type].tagLabel
|
|
@@ -61,7 +63,7 @@ var EquipmentItem = function EquipmentItem(_ref) {
|
|
|
61
63
|
fontWeight: part.highlight ? 'bold' : 'inherit'
|
|
62
64
|
}
|
|
63
65
|
}, part.text);
|
|
64
|
-
})), suffixRenderer({
|
|
66
|
+
})), !showsJustText && suffixRenderer({
|
|
65
67
|
props: props,
|
|
66
68
|
element: element
|
|
67
69
|
})));
|
|
@@ -27,6 +27,8 @@ var _reactIntl = require("react-intl");
|
|
|
27
27
|
|
|
28
28
|
var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
|
|
29
29
|
|
|
30
|
+
var _overflowableText = _interopRequireDefault(require("../OverflowableText/overflowable-text"));
|
|
31
|
+
|
|
30
32
|
var _excluded = ["name", "classes", "rows", "columns", "rowHeight", "headerHeight", "rowCount", "sortable", "enableExportCSV"],
|
|
31
33
|
_excluded2 = ["dataKey"];
|
|
32
34
|
|
|
@@ -93,7 +95,11 @@ var defaultStyles = {
|
|
|
93
95
|
fontWeight: 'bold'
|
|
94
96
|
},
|
|
95
97
|
rowBackgroundDark: {},
|
|
96
|
-
rowBackgroundLight: {}
|
|
98
|
+
rowBackgroundLight: {},
|
|
99
|
+
cellTooltip: {
|
|
100
|
+
maxWidth: '1260px',
|
|
101
|
+
fontSize: '0.9rem'
|
|
102
|
+
}
|
|
97
103
|
};
|
|
98
104
|
|
|
99
105
|
var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -242,7 +248,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
242
248
|
variant: "body",
|
|
243
249
|
style: {
|
|
244
250
|
height: rowHeight,
|
|
245
|
-
|
|
251
|
+
width: '100%'
|
|
246
252
|
},
|
|
247
253
|
align: columnIndex != null && columns[columnIndex].numeric || false ? 'right' : 'left',
|
|
248
254
|
onClick: function onClick() {
|
|
@@ -250,7 +256,10 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
250
256
|
onCellClick(rows[rowIndex], columns[columnIndex]);
|
|
251
257
|
}
|
|
252
258
|
}
|
|
253
|
-
},
|
|
259
|
+
}, /*#__PURE__*/_react["default"].createElement(_overflowableText["default"], {
|
|
260
|
+
text: displayedValue,
|
|
261
|
+
tooltipStyle: classes.cellTooltip
|
|
262
|
+
}));
|
|
254
263
|
});
|
|
255
264
|
|
|
256
265
|
_defineProperty(_assertThisInitialized(_this), "headerRenderer", function (_ref4) {
|
|
@@ -13,7 +13,7 @@ var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
|
|
|
13
13
|
|
|
14
14
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
15
15
|
|
|
16
|
-
var _excluded = ["text", "className", "children"];
|
|
16
|
+
var _excluded = ["text", "tooltipStyle", "className", "children"];
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
@@ -29,12 +29,12 @@ var overflowStyle = function overflowStyle(theme) {
|
|
|
29
29
|
return {
|
|
30
30
|
overflow: {
|
|
31
31
|
display: 'inline-block',
|
|
32
|
-
whiteSpace: '
|
|
32
|
+
whiteSpace: 'pre',
|
|
33
33
|
textOverflow: 'ellipsis',
|
|
34
34
|
overflow: 'hidden'
|
|
35
35
|
},
|
|
36
36
|
tooltip: {
|
|
37
|
-
whiteSpace: '
|
|
37
|
+
whiteSpace: 'pre',
|
|
38
38
|
width: 'fit-content',
|
|
39
39
|
maxWidth: 'fit-content'
|
|
40
40
|
}
|
|
@@ -45,6 +45,7 @@ var useStyles = (0, _makeStyles["default"])(overflowStyle);
|
|
|
45
45
|
|
|
46
46
|
var OverflowableText = function OverflowableText(_ref) {
|
|
47
47
|
var text = _ref.text,
|
|
48
|
+
tooltipStyle = _ref.tooltipStyle,
|
|
48
49
|
className = _ref.className,
|
|
49
50
|
children = _ref.children,
|
|
50
51
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -67,7 +68,7 @@ var OverflowableText = function OverflowableText(_ref) {
|
|
|
67
68
|
title: text || '',
|
|
68
69
|
disableHoverListener: !overflowed,
|
|
69
70
|
classes: {
|
|
70
|
-
tooltip: classes.tooltip
|
|
71
|
+
tooltip: tooltipStyle ? tooltipStyle : classes.tooltip
|
|
71
72
|
}
|
|
72
73
|
}, /*#__PURE__*/_react["default"].createElement("div", _extends({}, props, {
|
|
73
74
|
ref: element,
|
|
@@ -80,6 +81,7 @@ exports.OverflowableText = OverflowableText;
|
|
|
80
81
|
OverflowableText.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
81
82
|
children: _propTypes["default"].array,
|
|
82
83
|
text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number, _propTypes["default"].node]),
|
|
84
|
+
tooltipStyle: _propTypes["default"].string,
|
|
83
85
|
className: _propTypes["default"].string
|
|
84
86
|
} : {};
|
|
85
87
|
var _default = OverflowableText;
|
|
@@ -235,7 +235,9 @@ var TopBar = function TopBar(_ref) {
|
|
|
235
235
|
elementsFound = _ref.elementsFound,
|
|
236
236
|
renderElement = _ref.renderElement,
|
|
237
237
|
onLanguageClick = _ref.onLanguageClick,
|
|
238
|
-
language = _ref.language
|
|
238
|
+
language = _ref.language,
|
|
239
|
+
searchTermDisabled = _ref.searchTermDisabled,
|
|
240
|
+
initialSearchTerm = _ref.initialSearchTerm;
|
|
239
241
|
var classes = useStyles();
|
|
240
242
|
|
|
241
243
|
var _React$useState = _react["default"].useState(null),
|
|
@@ -387,7 +389,9 @@ var TopBar = function TopBar(_ref) {
|
|
|
387
389
|
_onSelectionChange(element);
|
|
388
390
|
},
|
|
389
391
|
elementsFound: elementsFound,
|
|
390
|
-
renderElement: renderElement
|
|
392
|
+
renderElement: renderElement,
|
|
393
|
+
searchTermDisabled: searchTermDisabled,
|
|
394
|
+
initialSearchTerm: initialSearchTerm
|
|
391
395
|
}), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
392
396
|
color: "inherit",
|
|
393
397
|
onClick: handleClickElementSearch,
|
|
@@ -630,7 +634,9 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
630
634
|
onSelectionChange: _propTypes["default"].func,
|
|
631
635
|
elementsFound: _propTypes["default"].array,
|
|
632
636
|
onLanguageClick: _propTypes["default"].func.isRequired,
|
|
633
|
-
language: _propTypes["default"].string.isRequired
|
|
637
|
+
language: _propTypes["default"].string.isRequired,
|
|
638
|
+
searchTermDisabled: _propTypes["default"].bool,
|
|
639
|
+
initialSearchTerm: _propTypes["default"].string
|
|
634
640
|
} : {};
|
|
635
641
|
var _default = TopBar;
|
|
636
642
|
exports["default"] = _default;
|
|
@@ -113,7 +113,8 @@ var TreeViewFinder = function TreeViewFinder(props) {
|
|
|
113
113
|
onTreeBrowse = props.onTreeBrowse,
|
|
114
114
|
validationButtonText = props.validationButtonText,
|
|
115
115
|
onlyLeaves = props.onlyLeaves,
|
|
116
|
-
multiselect = props.multiselect
|
|
116
|
+
multiselect = props.multiselect,
|
|
117
|
+
sortMethod = props.sortMethod;
|
|
117
118
|
|
|
118
119
|
var _useState = (0, _react.useState)({}),
|
|
119
120
|
mapPrintedNodes = _useState[0],
|
|
@@ -225,7 +226,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
|
|
|
225
226
|
key: node.id,
|
|
226
227
|
nodeId: node.id,
|
|
227
228
|
label: renderTreeItemLabel(node)
|
|
228
|
-
}, Array.isArray(node.children) ? node.children.length ? node.children.map(function (child) {
|
|
229
|
+
}, Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map(function (child) {
|
|
229
230
|
return renderTree(child);
|
|
230
231
|
}) : [false] // Pass non empty Array here to simulate a child then this node isn't considered as a leaf.
|
|
231
232
|
: null);
|
|
@@ -269,7 +270,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
|
|
|
269
270
|
className: classes.icon
|
|
270
271
|
}),
|
|
271
272
|
multiSelect: multiselect
|
|
272
|
-
}, data && Array.isArray(data) ? data.map(function (child) {
|
|
273
|
+
}, data && Array.isArray(data) ? data.sort(sortMethod).map(function (child) {
|
|
273
274
|
return renderTree(child);
|
|
274
275
|
}) : null)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
275
276
|
variant: "contained",
|
|
@@ -319,7 +320,8 @@ TreeViewFinder.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
319
320
|
defaultSelected: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
320
321
|
defaultExpanded: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
321
322
|
onlyLeaves: _propTypes["default"].bool,
|
|
322
|
-
multiselect: _propTypes["default"].bool
|
|
323
|
+
multiselect: _propTypes["default"].bool,
|
|
324
|
+
sortMethod: _propTypes["default"].func
|
|
323
325
|
} : {};
|
|
324
326
|
/* TreeViewFinder props default values */
|
|
325
327
|
|
|
@@ -327,7 +329,8 @@ TreeViewFinder.defaultProps = {
|
|
|
327
329
|
defaultSelected: [],
|
|
328
330
|
defaultExpanded: [],
|
|
329
331
|
onlyLeaves: true,
|
|
330
|
-
multiselect: false
|
|
332
|
+
multiselect: false,
|
|
333
|
+
sortMethod: undefined
|
|
331
334
|
};
|
|
332
335
|
|
|
333
336
|
var _default = (0, _withStyles["default"])(defaultStyles)(TreeViewFinder);
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var card_error_boundary_en = {
|
|
6
13
|
'card_error_boundary/title': 'Sorry, unexpected error :(',
|
|
7
14
|
'card_error_boundary/content': 'Please reload, or close and reopen this application, or contact support.',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var card_error_boundary_fr = {
|
|
6
13
|
'card_error_boundary/title': 'Désolé, erreur inattendue :(',
|
|
7
14
|
'card_error_boundary/content': 'Veuillez recharger, ou fermer et réouvrir cette application, ou contacter le support.',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var element_search_en = {
|
|
6
13
|
'element_search/label': 'Search for an element',
|
|
7
14
|
'element_search/noResult': 'No result'
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var element_search_fr = {
|
|
6
13
|
'element_search/label': 'Rechercher un élément',
|
|
7
14
|
'element_search/noResult': 'Aucun résultat'
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var equipment_search_en = {
|
|
6
13
|
'equipment_search/label': 'Search for an equipment',
|
|
7
14
|
'equipment_search/switchTag': 'SWITCH',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var equipment_search_fr = {
|
|
6
13
|
'equipment_search/label': 'Rechercher un équipement',
|
|
7
14
|
'equipment_search/switchTag': 'SWITCH',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var login_en = {
|
|
6
13
|
'login/login': 'Login',
|
|
7
14
|
'login/connection': 'Connection'
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var login_fr = {
|
|
6
13
|
'login/login': 'Se connecter',
|
|
7
14
|
'login/connection': 'Connexion'
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var report_viewer_en = {
|
|
6
13
|
'report_viewer/close': 'Close',
|
|
7
14
|
'report_viewer/severity': 'Severity',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var report_viewer_fr = {
|
|
6
13
|
'report_viewer/close': 'Fermer',
|
|
7
14
|
'report_viewer/severity': 'Sévérité',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var table_en = {
|
|
6
13
|
'MuiVirtualizedTable/exportCSV': 'Export to CSV File'
|
|
7
14
|
};
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var table_fr = {
|
|
6
13
|
'MuiVirtualizedTable/exportCSV': 'Exporter vers un fichier CSV'
|
|
7
14
|
};
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var top_bar_en = {
|
|
6
13
|
'top-bar/settings': 'Settings',
|
|
7
14
|
'top-bar/logout': 'Logout',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var top_bar_fr = {
|
|
6
13
|
'top-bar/settings': 'Paramètres',
|
|
7
14
|
'top-bar/logout': 'Se déconnecter',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var treeview_finder_en = {
|
|
6
13
|
'treeview_finder/close': 'Close',
|
|
7
14
|
'treeview_finder/cancel': 'Cancel',
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
5
12
|
var treeview_finder_fr = {
|
|
6
13
|
'treeview_finder/close': 'Fermer',
|
|
7
14
|
'treeview_finder/cancel': 'Annuler',
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useImportExportParams = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
|
|
10
|
+
var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
19
|
+
|
|
20
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
|
|
22
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
+
|
|
24
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
+
|
|
26
|
+
var useStyles = (0, _makeStyles["default"])(function (theme) {
|
|
27
|
+
return {
|
|
28
|
+
paramListItem: {
|
|
29
|
+
justifyContent: 'space-between',
|
|
30
|
+
gap: theme.spacing(2)
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
function longestCommonPrefix(strs) {
|
|
36
|
+
if (!(strs === null || strs === void 0 ? void 0 : strs.length)) return '';
|
|
37
|
+
var prefix = strs.reduce(function (acc, str) {
|
|
38
|
+
return str.length < acc.length ? str : acc;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
for (var _iterator = _createForOfIteratorHelperLoose(strs), _step; !(_step = _iterator()).done;) {
|
|
42
|
+
var str = _step.value;
|
|
43
|
+
|
|
44
|
+
while (str.slice(0, prefix.length) !== prefix) {
|
|
45
|
+
prefix = prefix.slice(0, -1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return prefix;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var useImportExportParams = function useImportExportParams(paramsAsArray) {
|
|
53
|
+
var classes = useStyles();
|
|
54
|
+
var longestPrefix = longestCommonPrefix(paramsAsArray.map(function (m) {
|
|
55
|
+
return m.name;
|
|
56
|
+
}));
|
|
57
|
+
var lastDotIndex = longestPrefix.lastIndexOf('.');
|
|
58
|
+
var prefix = longestPrefix.slice(0, lastDotIndex + 1);
|
|
59
|
+
var defaultValues = (0, _react.useMemo)(function () {
|
|
60
|
+
return Object.fromEntries(paramsAsArray.map(function (m) {
|
|
61
|
+
var _m$defaultValue, _m$defaultValue2;
|
|
62
|
+
|
|
63
|
+
if (m.type === 'BOOLEAN') return [m.name, m.defaultValue];
|
|
64
|
+
if (m.type === 'STRING_LIST') return [m.name, (_m$defaultValue = m.defaultValue) !== null && _m$defaultValue !== void 0 ? _m$defaultValue : []];
|
|
65
|
+
return [m.name, (_m$defaultValue2 = m.defaultValue) !== null && _m$defaultValue2 !== void 0 ? _m$defaultValue2 : null];
|
|
66
|
+
}));
|
|
67
|
+
}, [paramsAsArray]);
|
|
68
|
+
|
|
69
|
+
var _useState = (0, _react.useState)(defaultValues),
|
|
70
|
+
currentValues = _useState[0],
|
|
71
|
+
setCurrentValues = _useState[1];
|
|
72
|
+
|
|
73
|
+
var onFieldChange = function onFieldChange(value, paramName) {
|
|
74
|
+
setCurrentValues(function (prevCurrentValues) {
|
|
75
|
+
var nextCurrentValues = _extends({}, prevCurrentValues);
|
|
76
|
+
|
|
77
|
+
nextCurrentValues[paramName] = value;
|
|
78
|
+
return nextCurrentValues;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var renderField = function renderField(param) {
|
|
83
|
+
var _currentValues$param$, _param$possibleValues, _currentValues$param$2, _currentValues$param$3;
|
|
84
|
+
|
|
85
|
+
switch (param.type) {
|
|
86
|
+
case 'BOOLEAN':
|
|
87
|
+
return /*#__PURE__*/_react["default"].createElement(_material.Switch, {
|
|
88
|
+
checked: (_currentValues$param$ = currentValues === null || currentValues === void 0 ? void 0 : currentValues[param.name]) !== null && _currentValues$param$ !== void 0 ? _currentValues$param$ : defaultValues[param.name],
|
|
89
|
+
onChange: function onChange(e) {
|
|
90
|
+
return onFieldChange(e.target.checked, param.name);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
case 'STRING_LIST':
|
|
95
|
+
return /*#__PURE__*/_react["default"].createElement(_material.Autocomplete, {
|
|
96
|
+
fullWidth: true,
|
|
97
|
+
multiple: true,
|
|
98
|
+
options: (_param$possibleValues = param.possibleValues) !== null && _param$possibleValues !== void 0 ? _param$possibleValues : [],
|
|
99
|
+
freeSolo: !param.possibleValues,
|
|
100
|
+
onChange: function onChange(e, value) {
|
|
101
|
+
return onFieldChange(value, param.name);
|
|
102
|
+
},
|
|
103
|
+
value: (_currentValues$param$2 = currentValues === null || currentValues === void 0 ? void 0 : currentValues[param.name]) !== null && _currentValues$param$2 !== void 0 ? _currentValues$param$2 : defaultValues[param.name],
|
|
104
|
+
renderTags: function renderTags(value, getTagProps) {
|
|
105
|
+
return value.map(function (option, index) {
|
|
106
|
+
return /*#__PURE__*/_react["default"].createElement(_material.Chip, _extends({
|
|
107
|
+
variant: "outlined",
|
|
108
|
+
label: option
|
|
109
|
+
}, getTagProps({
|
|
110
|
+
index: index
|
|
111
|
+
})));
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
renderInput: function renderInput(options) {
|
|
115
|
+
return /*#__PURE__*/_react["default"].createElement(_material.TextField, _extends({}, options, {
|
|
116
|
+
variant: "standard"
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
default:
|
|
122
|
+
return /*#__PURE__*/_react["default"].createElement(_material.TextField, {
|
|
123
|
+
fullWidth: true,
|
|
124
|
+
defaultValue: (_currentValues$param$3 = currentValues === null || currentValues === void 0 ? void 0 : currentValues[param.name]) !== null && _currentValues$param$3 !== void 0 ? _currentValues$param$3 : defaultValues[param.name],
|
|
125
|
+
onChange: function onChange(e) {
|
|
126
|
+
return onFieldChange(e.target.value, param.name);
|
|
127
|
+
},
|
|
128
|
+
variant: 'standard'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
var resetValuesToDefault = function resetValuesToDefault() {
|
|
134
|
+
setCurrentValues({});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
var paramsComponent = /*#__PURE__*/_react["default"].createElement(_material.List, null, paramsAsArray.map(function (param) {
|
|
138
|
+
return /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
|
|
139
|
+
title: param.description,
|
|
140
|
+
enterDelay: 1200,
|
|
141
|
+
key: param.name
|
|
142
|
+
}, /*#__PURE__*/_react["default"].createElement(_material.ListItem, {
|
|
143
|
+
key: param.name,
|
|
144
|
+
className: classes.paramListItem
|
|
145
|
+
}, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
|
|
146
|
+
style: {
|
|
147
|
+
minWidth: '30%'
|
|
148
|
+
}
|
|
149
|
+
}, param.name.slice(prefix.length)), renderField(param)));
|
|
150
|
+
}));
|
|
151
|
+
|
|
152
|
+
return [currentValues, paramsComponent, resetValuesToDefault];
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
exports.useImportExportParams = useImportExportParams;
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.EquipmentItem = exports.TagRenderer = exports.setSignInCallbackError = exports.SIGNIN_CALLBACK_ERROR = exports.setLoggedUser = exports.USER = exports.LANG_FRENCH = exports.LANG_ENGLISH = exports.LANG_SYSTEM = exports.LIGHT_THEME = exports.DARK_THEME = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = exports.getFileIcon = exports.elementType = exports.getPreLoginPath = exports.dispatchUser = exports.logout = exports.initializeAuthenticationProd = exports.initializeAuthenticationDev = exports.equipmentStyles = exports.getEquipmentsInfosForSearchBar = exports.EQUIPMENT_TYPE = void 0;
|
|
4
|
+
exports.useImportExportParams = exports.EquipmentItem = exports.TagRenderer = exports.setSignInCallbackError = exports.SIGNIN_CALLBACK_ERROR = exports.setLoggedUser = exports.USER = exports.LANG_FRENCH = exports.LANG_ENGLISH = exports.LANG_SYSTEM = exports.LIGHT_THEME = exports.DARK_THEME = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = exports.getFileIcon = exports.elementType = exports.getPreLoginPath = exports.dispatchUser = exports.logout = exports.initializeAuthenticationProd = exports.initializeAuthenticationDev = exports.equipmentStyles = exports.getEquipmentsInfosForSearchBar = exports.EQUIPMENT_TYPE = void 0;
|
|
5
5
|
|
|
6
6
|
var _TreeViewFinder2 = _interopRequireDefault(require("./components/TreeViewFinder"));
|
|
7
7
|
|
|
@@ -152,6 +152,10 @@ var _CardErrorBoundary2 = _interopRequireDefault(require("./components/CardError
|
|
|
152
152
|
|
|
153
153
|
exports.CardErrorBoundary = _CardErrorBoundary2["default"];
|
|
154
154
|
|
|
155
|
+
var _useImportExportParams = require("./hooks/useImportExportParams");
|
|
156
|
+
|
|
157
|
+
exports.useImportExportParams = _useImportExportParams.useImportExportParams;
|
|
158
|
+
|
|
155
159
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
156
160
|
|
|
157
161
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/utils/AuthService.js
CHANGED
|
@@ -147,6 +147,15 @@ function logout(dispatch, userManagerInstance) {
|
|
|
147
147
|
function dispatchUser(dispatch, userManagerInstance) {
|
|
148
148
|
return userManagerInstance.getUser().then(function (user) {
|
|
149
149
|
if (user) {
|
|
150
|
+
var now = parseInt(Date.now() / 1000);
|
|
151
|
+
var exp = (0, _jwtDecode["default"])(user.id_token).exp;
|
|
152
|
+
var idTokenExpiresIn = exp - now;
|
|
153
|
+
|
|
154
|
+
if (idTokenExpiresIn < 0) {
|
|
155
|
+
console.debug('User token is expired and will not be dispatched');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
150
159
|
console.debug('User has been successfully loaded from store.');
|
|
151
160
|
return dispatch((0, _actions.setLoggedUser)(user));
|
|
152
161
|
} else {
|