@gpa-gemstone/common-pages 0.0.122 → 0.0.123
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/lib/BulkUpload.d.ts +53 -0
- package/lib/BulkUpload.js +156 -0
- package/lib/Note.d.ts +1 -3
- package/lib/Note.js +39 -63
- package/lib/Pipelines/CSVPipeline.d.ts +7 -0
- package/lib/Pipelines/CSVPipeline.js +323 -0
- package/lib/SelectionPopup.d.ts +0 -2
- package/lib/StandardSelectPopup.d.ts +0 -2
- package/lib/StandardSelectPopup.js +14 -13
- package/lib/TimeFilter.d.ts +28 -0
- package/lib/TimeFilter.js +273 -0
- package/lib/TimeWindowUtils.d.ts +26 -0
- package/lib/TimeWindowUtils.js +110 -0
- package/lib/ValueList/GroupInfo.js +2 -2
- package/lib/index.d.ts +6 -6
- package/lib/index.js +8 -11
- package/lib/user/AdditionalField.js +4 -4
- package/lib/user/UserInfo.js +1 -1
- package/package.json +61 -61
@@ -0,0 +1,273 @@
|
|
1
|
+
"use strict";
|
2
|
+
//******************************************************************************************************
|
3
|
+
// TimeFilter.tsx - Gbtc
|
4
|
+
//
|
5
|
+
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
|
6
|
+
//
|
7
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
8
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
9
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
10
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
11
|
+
//
|
12
|
+
// http://opensource.org/licenses/MIT
|
13
|
+
//
|
14
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
15
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
16
|
+
// License for the specific language governing permissions and limitations.
|
17
|
+
//
|
18
|
+
// Code Modification History:
|
19
|
+
// ----------------------------------------------------------------------------------------------------
|
20
|
+
// 09/16/2021 - Christoph Lackner
|
21
|
+
// Generated original version of source code.
|
22
|
+
// 06/20/2024 - Ali Karrar
|
23
|
+
// Moved TimeFilter from SEBrowser to gemstone
|
24
|
+
//******************************************************************************************************
|
25
|
+
var __assign = (this && this.__assign) || function () {
|
26
|
+
__assign = Object.assign || function(t) {
|
27
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
28
|
+
s = arguments[i];
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
30
|
+
t[p] = s[p];
|
31
|
+
}
|
32
|
+
return t;
|
33
|
+
};
|
34
|
+
return __assign.apply(this, arguments);
|
35
|
+
};
|
36
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
37
|
+
if (k2 === undefined) k2 = k;
|
38
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
39
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
40
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
41
|
+
}
|
42
|
+
Object.defineProperty(o, k2, desc);
|
43
|
+
}) : (function(o, m, k, k2) {
|
44
|
+
if (k2 === undefined) k2 = k;
|
45
|
+
o[k2] = m[k];
|
46
|
+
}));
|
47
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
48
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
49
|
+
}) : function(o, v) {
|
50
|
+
o["default"] = v;
|
51
|
+
});
|
52
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
53
|
+
if (mod && mod.__esModule) return mod;
|
54
|
+
var result = {};
|
55
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
56
|
+
__setModuleDefault(result, mod);
|
57
|
+
return result;
|
58
|
+
};
|
59
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
60
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
61
|
+
};
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
63
|
+
exports.getTimeWindow = getTimeWindow;
|
64
|
+
var React = __importStar(require("react"));
|
65
|
+
var moment_1 = __importDefault(require("moment"));
|
66
|
+
var react_forms_1 = require("@gpa-gemstone/react-forms");
|
67
|
+
var TimeWindowUtils_1 = require("./TimeWindowUtils");
|
68
|
+
var QuickSelects_1 = require("./TimeFilter/QuickSelects");
|
69
|
+
// Converts ITimeFilter to an ITimeWindow filter
|
70
|
+
function getTimeWindow(flt, format) {
|
71
|
+
var _a, _b;
|
72
|
+
var _c, _d, _e;
|
73
|
+
var center, start, end, unit, duration, halfDuration;
|
74
|
+
if ('center' in flt && 'halfDuration' in flt) { // type is ICenterDuration
|
75
|
+
center = (0, TimeWindowUtils_1.getMoment)(flt.center, format);
|
76
|
+
_a = (0, TimeWindowUtils_1.getStartEndTime)(center, flt.halfDuration, flt.unit), start = _a[0], end = _a[1];
|
77
|
+
unit = flt.unit;
|
78
|
+
halfDuration = flt.halfDuration;
|
79
|
+
duration = halfDuration * 2;
|
80
|
+
}
|
81
|
+
else if ('start' in flt && 'duration' in flt) { // type is IStartDuration
|
82
|
+
start = (0, TimeWindowUtils_1.getMoment)(flt.start, format);
|
83
|
+
var d = moment_1.default.duration(flt.duration / 2.0, flt.unit);
|
84
|
+
center = start.clone().add(d);
|
85
|
+
end = center.clone().add(d);
|
86
|
+
unit = flt.unit;
|
87
|
+
duration = flt.duration,
|
88
|
+
halfDuration = duration / 2.0;
|
89
|
+
}
|
90
|
+
else if ('end' in flt && 'duration' in flt) { // type is IEndDuration
|
91
|
+
end = (0, TimeWindowUtils_1.getMoment)(flt.end, format);
|
92
|
+
var d = moment_1.default.duration(flt.duration / 2.0, flt.unit);
|
93
|
+
center = end.clone().subtract(d);
|
94
|
+
start = center.clone().subtract(d);
|
95
|
+
unit = flt.unit;
|
96
|
+
duration = flt.duration,
|
97
|
+
halfDuration = duration / 2.0;
|
98
|
+
}
|
99
|
+
else if ('start' in flt && 'end' in flt) { // type is IStartEnd
|
100
|
+
start = (0, TimeWindowUtils_1.getMoment)(flt.start, format);
|
101
|
+
end = (0, TimeWindowUtils_1.getMoment)(flt.end, format);
|
102
|
+
_b = (0, TimeWindowUtils_1.findAppropriateUnit)(start, end, undefined, true), unit = _b[0], halfDuration = _b[1];
|
103
|
+
var d = moment_1.default.duration(halfDuration, unit);
|
104
|
+
center = start.clone().add(d);
|
105
|
+
duration = halfDuration * 2;
|
106
|
+
}
|
107
|
+
return { center: (_c = center === null || center === void 0 ? void 0 : center.format(format)) !== null && _c !== void 0 ? _c : '',
|
108
|
+
start: (_d = start === null || start === void 0 ? void 0 : start.format(format)) !== null && _d !== void 0 ? _d : '',
|
109
|
+
end: (_e = end === null || end === void 0 ? void 0 : end.format(format)) !== null && _e !== void 0 ? _e : '',
|
110
|
+
unit: unit !== null && unit !== void 0 ? unit : 'ms',
|
111
|
+
duration: duration !== null && duration !== void 0 ? duration : 0,
|
112
|
+
halfDuration: halfDuration !== null && halfDuration !== void 0 ? halfDuration : 0 };
|
113
|
+
}
|
114
|
+
// Returns a row div element with props as children of row
|
115
|
+
function Row(props) {
|
116
|
+
var _a;
|
117
|
+
if (props.addRow) {
|
118
|
+
return React.createElement("div", { className: "row ".concat((_a = props.class) !== null && _a !== void 0 ? _a : '') }, props.children);
|
119
|
+
}
|
120
|
+
return React.createElement(React.Fragment, null, props.children);
|
121
|
+
}
|
122
|
+
var TimeFilter = function (props) {
|
123
|
+
var _a, _b, _c;
|
124
|
+
var format = (0, QuickSelects_1.getFormat)(props.format);
|
125
|
+
var QuickSelects = React.useMemo(function () { return QuickSelects_1.AvailableQuickSelects.filter(function (qs) { return !qs.hideQuickPick(props.format); }); }, [props.format]);
|
126
|
+
var _d = React.useState(-1), activeQP = _d[0], setActiveQP = _d[1];
|
127
|
+
var _e = React.useState(getTimeWindow(props.filter, format)), filter = _e[0], setFilter = _e[1];
|
128
|
+
React.useEffect(function () {
|
129
|
+
if (!isEqual(filter, props.filter))
|
130
|
+
props.setFilter(filter.center, filter.start, filter.end, filter.unit, filter.duration);
|
131
|
+
}, [filter]);
|
132
|
+
//Checks typing of ITimeFilter and then compares to ITimeWindow
|
133
|
+
function isEqual(flt1, flt2) {
|
134
|
+
var flt = getTimeWindow(flt2, format);
|
135
|
+
return flt1.center == flt.center &&
|
136
|
+
flt1.unit == flt.unit &&
|
137
|
+
flt1.duration == flt.duration;
|
138
|
+
}
|
139
|
+
React.useEffect(function () {
|
140
|
+
if (!isEqual(filter, props.filter)) {
|
141
|
+
var flt = getTimeWindow(props.filter, format);
|
142
|
+
setFilter(flt);
|
143
|
+
}
|
144
|
+
}, [props.filter]);
|
145
|
+
return (React.createElement("fieldset", { className: "border", style: { padding: '10px', height: '100%' } },
|
146
|
+
React.createElement("legend", { className: "w-auto", style: { fontSize: 'large' } }, "Date/Time Filter:"),
|
147
|
+
React.createElement(Row, { addRow: props.isHorizontal },
|
148
|
+
props.dateTimeSetting === 'center' ?
|
149
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
150
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-2' : 'col-6') : 'col-12' },
|
151
|
+
React.createElement(react_forms_1.DatePicker, { Record: filter, Field: "center", Help: "All times are in system time. System time is currently set to ".concat(props.timeZone, ". "), Setter: function (r) {
|
152
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { center: r.center, start: r.start, end: r.end })); });
|
153
|
+
setActiveQP(-1);
|
154
|
+
}, Label: 'Time Window Center:', Type: (_a = props.format) !== null && _a !== void 0 ? _a : 'datetime-local', Valid: function () { return true; }, Format: format })))
|
155
|
+
: null,
|
156
|
+
props.dateTimeSetting === 'startWindow' || props.dateTimeSetting === 'startEnd' ?
|
157
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
158
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-2' : 'col-6') : 'col-12' },
|
159
|
+
React.createElement(react_forms_1.DatePicker, { Record: filter, Field: "start", Help: "All times are in system time. System time is currently set to ".concat(props.timeZone, ". "), Setter: function (r) {
|
160
|
+
var _a;
|
161
|
+
var halfDur = filter.halfDuration;
|
162
|
+
var unit = filter.unit;
|
163
|
+
if (props.dateTimeSetting === 'startEnd') {
|
164
|
+
_a = (0, TimeWindowUtils_1.findAppropriateUnit)((0, TimeWindowUtils_1.getMoment)(r.start, format), (0, TimeWindowUtils_1.getMoment)(filter.end, format), undefined, true), unit = _a[0], halfDur = _a[1];
|
165
|
+
}
|
166
|
+
var flt = getTimeWindow({ start: r.start, duration: halfDur * 2, unit: unit }, format);
|
167
|
+
setFilter(flt);
|
168
|
+
setActiveQP(-1);
|
169
|
+
}, Label: 'Start of Time Window:', Type: (_b = props.format) !== null && _b !== void 0 ? _b : 'datetime-local', Valid: function () { return true; }, Format: format })))
|
170
|
+
: null,
|
171
|
+
props.dateTimeSetting === 'endWindow' || props.dateTimeSetting === 'startEnd' ?
|
172
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
173
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-2' : 'col-6') : 'col-12' },
|
174
|
+
React.createElement(react_forms_1.DatePicker, { Record: filter, Field: "end", Help: "All times are in system time. System time is currently set to ".concat(props.timeZone, ". "), Setter: function (r) {
|
175
|
+
var _a;
|
176
|
+
var halfDur = filter.halfDuration;
|
177
|
+
var unit = filter.unit;
|
178
|
+
if (props.dateTimeSetting === 'startEnd') {
|
179
|
+
_a = (0, TimeWindowUtils_1.findAppropriateUnit)((0, TimeWindowUtils_1.getMoment)(filter.start, format), (0, TimeWindowUtils_1.getMoment)(r.end, format), undefined, true), unit = _a[0], halfDur = _a[1];
|
180
|
+
}
|
181
|
+
var flt = getTimeWindow({ end: r.end, duration: halfDur * 2, unit: unit }, format);
|
182
|
+
setFilter(flt);
|
183
|
+
setActiveQP(-1);
|
184
|
+
}, Label: 'End of Time Window :', Type: (_c = props.format) !== null && _c !== void 0 ? _c : 'datetime-local', Valid: function () { return true; }, Format: format })))
|
185
|
+
: null,
|
186
|
+
props.dateTimeSetting === 'center' ?
|
187
|
+
React.createElement(React.Fragment, null,
|
188
|
+
React.createElement("label", { style: { width: '100%', position: 'relative', float: "left" } }, "Time Window(+/-): "),
|
189
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
190
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
191
|
+
React.createElement(react_forms_1.Input, { Record: filter, Field: 'halfDuration', Setter: function (r) {
|
192
|
+
var flt = getTimeWindow({ center: filter.center, halfDuration: r.halfDuration, unit: filter.unit }, format);
|
193
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { duration: r.duration, halfDuration: r.halfDuration, start: flt.start, end: flt.end })); });
|
194
|
+
setActiveQP(-1);
|
195
|
+
}, Label: '', Valid: function () { return true; }, Type: 'number' })),
|
196
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
197
|
+
React.createElement(react_forms_1.Select, { Record: filter, Label: '', Field: 'unit', Setter: function (r) {
|
198
|
+
var flt = getTimeWindow({ center: filter.center, halfDuration: filter.halfDuration, unit: r.unit }, format);
|
199
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { unit: r.unit, start: flt.start, end: flt.end })); });
|
200
|
+
setActiveQP(-1);
|
201
|
+
}, Options: TimeWindowUtils_1.units.map(function (unit) { return ({
|
202
|
+
Value: unit,
|
203
|
+
Label: (0, TimeWindowUtils_1.readableUnit)(unit)
|
204
|
+
}); }) }))))
|
205
|
+
: null,
|
206
|
+
props.dateTimeSetting === 'startWindow' ?
|
207
|
+
React.createElement(React.Fragment, null,
|
208
|
+
React.createElement("label", { style: { width: '100%', position: 'relative', float: "left" } }, "Time Window(+): "),
|
209
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
210
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
211
|
+
React.createElement(react_forms_1.Input, { Record: filter, Field: 'duration', Setter: function (r) {
|
212
|
+
var flt = getTimeWindow({ start: filter.start, duration: r.duration, unit: filter.unit }, format);
|
213
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { duration: r.duration, halfDuration: r.halfDuration, center: flt.center, end: flt.end })); });
|
214
|
+
setActiveQP(-1);
|
215
|
+
}, Label: '', Valid: function () { return true; }, Type: 'number' })),
|
216
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
217
|
+
React.createElement(react_forms_1.Select, { Record: filter, Label: '', Field: 'unit', Setter: function (r) {
|
218
|
+
var flt = getTimeWindow({ start: filter.start, duration: filter.duration, unit: r.unit }, format);
|
219
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { unit: r.unit, center: flt.center, end: flt.end })); });
|
220
|
+
setActiveQP(-1);
|
221
|
+
}, Options: TimeWindowUtils_1.units.map(function (unit) { return ({
|
222
|
+
Value: unit,
|
223
|
+
Label: (0, TimeWindowUtils_1.readableUnit)(unit)
|
224
|
+
}); }) }))))
|
225
|
+
: null,
|
226
|
+
props.dateTimeSetting === 'endWindow' ?
|
227
|
+
React.createElement(React.Fragment, null,
|
228
|
+
React.createElement("label", { style: { width: '100%', position: 'relative', float: "left" } }, "Time Window(-): "),
|
229
|
+
React.createElement(Row, { addRow: !props.isHorizontal },
|
230
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
231
|
+
React.createElement(react_forms_1.Input, { Record: filter, Field: 'duration', Setter: function (r) {
|
232
|
+
var flt = getTimeWindow({ end: filter.end, duration: r.duration, unit: filter.unit }, format);
|
233
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { duration: r.duration, halfDuration: r.halfDuration, center: flt.center, start: flt.start })); });
|
234
|
+
setActiveQP(-1);
|
235
|
+
}, Label: '', Valid: function () { return true; }, Type: 'number' })),
|
236
|
+
React.createElement("div", { className: props.isHorizontal ? (props.showQuickSelect ? 'col-1' : 'col-3') : 'col-6' },
|
237
|
+
React.createElement(react_forms_1.Select, { Record: filter, Label: '', Field: 'unit', Setter: function (r) {
|
238
|
+
var flt = getTimeWindow({ end: filter.end, duration: filter.duration, unit: r.unit }, format);
|
239
|
+
setFilter(function (prevFilter) { return (__assign(__assign({}, prevFilter), { unit: r.unit, center: flt.center, start: flt.start })); });
|
240
|
+
setActiveQP(-1);
|
241
|
+
}, Options: TimeWindowUtils_1.units.map(function (unit) { return ({
|
242
|
+
Value: unit,
|
243
|
+
Label: (0, TimeWindowUtils_1.readableUnit)(unit)
|
244
|
+
}); }) }))))
|
245
|
+
: null,
|
246
|
+
props.showQuickSelect ?
|
247
|
+
React.createElement("div", { className: props.isHorizontal ? 'col-8' : 'row' },
|
248
|
+
React.createElement(Row, { addRow: props.isHorizontal, class: "justify-content-center" }, QuickSelects.map(function (qs, i) {
|
249
|
+
if (i % 3 !== 0)
|
250
|
+
return null;
|
251
|
+
return (React.createElement("div", { key: i, className: props.isHorizontal ? 'col-2' : "col-4", style: { paddingLeft: (props.isHorizontal ? 0 : (i % 9 == 0 ? 15 : 0)), paddingRight: (props.isHorizontal ? 2 : ((i % 18 == 6 || i % 18 == 15) ? 15 : 2)), marginTop: 10 } },
|
252
|
+
React.createElement("ul", { className: "list-group", key: i },
|
253
|
+
React.createElement("li", { key: i, style: { cursor: 'pointer' }, onClick: function () {
|
254
|
+
var flt = getTimeWindow(QuickSelects[i].createFilter(props.timeZone, props.format), format);
|
255
|
+
props.setFilter(flt.center, flt.start, flt.end, flt.unit, flt.duration);
|
256
|
+
setActiveQP(i);
|
257
|
+
}, className: "item badge badge-" + (i == activeQP ? "primary" : "secondary") }, QuickSelects[i].label),
|
258
|
+
i + 1 < QuickSelects.length ?
|
259
|
+
React.createElement("li", { key: i + 1, style: { marginTop: 3, cursor: 'pointer' }, className: "item badge badge-" + (i + 1 == activeQP ? "primary" : "secondary"), onClick: function () {
|
260
|
+
var flt = getTimeWindow(QuickSelects[i + 1].createFilter(props.timeZone, props.format), format);
|
261
|
+
props.setFilter(flt.center, flt.start, flt.end, flt.unit, flt.duration);
|
262
|
+
setActiveQP(i + 1);
|
263
|
+
} }, QuickSelects[i + 1].label) : null,
|
264
|
+
i + 2 < QuickSelects.length ?
|
265
|
+
React.createElement("li", { key: i + 2, style: { marginTop: 3, cursor: 'pointer' }, className: "item badge badge-" + (i + 2 == activeQP ? "primary" : "secondary"), onClick: function () {
|
266
|
+
var flt = getTimeWindow(QuickSelects[i + 2].createFilter(props.timeZone, props.format), format);
|
267
|
+
props.setFilter(flt.center, flt.start, flt.end, flt.unit, flt.duration);
|
268
|
+
setActiveQP(i + 2);
|
269
|
+
} }, QuickSelects[i + 2].label) : null)));
|
270
|
+
})))
|
271
|
+
: null)));
|
272
|
+
};
|
273
|
+
exports.default = TimeFilter;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import moment from 'moment';
|
2
|
+
export interface IStartEnd {
|
3
|
+
start: string;
|
4
|
+
end: string;
|
5
|
+
}
|
6
|
+
export interface IStartDuration {
|
7
|
+
start: string;
|
8
|
+
duration: number;
|
9
|
+
unit: TimeUnit;
|
10
|
+
}
|
11
|
+
export interface IEndDuration {
|
12
|
+
end: string;
|
13
|
+
duration: number;
|
14
|
+
unit: TimeUnit;
|
15
|
+
}
|
16
|
+
export interface ICenterDuration {
|
17
|
+
center: string;
|
18
|
+
halfDuration: number;
|
19
|
+
unit: TimeUnit;
|
20
|
+
}
|
21
|
+
export type TimeUnit = 'y' | 'M' | 'w' | 'd' | 'h' | 'm' | 's' | 'ms';
|
22
|
+
export declare const units: TimeUnit[];
|
23
|
+
export declare function findAppropriateUnit(startTime: moment.Moment, endTime: moment.Moment, unit?: TimeUnit, useHalfWindow?: boolean): [TimeUnit, number];
|
24
|
+
export declare function getStartEndTime(center: moment.Moment, duration: number, unit: TimeUnit): [moment.Moment, moment.Moment];
|
25
|
+
export declare function getMoment(date: string, format?: string, time?: string): moment.Moment;
|
26
|
+
export declare function readableUnit(unit: TimeUnit): "Year(s)" | "Month(s)" | "Week(s)" | "Day(s)" | "Hour(s)" | "Minute(s)" | "Second(s)" | "Millisecond(s)";
|
@@ -0,0 +1,110 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.units = void 0;
|
7
|
+
exports.findAppropriateUnit = findAppropriateUnit;
|
8
|
+
exports.getStartEndTime = getStartEndTime;
|
9
|
+
exports.getMoment = getMoment;
|
10
|
+
exports.readableUnit = readableUnit;
|
11
|
+
//******************************************************************************************************
|
12
|
+
// TimeWindowUtils.tsx - Gbtc
|
13
|
+
//
|
14
|
+
// Copyright © 2023, Grid Protection Alliance. All Rights Reserved.
|
15
|
+
//
|
16
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
17
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
18
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
19
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
20
|
+
//
|
21
|
+
// http://opensource.org/licenses/MIT
|
22
|
+
//
|
23
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
24
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
25
|
+
// License for the specific language governing permissions and limitations.
|
26
|
+
//
|
27
|
+
// Code Modification History:
|
28
|
+
// ----------------------------------------------------------------------------------------------------
|
29
|
+
// 07/11/2023 - C. Lackner
|
30
|
+
// Generated original version of source code.
|
31
|
+
// 06/20/2024 - Ali Karrar
|
32
|
+
// Moved TimeWindowUtil from SEBrowser to gemstone
|
33
|
+
//******************************************************************************************************
|
34
|
+
var moment_1 = __importDefault(require("moment"));
|
35
|
+
exports.units = ['ms', 's', 'm', 'h', 'd', 'w', 'M', 'y'];
|
36
|
+
/*
|
37
|
+
* A Function to determine the most appropriate unit for a window of time specified by start and end time
|
38
|
+
*/
|
39
|
+
function findAppropriateUnit(startTime, endTime, unit, useHalfWindow) {
|
40
|
+
var unitIndex = exports.units.findIndex(function (u) { return u == unit; });
|
41
|
+
if (unit === undefined)
|
42
|
+
unitIndex = 7;
|
43
|
+
var diff = endTime.diff(startTime, exports.units[unitIndex], true);
|
44
|
+
if (useHalfWindow !== undefined && useHalfWindow)
|
45
|
+
diff = diff / 2;
|
46
|
+
for (var i = unitIndex; i >= 1; i--) {
|
47
|
+
if (i == 6) // Remove month as appropriate due to innacuracy in definition (31/30/28/29 days)
|
48
|
+
continue;
|
49
|
+
if (Number.isInteger(diff)) {
|
50
|
+
return [exports.units[i], diff];
|
51
|
+
}
|
52
|
+
var nextI = i - 1;
|
53
|
+
if (nextI == 6)
|
54
|
+
nextI = 5;
|
55
|
+
diff = endTime.diff(startTime, exports.units[nextI], true);
|
56
|
+
if (useHalfWindow !== undefined && useHalfWindow)
|
57
|
+
diff = diff / 2;
|
58
|
+
if (diff > 65000) {
|
59
|
+
diff = endTime.diff(startTime, exports.units[i], true);
|
60
|
+
if (useHalfWindow !== undefined && useHalfWindow)
|
61
|
+
diff = diff / 2;
|
62
|
+
return [exports.units[i], Math.round(diff)];
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return [exports.units[0], Math.round(diff)];
|
66
|
+
}
|
67
|
+
/*
|
68
|
+
* Determines a start time and end time for a window given by center time and duration
|
69
|
+
*/
|
70
|
+
function getStartEndTime(center, duration, unit) {
|
71
|
+
var d = moment_1.default.duration(duration, unit);
|
72
|
+
var start = center.clone().subtract(d.asHours(), 'h');
|
73
|
+
var end = center.clone().add(d.asHours(), 'h');
|
74
|
+
return [start, end];
|
75
|
+
}
|
76
|
+
/*
|
77
|
+
* Returns a formatted version of date and time provided
|
78
|
+
*/
|
79
|
+
function getMoment(date, format, time) {
|
80
|
+
if (time === undefined)
|
81
|
+
return (0, moment_1.default)(date, format !== null && format !== void 0 ? format : 'MM/DD/YYYY HH:mm:ss.SSS');
|
82
|
+
return (0, moment_1.default)(date + ' ' + time, 'MM/DD/YYYY HH:mm:ss.SSS');
|
83
|
+
}
|
84
|
+
/*
|
85
|
+
* Returns a unit string based on unit char input
|
86
|
+
*/
|
87
|
+
function readableUnit(unit) {
|
88
|
+
if (unit == 'y') {
|
89
|
+
return 'Year(s)';
|
90
|
+
}
|
91
|
+
else if (unit == 'M') {
|
92
|
+
return 'Month(s)';
|
93
|
+
}
|
94
|
+
else if (unit == 'w') {
|
95
|
+
return 'Week(s)';
|
96
|
+
}
|
97
|
+
else if (unit == 'd') {
|
98
|
+
return 'Day(s)';
|
99
|
+
}
|
100
|
+
else if (unit == 'h') {
|
101
|
+
return 'Hour(s)';
|
102
|
+
}
|
103
|
+
else if (unit == 'm') {
|
104
|
+
return 'Minute(s)';
|
105
|
+
}
|
106
|
+
else if (unit == 's') {
|
107
|
+
return 'Second(s)';
|
108
|
+
}
|
109
|
+
return 'Millisecond(s)';
|
110
|
+
}
|
@@ -81,13 +81,13 @@ var InfoWindow = function (props) {
|
|
81
81
|
if (errors.length === 0 && warnings.length > 0)
|
82
82
|
props.Setter(record);
|
83
83
|
}, hidden: record.ID === 0, "data-tooltip": 'Update', onMouseEnter: function () { return setHover('Update'); }, onMouseLeave: function () { return setHover('None'); } }, "Update")),
|
84
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (errors.length > 0), Position: 'top', Target: "Update" }, errors.map(function (t, i) { return React.createElement("p", { key: i },
|
84
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (errors.length > 0), Position: 'top', Theme: 'dark', Target: "Update" }, errors.map(function (t, i) { return React.createElement("p", { key: i },
|
85
85
|
gpa_symbols_1.CrossMark,
|
86
86
|
" ",
|
87
87
|
t); })),
|
88
88
|
React.createElement("div", { className: "btn-group mr-2" },
|
89
89
|
React.createElement("button", { className: "btn btn-default", onClick: function () { return setRecord(props.Record); }, disabled: warnings.length === 0, "data-tooltip": 'Clr', onMouseEnter: function () { return setHover('Clear'); }, onMouseLeave: function () { return setHover('None'); } }, "Reset")),
|
90
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (warnings.length > 0), Position: 'top', Target: "Clr" }, warnings.map(function (t, i) { return React.createElement("p", { key: i },
|
90
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (warnings.length > 0), Position: 'top', Theme: 'dark', Target: "Clr" }, warnings.map(function (t, i) { return React.createElement("p", { key: i },
|
91
91
|
gpa_symbols_1.Warning,
|
92
92
|
" ",
|
93
93
|
t); })))));
|
package/lib/index.d.ts
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
import Setting from './Setting';
|
2
1
|
import Note from './Note';
|
3
|
-
import ByValueList from './ValueList/ByValueList';
|
4
|
-
import ValueList from './ValueList/Group';
|
5
|
-
import ByUser from './user/ByUser';
|
6
|
-
import User from './user/User';
|
7
2
|
import { DefaultSearch } from './SearchBar';
|
8
3
|
import SelectPopup from './StandardSelectPopup';
|
9
4
|
import { DefaultSelects } from './SelectionPopup';
|
@@ -12,5 +7,10 @@ import TimeFilter from './TimeFilter/TimeFilter';
|
|
12
7
|
import EventTypeFilter from './EventTypeFilter';
|
13
8
|
import EventCharacteristicFilter from './EventCharacteristicFilter';
|
14
9
|
import NavBarFilterButton from './NavBarFilterButton';
|
10
|
+
import { useCSVPipeline } from './Pipelines/CSVPipeline';
|
15
11
|
import * as TimeWindowUtils from './TimeFilter/TimeWindowUtils';
|
16
|
-
|
12
|
+
import BulkUpload from './BulkUpload';
|
13
|
+
declare const Pipelines: {
|
14
|
+
CSV: typeof useCSVPipeline;
|
15
|
+
};
|
16
|
+
export { TimeFilter, TimeWindowUtils, EventTypeFilter, EventCharacteristicFilter, NavBarFilterButton, Note, DefaultSearch, SelectPopup, DefaultSelects, ErrorBoundary, Pipelines, BulkUpload };
|
package/lib/index.js
CHANGED
@@ -48,19 +48,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
49
49
|
};
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
51
|
-
exports.
|
52
|
-
var Setting_1 = __importDefault(require("./Setting"));
|
53
|
-
exports.Setting = Setting_1.default;
|
51
|
+
exports.BulkUpload = exports.Pipelines = exports.ErrorBoundary = exports.DefaultSelects = exports.SelectPopup = exports.DefaultSearch = exports.Note = exports.NavBarFilterButton = exports.EventCharacteristicFilter = exports.EventTypeFilter = exports.TimeWindowUtils = exports.TimeFilter = void 0;
|
54
52
|
var Note_1 = __importDefault(require("./Note"));
|
55
53
|
exports.Note = Note_1.default;
|
56
|
-
var ByValueList_1 = __importDefault(require("./ValueList/ByValueList"));
|
57
|
-
exports.ByValueList = ByValueList_1.default;
|
58
|
-
var Group_1 = __importDefault(require("./ValueList/Group"));
|
59
|
-
exports.ValueList = Group_1.default;
|
60
|
-
var ByUser_1 = __importDefault(require("./user/ByUser"));
|
61
|
-
exports.ByUser = ByUser_1.default;
|
62
|
-
var User_1 = __importDefault(require("./user/User"));
|
63
|
-
exports.User = User_1.default;
|
64
54
|
var SearchBar_1 = require("./SearchBar");
|
65
55
|
Object.defineProperty(exports, "DefaultSearch", { enumerable: true, get: function () { return SearchBar_1.DefaultSearch; } });
|
66
56
|
var StandardSelectPopup_1 = __importDefault(require("./StandardSelectPopup"));
|
@@ -77,5 +67,12 @@ var EventCharacteristicFilter_1 = __importDefault(require("./EventCharacteristic
|
|
77
67
|
exports.EventCharacteristicFilter = EventCharacteristicFilter_1.default;
|
78
68
|
var NavBarFilterButton_1 = __importDefault(require("./NavBarFilterButton"));
|
79
69
|
exports.NavBarFilterButton = NavBarFilterButton_1.default;
|
70
|
+
var CSVPipeline_1 = require("./Pipelines/CSVPipeline");
|
80
71
|
var TimeWindowUtils = __importStar(require("./TimeFilter/TimeWindowUtils"));
|
81
72
|
exports.TimeWindowUtils = TimeWindowUtils;
|
73
|
+
var BulkUpload_1 = __importDefault(require("./BulkUpload"));
|
74
|
+
exports.BulkUpload = BulkUpload_1.default;
|
75
|
+
var Pipelines = {
|
76
|
+
CSV: CSVPipeline_1.useCSVPipeline
|
77
|
+
};
|
78
|
+
exports.Pipelines = Pipelines;
|
@@ -168,7 +168,7 @@ function AdditionalField(props) {
|
|
168
168
|
(mode === 'Edit') ?
|
169
169
|
React.createElement("button", { className: "btn btn-default pull-right", "data-tooltip": 'View', onClick: function () { setMode('View'); setEditValues(values); }, onMouseEnter: function () { return setHover('View'); }, onMouseLeave: function () { return setHover('None'); } }, "View") :
|
170
170
|
React.createElement("button", { className: "btn btn-primary pull-right", onClick: function () { return setMode('Edit'); } }, "Edit"),
|
171
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'View' && changedFields.length > 0, Position: 'left', Target: "View" }, changedFields.map(function (fld, i) { return React.createElement("p", { key: i },
|
171
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'View' && changedFields.length > 0, Position: 'left', Theme: 'dark', Target: "View" }, changedFields.map(function (fld, i) { return React.createElement("p", { key: i },
|
172
172
|
gpa_symbols_1.Warning,
|
173
173
|
" Changes to '",
|
174
174
|
fld,
|
@@ -208,12 +208,12 @@ function AdditionalField(props) {
|
|
208
208
|
setShowEdit(true);
|
209
209
|
setNewField(props.EmptyField);
|
210
210
|
} }, "data-tooltip": 'New' }, "Add Field")),
|
211
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'New' && mode === 'View', Position: 'top', Target: "New" },
|
211
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'New' && mode === 'View', Position: 'top', Theme: 'dark', Target: "New" },
|
212
212
|
React.createElement("p", null, " To add a new Field switch to Edit mode by clicking on the Edit Button on the upper right corner.")),
|
213
213
|
React.createElement("div", { className: "btn-group mr-2" },
|
214
214
|
React.createElement("button", { className: "btn btn-primary" + (changedFields.length === 0 || mode === 'View' || errorFields.length > 0 ? ' disabled' : ''), onClick: function () { if (errorFields.length === 0 && changedFields.length > 0 && mode === 'Edit')
|
215
215
|
dispatch(props.AdditionalFieldSlice.UpdateValues({ ParentID: props.Id, Values: editValues })); }, onMouseEnter: function () { return setHover('Save'); }, onMouseLeave: function () { return setHover('None'); }, "data-tooltip": 'SaveValues' }, "Save Changes")),
|
216
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Save' && (mode === 'View' || changedFields.length > 0), Position: 'top', Target: "SaveValues" },
|
216
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Save' && (mode === 'View' || changedFields.length > 0), Position: 'top', Theme: 'dark', Target: "SaveValues" },
|
217
217
|
mode === 'View' ? React.createElement("p", null, " To change any Fields switch to Edit mode by clicking on the Edit Button on the upper right corner.") : null,
|
218
218
|
changedFields.length > 0 && errorFields.length === 0 ? changedFields.map(function (fld, i) { return React.createElement("p", { key: i },
|
219
219
|
" ",
|
@@ -232,7 +232,7 @@ function AdditionalField(props) {
|
|
232
232
|
if (changedFields.length > 0 && mode === 'Edit')
|
233
233
|
setEditValues(values);
|
234
234
|
}, onMouseEnter: function () { return setHover('Clear'); }, onMouseLeave: function () { return setHover('None'); }, "data-tooltip": 'Reset' }, "Reset")),
|
235
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (mode === 'View' || changedFields.length > 0), Position: 'top', Target: 'Reset' },
|
235
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (mode === 'View' || changedFields.length > 0), Position: 'top', Theme: 'dark', Target: 'Reset' },
|
236
236
|
mode === 'View' ? React.createElement("p", null, " To change any Fields switch to Edit mode by clicking on the Edit Button on the upper right corner.") : null,
|
237
237
|
changedFields.length > 0 ? changedFields.map(function (fld, i) { return React.createElement("p", { key: i },
|
238
238
|
gpa_symbols_1.Warning,
|
package/lib/user/UserInfo.js
CHANGED
@@ -115,7 +115,7 @@ function UserInfo(props) {
|
|
115
115
|
React.createElement("button", { className: "btn btn-primary", onClick: function () { return updateUser(); }, disabled: warnings.length === 0 }, "Update")),
|
116
116
|
React.createElement("div", { className: "btn-group mr-2" },
|
117
117
|
React.createElement("button", { className: "btn btn-default", onClick: function () { return setUser(currentUser); }, disabled: warnings.length === 0, "data-tooltip": 'Clr', onMouseEnter: function () { return setHover('Clear'); }, onMouseLeave: function () { return setHover('None'); } }, "Reset")),
|
118
|
-
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (warnings.length > 0), Position: 'top', Target: "Clr" }, warnings.map(function (t, i) { return React.createElement("p", { key: i },
|
118
|
+
React.createElement(react_interactive_1.ToolTip, { Show: hover === 'Clear' && (warnings.length > 0), Position: 'top', Theme: 'dark', Target: "Clr" }, warnings.map(function (t, i) { return React.createElement("p", { key: i },
|
119
119
|
gpa_symbols_1.Warning,
|
120
120
|
" ",
|
121
121
|
t); })))));
|