@dexteel/mesf-core 4.3.3 → 4.4.1-alpha

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/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # CHANGELOG
2
+ ## 4.4.0
3
+ - Add `/trendings` page. Needs specific version of mesf-core
2
4
  ## 4.3.3
3
5
  - Make submenu scrollable in Settings page
4
6
  ## 4.3.2
@@ -1,28 +1,4 @@
1
- export declare const updateAsset: (AssetIds: (number | string)[], ParentAssetId: number) => Promise<{
2
- ok: false;
3
- message: string;
4
- } | {
5
- ok: true;
6
- data: any;
7
- }>;
8
- export declare const insertAsset: (AssetName: string, ParentAssetId: number, CanBeDefaultAsset: boolean | null) => Promise<{
9
- ok: false;
10
- message: string;
11
- } | {
12
- ok: true;
13
- data: any;
14
- }>;
15
- export declare const UpdateAssetData: (AssetId: number, AssetName: string, ParentAssetId: number, IsAsset: boolean, CanBeDefaultAsset: boolean | null) => Promise<{
16
- ok: false;
17
- message: string;
18
- } | {
19
- ok: true;
20
- data: any;
21
- }>;
22
- export declare const removeAsset: (AssetId: number, IsActive: boolean) => Promise<{
23
- ok: false;
24
- message: string;
25
- } | {
26
- ok: true;
27
- data: any;
28
- }>;
1
+ export declare const updateAsset: (AssetIds: (number | string)[], ParentAssetId: number) => Promise<import("../../../../services/ApiService").ResponseMESF>;
2
+ export declare const insertAsset: (AssetName: string, ParentAssetId: number, CanBeDefaultAsset: boolean | null) => Promise<import("../../../../services/ApiService").ResponseMESF>;
3
+ export declare const UpdateAssetData: (AssetId: number, AssetName: string, ParentAssetId: number, IsAsset: boolean, CanBeDefaultAsset: boolean | null) => Promise<import("../../../../services/ApiService").ResponseMESF>;
4
+ export declare const removeAsset: (AssetId: number, IsActive: boolean) => Promise<import("../../../../services/ApiService").ResponseMESF>;
@@ -1,21 +1,3 @@
1
- export declare const GetJobsStatus: () => Promise<{
2
- ok: false;
3
- message: string;
4
- } | {
5
- ok: true;
6
- data: any;
7
- }>;
8
- export declare const SetJobEnable: (Enable: boolean, sProcedure: string) => Promise<{
9
- ok: false;
10
- message: string;
11
- } | {
12
- ok: true;
13
- data: any;
14
- }>;
15
- export declare const RestartJob: (sProcedure: string) => Promise<{
16
- ok: false;
17
- message: string;
18
- } | {
19
- ok: true;
20
- data: any;
21
- }>;
1
+ export declare const GetJobsStatus: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
2
+ export declare const SetJobEnable: (Enable: boolean, sProcedure: string) => Promise<import("../../../../services/ApiService").ResponseMESF>;
3
+ export declare const RestartJob: (sProcedure: string) => Promise<import("../../../../services/ApiService").ResponseMESF>;
@@ -1,7 +1 @@
1
- export declare const GetLogs: (Start: Date, End: Date, Search: string, LogTypeCode: number | string | null) => Promise<{
2
- ok: false;
3
- message: string;
4
- } | {
5
- ok: true;
6
- data: any;
7
- }>;
1
+ export declare const GetLogs: (Start: Date, End: Date, Search: string, LogTypeCode: number | string | null) => Promise<import("../../../../services/ApiService").ResponseMESF>;
@@ -1,44 +1,8 @@
1
1
  import { Profile } from "../../profiles/models/Profile";
2
2
  import { Action } from "../models/Action";
3
- export declare const getProfiles: () => Promise<{
4
- ok: false;
5
- message: string;
6
- } | {
7
- ok: true;
8
- data: any;
9
- }>;
10
- export declare const upsertProfile: (ProfileId: number, ProfileName: string) => Promise<{
11
- ok: false;
12
- message: string;
13
- } | {
14
- ok: true;
15
- data: any;
16
- }>;
17
- export declare const getActions: () => Promise<{
18
- ok: false;
19
- message: string;
20
- } | {
21
- ok: true;
22
- data: any;
23
- }>;
24
- export declare const getActionsByProfileId: (profile: Profile) => Promise<{
25
- ok: false;
26
- message: string;
27
- } | {
28
- ok: true;
29
- data: any;
30
- }>;
31
- export declare const upsertProfileActions: (profile: Profile, actions: Action[]) => Promise<{
32
- ok: false;
33
- message: string;
34
- } | {
35
- ok: true;
36
- data: any;
37
- }>;
38
- export declare const deleteProfile: (profileId: number) => Promise<{
39
- ok: false;
40
- message: string;
41
- } | {
42
- ok: true;
43
- data: any;
44
- }>;
3
+ export declare const getProfiles: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
4
+ export declare const upsertProfile: (ProfileId: number, ProfileName: string) => Promise<import("../../../../services/ApiService").ResponseMESF>;
5
+ export declare const getActions: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
6
+ export declare const getActionsByProfileId: (profile: Profile) => Promise<import("../../../../services/ApiService").ResponseMESF>;
7
+ export declare const upsertProfileActions: (profile: Profile, actions: Action[]) => Promise<import("../../../../services/ApiService").ResponseMESF>;
8
+ export declare const deleteProfile: (profileId: number) => Promise<import("../../../../services/ApiService").ResponseMESF>;
@@ -1,22 +1,4 @@
1
1
  import { ShiftParameters } from "../models/ShiftParameters";
2
- export declare const getShiftParameters: () => Promise<{
3
- ok: false;
4
- message: string;
5
- } | {
6
- ok: true;
7
- data: any;
8
- }>;
9
- export declare const upsertShiftParameters: ({ PatternStart, ShiftCodes, Crews, CrewRotation, Comments, }: ShiftParameters) => Promise<{
10
- ok: false;
11
- message: string;
12
- } | {
13
- ok: true;
14
- data: any;
15
- }>;
16
- export declare const DeleteShiftParameters: (PatternStart: Date) => Promise<{
17
- ok: false;
18
- message: string;
19
- } | {
20
- ok: true;
21
- data: any;
22
- }>;
2
+ export declare const getShiftParameters: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
3
+ export declare const upsertShiftParameters: ({ PatternStart, ShiftCodes, Crews, CrewRotation, Comments, }: ShiftParameters) => Promise<import("../../../../services/ApiService").ResponseMESF>;
4
+ export declare const DeleteShiftParameters: (PatternStart: Date) => Promise<import("../../../../services/ApiService").ResponseMESF>;
@@ -1,32 +1,8 @@
1
1
  import { User } from "../models/User";
2
- export declare const getUsers: () => Promise<{
3
- ok: false;
4
- message: string;
5
- } | {
6
- ok: true;
7
- data: any;
8
- }>;
9
- export declare const getDataUser: (UserId: number | null) => Promise<{
10
- ok: false;
11
- message: string;
12
- } | {
13
- ok: true;
14
- data: any;
15
- }>;
16
- export declare const getProfiles: () => Promise<{
17
- ok: false;
18
- message: string;
19
- } | {
20
- ok: true;
21
- data: any;
22
- }>;
23
- export declare const deleteUser: (userId: number) => Promise<{
24
- ok: false;
25
- message: string;
26
- } | {
27
- ok: true;
28
- data: any;
29
- }>;
2
+ export declare const getUsers: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
3
+ export declare const getDataUser: (UserId: number | null) => Promise<import("../../../../services/ApiService").ResponseMESF>;
4
+ export declare const getProfiles: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
5
+ export declare const deleteUser: (userId: number) => Promise<import("../../../../services/ApiService").ResponseMESF>;
30
6
  export declare const setPassword: (userId: number, password: string) => Promise<{
31
7
  ok: boolean;
32
8
  data: any;
@@ -36,24 +12,6 @@ export declare const setPassword: (userId: number, password: string) => Promise<
36
12
  message: any;
37
13
  data?: undefined;
38
14
  }>;
