@dexteel/mesf-core 4.24.1 → 4.25.1

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "4.24.1"
2
+ ".": "4.25.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ # Changelog
2
+
3
+ ## [4.25.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v4.25.0...@dexteel/mesf-core-v4.25.1) (2025-02-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **ShiftNavigator:** Check every minute if need to reload ([b404f9b](https://github.com/dexteel/mesf-core-frontend/commit/b404f9bc7231d76bcdc3c9edbf79351f3f07a9b9))
9
+
10
+ ## [4.25.0] - 2025-02-04
11
+
12
+
13
+
14
+ # Changelog
15
+
16
+ ## [4.25.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v4.24.1...@dexteel/mesf-core-v4.25.0) (2025-02-04)
17
+
18
+
19
+ ### Features
20
+
21
+ * **Realtime:** add useMesfRealtime hook ([974b52b](https://github.com/dexteel/mesf-core-frontend/commit/974b52b7f0e73784ab5bb3a18a623f893359ad8b))
22
+ * **ShiftNavigator:** Listen now datetime to show next shifts ([b279ff7](https://github.com/dexteel/mesf-core-frontend/commit/b279ff7d01aa5f8e3e69d973e60602940b69f7ec))
23
+
24
+ ## [4.24.1] - 2025-02-04
25
+
26
+
27
+
1
28
  # Changelog
2
29
 
3
30
  ## [4.24.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v4.24.0...@dexteel/mesf-core-v4.24.1) (2025-02-04)
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ onReceiveMessage: (author: string, message: string) => void;
3
+ };
4
+ export declare const useMesfRealtime: ({ onReceiveMessage }: Props) => void;
5
+ export {};
package/dist/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from "./components/shared/buttons/button-with-loading";
16
16
  export * from "./configuration/pages/users/models/User";
17
17
  export * from "./configuration/pages/users/repositories/UsersRepository";
18
18
  export * from "@microsoft/signalr";
19
+ export * from "./hooks/useMesfRealtime";
package/dist/index.esm.js CHANGED
@@ -8150,6 +8150,8 @@ var moment$2 = getMomentTz();
8150
8150
  var ShiftDayNavigatorControl = function (props) {
8151
8151
  var _a;
8152
8152
  var _b = useShiftNavigator(), shiftInfo = _b.shiftInfo, initShiftNavigator = _b.initShiftNavigator, moveShift = _b.moveShift, getShiftDataFromAPI = _b.getShiftDataFromAPI;
8153
+ var _c = useState(shiftInfo), shiftInfoCopy = _c[0], setShiftInfoCopy = _c[1];
8154
+ var _d = useState(""); _d[0]; var setError = _d[1];
8153
8155
  var shiftId = useParams().shiftId;
8154
8156
  var firstRender = useRef(true);
8155
8157
  var updateHistory = function (shiftId) {
@@ -8161,6 +8163,47 @@ var ShiftDayNavigatorControl = function (props) {
8161
8163
  updateHistory((_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId) === null || _a === void 0 ? void 0 : _a.toString());
8162
8164
  }
8163
8165
  }
8166
+ useEffect(function () {
8167
+ var fn = function () { return __awaiter(void 0, void 0, void 0, function () {
8168
+ var resp, shift, e_1;
8169
+ return __generator(this, function (_a) {
8170
+ switch (_a.label) {
8171
+ case 0:
8172
+ if (!((shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentEnd) && shiftInfo.CurrentEnd < new Date())) return [3 /*break*/, 4];
8173
+ _a.label = 1;
8174
+ case 1:
8175
+ _a.trys.push([1, 3, , 4]);
8176
+ return [4 /*yield*/, getShiftByParameters({
8177
+ productionDate: null,
8178
+ shiftId: shiftInfo.CurrentShiftId
8179
+ })];
8180
+ case 2:
8181
+ resp = _a.sent();
8182
+ if (resp.ok) {
8183
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$2
8184
+ .utc(resp.data.CurrentProductionDate)
8185
+ .toDate(), CurrentStart: moment$2.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$2.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$2
8186
+ .utc(resp.data.PreviousProductionDate)
8187
+ .toDate(), PreviousStart: moment$2.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$2.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$2
8188
+ .utc(resp.data.LastProductionDate)
8189
+ .toDate(), LastStart: moment$2.utc(resp.data.LastStart).toDate(), LastEnd: moment$2.utc(resp.data.LastEnd).toDate() });
8190
+ setShiftInfoCopy(shift);
8191
+ }
8192
+ return [3 /*break*/, 4];
8193
+ case 3:
8194
+ e_1 = _a.sent();
8195
+ setError(getError(e_1));
8196
+ return [3 /*break*/, 4];
8197
+ case 4: return [2 /*return*/];
8198
+ }
8199
+ });
8200
+ }); };
8201
+ var interval = setInterval(fn, 1000 * 60);
8202
+ return function () { return clearInterval(interval); };
8203
+ }, [shiftInfo]);
8204
+ useEffect(function () {
8205
+ setShiftInfoCopy(shiftInfo);
8206
+ }, [shiftInfo]);
8164
8207
  useEffect(function () {
8165
8208
  if (firstRender.current) {
8166
8209
  firstRender.current = false;
@@ -8210,13 +8253,13 @@ var ShiftDayNavigatorControl = function (props) {
8210
8253
  React__default.createElement(TextField, { label: "Shift - Crew", value: "".concat((shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) || "", " - ").concat((shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) || ""), placeholder: "Shift", "aria-readonly": true, variant: "outlined", size: "small" })),
8211
8254
  React__default.createElement(Grid, { item: true },
8212
8255
  React__default.createElement(Tooltip, { title: "Next Shift" },
8213
- React__default.createElement(IconButton$1, { "aria-label": "next", color: "primary", disabled: !(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.NextShiftId), onClick: function () {
8256
+ React__default.createElement(IconButton$1, { "aria-label": "next", color: "primary", disabled: !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.NextShiftId), onClick: function () {
8214
8257
  moveShift("Next").then(function () { });
8215
8258
  }, size: "small" },
8216
8259
  React__default.createElement(ArrowForwardRounded, null)))),
8217
8260
  React__default.createElement(Grid, { item: true },
8218
8261
  React__default.createElement(Tooltip, { title: "Last Shift" },
8219
- React__default.createElement(IconButton$1, { "aria-label": "delete", color: "primary", disabled: !(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.LastShiftId) || !(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.NextShiftId), onClick: function () {
8262
+ React__default.createElement(IconButton$1, { "aria-label": "delete", color: "primary", disabled: !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.LastShiftId) || !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.NextShiftId), onClick: function () {
8220
8263
  moveShift("Last").then(function () { });
8221
8264
  }, size: "small" },
8222
8265
  React__default.createElement(SkipNext, null)))))));
@@ -13631,6 +13674,36 @@ function MESFMain(_a) {
13631
13674
  React__default.createElement(Navigation, { showAreaSelector: showAreaSelector, showTrendingsIcon: showTrendingsIcon, navbarTitle: navbarTitle })))))))))))));
