@gpa-gemstone/common-pages 0.0.121 → 0.0.123
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/BulkUpload.d.ts +53 -0
- package/lib/BulkUpload.js +156 -0
- package/lib/Note.d.ts +1 -3
- package/lib/Note.js +43 -67
- package/lib/Pipelines/CSVPipeline.d.ts +7 -0
- package/lib/Pipelines/CSVPipeline.js +323 -0
- package/lib/SearchBar.js +4 -4
- 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/index.d.ts +6 -6
- package/lib/index.js +8 -11
- 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
|
+
}
|
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;
|
package/package.json
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
{
|
2
|
-
"name": "@gpa-gemstone/common-pages",
|
3
|
-
"version": "0.0.
|
4
|
-
"description": "Common UI pages for GPA products",
|
5
|
-
"main": "lib/index.js",
|
6
|
-
"types": "lib/index.d.ts",
|
7
|
-
"files": ["lib/**/*"],
|
8
|
-
"scripts": {
|
9
|
-
"test": "jest --config jestconfig.json",
|
10
|
-
"build": "tsc",
|
11
|
-
"format": "prettier --write \"src/**/*.tsx\"",
|
12
|
-
"lint": "eslint . --ext .ts,.tsx",
|
13
|
-
"prepare": "npm run build",
|
14
|
-
"prepublishOnly": "npm test && npm run lint",
|
15
|
-
"preversion": "npm run lint",
|
16
|
-
"version": "npm run format && git add -A src",
|
17
|
-
"postversion": "git push && git push --tags"
|
18
|
-
},
|
19
|
-
"repository": {
|
20
|
-
"type": "git",
|
21
|
-
"url": "https://github.com/GridProtectionAlliance/gpa-gemstone.git"
|
22
|
-
},
|
23
|
-
"keywords": [
|
24
|
-
"React",
|
25
|
-
"Interactive",
|
26
|
-
"GSF",
|
27
|
-
"Gemstone",
|
28
|
-
"GridProtectionAlliance"
|
29
|
-
],
|
30
|
-
"author": "GridProtectionAlliance",
|
31
|
-
"license": "MIT",
|
32
|
-
"bugs": {"url": "https://github.com/GridProtectionAlliance/gpa-gemstone/issues"},
|
33
|
-
"homepage": "https://github.com/GridProtectionAlliance/gpa-gemstone#readme",
|
34
|
-
"devDependencies": {
|
35
|
-
"@types/crypto-js": "^4.2.0",
|
36
|
-
"@types/jest": "^27.0.0",
|
37
|
-
"@types/jquery": "3.5.6",
|
38
|
-
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
39
|
-
"@typescript-eslint/parser": "^5.60.0",
|
40
|
-
"eslint": "^8.43.0",
|
41
|
-
"jest": "^29.0.0",
|
42
|
-
"prettier": "^2.3.2",
|
43
|
-
"ts-jest": "^29.0.0",
|
44
|
-
"typescript": "5.5.3"
|
45
|
-
},
|
46
|
-
"dependencies": {
|
47
|
-
"@gpa-gemstone/application-typings": "0.0.78",
|
48
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
49
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
50
|
-
"@gpa-gemstone/react-forms": "1.1.
|
51
|
-
"@gpa-gemstone/react-interactive": "1.0.
|
52
|
-
"@gpa-gemstone/react-table": "1.2.
|
53
|
-
"@reduxjs/toolkit": "1.8.3",
|
54
|
-
"crypto-js": "^4.2.0",
|
55
|
-
"moment": "^2.29.4",
|
56
|
-
"moment-timezone": "0.5.43",
|
57
|
-
"react": "^18.2.0",
|
58
|
-
"react-redux": "8.0.2",
|
59
|
-
"styled-components": "5.3.3"
|
60
|
-
},
|
61
|
-
"publishConfig": {"access": "public"}
|
1
|
+
{
|
2
|
+
"name": "@gpa-gemstone/common-pages",
|
3
|
+
"version": "0.0.123",
|
4
|
+
"description": "Common UI pages for GPA products",
|
5
|
+
"main": "lib/index.js",
|
6
|
+
"types": "lib/index.d.ts",
|
7
|
+
"files": ["lib/**/*"],
|
8
|
+
"scripts": {
|
9
|
+
"test": "jest --config jestconfig.json",
|
10
|
+
"build": "tsc",
|
11
|
+
"format": "prettier --write \"src/**/*.tsx\"",
|
12
|
+
"lint": "eslint . --ext .ts,.tsx",
|
13
|
+
"prepare": "npm run build",
|
14
|
+
"prepublishOnly": "npm test && npm run lint",
|
15
|
+
"preversion": "npm run lint",
|
16
|
+
"version": "npm run format && git add -A src",
|
17
|
+
"postversion": "git push && git push --tags"
|
18
|
+
},
|
19
|
+
"repository": {
|
20
|
+
"type": "git",
|
21
|
+
"url": "https://github.com/GridProtectionAlliance/gpa-gemstone.git"
|
22
|
+
},
|
23
|
+
"keywords": [
|
24
|
+
"React",
|
25
|
+
"Interactive",
|
26
|
+
"GSF",
|
27
|
+
"Gemstone",
|
28
|
+
"GridProtectionAlliance"
|
29
|
+
],
|
30
|
+
"author": "GridProtectionAlliance",
|
31
|
+
"license": "MIT",
|
32
|
+
"bugs": {"url": "https://github.com/GridProtectionAlliance/gpa-gemstone/issues"},
|
33
|
+
"homepage": "https://github.com/GridProtectionAlliance/gpa-gemstone#readme",
|
34
|
+
"devDependencies": {
|
35
|
+
"@types/crypto-js": "^4.2.0",
|
36
|
+
"@types/jest": "^27.0.0",
|
37
|
+
"@types/jquery": "3.5.6",
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
39
|
+
"@typescript-eslint/parser": "^5.60.0",
|
40
|
+
"eslint": "^8.43.0",
|
41
|
+
"jest": "^29.0.0",
|
42
|
+
"prettier": "^2.3.2",
|
43
|
+
"ts-jest": "^29.0.0",
|
44
|
+
"typescript": "5.5.3"
|
45
|
+
},
|
46
|
+
"dependencies": {
|
47
|
+
"@gpa-gemstone/application-typings": "0.0.78",
|
48
|
+
"@gpa-gemstone/gpa-symbols": "0.0.45",
|
49
|
+
"@gpa-gemstone/helper-functions": "0.0.36",
|
50
|
+
"@gpa-gemstone/react-forms": "1.1.77",
|
51
|
+
"@gpa-gemstone/react-interactive": "1.0.137",
|
52
|
+
"@gpa-gemstone/react-table": "1.2.58",
|
53
|
+
"@reduxjs/toolkit": "1.8.3",
|
54
|
+
"crypto-js": "^4.2.0",
|
55
|
+
"moment": "^2.29.4",
|
56
|
+
"moment-timezone": "0.5.43",
|
57
|
+
"react": "^18.2.0",
|
58
|
+
"react-redux": "8.0.2",
|
59
|
+
"styled-components": "5.3.3"
|
60
|
+
},
|
61
|
+
"publishConfig": {"access": "public"}
|
62
62
|
}
|