39
- export declare const upsertUser: (user: User) => Promise<{
40
- ok: false;
41
- message: string;
42
- } | {
43
- ok: true;
44
- data: any;
45
- }>;
46
- export declare const getAuthTypes: () => Promise<{
47
- ok: false;
48
- message: string;
49
- } | {
50
- ok: true;
51
- data: any;
52
- }>;
53
- export declare const setProfilesToUser: (UserId: number, profileIds: number[]) => Promise<{
54
- ok: false;
55
- message: string;
56
- } | {
57
- ok: true;
58
- data: any;
59
- }>;
15
+ export declare const upsertUser: (user: User) => Promise<import("../../../../services/ApiService").ResponseMESF>;
16
+ export declare const getAuthTypes: () => Promise<import("../../../../services/ApiService").ResponseMESF>;
17
+ export declare const setProfilesToUser: (UserId: number, profileIds: number[]) => Promise<import("../../../../services/ApiService").ResponseMESF>;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./context/axiosInstance";
3
3
  export * from "./MESFMain";
4
4
  export * from "./components/modals/modal.mesf";
5
5
  export * from "./components/modals/error-modal";
6
+ export * from './pages/trendings';
6
7
  export * from "./configuration";
7
8
  export * from "./context/UTLSettingContext";
8
9
  export * from "./context/assetContext";
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Typography, TextField, makeStyles as makeStyles$1, Button as Button$1, Grid as Grid$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, DialogContentText, DialogActions as DialogActions$2, FormHelperText, CircularProgress as CircularProgress$1, Badge, FormControlLabel, Checkbox, Snackbar as Snackbar$1, Paper as Paper$1, MenuItem as MenuItem$1, useTheme as useTheme$1, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
1
+ import { Typography, TextField, makeStyles as makeStyles$1, Button as Button$1, Grid as Grid$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, DialogContentText, DialogActions as DialogActions$2, FormHelperText, CircularProgress as CircularProgress$1, Badge, FormControlLabel, Checkbox, Snackbar as Snackbar$1, Paper as Paper$1, MenuItem as MenuItem$1, useTheme as useTheme$1, Box, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
2
2
  import { values, get, isNil as isNil$1, isEmpty } from 'lodash-es';
3
3
  import * as React from 'react';
4
4
  import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
@@ -20,8 +20,16 @@ import Grid from '@material-ui/core/Grid';
20
20
  import { isNil, get as get$1 } from 'lodash';
21
21
  import { DndProvider } from 'react-dnd';
22
22
  import { HTML5Backend } from 'react-dnd-html5-backend';
23
- import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
23
+ import { Line } from 'react-chartjs-2';
24
+ import { _adapters, Chart, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, TimeScale } from 'chart.js';
25
+ import moment from 'moment';
24
26
  import axios from 'axios';
27
+ import zoomPlugin from 'chartjs-plugin-zoom';
28
+ import { Alert as Alert$3, TreeView as TreeView$1, TreeItem as TreeItem$1 } from '@material-ui/lab';
29
+ import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
30
+ import FolderIcon from '@material-ui/icons/Folder';
31
+ import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile';
32
+ import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
25
33
  import PropTypes from 'prop-types';
26
34
  import { ResponsiveBar } from '@nivo/bar';
27
35
  import Select from '@material-ui/core/Select';
@@ -29,7 +37,6 @@ import { withStyles, alpha, makeStyles, createStyles, useTheme } from '@material
29
37
  import Collapse from '@material-ui/core/Collapse';
30
38
  import SvgIcon from '@material-ui/core/SvgIcon';
31
39
  import Code from '@material-ui/icons/Code';
32
- import Folder from '@material-ui/icons/Folder';
33
40
  import TreeItem from '@material-ui/lab/TreeItem';
34
41
  import TreeView from '@material-ui/lab/TreeView';
35
42
  import { useSpring, animated } from 'react-spring';
@@ -39,7 +46,6 @@ import Card from '@material-ui/core/Card';
39
46
  import CardActions from '@material-ui/core/CardActions';
40
47
  import CardContent from '@material-ui/core/CardContent';
41
48
  import Typography$1 from '@material-ui/core/Typography';
42
- import moment from 'moment';
43
49
  import Snackbar from '@material-ui/core/Snackbar';
44
50
  import CircularProgress from '@material-ui/core/CircularProgress';
45
51
  import Alert$2 from '@material-ui/lab/Alert';
@@ -65,7 +71,6 @@ import { ArrowRight } from '@material-ui/icons';
65
71
  import ImageIcon from '@material-ui/icons/Image';
66
72
  import ListAltIcon from '@material-ui/icons/ListAlt';
67
73
  import DescriptionIcon from '@material-ui/icons/Description';
68
- import { Alert as Alert$3 } from '@material-ui/lab';
69
74
  import FormControlLabel$1 from '@material-ui/core/FormControlLabel';
70
75
  import Checkbox$1 from '@material-ui/core/Checkbox';
71
76
  import Input from '@material-ui/core/Input';
@@ -414,7 +419,7 @@ var ModalTreeFilterControl = function (props) {
414
419
  nodes.isCode === true &&
415
420
  React__default.createElement(Code, { className: classes.treeLabelIcon, htmlColor: "#1ABC9C" }),
416
421
  nodes.isCode === false &&
417
- React__default.createElement(Folder, { className: classes.treeLabelIcon, htmlColor: '#F1C40F' }),
422
+ React__default.createElement(FolderIcon, { className: classes.treeLabelIcon, htmlColor: '#F1C40F' }),
418
423
  React__default.createElement(Typography, { variant: "body2", className: [classes.treeLabelText, (nodes.isActive ? '' : classes.treeLabelInactive)].join(' ') },
419
424
  React__default.createElement("span", null,
420
425
  nodes.isCode &&
@@ -997,8 +1002,8 @@ var Alert = function (props) {
997
1002
 
998
1003
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
999
1004
 
1000
- var css$1 = ".lds-ring {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n}\n.lds-ring div {\n box-sizing: border-box;\n display: block;\n position: absolute;\n width: 64px;\n height: 64px;\n margin: 8px;\n border: 5px solid rgb(63,81,181);\n border-radius: 50%;\n animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n border-color: rgb(63,81,181) transparent transparent transparent;\n}\n.lds-ring div:nth-child(1) {\n animation-delay: -0.45s;\n}\n.lds-ring div:nth-child(2) {\n animation-delay: -0.3s;\n}\n.lds-ring div:nth-child(3) {\n animation-delay: -0.15s;\n}\n@keyframes lds-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n";
1001
- n(css$1,{});
1005
+ var css$2 = ".lds-ring {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n}\n.lds-ring div {\n box-sizing: border-box;\n display: block;\n position: absolute;\n width: 64px;\n height: 64px;\n margin: 8px;\n border: 5px solid rgb(63,81,181);\n border-radius: 50%;\n animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n border-color: rgb(63,81,181) transparent transparent transparent;\n}\n.lds-ring div:nth-child(1) {\n animation-delay: -0.45s;\n}\n.lds-ring div:nth-child(2) {\n animation-delay: -0.3s;\n}\n.lds-ring div:nth-child(3) {\n animation-delay: -0.15s;\n}\n@keyframes lds-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n";
1006
+ n(css$2,{});
1002
1007
 
1003
1008
  var LazyLoading = function () {
1004
1009
  return (React__default.createElement(React__default.Fragment, null,
@@ -3790,7 +3795,7 @@ var ShiftsCrewsPage = function (props) {
3790
3795
 
3791
3796
  var TypeIcon = function (props) {
3792
3797
  if (props.droppable) {
3793
- return React__default.createElement(Folder, null);
3798
+ return React__default.createElement(FolderIcon, null);
3794
3799
  }
3795
3800
  switch (props.fileType) {
3796
3801
  case "image":
@@ -7818,6 +7823,709 @@ var Home = function () { return (React__default.createElement("div", { style: {
7818
7823
  position: 'absolute'
7819
7824
  } })); };
7820
7825
 
7826
+ /*!
7827
+ * chartjs-adapter-moment v1.0.1
7828
+ * https://www.chartjs.org
7829
+ * (c) 2022 chartjs-adapter-moment Contributors
7830
+ * Released under the MIT license
7831
+ */
7832
+
7833
+ const FORMATS = {
7834
+ datetime: 'MMM D, YYYY, h:mm:ss a',
7835
+ millisecond: 'h:mm:ss.SSS a',
7836
+ second: 'h:mm:ss a',
7837
+ minute: 'h:mm a',
7838
+ hour: 'hA',
7839
+ day: 'MMM D',
7840
+ week: 'll',
7841
+ month: 'MMM YYYY',
7842
+ quarter: '[Q]Q - YYYY',
7843
+ year: 'YYYY'
7844
+ };
7845
+
7846
+ _adapters._date.override(typeof moment === 'function' ? {
7847
+ _id: 'moment', // DEBUG ONLY
7848
+
7849
+ formats: function() {
7850
+ return FORMATS;
7851
+ },
7852
+
7853
+ parse: function(value, format) {
7854
+ if (typeof value === 'string' && typeof format === 'string') {
7855
+ value = moment(value, format);
7856
+ } else if (!(value instanceof moment)) {
7857
+ value = moment(value);
7858
+ }
7859
+ return value.isValid() ? value.valueOf() : null;
7860
+ },
7861
+
7862
+ format: function(time, format) {
7863
+ return moment(time).format(format);
7864
+ },
7865
+
7866
+ add: function(time, amount, unit) {
7867
+ return moment(time).add(amount, unit).valueOf();
7868
+ },
7869
+
7870
+ diff: function(max, min, unit) {
7871
+ return moment(max).diff(moment(min), unit);
7872
+ },
7873
+
7874
+ startOf: function(time, unit, weekday) {
7875
+ time = moment(time);
7876
+ if (unit === 'isoWeek') {
7877
+ weekday = Math.trunc(Math.min(Math.max(0, weekday), 6));
7878
+ return time.isoWeekday(weekday).startOf('day').valueOf();
7879
+ }
7880
+ return time.startOf(unit).valueOf();
7881
+ },
7882
+
7883
+ endOf: function(time, unit) {
7884
+ return moment(time).endOf(unit).valueOf();
7885
+ }
7886
+ } : {});
7887
+
7888
+ var formatDate = function (date) {
7889
+ // Format: "MM/DD/YYYY HH:MM:SS.sss"
7890
+ var day = date.getDate().toString();
7891
+ var month = (date.getMonth() + 1).toString(); // getMonth() returns 0-11
7892
+ var year = date.getFullYear();
7893
+ var hours = date.getHours().toString();
7894
+ var minutes = date.getMinutes().toString();
7895
+ var seconds = date.getSeconds().toString();
7896
+ var milliseconds = date.getMilliseconds().toString();
7897
+ // Adding leading zeros for day, month, hours, minutes, and seconds if necessary
7898
+ day = day.padStart(2, '0');
7899
+ month = month.padStart(2, '0');
7900
+ hours = hours.padStart(2, '0');
7901
+ minutes = minutes.padStart(2, '0');
7902
+ seconds = seconds.padStart(2, '0');
7903
+ // Milliseconds to ensure 3 digits
7904
+ milliseconds = milliseconds.padStart(3, '0');
7905
+ return "".concat(month, "/").concat(day, "/").concat(year, " ").concat(hours, ":").concat(minutes, ":").concat(seconds, ".").concat(milliseconds);
7906
+ };
7907
+ var DateComponent = function (_a) {
7908
+ var date = _a.date;
7909
+ return React__default.createElement("div", null, formatDate(date));
7910
+ };
7911
+
7912
+ var CustomOptionsComponent = function (_a) {
7913
+ var customOptions = _a.customOptions, setCustomOptions = _a.setCustomOptions;
7914
+ var handleGridChange = function (value) {
7915
+ setCustomOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { showGrid: value })); });
7916
+ };
7917
+ var handleSteppedChange = function (value) {
7918
+ setCustomOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { stepped: value })); });
7919
+ };
7920
+ return (React__default.createElement("div", null,
7921
+ React__default.createElement("label", null,
7922
+ React__default.createElement("input", { type: "checkbox", checked: customOptions.showGrid, onChange: function (e) { return handleGridChange(e.target.checked); } }),
7923
+ "Show Grid"),
7924
+ React__default.createElement("label", null,
7925
+ React__default.createElement("input", { type: "checkbox", checked: customOptions.stepped, onChange: function (e) { return handleSteppedChange(e.target.checked); } }),
7926
+ "Stepped")));
7927
+ };
7928
+
7929
+ var css$1 = "/* ContextMenu.css */\n.context-menu {\n position: absolute;\n z-index: 1000;\n background-color: #fff;\n border: 1px solid #ddd;\n box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n overflow: hidden;\n}\n\n .context-menu ul {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n .context-menu li {\n padding: 8px 15px;\n cursor: pointer;\n border-bottom: 1px solid #eee;\n background-color: #fff;\n color: #333;\n font-size: 14px;\n }\n\n .context-menu li:hover {\n background-color: #f5f5f5;\n }\n\n\n";
7930
+ n(css$1,{});
7931
+
7932
+ var TagSelectionModal = function (_a) {
7933
+ var isOpen = _a.isOpen; _a.onClose; var onTagSelect = _a.onTagSelect;
7934
+ var _b = useState(true), isLoading = _b[0], setIsLoading = _b[1];
7935
+ var _c = useState([]), treeData = _c[0], setTreeData = _c[1];
7936
+ var _d = useState([]), expanded = _d[0], setExpanded = _d[1];
7937
+ useEffect(function () {
7938
+ var loadData = function () { return __awaiter(void 0, void 0, void 0, function () {
7939
+ var children;
7940
+ return __generator(this, function (_a) {
7941
+ switch (_a.label) {
7942
+ case 0:
7943
+ if (!isOpen) return [3 /*break*/, 2];
7944
+ setIsLoading(true);
7945
+ return [4 /*yield*/, fetchChildren('root')];
7946
+ case 1:
7947
+ children = _a.sent();
7948
+ setTreeData([{ tagId: null, tagName: 'root', children: children, isLoaded: true, shortName: 'Tags', tag: null }]);
7949
+ setIsLoading(false);
7950
+ _a.label = 2;
7951
+ case 2: return [2 /*return*/];
7952
+ }
7953
+ });
7954
+ }); };
7955
+ loadData();
7956
+ }, [isOpen]);
7957
+ var fetchChildren = function (tagName, depth, maxDepth) {
7958
+ if (depth === void 0) { depth = 0; }
7959
+ if (maxDepth === void 0) { maxDepth = 3; }
7960
+ return __awaiter(void 0, void 0, void 0, function () {
7961
+ var response, childrenData, error_1;
7962
+ return __generator(this, function (_a) {
7963
+ switch (_a.label) {
7964
+ case 0:
7965
+ // Limiting the recursion depth for safety
7966
+ if (depth > maxDepth) {
7967
+ return [2 /*return*/, []];
7968
+ }
7969
+ _a.label = 1;
7970
+ case 1:
7971
+ _a.trys.push([1, 4, , 5]);
7972
+ return [4 /*yield*/, axios.get("/Tag/".concat(tagName, "/children"))];
7973
+ case 2:
7974
+ response = _a.sent();
7975
+ return [4 /*yield*/, Promise.all(response.data.map(function (dbTag) { return __awaiter(void 0, void 0, void 0, function () {
7976
+ var childTagName, children;
7977
+ return __generator(this, function (_a) {
7978
+ switch (_a.label) {
7979
+ case 0:
7980
+ childTagName = tagName !== 'root' ? tagName + '.' + dbTag.tagName : dbTag.tagName;
7981
+ return [4 /*yield*/, fetchChildren(childTagName, depth + 1, maxDepth)];
7982
+ case 1:
7983
+ children = _a.sent();
7984
+ return [2 /*return*/, {
7985
+ tagId: dbTag.tagId,
7986
+ tagName: childTagName,
7987
+ shortName: dbTag.tagName,
7988
+ children: children,
7989
+ isLoaded: true,
7990
+ tag: {
7991
+ tagId: dbTag.tagId,
7992
+ tagName: dbTag.tagName,
7993
+ tagType: dbTag.tagType,
7994
+ color: '#FF0000',
7995
+ autoScale: true,
7996
+ minScale: null,
7997
+ maxScale: null,
7998
+ visible: true
7999
+ }
8000
+ }];
8001
+ }
8002
+ });
8003
+ }); }))];
8004
+ case 3:
8005
+ childrenData = _a.sent();
8006
+ // Flatten the structure if needed or perform other transformations
8007
+ // ...
8008
+ return [2 /*return*/, childrenData];
8009
+ case 4:
8010
+ error_1 = _a.sent();
8011
+ console.error('Error fetching children:', error_1);
8012
+ return [2 /*return*/, []];
8013
+ case 5: return [2 /*return*/];
8014
+ }
8015
+ });
8016
+ });
8017
+ };
8018
+ /* I have to get the grandchildren because the toggle action would not be triggered if no children */
8019
+ var handleNodeToggle = function (event, nodeIds) { return __awaiter(void 0, void 0, void 0, function () {
8020
+ return __generator(this, function (_a) {
8021
+ console.log('Toggle:', nodeIds);
8022
+ setExpanded(nodeIds);
8023
+ return [2 /*return*/];
8024
+ });
8025
+ }); };
8026
+ var handleNodeSelect = function (event, nodeId) { return __awaiter(void 0, void 0, void 0, function () {
8027
+ var node;
8028
+ return __generator(this, function (_a) {
8029
+ // console.log('Selected Node ID:', nodeId);
8030
+ console.log('treeData', treeData);
8031
+ node = findNode(treeData, nodeId);
8032
+ if (node === null || node === void 0 ? void 0 : node.tagId) {
8033
+ onTagSelect(node.tag);
8034
+ }
8035
+ return [2 /*return*/];
8036
+ });
8037
+ }); };
8038
+ var findNode = function (nodes, tagName) {
8039
+ for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
8040
+ var node = nodes_1[_i];
8041
+ if (node.tagName === tagName) {
8042
+ return node;
8043
+ }
8044
+ else if (node.children) {
8045
+ var found = findNode(node.children, tagName);
8046
+ if (found)
8047
+ return found;
8048
+ }
8049
+ }
8050
+ return null;
8051
+ };
8052
+ var renderTree = function (node) { return (React__default.createElement(TreeItem$1, { key: node.tagName, nodeId: node.tagName, label: node.shortName, endIcon: React__default.createElement(ArrowDropDownIcon, null), icon: node.children && node.children.length > 0 ? React__default.createElement(FolderIcon, null) : React__default.createElement(InsertDriveFileIcon, null) }, node.children && node.children.map(function (child) { return renderTree(child); }))); };
8053
+ return (React__default.createElement("div", { style: { display: isOpen ? 'block' : 'none', minHeight: "400px", minWidth: "600px" } },
8054
+ React__default.createElement("div", null, isLoading ? (React__default.createElement(Grid$1, { container: true, justifyContent: "center", alignItems: "center", style: { minHeight: "100px" } },
8055
+ React__default.createElement(CircularProgress$1, { size: "2rem" }))) : React__default.createElement(TreeView$1, { expanded: expanded, onNodeSelect: handleNodeSelect, onNodeToggle: handleNodeToggle }, treeData.map(function (tree) { return renderTree(tree); })))));
8056
+ };
8057
+
8058
+ var TableComponent = function (_a) {
8059
+ var tagList = _a.tagList, setTagList = _a.setTagList, cursorData = _a.cursorData, onDeleteTag = _a.onDeleteTag, onAddTag = _a.onAddTag;
8060
+ var handleChange = function (index, value, property) {
8061
+ setTagList(function (prev) { return prev.map(function (tag, currentIndex) {
8062
+ var _a;
8063
+ return currentIndex === index ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.autoScale = false, _a)) : tag;
8064
+ }); });
8065
+ };
8066
+ var handleVisibilityChange = function (index, value) {
8067
+ setTagList(function (prev) { return prev.map(function (tag, currentIndex) { return currentIndex === index ? __assign(__assign({}, tag), { visible: value }) : tag; }); });
8068
+ };
8069
+ var handleAutoScaleChange = function (index, value) {
8070
+ setTagList(function (prev) { return prev.map(function (tag, currentIndex) { return currentIndex === index ? __assign(__assign({}, tag), { autoScale: value }) : tag; }); });
8071
+ };
8072
+ var _b = useState(null), selectedRowIndex = _b[0], setSelectedRowIndex = _b[1];
8073
+ var _c = useState(false), modalOpen = _c[0], setModalOpen = _c[1];
8074
+ var handleOpen = function () { return setModalOpen(true); };
8075
+ var handleClose = function () { return setModalOpen(false); };
8076
+ var ContextMenu = function (_a) {
8077
+ var x = _a.x, y = _a.y, options = _a.options;
8078
+ var handleContextMenuClick = function (e) {
8079
+ e.stopPropagation(); // Prevent click inside the menu from closing it
8080
+ };
8081
+ return (React__default.createElement("div", { className: "context-menu", style: { top: y, left: x }, onClick: handleContextMenuClick },
8082
+ React__default.createElement("ul", null, options.map(function (option) { return (React__default.createElement("li", { key: option.id, onClick: option.onClick }, option.label)); }))));
8083
+ };
8084
+ // Position state for the context menu
8085
+ var _d = useState({ x: 0, y: 0 }), contextMenuPosition = _d[0], setContextMenuPosition = _d[1];
8086
+ var contextMenuOptions = [
8087
+ { id: 'delete', label: 'Remove Tag', onClick: function () { return handleDelete(); } },
8088
+ { id: 'add', label: 'Add Tag', onClick: function () { return handleTagAdd(); } },
8089
+ // ... other options
8090
+ ];
8091
+ var handleTagAdd = function () {
8092
+ handleOpen();
8093
+ };
8094
+ var handleTagSelect = function (selectedTag) {
8095
+ onAddTag(selectedTag);
8096
+ handleClose();
8097
+ };
8098
+ var handleDelete = function (index) {
8099
+ if (selectedRowIndex !== null) {
8100
+ var tagToDelete = tagList[selectedRowIndex];
8101
+ onDeleteTag(tagToDelete.tagId);
8102
+ setSelectedRowIndex(null); // Reset the selected row index
8103
+ }
8104
+ };
8105
+ useEffect(function () {
8106
+ var handleGlobalClick = function (e) {
8107
+ if (selectedRowIndex !== null) {
8108
+ setSelectedRowIndex(null);
8109
+ }
8110
+ };
8111
+ var handleKeyDown = function (e) {
8112
+ if (e.key === "Escape" && selectedRowIndex !== null) {
8113
+ setSelectedRowIndex(null);
8114
+ }
8115
+ };
8116
+ // Attach event listeners
8117
+ document.addEventListener('click', handleGlobalClick);
8118
+ document.addEventListener('keydown', handleKeyDown);
8119
+ // Cleanup function
8120
+ return function () {
8121
+ document.removeEventListener('click', handleGlobalClick);
8122
+ document.removeEventListener('keydown', handleKeyDown);
8123
+ };
8124
+ }, [selectedRowIndex]);
8125
+ var handleRowClick = function (index) {
8126
+ setSelectedRowIndex(index);
8127
+ };
8128
+ var handleRightClick = function (event, index) {
8129
+ event.preventDefault();
8130
+ event.stopPropagation(); // Prevent the click event from propagating to the document
8131
+ setSelectedRowIndex(index);
8132
+ setContextMenuPosition({ x: event.clientX, y: event.clientY });
8133
+ };
8134
+ return (React__default.createElement("div", null,
8135
+ React__default.createElement("table", { cellPadding: '5px' },
8136
+ React__default.createElement("thead", null,
8137
+ React__default.createElement("tr", null,
8138
+ React__default.createElement("th", null, "Visible"),
8139
+ React__default.createElement("th", null, "Tag Name"),
8140
+ React__default.createElement("th", null, "Color"),
8141
+ React__default.createElement("th", null, "Min Scale"),
8142
+ React__default.createElement("th", null, "Max Scale"),
8143
+ React__default.createElement("th", null, "AutoScale"),
8144
+ React__default.createElement("th", null, "X"),
8145
+ React__default.createElement("th", null, "Y"))),
8146
+ React__default.createElement("tbody", null, tagList.map(function (tag, index) { return (React__default.createElement("tr", { key: tag.tagName, onClick: function () { return handleRowClick(index); }, onContextMenu: function (e) { return handleRightClick(e, index); }, className: selectedRowIndex === index ? "selected-row" : "" },
8147
+ React__default.createElement("td", null,
8148
+ React__default.createElement("input", { type: "checkbox", checked: tag.visible, onChange: function (e) { return handleVisibilityChange(index, e.target.checked); } })),
8149
+ React__default.createElement("td", null, tag.tagName),
8150
+ React__default.createElement("td", null,
8151
+ React__default.createElement("div", { style: {
8152
+ backgroundColor: tag.color,
8153
+ width: '20px',
8154
+ height: '20px'
8155
+ } })),
8156
+ React__default.createElement("td", null,
8157
+ React__default.createElement("input", { type: "text", style: { width: '100%' }, value: tag.minScale, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
8158
+ var value = e.target.value;
8159
+ var numericValue = Number(value);
8160
+ // Check if the value is a number and not empty
8161
+ handleChange(index, numericValue, 'minScale');
8162
+ } })),
8163
+ React__default.createElement("td", null,
8164
+ React__default.createElement("input", { type: "text", style: { width: '100%' }, value: tag.maxScale, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
8165
+ var value = e.target.value;
8166
+ var numericValue = Number(value);
8167
+ // Check if the value is a number and not empty
8168
+ if (!isNaN(numericValue) && value.trim() !== '') {
8169
+ handleChange(index, numericValue, 'maxScale');
8170
+ }
8171
+ } })),
8172
+ React__default.createElement("td", null,
8173
+ React__default.createElement("input", { type: "checkbox", checked: tag.autoScale, onChange: function (e) { return handleAutoScaleChange(index, e.target.checked); } })),
8174
+ React__default.createElement("td", null, cursorData ? (function () {
8175
+ var date = new Date(cursorData.x);
8176
+ var formattedDate = date.toLocaleString('en-US', {
8177
+ hour12: false,
8178
+ month: 'short',
8179
+ day: 'numeric',
8180
+ hour: '2-digit',
8181
+ minute: '2-digit',
8182
+ second: '2-digit'
8183
+ });
8184
+ var milliseconds = date.getMilliseconds().toString().padStart(3, '0');
8185
+ return "".concat(formattedDate, ".").concat(milliseconds);
8186
+ })() : null),
8187
+ React__default.createElement("td", null, cursorData ? cursorData.values[index] : null))); }))),
8188
+ selectedRowIndex !== null && (React__default.createElement(ContextMenu, { x: contextMenuPosition.x, y: contextMenuPosition.y, options: contextMenuOptions })),
8189
+ React__default.createElement(MesfModal, { open: modalOpen, handleClose: handleClose, maxWidth: "lg", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
8190
+ React__default.createElement(MesfModal.Content, null,
8191
+ React__default.createElement(Box, null,
8192
+ React__default.createElement(Typography, { id: "modal-modal-description" },
8193
+ React__default.createElement(TagSelectionModal, { isOpen: modalOpen, onClose: function () { return handleClose; }, onTagSelect: handleTagSelect })))))));
8194
+ };
8195
+
8196
+ Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, TimeScale, zoomPlugin);
8197
+ function getVerticalLinePlugin(setCursorData) {
8198
+ return {
8199
+ id: 'verticalLinePlugin',
8200
+ beforeInit: function (chart) {
8201
+ var canvas = chart.canvas;
8202
+ chart.mouseX = null;
8203
+ canvas.addEventListener('mousemove', function (event) {
8204
+ var rect = canvas.getBoundingClientRect();
8205
+ chart.mouseX = event.clientX - rect.left;
8206
+ var xScale = chart.scales.x;
8207
+ var mouseXPixel = chart.mouseX - xScale.left; // Adjusting for the scale's position
8208
+ var timeAtCursor = xScale.min + (mouseXPixel * (xScale.max - xScale.min) / xScale.width);
8209
+ var valuesAtCursor = [];
8210
+ // Loop through each dataset to find the previous y-values at the current x-position
8211
+ chart.data.datasets.forEach(function (dataset) {
8212
+ // Find the closest preceding data point
8213
+ var previousDataPoint = null;
8214
+ for (var i = 0; i < dataset.data.length; i++) {
8215
+ if (dataset.data[i].x.getTime() <= timeAtCursor) {
8216
+ previousDataPoint = dataset.data[i];
8217
+ }
8218
+ else {
8219
+ break;
8220
+ }
8221
+ }
8222
+ if (previousDataPoint) {
8223
+ valuesAtCursor.push(previousDataPoint.y);
8224
+ }
8225
+ });
8226
+ setCursorData({ x: timeAtCursor, values: valuesAtCursor });
8227
+ chart.draw();
8228
+ });
8229
+ },
8230
+ afterDatasetsDraw: function (chart, args, options) {
8231
+ if (chart.mouseX) {
8232
+ var ctx = chart.ctx;
8233
+ var x = chart.mouseX;
8234
+ var topY = chart.chartArea.top;
8235
+ var bottomY = chart.chartArea.bottom;
8236
+ ctx.save();
8237
+ ctx.beginPath();
8238
+ ctx.moveTo(x, topY);
8239
+ ctx.lineTo(x, bottomY);
8240
+ ctx.strokeStyle = '#ff0000'; // Customize line color
8241
+ ctx.lineWidth = 1; // Customize line width
8242
+ ctx.stroke();
8243
+ ctx.restore();
8244
+ }
8245
+ }
8246
+ };
8247
+ }
8248
+ var Trending = function (_a) {
8249
+ _a.title; var start = _a.start, end = _a.end, tags = _a.tags;
8250
+ var _b = useState({
8251
+ labels: [],
8252
+ datasets: []
8253
+ }), chartData = _b[0], setChartData = _b[1];
8254
+ var _c = useState({
8255
+ start: start,
8256
+ end: end // assuming 'end' is a Date object
8257
+ }), timeScope = _c[0], setTimeScope = _c[1];
8258
+ var _d = useState(tags), tagList = _d[0], setTagList = _d[1];
8259
+ var _e = useState(null), cursorData = _e[0], setCursorData = _e[1];
8260
+ var verticalLinePlugin = getVerticalLinePlugin(setCursorData);
8261
+ var _f = useState({
8262
+ showGrid: true,
8263
+ stepped: false
8264
+ }), customOptions = _f[0], setCustomOptions = _f[1];
8265
+ var _g = useState(true), loading = _g[0], setLoading = _g[1];
8266
+ var _h = useState(''), error = _h[0], setError = _h[1];
8267
+ var debounceTimerRef = useRef(null);
8268
+ var handleZoom = function (_a) {
8269
+ var chart = _a.chart;
8270
+ console.log('detected');
8271
+ if (debounceTimerRef.current) {
8272
+ clearTimeout(debounceTimerRef.current);
8273
+ }
8274
+ debounceTimerRef.current = setTimeout(function () {
8275
+ // Handle zoom event and execute fetch
8276
+ var newStart = new Date(chart.scales.x.min);
8277
+ var newEnd = new Date(chart.scales.x.max);
8278
+ setTimeScope(function (prevData) { return (__assign(__assign({}, prevData), { start: newStart, end: newEnd })); });
8279
+ console.log('change start / end' + newStart + ' - ' + newEnd);
8280
+ }, 1000);
8281
+ };
8282
+ var handleDeleteTag = function (tagId) {
8283
+ setTagList(function (prevTagList) { return prevTagList.filter(function (tag) { return tag.tagId !== tagId; }); });
8284
+ };
8285
+ var handleAddTag = function (newTag) {
8286
+ if (newTag) {
8287
+ setTagList(function (prevTagList) {
8288
+ // Check if the tag is already in the list to avoid duplicates
8289
+ if (prevTagList.some(function (tag) { return tag.tagId === newTag.tagId; })) {
8290
+ return prevTagList; // Return the existing list if the tag is already there
8291
+ }
8292
+ return __spreadArray(__spreadArray([], prevTagList, true), [newTag], false); // Add the new tag to the list
8293
+ });
8294
+ }
8295
+ };
8296
+ var _j = useState({
8297
+ animation: {
8298
+ duration: 0 // No animation
8299
+ },
8300
+ responsive: true,
8301
+ maintainAspectRatio: false,
8302
+ scales: {
8303
+ x: {
8304
+ type: 'time',
8305
+ ticks: {
8306
+ // Customize tick behavior if needed
8307
+ autoSkip: true,
8308
+ maxTicksLimit: 20,
8309
+ callback: function (value, index, values) {
8310
+ // Extract the time and date from the current value
8311
+ var currentDate = new Date(value);
8312
+ var time = currentDate.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' });
8313
+ var date = currentDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
8314
+ // For the first tick, return both date and time
8315
+ if (index === 0) {
8316
+ return [time, date];
8317
+ }
8318
+ // For subsequent ticks, compare the date with the previous tick
8319
+ var previousDate = new Date(values[index - 1].value);
8320
+ if (currentDate.getDate() !== previousDate.getDate() ||
8321
+ currentDate.getMonth() !== previousDate.getMonth() ||
8322
+ currentDate.getFullYear() !== previousDate.getFullYear()) {
8323
+ // If the date has changed, return both time and date
8324
+ return [time, date];
8325
+ }
8326
+ // If the date hasn't changed, return only the time
8327
+ return [time, ''];
8328
+ }
8329
+ },
8330
+ grid: {
8331
+ display: true
8332
+ }
8333
+ },
8334
+ y: {
8335
+ grid: {
8336
+ display: true
8337
+ }
8338
+ }
8339
+ },
8340
+ plugins: {
8341
+ tooltip: { enabled: false },
8342
+ legend: { display: false },
8343
+ zoom: {
8344
+ zoom: {
8345
+ wheel: { enabled: true, mode: 'x' },
8346
+ pinch: { enabled: true, mode: 'x' },
8347
+ onZoom: handleZoom,
8348
+ mode: 'x'
8349
+ },
8350
+ pan: {
8351
+ enabled: true,
8352
+ mode: 'x',
8353
+ onPan: handleZoom
8354
+ }
8355
+ }
8356
+ }
8357
+ }), chartOptions = _j[0], setChartOptions = _j[1];
8358
+ useEffect(function () {
8359
+ var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
8360
+ var tagIds, response, series_1, axes_1, updatedSeries, error_1;
8361
+ return __generator(this, function (_a) {
8362
+ switch (_a.label) {
8363
+ case 0:
8364
+ _a.trys.push([0, 2, , 3]);
8365
+ console.log('fetching data');
8366
+ setLoading(true);
8367
+ tagIds = tagList.map(function (tag) { return tag.tagId; });
8368
+ return [4 /*yield*/, axios.post('/series?nodeName=null', {
8369
+ start: timeScope.start.getTime(),
8370
+ end: timeScope.end.getTime(),
8371
+ tagIds: tagIds,
8372
+ sampleCount: 1000
8373
+ })];
8374
+ case 1:
8375
+ response = _a.sent();
8376
+ series_1 = response.data;
8377
+ axes_1 = [];
8378
+ tagList.forEach(function (tag, index) {
8379
+ if (tag.autoScale && series_1[index]) {
8380
+ var serieSamples = series_1[index].map(function (sample) { return sample.value; });
8381
+ var _a = calculateScales(Math.min.apply(Math, serieSamples), Math.max.apply(Math, serieSamples), 3), minScale = _a.minScale, maxScale = _a.maxScale;
8382
+ tag.minScale = minScale;
8383
+ tag.maxScale = maxScale;
8384
+ }
8385
+ var existingAxis = axes_1.find(function (existingTag) { return areRangesSimilar(existingTag, tag); });
8386
+ if (!existingAxis) {
8387
+ axes_1.push(tag); // Add new axis if no similar one exists
8388
+ }
8389
+ });
8390
+ axes_1.map(function (axis, index) {
8391
+ return {
8392
+ id: "y-axis-".concat(index),
8393
+ type: 'linear',
8394
+ display: axis.visible,
8395
+ scaleLabel: {
8396
+ display: true,
8397
+ labelString: axis.tagName
8398
+ },
8399
+ ticks: {
8400
+ min: axis.autoScale ? undefined : axis.minScale,
8401
+ max: axis.autoScale ? undefined : axis.maxScale
8402
+ },
8403
+ grid: {
8404
+ display: true
8405
+ }
8406
+ };
8407
+ });
8408
+ setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { scales: __assign(__assign({}, prevOptions.scales), { y: { grid: { display: true } } }) })); });
8409
+ updatedSeries = series_1.map(function (serie, index) {
8410
+ var tag = tagList[index];
8411
+ var axisIndex = axes_1.findIndex(function (existingTag) { return areRangesSimilar(existingTag, tag); });
8412
+ return {
8413
+ yAxisID: "y-axis-".concat(axisIndex),
8414
+ data: serie.map(function (sample) { return ({
8415
+ x: new Date(sample.timestamp),
8416
+ y: sample.value
8417
+ }); }),
8418
+ borderColor: tag.color,
8419
+ hidden: !tag.visible,
8420
+ pointRadius: (serie.length <= 50) ? 3 : 0 // Example threshold
8421
+ };
8422
+ });
8423
+ setChartData({
8424
+ labels: [],
8425
+ datasets: updatedSeries
8426
+ });
8427
+ setLoading(false);
8428
+ return [3 /*break*/, 3];
8429
+ case 2:
8430
+ error_1 = _a.sent();
8431
+ console.error('Error fetching data:', error_1);
8432
+ setError('Failed to fetch data');
8433
+ setLoading(false);
8434
+ return [3 /*break*/, 3];
8435
+ case 3: return [2 /*return*/];
8436
+ }
8437
+ });
8438
+ }); };
8439
+ fetchData();
8440
+ }, [timeScope, tagList]);
8441
+ useEffect(function () {
8442
+ var changeOptions = function () {
8443
+ console.log('change options');
8444
+ setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { elements: {
8445
+ line: {
8446
+ stepped: customOptions.stepped,
8447
+ lineTension: 0.1
8448
+ }
8449
+ }, scales: __assign(__assign({}, prevOptions.scales), { x: __assign(__assign({}, prevOptions.scales.x), { grid: __assign(__assign({}, prevOptions.scales.x.grid), { display: customOptions.showGrid }) }), y: __assign(__assign({}, prevOptions.scales.y), { grid: __assign(__assign({}, prevOptions.scales.y.grid), { display: customOptions.showGrid }) }) }) })); });
8450
+ };
8451
+ changeOptions();
8452
+ }, [customOptions]);
8453
+ function areRangesSimilar(tag1, tag2) {
8454
+ var threshold = 1; // Define a threshold for "closeness"
8455
+ // Helper function to safely compute logarithm, avoiding negative and zero values
8456
+ var safeLog = function (value) {
8457
+ if (value <= 0) {
8458
+ return null; // or some safe value depending on your context
8459
+ }
8460
+ return Math.log(value);
8461
+ };
8462
+ var logTag1Min = safeLog(tag1.minScale);
8463
+ var logTag1Max = safeLog(tag1.maxScale);
8464
+ var logTag2Min = safeLog(tag2.minScale);
8465
+ var logTag2Max = safeLog(tag2.maxScale);
8466
+ // Check if any log value is null, which indicates an invalid comparison
8467
+ if (logTag1Min === null || logTag1Max === null || logTag2Min === null || logTag2Max === null) {
8468
+ return false;
8469
+ }
8470
+ var logDiffMin = Math.abs(logTag1Min - logTag2Min);
8471
+ var logDiffMax = Math.abs(logTag1Max - logTag2Max);
8472
+ return logDiffMin < threshold && logDiffMax < threshold;
8473
+ }
8474
+ function calculateScales(min, max, sigDigits) {
8475
+ var roundToSignificantDigits = function (num) {
8476
+ if (num === 0)
8477
+ return 0;
8478
+ var multiplier = Math.pow(10, sigDigits - Math.floor(Math.log10(Math.abs(num))) - 1);
8479
+ return Math.round(num * multiplier) / multiplier;
8480
+ };
8481
+ var minScale = roundToSignificantDigits(min);
8482
+ var maxScale = roundToSignificantDigits(max);
8483
+ // Adjust minScale and maxScale if necessary
8484
+ if (minScale > min) {
8485
+ minScale *= .9;
8486
+ }
8487
+ if (maxScale < max) {
8488
+ maxScale *= 1.1;
8489
+ }
8490
+ return { minScale: minScale, maxScale: maxScale };
8491
+ }
8492
+ if (error)
8493
+ return React__default.createElement("p", null,
8494
+ "Error: ",
8495
+ error);
8496
+ return (React__default.createElement("div", { className: "dashboard" },
8497
+ React__default.createElement("div", { className: "header" },
8498
+ React__default.createElement("div", { className: "date-pickers", style: { marginBottom: "5vh" } },
8499
+ React__default.createElement(DateComponent, { date: timeScope.start }),
8500
+ React__default.createElement(DateComponent, { date: timeScope.end })),
8501
+ React__default.createElement("div", { className: "options" },
8502
+ React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions })),
8503
+ React__default.createElement("div", { className: "buttons", style: { padding: "15px" } },
8504
+ React__default.createElement("button", null, "Button"),
8505
+ React__default.createElement("button", null, "Button"))),
8506
+ React__default.createElement("div", { className: "chart-container" },
8507
+ React__default.createElement(Line, { data: chartData, options: chartOptions, plugins: [verticalLinePlugin] })),
8508
+ React__default.createElement("div", { className: "table-container", style: { marginTop: "30vh" } },
8509
+ React__default.createElement(TableComponent, { tagList: tagList, setTagList: setTagList, cursorData: cursorData, onDeleteTag: handleDeleteTag, onAddTag: handleAddTag })),
8510
+ loading ? React__default.createElement("p", { className: "loading" }, "Loading...") : null));
8511
+ };
8512
+
8513
+ // @flow
8514
+ var TrendingsIndex = function (props) {
8515
+ var _a = useState(new Date('2023-11-16')), startDate = _a[0]; _a[1];
8516
+ var _b = useState(new Date('2023-11-17')), endDate = _b[0]; _b[1];
8517
+ return (React.createElement(Box, { p: 3, style: { maxWidth: '99%' } },
8518
+ React.createElement(Paper, null,
8519
+ React.createElement(Grid$1, { container: true, spacing: 3, style: { padding: "20px" } },
8520
+ React.createElement(Grid$1, { item: true, xs: 12 },
8521
+ React.createElement(Trending, { title: "Trending Chart", start: startDate, end: endDate, tags: [
8522
+ { tagId: 29, tagName: 't1', tagType: 'number', color: 'red', autoScale: true, minScale: 0, maxScale: 100, visible: true },
8523
+ { tagId: 44, tagName: 't2', tagType: 'number', color: 'blue', autoScale: true, minScale: 0, maxScale: 100, visible: true },
8524
+ { tagId: 50, tagName: 't3', tagType: 'number', color: 'green', autoScale: true, minScale: 0, maxScale: 100, visible: true },
8525
+ { tagId: 46, tagName: 't4', tagType: 'number', color: 'black', autoScale: true, minScale: 0, maxScale: 100, visible: true },
8526
+ ] }))))));
8527
+ };
8528
+
7821
8529
  var MESFMainRouter = function () {
7822
8530
  var CustomRoutes = useContext(RouterContext);
7823
8531
  return (React__default.createElement(React__default.Fragment, null,
@@ -7825,6 +8533,7 @@ var MESFMainRouter = function () {
7825
8533
  React__default.createElement(Route, { path: "/", element: React__default.createElement(Navigate, { replace: true, to: "/home" }) }),
7826
8534
  React__default.createElement(Route, { path: "/configuration/*", element: React__default.createElement(Configuration, null) }),
7827
8535
  React__default.createElement(Route, { path: "/account", element: React__default.createElement(Account, null) }),
8536
+ React__default.createElement(Route, { path: "/trendings", element: React__default.createElement(TrendingsIndex, null) }),
7828
8537
  React__default.createElement(Route, { path: "/home", element: React__default.createElement(Home, null) })),
7829
8538
  React__default.createElement(CustomRoutes, null)));
7830
8539
  };
