@gpa-gemstone/common-pages 0.0.185 → 0.0.187

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.
@@ -10,6 +10,10 @@ interface IProps {
10
10
  * Interval, in milliseconds, between successive HeartBeat checks
11
11
  * */
12
12
  IntervalMS: number;
13
+ /**
14
+ * Interval, in milliseconds, before checking an in-flight HeartBeat again
15
+ * */
16
+ RetryIntervalMS?: number;
13
17
  }
14
18
  /**
15
19
  * Periodically calls HeartBeat to verify connectivity to the server and, when a
@@ -53,26 +53,39 @@ var react_interactive_1 = require("@gpa-gemstone/react-interactive");
53
53
  * reconnect. Renders nothing while the server is reachable.
54
54
  */
55
55
  var HeartBeatCheck = function (props) {
56
- var _a = React.useState(false), showError = _a[0], setShowError = _a[1];
56
+ var _a;
57
+ var _b = React.useState(false), showError = _b[0], setShowError = _b[1];
58
+ var retryIntervalMS = (_a = props.RetryIntervalMS) !== null && _a !== void 0 ? _a : 10000;
57
59
  //Effect to call heartbeat on consumer defined interval
58
60
  React.useEffect(function () {
59
61
  var updateServiceStatus = null;
62
+ var nextCheck;
63
+ var isActive = true;
60
64
  var checkServiceStatus = function () {
65
+ if (updateServiceStatus != null) {
66
+ nextCheck = setTimeout(checkServiceStatus, retryIntervalMS);
67
+ return;
68
+ }
61
69
  updateServiceStatus = props.HeartBeat();
70
+ nextCheck = setTimeout(checkServiceStatus, props.IntervalMS);
62
71
  updateServiceStatus.then(function () {
63
- setShowError(false);
72
+ updateServiceStatus = null;
73
+ if (isActive)
74
+ setShowError(false);
64
75
  }, function () {
65
- setShowError(true);
76
+ updateServiceStatus = null;
77
+ if (isActive)
78
+ setShowError(true);
66
79
  });
67
80
  };
68
81
  checkServiceStatus();
69
- var interval = setInterval(checkServiceStatus, props.IntervalMS);
70
82
  return function () {
71
- clearInterval(interval);
83
+ isActive = false;
84
+ clearTimeout(nextCheck);
72
85
  if ((updateServiceStatus === null || updateServiceStatus === void 0 ? void 0 : updateServiceStatus.abort) != null)
73
86
  updateServiceStatus.abort();
74
87
  };
75
- }, [props.HeartBeat, props.IntervalMS]);
88
+ }, [props.HeartBeat, props.IntervalMS, retryIntervalMS]);
76
89
  if (!showError)
77
90
  return null;
78
91
  return (React.createElement(react_interactive_1.Modal, { Show: true, Title: "Error Communicating with Application", Size: 'sm', ShowCancel: false, ShowConfirm: false, ShowX: false, CallBack: function () { } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/common-pages",
3
- "version": "0.0.185",
3
+ "version": "0.0.187",
4
4
  "description": "Common UI pages for GPA products",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "bugs": {"url": "https://github.com/GridProtectionAlliance/gpa-gemstone/issues"},
33
33
  "homepage": "https://github.com/GridProtectionAlliance/gpa-gemstone#readme",
34
34
  "devDependencies": {
35
+ "@testing-library/react": "^14.3.1",
35
36
  "@types/crypto-js": "^4.2.0",
36
37
  "@types/jest": "^27.0.0",
37
38
  "@types/jquery": "3.5.6",
@@ -42,6 +43,7 @@
42
43
  "@typescript-eslint/parser": "^5.60.0",
43
44
  "eslint": "^8.43.0",
44
45
  "jest": "^29.0.0",
46
+ "jest-environment-jsdom": "^30.3.0",
45
47
  "prettier": "^2.3.2",
46
48
  "ts-jest": "^29.0.0",
47
49
  "typescript": "5.5.3"
@@ -50,9 +52,9 @@
50
52
  "@gpa-gemstone/application-typings": "0.0.99",
51
53
  "@gpa-gemstone/gpa-symbols": "0.0.65",
52
54
  "@gpa-gemstone/helper-functions": "0.0.61",
53
- "@gpa-gemstone/react-forms": "1.1.126",
54
- "@gpa-gemstone/react-interactive": "1.0.194",
55
- "@gpa-gemstone/react-table": "1.2.118",
55
+ "@gpa-gemstone/react-forms": "1.1.127",
56
+ "@gpa-gemstone/react-interactive": "1.0.195",
57
+ "@gpa-gemstone/react-table": "1.2.119",
56
58
  "@reduxjs/toolkit": "1.8.3",
57
59
  "crypto-js": "^4.2.0",
58
60
  "moment": "^2.29.4",