@dexteel/mesf-core 4.24.1 → 4.25.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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "4.24.1"
2
+ ".": "4.25.0"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # Changelog
2
+
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * **Realtime:** add useMesfRealtime hook ([974b52b](https://github.com/dexteel/mesf-core-frontend/commit/974b52b7f0e73784ab5bb3a18a623f893359ad8b))
9
+ * **ShiftNavigator:** Listen now datetime to show next shifts ([b279ff7](https://github.com/dexteel/mesf-core-frontend/commit/b279ff7d01aa5f8e3e69d973e60602940b69f7ec))
10
+
11
+ ## [4.24.1] - 2025-02-04
12
+
13
+
14
+
1
15
  # Changelog
2
16
 
3
17
  ## [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,45 @@ 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
+ if ((shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentEnd) && shiftInfo.CurrentEnd < new Date()) {
8168
+ var fn = function () { return __awaiter(void 0, void 0, void 0, function () {
8169
+ var resp, shift, e_1;
8170
+ return __generator(this, function (_a) {
8171
+ switch (_a.label) {
8172
+ case 0:
8173
+ _a.trys.push([0, 2, , 3]);
8174
+ return [4 /*yield*/, getShiftByParameters({
8175
+ productionDate: null,
8176
+ shiftId: shiftInfo.CurrentShiftId
8177
+ })];
8178
+ case 1:
8179
+ resp = _a.sent();
8180
+ if (resp.ok) {
8181
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$2
8182
+ .utc(resp.data.CurrentProductionDate)
8183
+ .toDate(), CurrentStart: moment$2.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$2.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$2
8184
+ .utc(resp.data.PreviousProductionDate)
8185
+ .toDate(), PreviousStart: moment$2.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$2.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$2
8186
+ .utc(resp.data.LastProductionDate)
8187
+ .toDate(), LastStart: moment$2.utc(resp.data.LastStart).toDate(), LastEnd: moment$2.utc(resp.data.LastEnd).toDate() });
8188
+ setShiftInfoCopy(shift);
8189
+ }
8190
+ return [3 /*break*/, 3];
8191
+ case 2:
8192
+ e_1 = _a.sent();
8193
+ setError(getError(e_1));
8194
+ return [3 /*break*/, 3];
8195
+ case 3: return [2 /*return*/];
8196
+ }
8197
+ });
8198
+ }); };
8199
+ fn();
8200
+ }
8201
+ }, [shiftInfo]);
8202
+ useEffect(function () {
8203
+ setShiftInfoCopy(shiftInfo);
8204
+ }, [shiftInfo]);
8164
8205
  useEffect(function () {
8165
8206
  if (firstRender.current) {
8166
8207
  firstRender.current = false;
@@ -8210,13 +8251,13 @@ var ShiftDayNavigatorControl = function (props) {
8210
8251
  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
8252
  React__default.createElement(Grid, { item: true },
8212
8253
  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 () {
8254
+ React__default.createElement(IconButton$1, { "aria-label": "next", color: "primary", disabled: !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.NextShiftId), onClick: function () {
8214
8255
  moveShift("Next").then(function () { });
8215
8256
  }, size: "small" },
8216
8257
  React__default.createElement(ArrowForwardRounded, null)))),
8217
8258
  React__default.createElement(Grid, { item: true },
8218
8259
  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 () {
8260
+ 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
8261
  moveShift("Last").then(function () { });
8221
8262
  }, size: "small" },
8222
8263
  React__default.createElement(SkipNext, null)))))));
@@ -13631,6 +13672,36 @@ function MESFMain(_a) {
13631
13672
  React__default.createElement(Navigation, { showAreaSelector: showAreaSelector, showTrendingsIcon: showTrendingsIcon, navbarTitle: navbarTitle })))))))))))));
13632
13673
  }
13633
13674
 
13675
+ var useMesfRealtime = function (_a) {
13676
+ var onReceiveMessage = _a.onReceiveMessage;
13677
+ useEffect(function () {
13678
+ var connection = new HubConnectionBuilder()
13679
+ .withUrl("/ws")
13680
+ .withAutomaticReconnect()
13681
+ .configureLogging(LogLevel$1.Information)
13682
+ .build();
13683
+ connection
13684
+ .start()
13685
+ .then(function () {
13686
+ console.log("Connection started");
13687
+ })["catch"](function (err) {
13688
+ console.log("Error while starting connection: " + err);
13689
+ });
13690
+ connection.on("ReceiveMessage", function (author, message) {
13691
+ onReceiveMessage(author, message);
13692
+ });
13693
+ return function () {
13694
+ connection
13695
+ .stop()
13696
+ .then(function () {
13697
+ console.log("Connection stopped");
13698
+ })["catch"](function (err) {
13699
+ console.log("Error while stopping connection: " + err);
13700
+ });
13701
+ };
13702
+ }, []);
13703
+ };
13704
+
13634
13705
  var useDefaultAreaId = function (setError) {
13635
13706
  var _a = useUserContext(), userId = _a.state.userId, setDefaultAreaId = _a.actions.setDefaultAreaId;
13636
13707
  return function () {
@@ -13770,5 +13841,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
13770
13841
  AreaSelector: AreaSelector
13771
13842
  });
13772
13843
 
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 };
13844
+ 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
13845
  //# sourceMappingURL=index.esm.js.map