@@ -8000,4 +8709,4 @@ var areaSelector = /*#__PURE__*/Object.freeze({
8000
8709
  AreaSelector: AreaSelector
8001
8710
  });
8002
8711
 
8003
- export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, 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, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TreePickerControl, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, formatNumber, getCrewStyle, getError, getShiftStyle, getTokenFromLS, renewToken, useAssetContext, useToken, useUTLSettingsContext, useUserContext };
8712
+ export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, 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, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TreePickerControl, TrendingsIndex, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, formatNumber, getCrewStyle, getError, getShiftStyle, getTokenFromLS, renewToken, useAssetContext, useToken, useUTLSettingsContext, useUserContext };
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ type Props = {
3
+ date: Date;
4
+ };
5
+ declare const DateComponent: React.FC<Props>;
6
+ export default DateComponent;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { CursorData, TagList } from './Trending';
3
+ import './ContextMenu.css';
4
+ interface TableComponentProps {
5
+ tagList: TagList;
6
+ setTagList: React.Dispatch<React.SetStateAction<TagList>>;
7
+ cursorData: CursorData;
8
+ onDeleteTag: (tagId: number) => void;
9
+ onAddTag: (tagId: number) => void;
10
+ }
11
+ declare const TableComponent: React.FC<TableComponentProps>;
12
+ export default TableComponent;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Tag } from './Trending';
3
+ interface TagSelectionModalProps {
4
+ isOpen: boolean;
5
+ onClose: () => void;
6
+ onTagSelect: (tag: Tag) => void;
7
+ }
8
+ declare const TagSelectionModal: React.FC<TagSelectionModalProps>;
9
+ export default TagSelectionModal;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import 'chartjs-adapter-moment/dist/chartjs-adapter-moment.esm.js';
3
+ interface TrendingProps {
4
+ title: string;
5
+ start: Date;
6
+ end: Date;
7
+ tags: Tag[];
8
+ }
9
+ interface Sample {
10
+ timestamp: number;
11
+ value: number;
12
+ }
13
+ export type SampleArray = Sample[][];
14
+ export interface Tag {
15
+ tagId: number;
16
+ tagName: string;
17
+ tagType: string;
18
+ color: string;
19
+ autoScale: boolean;
20
+ minScale: number;
21
+ maxScale: number;
22
+ visible: boolean;
23
+ }
24
+ export interface CursorData {
25
+ x: Date;
26
+ values: number[];
27
+ }
28
+ export interface CustomOptions {
29
+ showGrid: boolean;
30
+ stepped: boolean;
31
+ }
32
+ export type TagList = Tag[];
33
+ declare const Trending: React.FC<TrendingProps>;
34
+ export default Trending;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { CustomOptions } from "./Trending";
3
+ interface CustomOptionsComponentProps {
4
+ customOptions: CustomOptions;
5
+ setCustomOptions: React.Dispatch<React.SetStateAction<CustomOptions>>;
6
+ }
7
+ declare const CustomOptionsComponent: React.FC<CustomOptionsComponentProps>;
8
+ export default CustomOptionsComponent;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ type Props = {};
3
+ export declare const TrendingsIndex: (props: Props) => React.JSX.Element;
4
+ export {};
@@ -0,0 +1 @@
1
+ export declare const TrendingsReducer: import("@reduxjs/toolkit").Slice<{}, {}, "__">;
@@ -1,28 +1,4 @@
1
- export declare const getUser: (UserId: number, UserName: string | null) => Promise<{
2
- ok: false;
3
- message: string;
4
- } | {
5
- ok: true;
6
- data: any;
7
- }>;
8
- export declare const getAssets: () => Promise<{
9
- ok: false;
10
- message: string;
11
- } | {
12
- ok: true;
13
- data: any;
14
- }>;
15
- export declare const getUTLSettings: () => Promise<{
16
- ok: false;
17
- message: string;
18
- } | {
19
- ok: true;
20
- data: any;
21
- }>;
22
- export declare const upsertDefaultAreaId: (UserId: number, DefaultAreaId: number | null) => Promise<{
23
- ok: false;
24
- message: string;
25
- } | {
26
- ok: true;
27
- data: any;
28
- }>;
1
+ export declare const getUser: (UserId: number, UserName: string | null) => Promise<import("../services").ResponseMESF>;
2
+ export declare const getAssets: () => Promise<import("../services").ResponseMESF>;
3
+ export declare const getUTLSettings: () => Promise<import("../services").ResponseMESF>;
4
+ export declare const upsertDefaultAreaId: (UserId: number, DefaultAreaId: number | null) => Promise<import("../services").ResponseMESF>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexteel/mesf-core",
3
- "version": "4.3.3",
3
+ "version": "4.4.1-alpha",
4
4
  "author": "Dexteel Team",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -61,6 +61,9 @@
