@dexteel/mesf-core 4.5.2 → 4.5.4

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,8 @@
1
1
  # CHANGELOG
2
+ ## 4.5.4
3
+ - Add arrows dates navigator
4
+ ## 4.5.3
5
+ - Use color picker in trendings
2
6
  ## 4.5.0
3
7
  - Use inputs in `/trendings`
4
8
  ## 4.4.0
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, Tooltip, Box, FormControl as FormControl$1, Select as Select$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, Tooltip, Box, IconButton as IconButton$1, FormControl as FormControl$1, Select as Select$1, 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,6 +20,7 @@ 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 { ArrowRight, ChevronLeft, ChevronRight } from '@material-ui/icons';
23
24
  import axios from 'axios';
24
25
  import { _adapters, Chart, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip as Tooltip$1, Legend, TimeScale } from 'chart.js';
25
26
  import moment from 'moment';
@@ -29,6 +30,7 @@ import { Alert as Alert$3, TreeView as TreeView$1, TreeItem as TreeItem$1 } from
29
30
  import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
30
31
  import FolderIcon from '@material-ui/icons/Folder';
31
32
  import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile';
33
+ import Popover from '@material-ui/core/Popover';
32
34
  import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
33
35
  import PropTypes from 'prop-types';
34
36
  import { ResponsiveBar } from '@nivo/bar';
@@ -67,7 +69,6 @@ import 'ag-grid-enterprise/styles/ag-theme-balham.min.css';
67
69
  import 'ag-grid-community/styles/ag-grid.css';
68
70
  import 'ag-grid-community/styles/ag-theme-alpine.css';
69
71
  import { isAncestor, Tree } from '@minoru/react-dnd-treeview';
70
- import { ArrowRight } from '@material-ui/icons';
71
72
  import ImageIcon from '@material-ui/icons/Image';
72
73
  import ListAltIcon from '@material-ui/icons/ListAlt';
73
74
  import DescriptionIcon from '@material-ui/icons/Description';
@@ -8291,16 +8292,21 @@ var css$1 = "/* ContextMenu.css */\n.context-menu {\n position: absolute;\n
8291
8292
  n(css$1,{});
8292
8293
 
8293
8294
  var tagColors = [
8294
- "#2E4053",
8295
- "#5D6D7E",
8296
- "#85929E",
8297
- "#A93226",
8298
- "#CD6155",
8299
- "#2ECC71",
8300
- "#58D68D",
8301
- "#239B56",
8302
- "#7D3C98",
8303
- "#C39BD3", // Lavanda
8295
+ "#5eaf60",
8296
+ "green",
8297
+ "#62bd9c",
8298
+ "#53a285",
8299
+ "#add8e6",
8300
+ "#3280ba",
8301
+ "blue",
8302
+ "#5293c5",
8303
+ "#3d556f",
8304
+ "#a362bf",
8305
+ "#dab0d8",
8306
+ "black",
8307
+ "#e74b3c",
8308
+ "red",
8309
+ "#bf3b2c", // dark red
8304
8310
  ];
8305
8311
 
8306
8312
  var TagSelectionModal = function (_a) {
@@ -8449,6 +8455,59 @@ var TagSelectionModal = function (_a) {
8449
8455
  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); }))))));
8450
8456
  };
8451
8457
 
