asab_webui_shell 25.1.7 → 25.1.8-alpha.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.
|
@@ -124,6 +124,10 @@ var Application = /*#__PURE__*/function (_Component) {
|
|
|
124
124
|
_this.ReduxService.addReducer("sidebar", _reducer2["default"]);
|
|
125
125
|
_this.ReduxService.addReducer("navigation", _reducer4["default"]);
|
|
126
126
|
_this.ReduxService.addReducer("router", _reducer5["default"]);
|
|
127
|
+
|
|
128
|
+
// The application can provide a list of keys that should be automatically parsed as BigInt, when received from the server in Axios call
|
|
129
|
+
// This is important to preserve 64bit numbers from the server such as IP addresses, timestamps etc.
|
|
130
|
+
_this.JSONParseBigInt = new Set(props === null || props === void 0 ? void 0 : props.bigint);
|
|
127
131
|
_this._handleKeyUp = _this._handleKeyUp.bind(_this);
|
|
128
132
|
_this.state = {
|
|
129
133
|
networking: 0,
|
|
@@ -337,6 +341,10 @@ var Application = /*#__PURE__*/function (_Component) {
|
|
|
337
341
|
return undefined;
|
|
338
342
|
}
|
|
339
343
|
var axios = _axios["default"].create(_objectSpread(_objectSpread({}, props), {}, {
|
|
344
|
+
transformResponse: function transformResponse(res) {
|
|
345
|
+
return res;
|
|
346
|
+
},
|
|
347
|
+
// Disable implicit JSON parsing, we explicitly parse JSON in the interceptor ( https://stackoverflow.com/questions/41013082/disable-json-parsing-in-axios )
|
|
340
348
|
baseURL: service_url
|
|
341
349
|
}));
|
|
342
350
|
|
|
@@ -370,9 +378,39 @@ var Application = /*#__PURE__*/function (_Component) {
|
|
|
370
378
|
return Promise.reject(error);
|
|
371
379
|
});
|
|
372
380
|
|
|
373
|
-
// We want to remove networking indicator when we
|
|
381
|
+
// We want to remove the networking indicator when we receive the response
|
|
374
382
|
axios.interceptors.response.use(function (response) {
|
|
383
|
+
var _response$headers$con;
|
|
384
|
+
// Call the `popNetworkingIndicator` method to remove the networking indicator (e.g., loading spinner)
|
|
375
385
|
that.popNetworkingIndicator();
|
|
386
|
+
|
|
387
|
+
// Check if the response content type is 'application/json' or starts with 'application/json'
|
|
388
|
+
if (response !== null && response !== void 0 && (_response$headers$con = response.headers['content-type']) !== null && _response$headers$con !== void 0 && _response$headers$con.startsWith('application/json')) {
|
|
389
|
+
// If the response is JSON, then parse it with respect to BigInt
|
|
390
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
|
|
391
|
+
try {
|
|
392
|
+
// Parse the response data using a custom reviver function
|
|
393
|
+
response.data = JSON.parse(response.data,
|
|
394
|
+
// Custom reviver function to handle BigInt values
|
|
395
|
+
function (key, value, context) {
|
|
396
|
+
// If there is no data in the JSONParseBigInt, return the value immediately
|
|
397
|
+
if (that.JSONParseBigInt.size === 0) {
|
|
398
|
+
return value;
|
|
399
|
+
}
|
|
400
|
+
// Check if the key is in the `JSONParseBigInt` set and the value is a number
|
|
401
|
+
if (that.JSONParseBigInt.has(key) && typeof value === 'number') {
|
|
402
|
+
// Convert the number to a BigInt
|
|
403
|
+
return BigInt(context.source);
|
|
404
|
+
}
|
|
405
|
+
// Return the original value if no conversion is needed
|
|
406
|
+
return value;
|
|
407
|
+
});
|
|
408
|
+
} catch (e) {
|
|
409
|
+
// Log any errors that occur during JSON parsing
|
|
410
|
+
console.error("Error in axios.interceptors.response", e);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// If the request was satisfied (application/json and presence of BigInt) return the modified object. If not, we return unchanged object
|
|
376
414
|
return response;
|
|
377
415
|
}, function (error) {
|
|
378
416
|
that.popNetworkingIndicator();
|
|
@@ -86,7 +86,7 @@ function AuthHeaderDropdown(props) {
|
|
|
86
86
|
}) : /*#__PURE__*/_react["default"].createElement("i", {
|
|
87
87
|
alt: userinfo === null || userinfo === void 0 ? void 0 : userinfo.username,
|
|
88
88
|
className: "pe-2 bi ".concat(isSuperuser ? 'bi-universal-access' : 'bi-person-gear')
|
|
89
|
-
}), /*#__PURE__*/_react["default"].createElement("span", null, userinfo === null || userinfo === void 0 ? void 0 : userinfo.username)), /*#__PURE__*/_react["default"].createElement(_reactstrap.DropdownMenu, {
|
|
89
|
+
}), /*#__PURE__*/_react["default"].createElement("span", null, (userinfo === null || userinfo === void 0 ? void 0 : userinfo.username) || (userinfo === null || userinfo === void 0 ? void 0 : userinfo.sub))), /*#__PURE__*/_react["default"].createElement(_reactstrap.DropdownMenu, {
|
|
90
90
|
className: "shadow"
|
|
91
91
|
}, /*#__PURE__*/_react["default"].createElement(_reactstrap.DropdownItem, {
|
|
92
92
|
header: true
|