@dexteel/mesf-core 4.6.0 → 4.6.2
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 +5 -1
- package/dist/index.esm.js +177 -74
- package/dist/index.esm.js.map +1 -1
- package/dist/pages/trendings/components/chart/TableComponent.d.ts +1 -0
- package/dist/pages/trendings/components/chart/Trending.d.ts +1 -0
- package/dist/pages/trendings/components/chart/components/modals/loadView/LoadViewModal.d.ts +1 -1
- package/dist/pages/trendings/components/chart/components/modals/saveAsView/SaveAsViewModal.d.ts +1 -1
- package/dist/pages/trendings/components/chart/components/modals/saveView/SaveViewModal.d.ts +7 -0
- package/dist/pages/trendings/components/chart/context/TrendingContext.d.ts +10 -0
- package/dist/pages/trendings/components/chart/models/TrendingModels.d.ts +4 -0
- package/dist/pages/trendings/components/chart/sections/trending-chart.d.ts +2 -1
- package/dist/pages/trendings/reducers/trendings.reducer.d.ts +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
## 4.6.2
|
|
3
|
+
- Save Current View changes
|
|
4
|
+
## 4.6.1
|
|
5
|
+
- Fix manual scales
|
|
2
6
|
## 4.6.0
|
|
3
7
|
- Add Views and ViewTags functionalities to Trendings
|
|
4
8
|
## 4.5.9
|
|
@@ -84,4 +88,4 @@
|
|
|
84
88
|
## 2.1.5
|
|
85
89
|
- Fix exportExcel method. Now it supports when sheets structure is defined. **REQUIRES mesf-core-api@1.2.2**
|
|
86
90
|
## 2.1.3
|
|
87
|
-
- Implementation of **exportExcel** inside MESApiService. **REQUIRES mesf-core-api@1.2.0**
|
|
91
|
+
- Implementation of **exportExcel** inside MESApiService. **REQUIRES mesf-core-api@1.2.0**
|
package/dist/index.esm.js
CHANGED
|
@@ -8469,6 +8469,9 @@ var TrendingsReducer = createSlice({
|
|
|
8469
8469
|
setViewTags: function (state, _a) {
|
|
8470
8470
|
var payload = _a.payload;
|
|
8471
8471
|
state.viewTags = payload;
|
|
8472
|
+
},
|
|
8473
|
+
setGraphShouldUpdate: function (state) {
|
|
8474
|
+
state.graphShouldUpdate = +1;
|
|
8472
8475
|
}
|
|
8473
8476
|
}
|
|
8474
8477
|
});
|
|
@@ -8878,7 +8881,7 @@ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisibl
|
|
|
8878
8881
|
|
|
8879
8882
|
var LoadViewModal = function (_a) {
|
|
8880
8883
|
var open = _a.open, handleClose = _a.handleClose;
|
|
8881
|
-
var _b = useTrendingContext(), _c = _b.state
|
|
8884
|
+
var _b = useTrendingContext(), _c = _b.state, views = _c.views, viewSelected = _c.viewSelected, _d = _b.actions; _d.setViews; var setViewTags = _d.setViewTags, setViewSelected = _d.setViewSelected;
|
|
8882
8885
|
var _e = useState(false), isLoading = _e[0], setIsLoading = _e[1];
|
|
8883
8886
|
var _f = useState(''), error = _f[0], setError = _f[1];
|
|
8884
8887
|
var handleSelect = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -8898,21 +8901,21 @@ var LoadViewModal = function (_a) {
|
|
|
8898
8901
|
setError(viewTagsResp.message);
|
|
8899
8902
|
}
|
|
8900
8903
|
setIsLoading(false);
|
|
8901
|
-
handleClose();
|
|
8904
|
+
handleClose(true);
|
|
8902
8905
|
_a.label = 2;
|
|
8903
8906
|
case 2: return [2 /*return*/];
|
|
8904
8907
|
}
|
|
8905
8908
|
});
|
|
8906
8909
|
}); };
|
|
8907
8910
|
return (React__default.createElement("div", null,
|
|
8908
|
-
React__default.createElement(MesfModal, { open: open, handleClose: handleClose, maxWidth: "xl", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
8911
|
+
React__default.createElement(MesfModal, { open: open, handleClose: function () { return handleClose(false); }, maxWidth: "xl", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
8909
8912
|
React__default.createElement(MesfModal.Content, null,
|
|
8910
8913
|
React__default.createElement(Grid$1, { container: true },
|
|
8911
8914
|
React__default.createElement(Grid$1, { item: true, md: 12 }, views.length ? (React__default.createElement(Autocomplete, { size: 'small', id: "list-of-views", options: views, getOptionLabel: function (option) { return option.ViewName; }, onChange: function (ev, val) { return setViewSelected(val); }, style: { width: "100%" }, renderInput: function (params) { return React__default.createElement(TextField, __assign({}, params, { label: "Views", variant: "outlined" })); } })) :
|
|
8912
8915
|
(React__default.createElement("div", null, "No tag views detected, please add one"))))),
|
|
8913
8916
|
React__default.createElement(MesfModal.Actions, null,
|
|
8914
8917
|
React__default.createElement("div", { style: { paddingTop: "1rem" } },
|
|
8915
|
-
React__default.createElement(Button$1, { variant: 'outlined', style: { marginRight: "1rem" }, color: 'secondary', onClick: handleClose }, "Cancel"),
|
|
8918
|
+
React__default.createElement(Button$1, { variant: 'outlined', style: { marginRight: "1rem" }, color: 'secondary', onClick: function () { return handleClose(false); } }, "Cancel"),
|
|
8916
8919
|
React__default.createElement(ButtonWithLoading, { onClick: handleSelect, variant: 'contained', color: 'primary', isLoading: isLoading, style: { marginRight: "1rem" } }, "Apply")))),
|
|
8917
8920
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); } })));
|
|
8918
8921
|
};
|
|
@@ -9024,7 +9027,7 @@ var SaveAsViewModal = function (_a) {
|
|
|
9024
9027
|
setError("Tag ".concat(index, " failed with reason: ").concat(result.reason));
|
|
9025
9028
|
}
|
|
9026
9029
|
else {
|
|
9027
|
-
handleClose();
|
|
9030
|
+
handleClose(true);
|
|
9028
9031
|
}
|
|
9029
9032
|
});
|
|
9030
9033
|
return [3 /*break*/, 4];
|
|
@@ -9038,7 +9041,7 @@ var SaveAsViewModal = function (_a) {
|
|
|
9038
9041
|
});
|
|
9039
9042
|
}); };
|
|
9040
9043
|
return (React__default.createElement(React__default.Fragment, null,
|
|
9041
|
-
React__default.createElement(MesfModal, { open: open, handleClose: handleClose, maxWidth: "xl", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
9044
|
+
React__default.createElement(MesfModal, { open: open, handleClose: function () { return handleClose(false); }, maxWidth: "xl", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
9042
9045
|
React__default.createElement(Divider, null),
|
|
9043
9046
|
React__default.createElement(MesfModal.Content, null,
|
|
9044
9047
|
React__default.createElement(Grid$1, { container: true, spacing: 5, style: { padding: "1rem" } },
|
|
@@ -9052,7 +9055,7 @@ var SaveAsViewModal = function (_a) {
|
|
|
9052
9055
|
React__default.createElement(MesfModal.Actions, null,
|
|
9053
9056
|
React__default.createElement(Grid$1, { container: true, spacing: 1, style: { display: 'flex', alignItems: 'flex-end', justifyContent: 'flex-end' } },
|
|
9054
9057
|
React__default.createElement(Grid$1, { item: true },
|
|
9055
|
-
React__default.createElement(Button$1, { variant: 'outlined', color: 'secondary', onClick: handleClose }, "Cancel")),
|
|
9058
|
+
React__default.createElement(Button$1, { variant: 'outlined', color: 'secondary', onClick: function () { return handleClose(false); } }, "Cancel")),
|
|
9056
9059
|
React__default.createElement(Grid$1, { item: true },
|
|
9057
9060
|
React__default.createElement(ButtonWithLoading, { variant: 'contained', color: 'primary', onClick: handleSubmit, isLoading: isLoading }, "Save"))))),
|
|
9058
9061
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); } })));
|
|
@@ -9190,12 +9193,76 @@ var timeDifference = function (start, end) {
|
|
|
9190
9193
|
return "".concat(hours, "h ").concat(remainingMinutes, "m ").concat(remainingSeconds, "s");
|
|
9191
9194
|
};
|
|
9192
9195
|
|
|
9196
|
+
var SaveViewModal = function (_a) {
|
|
9197
|
+
var open = _a.open, handleClose = _a.handleClose;
|
|
9198
|
+
var _b = useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
|
9199
|
+
var _c = useState(''), error = _c[0], setError = _c[1];
|
|
9200
|
+
var _d = useTrendingContext().state, viewTags = _d.viewTags, viewSelected = _d.viewSelected;
|
|
9201
|
+
var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9202
|
+
var resp, results;
|
|
9203
|
+
return __generator(this, function (_a) {
|
|
9204
|
+
switch (_a.label) {
|
|
9205
|
+
case 0:
|
|
9206
|
+
setIsLoading(true);
|
|
9207
|
+
if (!(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId)) return [3 /*break*/, 4];
|
|
9208
|
+
return [4 /*yield*/, upsertView(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, viewSelected.ViewName, viewSelected.IsPublic)];
|
|
9209
|
+
case 1:
|
|
9210
|
+
resp = _a.sent();
|
|
9211
|
+
if (!resp.ok) return [3 /*break*/, 3];
|
|
9212
|
+
return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
|
|
9213
|
+
var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
|
|
9214
|
+
upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)
|
|
9215
|
+
.then(function (r) {
|
|
9216
|
+
if (!r.ok) {
|
|
9217
|
+
setError(r.message);
|
|
9218
|
+
}
|
|
9219
|
+
});
|
|
9220
|
+
}))];
|
|
9221
|
+
case 2:
|
|
9222
|
+
results = _a.sent();
|
|
9223
|
+
results.forEach(function (result, index) {
|
|
9224
|
+
if (result.status === "rejected") {
|
|
9225
|
+
setError("Tag ".concat(index, " failed with reason: ").concat(result.reason));
|
|
9226
|
+
}
|
|
9227
|
+
else {
|
|
9228
|
+
handleClose(true);
|
|
9229
|
+
}
|
|
9230
|
+
});
|
|
9231
|
+
return [3 /*break*/, 4];
|
|
9232
|
+
case 3:
|
|
9233
|
+
setError(resp.message);
|
|
9234
|
+
_a.label = 4;
|
|
9235
|
+
case 4:
|
|
9236
|
+
setIsLoading(false);
|
|
9237
|
+
return [2 /*return*/];
|
|
9238
|
+
}
|
|
9239
|
+
});
|
|
9240
|
+
}); };
|
|
9241
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
9242
|
+
React__default.createElement(MesfModal, { open: open, handleClose: function () { return handleClose(false); }, maxWidth: "xl", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
9243
|
+
React__default.createElement(Divider, null),
|
|
9244
|
+
React__default.createElement(MesfModal.Content, null,
|
|
9245
|
+
React__default.createElement(Grid$1, { container: true, spacing: 5, style: { padding: "1rem" } },
|
|
9246
|
+
React__default.createElement(Grid$1, { item: true, md: 12, xs: 12, style: { padding: "10px", width: "100%" } },
|
|
9247
|
+
React__default.createElement(Typography, null,
|
|
9248
|
+
"Do you want to save changes on ",
|
|
9249
|
+
React__default.createElement("strong", null, viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewName),
|
|
9250
|
+
" ?")))),
|
|
9251
|
+
React__default.createElement(Divider, null),
|
|
9252
|
+
React__default.createElement(MesfModal.Actions, null,
|
|
9253
|
+
React__default.createElement(Grid$1, { container: true, spacing: 1, style: { display: 'flex', alignItems: 'flex-end', justifyContent: 'flex-end' } },
|
|
9254
|
+
React__default.createElement(Grid$1, { item: true },
|
|
9255
|
+
React__default.createElement(Button$1, { variant: 'outlined', color: 'secondary', onClick: function () { return handleClose(false); } }, "Cancel")),
|
|
9256
|
+
React__default.createElement(Grid$1, { item: true },
|
|
9257
|
+
React__default.createElement(ButtonWithLoading, { variant: 'contained', color: 'primary', onClick: handleSubmit, isLoading: isLoading }, "Save"))))),
|
|
9258
|
+
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); } })));
|
|
9259
|
+
};
|
|
9260
|
+
|
|
9193
9261
|
var TableComponent = function (_a) {
|
|
9194
|
-
var chartData = _a.chartData, cursorData = _a.cursorData;
|
|
9262
|
+
var chartData = _a.chartData, cursorData = _a.cursorData, getTagsFromAPI = _a.getTagsFromAPI;
|
|
9195
9263
|
var classes = useTagsTableStyles();
|
|
9196
|
-
var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected,
|
|
9197
|
-
var
|
|
9198
|
-
var _e = useState(""); _e[0]; _e[1];
|
|
9264
|
+
var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected, _d = _b.actions, setViewTags = _d.setViewTags, setGraphShouldUpdate = _d.setGraphShouldUpdate;
|
|
9265
|
+
var _e = useState(''), error = _e[0], setError = _e[1];
|
|
9199
9266
|
var dataTable = useTagsDataTable({ viewTags: viewTags, chartData: chartData, cursorData: cursorData });
|
|
9200
9267
|
var _f = useState({}), editableTagNames = _f[0], setEditableTagNames = _f[1];
|
|
9201
9268
|
var handleChange = function (tagId, value, property) {
|
|
@@ -9204,6 +9271,7 @@ var TableComponent = function (_a) {
|
|
|
9204
9271
|
return tag.TagId === tagId ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.IsAutoScale = false, _a)) : tag;
|
|
9205
9272
|
});
|
|
9206
9273
|
setViewTags(newTags);
|
|
9274
|
+
setGraphShouldUpdate();
|
|
9207
9275
|
};
|
|
9208
9276
|
var handleChangeAlias = function (tagId, newName) {
|
|
9209
9277
|
var newTags = viewTags.map(function (tag) { return (tag.TagId === tagId ? __assign(__assign({}, tag), { Alias: newName }) : tag); });
|
|
@@ -9232,10 +9300,16 @@ var TableComponent = function (_a) {
|
|
|
9232
9300
|
setViewTags(newArr);
|
|
9233
9301
|
}
|
|
9234
9302
|
};
|
|
9303
|
+
var handleAbleScales = function (tagId, checked) {
|
|
9304
|
+
if (checked) {
|
|
9305
|
+
handleAutoScaleChange(tagId, checked);
|
|
9306
|
+
}
|
|
9307
|
+
};
|
|
9235
9308
|
var _g = useState(null), selectedRowIndex = _g[0], setSelectedRowIndex = _g[1];
|
|
9236
9309
|
var _h = useState(false), addTagModalOpen = _h[0], setAddTagModalOpen = _h[1];
|
|
9237
|
-
var _j = useState(false),
|
|
9238
|
-
var _k = useState(false),
|
|
9310
|
+
var _j = useState(false), saveViewModalOpen = _j[0], setSaveViewModalOpen = _j[1];
|
|
9311
|
+
var _k = useState(false), saveAsViewModalOpen = _k[0], setSaveAsViewModalOpen = _k[1];
|
|
9312
|
+
var _l = useState(false), loadViewOpen = _l[0], setLoadViewOpen = _l[1];
|
|
9239
9313
|
var handleClose = function () { return setAddTagModalOpen(false); };
|
|
9240
9314
|
var ContextMenu = function (_a) {
|
|
9241
9315
|
var x = _a.x, y = _a.y, options = _a.options;
|
|
@@ -9246,12 +9320,13 @@ var TableComponent = function (_a) {
|
|
|
9246
9320
|
React__default.createElement("ul", null, options.map(function (option) { return (React__default.createElement("li", { key: option.id, onClick: option.onClick }, option.label)); }))));
|
|
9247
9321
|
};
|
|
9248
9322
|
// Position state for the context menu
|
|
9249
|
-
var
|
|
9323
|
+
var _m = useState({ x: 0, y: 0 }), contextMenuPosition = _m[0], setContextMenuPosition = _m[1];
|
|
9250
9324
|
var contextMenuOptions = [
|
|
9251
9325
|
{ id: 'delete', label: 'Remove Tag', onClick: function () { return handleDelete(); } },
|
|
9252
9326
|
{ id: 'add', label: 'Add Tag', onClick: function () { return setAddTagModalOpen(true); } },
|
|
9253
9327
|
{ id: 'saveDefault', label: 'Save Default To Tag', onClick: function () { return handleSaveDefaultToTag(); } },
|
|
9254
|
-
{ id: '
|
|
9328
|
+
{ id: 'saveView', label: 'Save View', onClick: function () { setSaveViewModalOpen(true); } },
|
|
9329
|
+
{ id: 'saveViewAs', label: 'Save View as', onClick: function () { return setSaveAsViewModalOpen(true); } },
|
|
9255
9330
|
{ id: 'loadView', label: 'Load View', onClick: function () { return setLoadViewOpen(true); } },
|
|
9256
9331
|
];
|
|
9257
9332
|
var handleTagSelect = function (selectedTag) {
|
|
@@ -9433,13 +9508,21 @@ var TableComponent = function (_a) {
|
|
|
9433
9508
|
React__default.createElement("td", { className: classes.color },
|
|
9434
9509
|
React__default.createElement(ColorPicker, { onChange: handleColorChange, color: tag.Color, elementId: tag.TagId })),
|
|
9435
9510
|
React__default.createElement("td", { className: classes.inputCol },
|
|
9436
|
-
React__default.createElement("input", { type: "text", style: { width: '100%' },
|
|
9511
|
+
React__default.createElement("input", { type: "text", style: __assign({ width: '100%' }, (tag.IsAutoScale ? {
|
|
9512
|
+
backgroundColor: 'rgba(239, 239, 239, 0.3)',
|
|
9513
|
+
color: 'rgba(84, 84, 84, 1)',
|
|
9514
|
+
border: '1px solid rgba(118, 118, 118, 0.3)'
|
|
9515
|
+
} : {})), value: tag.MinScale, onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
|
|
9437
9516
|
var value = e.target.value;
|
|
9438
9517
|
var numericValue = Number(value);
|
|
9439
9518
|
handleChange(tag.TagId, numericValue, 'MinScale');
|
|
9440
9519
|
} })),
|
|
9441
9520
|
React__default.createElement("td", { className: classes.inputCol },
|
|
9442
|
-
React__default.createElement("input", { type: "text", style: { width: '100%' },
|
|
9521
|
+
React__default.createElement("input", { type: "text", style: __assign({ width: '100%' }, (tag.IsAutoScale ? {
|
|
9522
|
+
backgroundColor: 'rgba(239, 239, 239, 0.3)',
|
|
9523
|
+
color: 'rgba(84, 84, 84, 1)',
|
|
9524
|
+
border: '1px solid rgba(118, 118, 118, 0.3)'
|
|
9525
|
+
} : {})), value: tag.MaxScale, onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
|
|
9443
9526
|
var value = e.target.value;
|
|
9444
9527
|
var numericValue = Number(value);
|
|
9445
9528
|
// Check if the value is a number and not empty
|
|
@@ -9468,8 +9551,21 @@ var TableComponent = function (_a) {
|
|
|
9468
9551
|
React__default.createElement(Button$1, { onClick: function () { return setLoadViewOpen(true); }, variant: 'outlined', color: 'primary' }, " Load view"))))))),
|
|
9469
9552
|
selectedRowIndex !== null && (React__default.createElement(ContextMenu, { x: contextMenuPosition.x, y: contextMenuPosition.y, options: contextMenuOptions })),
|
|
9470
9553
|
React__default.createElement(AddTagModal, { open: addTagModalOpen, handleClose: handleClose, onTagSelect: handleTagSelect }),
|
|
9471
|
-
React__default.createElement(
|
|
9472
|
-
|
|
9554
|
+
React__default.createElement(SaveViewModal, { open: saveViewModalOpen, handleClose: function (shouldUpdate) {
|
|
9555
|
+
setSaveViewModalOpen(false);
|
|
9556
|
+
if (shouldUpdate)
|
|
9557
|
+
getTagsFromAPI().then(function () { });
|
|
9558
|
+
} }),
|
|
9559
|
+
React__default.createElement(SaveAsViewModal, { open: saveAsViewModalOpen, handleClose: function (shouldUpdate) {
|
|
9560
|
+
setSaveAsViewModalOpen(false);
|
|
9561
|
+
if (shouldUpdate)
|
|
9562
|
+
getTagsFromAPI().then(function () { });
|
|
9563
|
+
} }),
|
|
9564
|
+
React__default.createElement(LoadViewModal, { open: loadViewOpen, handleClose: function (shouldUpdate) {
|
|
9565
|
+
setLoadViewOpen(false);
|
|
9566
|
+
if (shouldUpdate)
|
|
9567
|
+
getTagsFromAPI().then(function () { });
|
|
9568
|
+
} })),
|
|
9473
9569
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); } })));
|
|
9474
9570
|
};
|
|
9475
9571
|
|
|
@@ -9868,53 +9964,62 @@ var TrendingChart = function (_a) {
|
|
|
9868
9964
|
var verticalLinePlugin = useGetVerticalLinePlugin(setChartArea, setLineTabCoords);
|
|
9869
9965
|
var xAxisDatePlugin = useXAxisDatePlugin();
|
|
9870
9966
|
var yAxisPlugin = useYAxisPlugin();
|
|
9967
|
+
var seriesVsTags = useRef({});
|
|
9871
9968
|
useEffect(function () {
|
|
9872
9969
|
var axes = [];
|
|
9873
9970
|
if (!series.length) {
|
|
9874
9971
|
return;
|
|
9875
9972
|
}
|
|
9876
9973
|
viewTags.forEach(function (tag, index) {
|
|
9877
|
-
var
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9974
|
+
var existingAxis = axes.findIndex(function (existingTag) {
|
|
9975
|
+
return areRangesSimilar(existingTag, tag);
|
|
9976
|
+
});
|
|
9977
|
+
if (existingAxis === -1) {
|
|
9978
|
+
axes.push(tag); // Add new axis if no similar one exists
|
|
9979
|
+
seriesVsTags.current[tag.TagId] = tag.TagId;
|
|
9980
|
+
}
|
|
9981
|
+
else {
|
|
9982
|
+
seriesVsTags.current[tag.TagId] = axes[existingAxis].TagId;
|
|
9885
9983
|
}
|
|
9886
9984
|
});
|
|
9887
9985
|
// Configure yAxes based on grouped axes
|
|
9888
|
-
var yAxesConfig = axes.map(function (axis
|
|
9986
|
+
var yAxesConfig = axes.map(function (axis) {
|
|
9889
9987
|
return {
|
|
9890
|
-
id: "y-axis-".concat(
|
|
9988
|
+
id: "y-axis-".concat(axis.TagId),
|
|
9891
9989
|
type: "linear",
|
|
9892
|
-
display: axis.
|
|
9990
|
+
display: axis.IsVisible,
|
|
9893
9991
|
scaleLabel: {
|
|
9894
9992
|
display: true,
|
|
9895
|
-
labelString: axis.
|
|
9896
|
-
},
|
|
9897
|
-
ticks: {
|
|
9898
|
-
min: axis.autoScale ? undefined : axis.minScale,
|
|
9899
|
-
max: axis.autoScale ? undefined : axis.maxScale
|
|
9993
|
+
labelString: axis.TagName
|
|
9900
9994
|
},
|
|
9995
|
+
min: axis.IsAutoScale ? undefined : axis.MinScale,
|
|
9996
|
+
max: axis.IsAutoScale ? undefined : axis.MaxScale,
|
|
9997
|
+
suggestedMin: axis.IsAutoScale ? undefined : axis.MinScale,
|
|
9998
|
+
suggestedMax: axis.IsAutoScale ? undefined : axis.MaxScale,
|
|
9999
|
+
stepSize: 10,
|
|
9901
10000
|
grid: {
|
|
9902
10001
|
display: true
|
|
9903
10002
|
},
|
|
9904
|
-
afterUpdate: function (
|
|
9905
|
-
var chart =
|
|
10003
|
+
afterUpdate: function (a) {
|
|
10004
|
+
var chart = a.chart;
|
|
9906
10005
|
var keys = Object.keys(chart.scales).filter(function (sc) { return sc !== 'x'; });
|
|
10006
|
+
var counterOfDefaultsScales = 0;
|
|
9907
10007
|
if (keys.length > 1) {
|
|
9908
10008
|
for (var scaleKey in chart.scales) {
|
|
9909
10009
|
var scale = chart.scales[scaleKey];
|
|
9910
10010
|
if (scale.max === 1 && scale.min === 0) {
|
|
9911
10011
|
chart.scales[scaleKey].display = false;
|
|
9912
10012
|
chart.scales[scaleKey].options.display = false;
|
|
10013
|
+
counterOfDefaultsScales++;
|
|
9913
10014
|
}
|
|
9914
10015
|
else {
|
|
9915
10016
|
chart.scales[scaleKey].display = true;
|
|
9916
10017
|
chart.scales[scaleKey].options.display = true;
|
|
9917
10018
|
}
|
|
10019
|
+
if (counterOfDefaultsScales === keys.length) {
|
|
10020
|
+
chart.scales[keys[0]].display = true;
|
|
10021
|
+
chart.scales[keys[0]].options.display = true;
|
|
10022
|
+
}
|
|
9918
10023
|
}
|
|
9919
10024
|
}
|
|
9920
10025
|
}
|
|
@@ -9929,11 +10034,9 @@ var TrendingChart = function (_a) {
|
|
|
9929
10034
|
});
|
|
9930
10035
|
var updatedSeries = series.map(function (serie, index) {
|
|
9931
10036
|
var tag = viewTags[index];
|
|
9932
|
-
var
|
|
9933
|
-
return areRangesSimilar(existingTag, tag);
|
|
9934
|
-
});
|
|
10037
|
+
var yAxisTagId = seriesVsTags.current[tag.TagId];
|
|
9935
10038
|
return {
|
|
9936
|
-
yAxisID:
|
|
10039
|
+
yAxisID: "y-axis-".concat(yAxisTagId),
|
|
9937
10040
|
data: serie.map(function (sample) { return ({
|
|
9938
10041
|
x: new Date(sample.timestamp),
|
|
9939
10042
|
y: sample.value
|
|
@@ -9982,7 +10085,7 @@ var TrendingChart = function (_a) {
|
|
|
9982
10085
|
|
|
9983
10086
|
Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
|
|
9984
10087
|
var Trending = function (_a) {
|
|
9985
|
-
_a.title;
|
|
10088
|
+
_a.title; var getTagsFromAPI = _a.getTagsFromAPI;
|
|
9986
10089
|
var _b = useTrendingContext(), state = _b.state, viewTags = _b.state.viewTags;
|
|
9987
10090
|
var _c = useState(''), error = _c[0], setError = _c[1];
|
|
9988
10091
|
var _d = useState(true), loading = _d[0], setLoading = _d[1];
|
|
@@ -10039,7 +10142,7 @@ var Trending = function (_a) {
|
|
|
10039
10142
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '45%' } },
|
|
10040
10143
|
React__default.createElement(TrendingChart, { series: series, chartData: chartData, setChartData: setChartData, chartOptions: chartOptions, setChartOptions: setChartOptions, setCursorData: setCursorData })),
|
|
10041
10144
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '40%', minWidth: "100%", paddingTop: "3rem" } },
|
|
10042
|
-
React__default.createElement(TableComponent, { chartData: chartData, cursorData: cursorData })),
|
|
10145
|
+
React__default.createElement(TableComponent, { chartData: chartData, cursorData: cursorData, getTagsFromAPI: getTagsFromAPI })),
|
|
10043
10146
|
loading && (React__default.createElement(Grid$1, { item: true, xs: 12, style: { textAlign: 'center' } },
|
|
10044
10147
|
React__default.createElement("p", null, "Loading...")))),
|
|
10045
10148
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); }, title: "ERROR" })));
|
|
@@ -10048,44 +10151,44 @@ var Trending = function (_a) {
|
|
|
10048
10151
|
var TrendingsPage = function (props) {
|
|
10049
10152
|
var _a = useState(''), error = _a[0], setError = _a[1];
|
|
10050
10153
|
var _b = useTrendingContext().actions, setViews = _b.setViews, setViewTags = _b.setViewTags, setViewSelected = _b.setViewSelected;
|
|
10154
|
+
var getTagsFromAPI = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
10155
|
+
var viewsResp, lastCreated, viewTagsResp;
|
|
10156
|
+
return __generator(this, function (_a) {
|
|
10157
|
+
switch (_a.label) {
|
|
10158
|
+
case 0: return [4 /*yield*/, getViews(null)];
|
|
10159
|
+
case 1:
|
|
10160
|
+
viewsResp = _a.sent();
|
|
10161
|
+
if (!viewsResp.ok) return [3 /*break*/, 3];
|
|
10162
|
+
setViews(viewsResp.data.tables[0].rows);
|
|
10163
|
+
lastCreated = viewsResp.data.tables[0].rows.reduce(function (prev, current) { return (prev.ViewId > current.ViewId) ? prev : current; });
|
|
10164
|
+
//viewSelected
|
|
10165
|
+
setViewSelected(lastCreated);
|
|
10166
|
+
return [4 /*yield*/, getViewTags(lastCreated.ViewId)];
|
|
10167
|
+
case 2:
|
|
10168
|
+
viewTagsResp = _a.sent();
|
|
10169
|
+
if (viewTagsResp.ok) {
|
|
10170
|
+
setViewTags(viewTagsResp.data.tables[0].rows);
|
|
10171
|
+
}
|
|
10172
|
+
else {
|
|
10173
|
+
setError(viewTagsResp.message);
|
|
10174
|
+
}
|
|
10175
|
+
return [3 /*break*/, 4];
|
|
10176
|
+
case 3:
|
|
10177
|
+
setError(viewsResp.message);
|
|
10178
|
+
_a.label = 4;
|
|
10179
|
+
case 4: return [2 /*return*/];
|
|
10180
|
+
}
|
|
10181
|
+
});
|
|
10182
|
+
}); };
|
|
10051
10183
|
useEffect(function () {
|
|
10052
|
-
|
|
10053
|
-
var viewsResp, lastCreated, viewTagsResp;
|
|
10054
|
-
return __generator(this, function (_a) {
|
|
10055
|
-
switch (_a.label) {
|
|
10056
|
-
case 0: return [4 /*yield*/, getViews(null)];
|
|
10057
|
-
case 1:
|
|
10058
|
-
viewsResp = _a.sent();
|
|
10059
|
-
if (!viewsResp.ok) return [3 /*break*/, 3];
|
|
10060
|
-
setViews(viewsResp.data.tables[0].rows);
|
|
10061
|
-
lastCreated = viewsResp.data.tables[0].rows.reduce(function (prev, current) { return (prev.ViewId > current.ViewId) ? prev : current; });
|
|
10062
|
-
//viewSelected
|
|
10063
|
-
setViewSelected(lastCreated);
|
|
10064
|
-
return [4 /*yield*/, getViewTags(lastCreated.ViewId)];
|
|
10065
|
-
case 2:
|
|
10066
|
-
viewTagsResp = _a.sent();
|
|
10067
|
-
if (viewTagsResp.ok) {
|
|
10068
|
-
setViewTags(viewTagsResp.data.tables[0].rows);
|
|
10069
|
-
}
|
|
10070
|
-
else {
|
|
10071
|
-
setError(viewTagsResp.message);
|
|
10072
|
-
}
|
|
10073
|
-
return [3 /*break*/, 4];
|
|
10074
|
-
case 3:
|
|
10075
|
-
setError(viewsResp.message);
|
|
10076
|
-
_a.label = 4;
|
|
10077
|
-
case 4: return [2 /*return*/];
|
|
10078
|
-
}
|
|
10079
|
-
});
|
|
10080
|
-
}); };
|
|
10081
|
-
getTags();
|
|
10184
|
+
getTagsFromAPI();
|
|
10082
10185
|
}, []);
|
|
10083
10186
|
return (React__default.createElement(React__default.Fragment, null,
|
|
10084
10187
|
React__default.createElement(Box, { p: 3, style: { maxWidth: "100%" } },
|
|
10085
10188
|
React__default.createElement(Paper, null,
|
|
10086
10189
|
React__default.createElement(Grid$1, { container: true, spacing: 3, style: { padding: "20px" } },
|
|
10087
10190
|
React__default.createElement(Grid$1, { item: true, xs: 12 },
|
|
10088
|
-
React__default.createElement(Trending, { title: "Trending Chart" }))))),
|
|
10191
|
+
React__default.createElement(Trending, { title: "Trending Chart", getTagsFromAPI: getTagsFromAPI }))))),
|
|
10089
10192
|
React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(''); }, size: "xl", title: "ERROR" })));
|
|
10090
10193
|
};
|
|
10091
10194
|
|