61
61
  "@nivo/bar": "^0.79.1",
62
62
  "@nivo/core": "^0.79.0",
63
63
  "@reduxjs/toolkit": "^1.6.2",
64
+ "ag-grid-community": "^29.2.0",
65
+ "ag-grid-enterprise": "^29.2.0",
66
+ "ag-grid-react": "^29.2.0",
64
67
  "bootstrap": "^4.6.1",
65
68
  "moment": "^2.29.1",
66
69
  "prop-types": "^15.8.1",
@@ -71,10 +74,7 @@
71
74
  "react-spring": "^9.4.3",
72
75
  "rimraf": "^3.0.2",
73
76
  "string-to-color": "^2.2.2",
74
- "use-complex-state": "^1.1.0",
75
- "ag-grid-community": "^29.2.0",
76
- "ag-grid-enterprise": "^29.2.0",
77
- "ag-grid-react": "^29.2.0"
77
+ "use-complex-state": "^1.1.0"
78
78
  },
79
79
  "browserslist": {
80
80
  "production": [
@@ -95,7 +95,11 @@
95
95
  "@emotion/styled": "^11.11.0",
96
96
  "@minoru/react-dnd-treeview": "^3.4.4",
97
97
  "axios": "^1.3.5",
98
+ "chart.js": "^4.4.1",
99
+ "chartjs-adapter-moment": "^1.0.1",
100
+ "chartjs-plugin-zoom": "^2.0.1",
98
101
  "lodash-es": "^4.17.21",
102
+ "react-chartjs-2": "^5.2.0",
99
103
  "react-dnd": "^16.0.1",
100
104
  "string-to-color": "^2.2.2",
101
105
  "tsc": "^2.0.3"