logitude-dashboard-library 3.1.2 → 3.1.4

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/dist/index.js CHANGED
@@ -140,14 +140,19 @@ var ApiServices = /*#__PURE__*/function () {
140
140
  });
141
141
  };
142
142
 
143
- _proto.post = function post(api, date) {
143
+ _proto.post = function post(api, date, requestSignal) {
144
+ if (requestSignal === void 0) {
145
+ requestSignal = undefined;
146
+ }
147
+
144
148
  var token = this.getTokenFromStorage();
145
149
  var apiURL = "" + this._apiUrl + api;
146
150
  return axios.post(apiURL, date, {
147
151
  headers: {
148
152
  'Content-Type': 'application/json',
149
153
  'Token': token
150
- }
154
+ },
155
+ signal: requestSignal
151
156
  });
152
157
  };
153
158
 
@@ -196,8 +201,13 @@ var DashboardAnalyticsService = /*#__PURE__*/function () {
196
201
 
197
202
  var _proto = DashboardAnalyticsService.prototype;
198
203
 
199
- _proto.getData = function getData(widget) {
200
- return this._ApiServices.post("/api/" + this.controller + "/PostGetDataAnalytic", widget);
204
+ _proto.getData = function getData(widget, signal) {
205
+ if (signal === void 0) {
206
+ signal = undefined;
207
+ }
208
+
209
+ console.log("signal >>>", signal);
210
+ return this._ApiServices.post("/api/" + this.controller + "/PostGetDataAnalytic", widget, signal);
201
211
  };
202
212
 
203
213
  _proto.getKpiData = function getKpiData(widget) {
@@ -1415,6 +1425,7 @@ var FusionChart = React.forwardRef(function (props, comRef) {
1415
1425
  resizeTimer = _useState4[0],
1416
1426
  setResizeTimer = _useState4[1];
1417
1427
 
1428
+ var axiosController = React.useRef(new AbortController());
1418
1429
  var widget = React.useRef();
1419
1430
 
1420
1431
  var _useState5 = React.useState({}),
@@ -1434,6 +1445,7 @@ var FusionChart = React.forwardRef(function (props, comRef) {
1434
1445
  React.useEffect(function () {
1435
1446
  var _props$dataBinding;
1436
1447
 
1448
+ axiosController.current = new AbortController();
1437
1449
  widget.current = props.widget;
1438
1450
  RefreshData();
1439
1451
  (_props$dataBinding = props.dataBinding) === null || _props$dataBinding === void 0 ? void 0 : _props$dataBinding.widgetUpdated.subscribe(function (updatedWidget) {
@@ -1450,7 +1462,16 @@ var FusionChart = React.forwardRef(function (props, comRef) {
1450
1462
  });
1451
1463
  window.addEventListener("resize", handleResize);
1452
1464
  return function () {
1453
- return window.removeEventListener("resize", handleResize);
1465
+ var _axiosController$curr;
1466
+
1467
+ window.removeEventListener("resize", handleResize);
1468
+ setDataLoaded(false);
1469
+
1470
+ if (axiosController && axiosController !== null && axiosController !== void 0 && (_axiosController$curr = axiosController.current) !== null && _axiosController$curr !== void 0 && _axiosController$curr.abort) {
1471
+ var _axiosController$curr2;
1472
+
1473
+ axiosController === null || axiosController === void 0 ? void 0 : (_axiosController$curr2 = axiosController.current) === null || _axiosController$curr2 === void 0 ? void 0 : _axiosController$curr2.abort();
1474
+ }
1454
1475
  };
1455
1476
  }, []);
1456
1477
 
@@ -1499,9 +1520,21 @@ var FusionChart = React.forwardRef(function (props, comRef) {
1499
1520
  var postWidget = _extends({}, widget.current);
1500
1521
 
1501
1522
  postWidget.onChange = undefined;
1502
- dashboardAnalyticsService.getData(postWidget).then(function (result) {
1523
+ var signal = undefined;
1524
+
1525
+ if (axiosController) {
1526
+ var _axiosController$curr3;
1527
+
1528
+ axiosController === null || axiosController === void 0 ? void 0 : (_axiosController$curr3 = axiosController.current) === null || _axiosController$curr3 === void 0 ? void 0 : _axiosController$curr3.abort();
1529
+ var updatedAxiosController = new AbortController();
1530
+ axiosController.current = updatedAxiosController;
1531
+ signal = updatedAxiosController === null || updatedAxiosController === void 0 ? void 0 : updatedAxiosController.signal;
1532
+ }
1533
+
1534
+ dashboardAnalyticsService.getData(postWidget, signal).then(function (result) {
1503
1535
  handleData(result === null || result === void 0 ? void 0 : result.data);
1504
1536
  chartData.current = result === null || result === void 0 ? void 0 : result.data;
1537
+ setDataLoaded(true);
1505
1538
  }, function (error) {
1506
1539
  var _error$response, _error$response$data, _error$response2, _error$response2$data;
1507
1540