@copart/ops-tool-kit 1.10.0-alpha.25 → 1.10.0-alpha.28
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/ops-tool-kit.js +46 -18
- package/dist/ops-tool-kit.js.map +1 -1
- package/package.json +1 -1
package/dist/ops-tool-kit.js
CHANGED
|
@@ -33,7 +33,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
33
33
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
34
34
|
|
|
35
35
|
const name$f = "@copart/ops-tool-kit";
|
|
36
|
-
const version$5 = "1.10.0-alpha.
|
|
36
|
+
const version$5 = "1.10.0-alpha.28";
|
|
37
37
|
const main$1 = "dist/ops-tool-kit.js";
|
|
38
38
|
const style = "dist/ops-tool-kit.css";
|
|
39
39
|
const files = [
|
|
@@ -37153,6 +37153,21 @@ var SanitizeNotificationContent = function SanitizeNotificationContent(str) {
|
|
|
37153
37153
|
var regex = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>|<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi;
|
|
37154
37154
|
return str.replace(regex, '');
|
|
37155
37155
|
};
|
|
37156
|
+
var throttle = function throttle(func, delay) {
|
|
37157
|
+
var lastExecution = 0;
|
|
37158
|
+
return function () {
|
|
37159
|
+
var now = Date.now();
|
|
37160
|
+
|
|
37161
|
+
if (now - lastExecution >= delay) {
|
|
37162
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
37163
|
+
args[_key] = arguments[_key];
|
|
37164
|
+
}
|
|
37165
|
+
|
|
37166
|
+
func.apply(this, args);
|
|
37167
|
+
lastExecution = now;
|
|
37168
|
+
}
|
|
37169
|
+
};
|
|
37170
|
+
};
|
|
37156
37171
|
|
|
37157
37172
|
var useWindowSize = function useWindowSize() {
|
|
37158
37173
|
var isClient = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object';
|
|
@@ -41577,7 +41592,7 @@ var generateQuery = function generateQuery(yardNumber, email) {
|
|
|
41577
41592
|
var startDateTsUTC = moment.utc(new Date()).add(1, 'days').format('YYYY-MM-DDTHH:mm:ss[Z]');
|
|
41578
41593
|
var EndDateTsUTC = moment.utc(new Date()).format('YYYY-MM-DDTHH:mm:ss[Z]');
|
|
41579
41594
|
var countryCodes = window.location.hostname.includes('.com') ? '"USA", "CAN"' : '"ARE", "OMN", "BHR", "IRL", "GBR"';
|
|
41580
|
-
return "fq=(facilities:".concat(yardNumber, " OR user_details:\"").concat(email, "\" OR group_user_details:\"").concat(email, "\" OR applications:\"").concat(encodeURIComponent(getCurrentApp()), "\")&fq=((start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTsUTC, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]) OR (!start_date_timezone:\"UTC\" AND !end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTs, " TO *]) OR (!start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]))&fq=(operating_country_a3_code:(").concat(countryCodes, "))&fq=status:A&rows=10000&q=*:*");
|
|
41595
|
+
return "fq=(facilities:".concat(yardNumber, " OR user_details:\"").concat(email, "\" OR group_user_details:\"").concat(email, "\" OR applications:\"").concat(encodeURIComponent(getCurrentApp()), "\")&fq=((start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTsUTC, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]) OR (!start_date_timezone:\"UTC\" AND !end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTs, " TO *]) OR (!start_date_timezone:\"UTC\" AND end_date_timezone:\"UTC\" AND start_date_ts_utc:[* TO ").concat(startDateTs, "] AND end_date_ts_utc:[").concat(EndDateTsUTC, " TO *]))&fq=(operating_country_a3_code:(").concat(countryCodes, ") OR destination_type:(\"groups\",\"users\"))&fq=status:A&rows=10000&q=*:*");
|
|
41581
41596
|
};
|
|
41582
41597
|
|
|
41583
41598
|
var generateTargets = function generateTargets(notification) {
|
|
@@ -41728,7 +41743,7 @@ function startWebSocketConnection(updateNotifications, updateAllNotificationsLis
|
|
|
41728
41743
|
}
|
|
41729
41744
|
|
|
41730
41745
|
var getFirebaseConfig = function getFirebaseConfig() {
|
|
41731
|
-
var appConfig = storage$1.
|
|
41746
|
+
var appConfig = storage$1.getLocalItem('opsportal-core:config');
|
|
41732
41747
|
return appConfig.runConfig ? appConfig.runConfig.firebaseConfig : appConfig.firebaseConfig;
|
|
41733
41748
|
};
|
|
41734
41749
|
|
|
@@ -41736,25 +41751,35 @@ var getFirebaseConfig = function getFirebaseConfig() {
|
|
|
41736
41751
|
// firebase.initializeApp(firebaseConfig)
|
|
41737
41752
|
// }
|
|
41738
41753
|
|
|
41739
|
-
function attachHandlers(firebase, updateNotifications, updateAllFirebaseNotificationsList) {
|
|
41754
|
+
function attachHandlers(firebase, updateNotifications, updateAllFirebaseNotificationsList, throttledFunction) {
|
|
41740
41755
|
var today = getTodayDate();
|
|
41741
41756
|
firebase.database().ref().child('ops-news').orderByChild('ends_at').startAt(today).on('value', function (snapshot) {
|
|
41742
|
-
compose(
|
|
41743
|
-
|
|
41744
|
-
|
|
41745
|
-
|
|
41757
|
+
// compose(
|
|
41758
|
+
// updateNotifications,
|
|
41759
|
+
// filterNotificationsFireBase,
|
|
41760
|
+
// mapNotifications,
|
|
41761
|
+
// values,
|
|
41762
|
+
// )(snapshot.val())
|
|
41763
|
+
// setTimeout(()=>{
|
|
41764
|
+
// compose(updateAllFirebaseNotificationsList,mapNotifications,values)(snapshot.val())
|
|
41765
|
+
// },500)
|
|
41766
|
+
throttledFunction(updateNotifications, snapshot);
|
|
41746
41767
|
});
|
|
41747
41768
|
}
|
|
41748
41769
|
|
|
41749
41770
|
var getFireBaseNotifications = function getFireBaseNotifications(updateNotifications, updateAllFirebaseNotificationsList) {
|
|
41750
|
-
var
|
|
41771
|
+
var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
|
|
41772
|
+
var firebaseConfig = getFirebaseConfig();
|
|
41773
|
+
var throttledFunction = throttle(function (updateNotifications, snapshot) {
|
|
41774
|
+
compose(updateNotifications, filterNotificationsFireBase, mapNotifications, values$1)(snapshot.val());
|
|
41775
|
+
}, delay * 1000); // connect(firebaseConfig)
|
|
41751
41776
|
|
|
41752
41777
|
var firebase;
|
|
41753
41778
|
Promise.resolve().then(function () { return index_esm$1; }).then(function (module) {
|
|
41754
41779
|
firebase = module.default;
|
|
41755
41780
|
Promise.resolve().then(function () { return index_esm; }).then(function (module) {
|
|
41756
41781
|
firebase.initializeApp(firebaseConfig);
|
|
41757
|
-
attachHandlers(firebase, updateNotifications, updateAllFirebaseNotificationsList);
|
|
41782
|
+
attachHandlers(firebase, updateNotifications, updateAllFirebaseNotificationsList, throttledFunction);
|
|
41758
41783
|
});
|
|
41759
41784
|
});
|
|
41760
41785
|
};
|
|
@@ -42187,14 +42212,17 @@ var AppBar = function AppBar(_ref) {
|
|
|
42187
42212
|
setFirebaseinitialized = _useState20[1];
|
|
42188
42213
|
|
|
42189
42214
|
var listOfAllNotificationsRef = React.useRef(listOfAllNotifications);
|
|
42215
|
+
var socketRetryCountRef = React.useRef(0);
|
|
42190
42216
|
React.useEffect(function () {
|
|
42191
42217
|
listOfAllNotificationsRef.current = listOfAllNotifications;
|
|
42192
42218
|
}, [listOfAllNotifications]);
|
|
42193
42219
|
|
|
42194
42220
|
var updateNotifications = function updateNotifications(newNotifications) {
|
|
42195
|
-
|
|
42196
|
-
|
|
42197
|
-
|
|
42221
|
+
if (newNotifications.length) {
|
|
42222
|
+
setNotifications(function (notifications) {
|
|
42223
|
+
return filterDuplicateAndSave(notifications, newNotifications);
|
|
42224
|
+
});
|
|
42225
|
+
}
|
|
42198
42226
|
};
|
|
42199
42227
|
|
|
42200
42228
|
var filterOut = function filterOut(notifications, notificationToRemove) {
|
|
@@ -42331,11 +42359,10 @@ var AppBar = function AppBar(_ref) {
|
|
|
42331
42359
|
};
|
|
42332
42360
|
|
|
42333
42361
|
var selectedYard = (_storage$getSessionIt = storage$1.getSessionItem('dashboard')) === null || _storage$getSessionIt === void 0 ? void 0 : _storage$getSessionIt.selectedYard;
|
|
42334
|
-
var socketRetryCount = 0;
|
|
42335
42362
|
|
|
42336
42363
|
var reConnectSocket = function reConnectSocket() {
|
|
42337
|
-
if (
|
|
42338
|
-
|
|
42364
|
+
if (socketRetryCountRef.current < 15) {
|
|
42365
|
+
socketRetryCountRef.current = socketRetryCountRef.current + 1;
|
|
42339
42366
|
socketClient && socketClient.close();
|
|
42340
42367
|
setSocketClient(startWebSocketConnection(updateNotifications, updateAllNotificationsList, reConnectSocket));
|
|
42341
42368
|
}
|
|
@@ -42344,7 +42371,7 @@ var AppBar = function AppBar(_ref) {
|
|
|
42344
42371
|
var handleVisibilityChange = function handleVisibilityChange() {
|
|
42345
42372
|
if (document.visibilityState === 'visible') {
|
|
42346
42373
|
if (socketClient && socketClient.readyState !== WebSocket.OPEN) {
|
|
42347
|
-
|
|
42374
|
+
socketRetryCountRef.current = 0;
|
|
42348
42375
|
reConnectSocket();
|
|
42349
42376
|
}
|
|
42350
42377
|
}
|
|
@@ -42383,7 +42410,8 @@ var AppBar = function AppBar(_ref) {
|
|
|
42383
42410
|
}
|
|
42384
42411
|
|
|
42385
42412
|
if (!firebaseInitialized && notificationsSource.includes('Firebase')) {
|
|
42386
|
-
|
|
42413
|
+
var delay = coreAppConfig.firebaseTimerInSec || 60;
|
|
42414
|
+
getFireBaseNotifications(updateNotifications, updateAllFirebaseNotificationsList, delay);
|
|
42387
42415
|
setFirebaseinitialized(true);
|
|
42388
42416
|
}
|
|
42389
42417
|
}
|