8458
+ var useTagColorsStyles = makeStyles$1({
8459
+ swatch: {
8460
+ width: '25px',
8461
+ height: '25px',
8462
+ display: 'inline-block',
8463
+ margin: '2px',
8464
+ borderRadius: '4px',
8465
+ cursor: 'pointer'
8466
+ },
8467
+ popover: {
8468
+ display: 'flex',
8469
+ flexWrap: 'wrap',
8470
+ padding: '10px',
8471
+ maxWidth: '165px'
8472
+ }
8473
+ });
8474
+
8475
+ var Swatch = function (_a) {
8476
+ var color = _a.color, onSelect = _a.onSelect;
8477
+ var classes = useTagColorsStyles();
8478
+ return (React__default.createElement("div", { className: classes.swatch, style: { backgroundColor: color }, onClick: function () { return onSelect(color); } }));
8479
+ };
8480
+ var ColorPicker = function (_a) {
8481
+ var onChange = _a.onChange, color = _a.color, elementId = _a.elementId;
8482
+ var classes = useTagColorsStyles();
8483
+ var _b = useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
8484
+ var handleClick = function (event) {
8485
+ setAnchorEl(event.currentTarget);
8486
+ };
8487
+ var handleClose = function () {
8488
+ setAnchorEl(null);
8489
+ };
8490
+ var open = Boolean(anchorEl);
8491
+ var id = open ? 'simple-popover' : undefined;
8492
+ return (React__default.createElement("div", null,
8493
+ React__default.createElement(Button, { "aria-describedby": id, variant: "outlined", onClick: handleClick, style: {
8494
+ backgroundColor: color,
8495
+ width: '20px',
8496
+ height: '20px',
8497
+ minWidth: '20px',
8498
+ padding: 0,
8499
+ margin: '4px'
8500
+ } }),
8501
+ React__default.createElement(Popover, { id: id, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
8502
+ vertical: 'bottom',
8503
+ horizontal: 'left'
8504
+ } },
8505
+ React__default.createElement("div", { className: classes.popover }, tagColors.map(function (color) { return (React__default.createElement(Swatch, { key: color, color: color, onSelect: function (color) {
8506
+ onChange(elementId, color);
8507
+ handleClose();
8508
+ } })); })))));
8509
+ };
8510
+
8452
8511
  var useTagsTableStyles = makeStyles$1(function (theme) { return ({
8453
8512
  checkbox: {
8454
8513
  '& input[type="checkbox"]': {
@@ -8473,6 +8532,9 @@ var TableComponent = function (_a) {
8473
8532
  var handleAutoScaleChange = function (index, value) {
8474
8533
  setTagList(function (prev) { return prev.map(function (tag, currentIndex) { return currentIndex === index ? __assign(__assign({}, tag), { autoScale: value }) : tag; }); });
8475
8534
  };
8535
+ var handleColorChange = function (tagId, value) {
8536
+ setTagList(function (prev) { return prev.map(function (tag) { return tag.tagId === tagId ? __assign(__assign({}, tag), { color: value }) : tag; }); });
8537
+ };
8476
8538
  var _b = useState(null), selectedRowIndex = _b[0], setSelectedRowIndex = _b[1];
8477
8539
  var _c = useState(false), modalOpen = _c[0], setModalOpen = _c[1];
8478
8540
  var handleOpen = function () { return setModalOpen(true); };
@@ -8572,11 +8634,7 @@ var TableComponent = function (_a) {
8572
8634
  React__default.createElement(Tooltip, { title: tag.tagName, placement: "top", arrow: true, interactive: true, enterDelay: 500 },
8573
8635
  React__default.createElement("div", { style: cellStyles.tagName }, tag.tagName))),
8574
8636
  React__default.createElement("td", { style: headerStyles.color },
8575
- React__default.createElement("div", { style: {
8576
- backgroundColor: tag.color,
8577
- width: '20px',
8578
- height: '20px'
8579
- } })),
8637
+ React__default.createElement(ColorPicker, { onChange: handleColorChange, color: tag.color, elementId: tag.tagId })),
8580
8638
  React__default.createElement("td", null,
8581
8639
  React__default.createElement("input", { type: "text", style: { width: '100%' }, value: tag.minScale, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
8582
8640
  var value = e.target.value;
@@ -8628,6 +8686,13 @@ var TrendingsReducer = createSlice({
8628
8686
  reducers: {
8629
8687
  setTotalScope: function (state, _a) {
8630
8688
  var payload = _a.payload; _a.type;
8689
+ if (!isNil$1(payload.start) && !isNil$1(payload.end) && !isNil$1(payload.scope)) {
8690
+ //from arrow navigators
8691
+ state.timeScopeStart = payload.start;
8692
+ state.timeScopeEnd = payload.end;
8693
+ state.scope = payload.scope;
8694
+ return;
8695
+ }
8631
8696
  if (!isNil$1(payload.scope)) {
8632
8697
  if (payload.scope !== "custom") {
8633
8698
  switch (payload.scope) {
@@ -8666,7 +8731,7 @@ var TrendingsReducer = createSlice({
8666
8731
  state.scope = payload.scope;
8667
8732
  return;
8668
8733
  }
8669
- if (!isNil$1(payload.start) && !isNil$1(payload.end)) {
8734
+ if (!isNil$1(payload.start) && !isNil$1(payload.end) && isNil$1(payload.scope)) {
8670
8735
  // from graph
8671
8736
  state.timeScopeStart = payload.start;
8672
8737
  state.timeScopeEnd = payload.end;
@@ -8817,6 +8882,11 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
8817
8882
  '& input[type="checkbox"]': {
8818
8883
  zoom: 1.5
8819
8884
  }
8885
+ },
8886
+ navigatorButton: {
8887
+ "& .MuiSvgIcon-root": {
8888
+ cursor: "pointer !important"
8889
+ }
8820
8890
  }
8821
8891
  }); });
8822
8892
 
@@ -8840,6 +8910,17 @@ var CustomOptionsComponent = function (_a) {
8840
8910
  "Stepped"))));
8841
8911
  };
8842
8912
 
8913
+ var dateNavigator = function (startDate, endDate, scope, operator) {
8914
+ if (scope === "custom")
8915
+ return;
8916
+ else {
8917
+ var _a = scope.split(" "), quantity = _a[0], duration = _a[1];
8918
+ var newStartDate = moment(startDate)[operator](quantity, duration[0]).toDate();
8919
+ var newEndDate = moment(endDate)[operator](quantity, duration[0]).toDate();
8920
+ return { newStartDate: newStartDate, newEndDate: newEndDate };
8921
+ }
8922
+ };
8923
+
8843
8924
  Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
8844
8925
  function getVerticalLinePlugin(setCursorData) {
8845
8926
  return {
@@ -8953,6 +9034,12 @@ var Trending = function (_a) {
8953
9034
  });
8954
9035
  }
8955
9036
  };
9037
+ var handleDateNavigator = function (operator) {
9038
+ var newDates = dateNavigator(state.timeScopeStart, state.timeScopeEnd, state.scope, operator);
9039
+ if (newDates) {
9040
+ actions.setTotalScope({ start: newDates.newStartDate, end: newDates.newEndDate, scope: state.scope });
9041
+ }
9042
+ };
8956
9043
  var _j = useState({
8957
9044
  animation: {
8958
9045
  duration: 0
@@ -8968,7 +9055,6 @@ var Trending = function (_a) {
8968
9055
  maxTicksLimit: 20,
8969
9056
  callback: function (value, index, values) {
8970
9057
  // Extract the time and date from the current value
8971
- console.log("VALUE", value);
8972
9058
  var currentDate = new Date(value);
8973
9059
  var time = currentDate.toLocaleTimeString("en-US", {
8974
9060
  hour12: false,
@@ -9176,6 +9262,8 @@ var Trending = function (_a) {
9176
9262
  return (React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
9177
9263
  React__default.createElement(Grid$1, { item: true, xs: 12, container: true, justifyContent: "space-between", alignItems: "center", style: { height: "15%" } },
9178
9264
  React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
9265
+ React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
9266
+ React__default.createElement(ChevronLeft, { fontSize: "large" })),
9179
9267
  React__default.createElement(Grid$1, { item: true },
9180
9268
  React__default.createElement(TextField, { type: "datetime-local", className: classes.datetimePicker, label: "Start", variant: "outlined", value: moment(state.timeScopeStart).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "start"); }, InputLabelProps: {
9181
9269
  shrink: true,
@@ -9197,7 +9285,9 @@ var Trending = function (_a) {
9197
9285
  React__default.createElement(TextField, { label: "End", variant: "outlined", className: classes.datetimePicker, type: "datetime-local", value: moment(state.timeScopeEnd).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "end"); }, InputLabelProps: {
9198
9286
  shrink: true,
9199
9287
  style: { marginLeft: "10px" }
9200
- } }))),
9288
+ } })),
9289
+ React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("add"); }, className: classes.navigatorButton },
9290
+ React__default.createElement(ChevronRight, { fontSize: "large" }))),
9201
9291
  React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
9202
9292
  React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
9203
9293
  React__default.createElement(Grid$1, { item: true, container: true },
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { CursorData, TagList } from './Trending';
3
2
  import './ContextMenu.css';
3
+ import { CursorData, TagList } from './Trending';
4
4
  interface TableComponentProps {
5
5
  tagList: TagList;
6
6
  setTagList: React.Dispatch<React.SetStateAction<TagList>>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ onChange: Function;
4
+ color: string;
5
+ elementId?: number;
6
+ }
7
+ declare const ColorPicker: ({ onChange, color, elementId }: Props) => React.JSX.Element;
8
+ export default ColorPicker;
@@ -23,6 +23,10 @@ export declare const useTrendingContext: () => {
23
23
  scope?: import("../models/scopes.model").scopeType | undefined;
24
24
  start?: Date | undefined;
25
25
  end: Date;
26
+ } | {
27
+ scope: import("../models/scopes.model").scopeType;
28
+ start: Date;
29
+ end: Date;
26
30
  };
27
31
  type: string;
28
32
  }): void;
@@ -0,0 +1 @@
1
+ export declare const useTagColorsStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"swatch" | "popover">;
@@ -1 +1 @@
1
- export declare const useTrendingStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"datetimePicker" | "select" | "labelOptions">;
1
+ export declare const useTrendingStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"datetimePicker" | "select" | "labelOptions" | "navigatorButton">;
@@ -0,0 +1,5 @@
1
+ import { scopeType } from "../models/scopes.model";
2
+ export declare const dateNavigator: (startDate: Date, endDate: Date, scope: scopeType, operator: "add" | "subtract") => {
3
+ newStartDate: Date;
4
+ newEndDate: Date;
5
+ } | undefined;
@@ -21,6 +21,10 @@ export declare const TrendingsReducer: import("@reduxjs/toolkit").Slice<{
21
21
  scope?: scopeType;
22
22
  start?: Date;
23
23
  end: Date;
24
+ } | {
25
+ scope: scopeType;
26
+ start: Date;
27
+ end: Date;
24
28
  };
25
29
  type: string;
26
30
  }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexteel/mesf-core",
3
- "version": "4.5.2",
3
+ "version": "4.5.4",
4
4
  "author": "Dexteel Team",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",