13632
13675
  }
13633
13676
 
13677
+ var useMesfRealtime = function (_a) {
13678
+ var onReceiveMessage = _a.onReceiveMessage;
13679
+ useEffect(function () {
13680
+ var connection = new HubConnectionBuilder()
13681
+ .withUrl("/ws")
13682
+ .withAutomaticReconnect()
13683
+ .configureLogging(LogLevel$1.Information)
13684
+ .build();
13685
+ connection
13686
+ .start()
13687
+ .then(function () {
13688
+ console.log("Connection started");
13689
+ })["catch"](function (err) {
13690
+ console.log("Error while starting connection: " + err);
13691
+ });
13692
+ connection.on("ReceiveMessage", function (author, message) {
13693
+ onReceiveMessage(author, message);
13694
+ });
13695
+ return function () {
13696
+ connection
13697
+ .stop()
13698
+ .then(function () {
13699
+ console.log("Connection stopped");
13700
+ })["catch"](function (err) {
13701
+ console.log("Error while stopping connection: " + err);
13702
+ });
13703
+ };
13704
+ }, []);
13705
+ };
13706
+
13634
13707
  var useDefaultAreaId = function (setError) {
13635
13708
  var _a = useUserContext(), userId = _a.state.userId, setDefaultAreaId = _a.actions.setDefaultAreaId;
13636
13709
  return function () {
@@ -13770,5 +13843,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
13770
13843
  AreaSelector: AreaSelector
13771
13844
  });
13772
13845
 
13773
- export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ErrorModal, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HorizontalTextControl, IntegerFormatter, Login, Logout, LongFilterPanel, MESApiService, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, NumericTextControl, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getError, getMomentTz, getProfiles, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUsers, renewToken, setPassword, setProfilesToUser, upsertUser, useAssetContext, useContextMenuMESF, useShiftNavigator, useShiftNavigatorManager, useStyles$6 as useStyles, useToken, useUTLSettingsContext, useUserContext };
13846
+ export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ErrorModal, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HorizontalTextControl, IntegerFormatter, Login, Logout, LongFilterPanel, MESApiService, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, NumericTextControl, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getError, getMomentTz, getProfiles, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUsers, renewToken, setPassword, setProfilesToUser, upsertUser, useAssetContext, useContextMenuMESF, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useStyles$6 as useStyles, useToken, useUTLSettingsContext, useUserContext };
13774
13847
  //# sourceMappingURL=index.esm.js.map