@gpa-gemstone/common-pages 0.0.103 → 0.0.105

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/lib/ErrorBoundary.d.ts +17 -17
  2. package/lib/ErrorBoundary.js +91 -68
  3. package/lib/Note.d.ts +22 -22
  4. package/lib/Note.js +256 -230
  5. package/lib/SearchBar.d.ts +37 -37
  6. package/lib/SearchBar.js +203 -180
  7. package/lib/SelectionPopup.d.ts +42 -42
  8. package/lib/SelectionPopup.js +93 -90
  9. package/lib/Setting.d.ts +8 -8
  10. package/lib/Setting.js +151 -125
  11. package/lib/SliceInterfaces.d.ts +76 -76
  12. package/lib/SliceInterfaces.js +2 -2
  13. package/lib/StandardSelectPopup.d.ts +20 -20
  14. package/lib/StandardSelectPopup.js +135 -109
  15. package/lib/TimeFilter/QuickSelects.d.ts +7 -0
  16. package/lib/TimeFilter/QuickSelects.js +240 -0
  17. package/lib/TimeFilter.d.ts +26 -0
  18. package/lib/TimeFilter.js +270 -0
  19. package/lib/TimeWindowUtils.d.ts +33 -0
  20. package/lib/TimeWindowUtils.js +121 -0
  21. package/lib/ValueList/ByValueList.d.ts +10 -10
  22. package/lib/ValueList/ByValueList.js +141 -115
  23. package/lib/ValueList/Group.d.ts +11 -11
  24. package/lib/ValueList/Group.js +97 -71
  25. package/lib/ValueList/GroupForm.d.ts +9 -9
  26. package/lib/ValueList/GroupForm.js +74 -51
  27. package/lib/ValueList/GroupInfo.d.ts +8 -8
  28. package/lib/ValueList/GroupInfo.js +95 -69
  29. package/lib/ValueList/GroupItem.d.ts +9 -9
  30. package/lib/ValueList/GroupItem.js +142 -116
  31. package/lib/ValueList/ItemForm.d.ts +9 -9
  32. package/lib/ValueList/ItemForm.js +82 -59
  33. package/lib/index.d.ts +12 -11
  34. package/lib/index.js +50 -45
  35. package/lib/user/AdditionalField.d.ts +26 -26
  36. package/lib/user/AdditionalField.js +290 -264
  37. package/lib/user/ByUser.d.ts +12 -12
  38. package/lib/user/ByUser.js +174 -148
  39. package/lib/user/User.d.ts +14 -14
  40. package/lib/user/User.js +97 -71
  41. package/lib/user/UserForm.d.ts +12 -12
  42. package/lib/user/UserForm.js +166 -143
  43. package/lib/user/UserInfo.d.ts +7 -7
  44. package/lib/user/UserInfo.js +123 -97
  45. package/lib/user/UserPermissions.d.ts +8 -8
  46. package/lib/user/UserPermissions.js +106 -83
  47. package/package.json +9 -8
@@ -1,90 +1,93 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // SelectionPopup.tsx - Gbtc
4
- //
5
- // Copyright © 2021, 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
- // 12/19/2021 - C. Lackner
21
- // Generated original version of source code.
22
- // ******************************************************************************************************
23
- var __assign = (this && this.__assign) || function () {
24
- __assign = Object.assign || function(t) {
25
- for (var s, i = 1, n = arguments.length; i < n; i++) {
26
- s = arguments[i];
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28
- t[p] = s[p];
29
- }
30
- return t;
31
- };
32
- return __assign.apply(this, arguments);
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.DefaultSelects = void 0;
36
- var React = require("react");
37
- var StandardSelectPopup_1 = require("./StandardSelectPopup");
38
- var SearchBar_1 = require("./SearchBar");
39
- /** This Implements a few standardized Selection Popups */
40
- var DefaultSelects;
41
- (function (DefaultSelects) {
42
- /** This Implements a standard Meter Selection Modal */
43
- function Meter(props) {
44
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Meter, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
45
- " ",
46
- props.children,
47
- " ");
48
- }
49
- DefaultSelects.Meter = Meter;
50
- /** This Implements a standard Substation Selection Modal */
51
- function Location(props) {
52
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Location, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
53
- " ",
54
- props.children,
55
- " ");
56
- }
57
- DefaultSelects.Location = Location;
58
- /** This Implements a standard Transmission Asset Selection Modal */
59
- function Asset(props) {
60
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Asset, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
61
- " ",
62
- props.children,
63
- " ");
64
- }
65
- DefaultSelects.Asset = Asset;
66
- /** This Implements a standard Asset Group Selection Modal */
67
- function AssetGroup(props) {
68
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.AssetGroup, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
69
- " ",
70
- props.children,
71
- " ");
72
- }
73
- DefaultSelects.AssetGroup = AssetGroup;
74
- /** This Implements a standard User Selection Modal */
75
- function User(props) {
76
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.User, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
77
- " ",
78
- props.children,
79
- " ");
80
- }
81
- DefaultSelects.User = User;
82
- /** This Implements a standard Customer Selection Modal */
83
- function Customer(props) {
84
- return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Customer, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
85
- " ",
86
- props.children,
87
- " ");
88
- }
89
- DefaultSelects.Customer = Customer;
90
- })(DefaultSelects = exports.DefaultSelects || (exports.DefaultSelects = {}));
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // SelectionPopup.tsx - Gbtc
4
+ //
5
+ // Copyright © 2021, 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
+ // 12/19/2021 - C. Lackner
21
+ // Generated original version of source code.
22
+ // ******************************************************************************************************
23
+ var __assign = (this && this.__assign) || function () {
24
+ __assign = Object.assign || function(t) {
25
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
26
+ s = arguments[i];
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28
+ t[p] = s[p];
29
+ }
30
+ return t;
31
+ };
32
+ return __assign.apply(this, arguments);
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.DefaultSelects = void 0;
39
+ var React = require("react");
40
+ var StandardSelectPopup_1 = __importDefault(require("./StandardSelectPopup"));
41
+ var SearchBar_1 = require("./SearchBar");
42
+ /** This Implements a few standardized Selection Popups */
43
+ var DefaultSelects;
44
+ (function (DefaultSelects) {
45
+ /** This Implements a standard Meter Selection Modal */
46
+ function Meter(props) {
47
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Meter, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
48
+ " ",
49
+ props.children,
50
+ " ");
51
+ }
52
+ DefaultSelects.Meter = Meter;
53
+ /** This Implements a standard Substation Selection Modal */
54
+ function Location(props) {
55
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Location, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
56
+ " ",
57
+ props.children,
58
+ " ");
59
+ }
60
+ DefaultSelects.Location = Location;
61
+ /** This Implements a standard Transmission Asset Selection Modal */
62
+ function Asset(props) {
63
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Asset, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
64
+ " ",
65
+ props.children,
66
+ " ");
67
+ }
68
+ DefaultSelects.Asset = Asset;
69
+ /** This Implements a standard Asset Group Selection Modal */
70
+ function AssetGroup(props) {
71
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.AssetGroup, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
72
+ " ",
73
+ props.children,
74
+ " ");
75
+ }
76
+ DefaultSelects.AssetGroup = AssetGroup;
77
+ /** This Implements a standard User Selection Modal */
78
+ function User(props) {
79
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.User, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
80
+ " ",
81
+ props.children,
82
+ " ");
83
+ }
84
+ DefaultSelects.User = User;
85
+ /** This Implements a standard Customer Selection Modal */
86
+ function Customer(props) {
87
+ return React.createElement(StandardSelectPopup_1.default, __assign({}, props, { Searchbar: function (children) { return React.createElement(SearchBar_1.DefaultSearch.Customer, { Slice: props.Slice, GetAddlFields: props.GetAddlFields, GetEnum: props.GetEnum, StorageID: props.StorageID, AddlFilters: props.AddlFilters }, children); } }),
88
+ " ",
89
+ props.children,
90
+ " ");
91
+ }
92
+ DefaultSelects.Customer = Customer;
93
+ })(DefaultSelects || (exports.DefaultSelects = DefaultSelects = {}));
package/lib/Setting.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
2
- import { ISearchableSlice } from './SliceInterfaces';
3
- import { SystemCenter } from '@gpa-gemstone/application-typings';
4
- interface IProps {
5
- SettingsSlice: ISearchableSlice<SystemCenter.Types.Setting>;
6
- }
7
- declare function Setting(props: IProps): JSX.Element;
8
- export default Setting;
1
+ import * as React from 'react';
2
+ import { ISearchableSlice } from './SliceInterfaces';
3
+ import { SystemCenter } from '@gpa-gemstone/application-typings';
4
+ interface IProps {
5
+ SettingsSlice: ISearchableSlice<SystemCenter.Types.Setting>;
6
+ }
7
+ declare function Setting(props: IProps): React.JSX.Element;
8
+ export default Setting;
package/lib/Setting.js CHANGED
@@ -1,125 +1,151 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // Setting.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
- // 04/28/2021 - C. Lackner
21
- // Generated original version of source code.
22
- // ******************************************************************************************************
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- var React = require("react");
25
- var react_forms_1 = require("@gpa-gemstone/react-forms");
26
- var react_table_1 = require("@gpa-gemstone/react-table");
27
- var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
28
- var react_interactive_1 = require("@gpa-gemstone/react-interactive");
29
- var react_redux_1 = require("react-redux");
30
- function Setting(props) {
31
- var dispatch = (0, react_redux_1.useDispatch)();
32
- var search = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchFilters);
33
- var searchStatus = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchStatus);
34
- var data = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchResults);
35
- var allSettings = (0, react_redux_1.useSelector)(props.SettingsSlice.Data);
36
- var status = (0, react_redux_1.useSelector)(props.SettingsSlice.Status);
37
- var _a = React.useState('Name'), sortField = _a[0], setSortField = _a[1];
38
- var _b = React.useState(true), ascending = _b[0], setAscending = _b[1];
39
- var emptySetting = { ID: 0, Name: '', Value: '', DefaultValue: '' };
40
- var _c = React.useState(emptySetting), editnewSetting = _c[0], setEditNewSetting = _c[1];
41
- var _d = React.useState('New'), editNew = _d[0], setEditNew = _d[1];
42
- var _e = React.useState(false), showModal = _e[0], setShowModal = _e[1];
43
- var _f = React.useState(false), showWarning = _f[0], setShowWarning = _f[1];
44
- var _g = React.useState(false), hasChanged = _g[0], setHasChanged = _g[1];
45
- var _h = React.useState([]), errors = _h[0], setErrors = _h[1];
46
- React.useEffect(function () {
47
- if (status === 'unintiated' || status === 'changed')
48
- dispatch(props.SettingsSlice.Fetch());
49
- }, [dispatch, status]);
50
- React.useEffect(function () {
51
- if (searchStatus === 'unintiated' || status === 'changed')
52
- dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: sortField, ascending: ascending }));
53
- }, [dispatch, searchStatus, ascending, sortField, search]);
54
- React.useEffect(function () { setHasChanged(false); }, [showModal]);
55
- React.useEffect(function () {
56
- var e = [];
57
- if (editnewSetting.Name == null || editnewSetting.Name.length === 0)
58
- e.push('A Name is required');
59
- if (editnewSetting.Name != null && editnewSetting.Name.length > 0 && allSettings.findIndex(function (s) { return s.Name.toLowerCase() === editnewSetting.Name.toLowerCase() && s.ID !== editnewSetting.ID; }) > -1)
60
- e.push('A Settign with this Name already exists.');
61
- if (editnewSetting.Value == null || editnewSetting.Value.length === 0)
62
- e.push('A Value is required');
63
- setErrors(e);
64
- }, [editnewSetting]);
65
- var searchFields = [
66
- { key: 'Name', label: 'Name', type: 'string', isPivotField: false },
67
- { key: 'DefaultValue', label: 'Default Value', type: 'string', isPivotField: false },
68
- { key: 'Value', label: 'Value', type: 'string', isPivotField: false }
69
- ];
70
- if (status === 'error')
71
- return React.createElement("div", { style: { width: '100%', height: '100%' } },
72
- React.createElement(react_interactive_1.ServerErrorIcon, { Show: true, Label: 'A Server Error Occured. Please Reload the Application' }));
73
- return (React.createElement(React.Fragment, null,
74
- React.createElement(react_interactive_1.LoadingScreen, { Show: status === 'loading' }),
75
- React.createElement("div", { style: { width: '100%', height: '100%' } },
76
- React.createElement(react_interactive_1.SearchBar, { CollumnList: searchFields, SetFilter: function (flds) { return dispatch(props.SettingsSlice.DBSearch({ filter: flds, sortField: sortField, ascending: ascending })); }, Direction: 'left', defaultCollumn: { key: 'Name', label: 'Name', type: 'string', isPivotField: false }, Width: '50%', Label: 'Search', ShowLoading: searchStatus === 'loading', ResultNote: searchStatus === 'error' ? 'Could not complete Search' : 'Found ' + data.length + ' Settings', GetEnum: function () {
77
- return function () { };
78
- } },
79
- React.createElement("li", { className: "nav-item", style: { width: '15%', paddingRight: 10 } },
80
- React.createElement("fieldset", { className: "border", style: { padding: '10px', height: '100%' } },
81
- React.createElement("legend", { className: "w-auto", style: { fontSize: 'large' } }, "Actions:"),
82
- React.createElement("form", null,
83
- React.createElement("button", { className: "btn btn-primary", onClick: function (event) { setEditNewSetting(emptySetting); setEditNew('New'); setShowModal(true); event.preventDefault(); } }, "Add Setting"))))),
84
- React.createElement("div", { style: { width: '100%', height: 'calc( 100% - 136px)' } },
85
- React.createElement(react_table_1.default, { cols: [
86
- { key: 'Name', field: 'Name', label: 'Setting Name', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
87
- { key: 'Value', field: 'Value', label: 'Current Value', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
88
- { key: 'DefaultValue', field: 'DefaultValue', label: 'Default Value', headerStyle: { width: '20%' }, rowStyle: { width: '20%' } },
89
- { key: 'scroll', label: '', headerStyle: { width: 17, padding: 0 }, rowStyle: { width: 0, padding: 0 } },
90
- ], tableClass: "table table-hover", data: data, sortKey: sortField, ascending: ascending, onSort: function (d) {
91
- if (d.colKey === 'scroll' || d.colField === undefined)
92
- return;
93
- if (d.colField === sortField)
94
- setAscending(!ascending);
95
- else {
96
- setAscending(true);
97
- setSortField(d.colField);
98
- }
99
- if (d.colField === sortField)
100
- dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: sortField, ascending: true }));
101
- else
102
- dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: d.colField, ascending: ascending }));
103
- }, onClick: function (item) { setEditNewSetting(item.row); setShowModal(true); setEditNew('Edit'); }, theadStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, tbodyStyle: { display: 'block', overflowY: 'scroll', maxHeight: window.innerHeight - 300, width: '100%' }, rowStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, selected: function () { return false; } }))),
104
- React.createElement(react_interactive_1.Modal, { Title: editNew === 'Edit' ? editnewSetting.Name + ' - Setting' : 'Add New Setting', Show: showModal, ShowX: true, Size: 'lg', ShowCancel: editNew === 'Edit', ConfirmText: 'Save', CancelText: 'Delete', CallBack: function (conf, isBtn) {
105
- if (conf && editNew === 'New')
106
- dispatch(props.SettingsSlice.DBAction({ verb: 'POST', record: editnewSetting }));
107
- if (conf && editNew === 'Edit')
108
- dispatch(props.SettingsSlice.DBAction({ verb: 'PATCH', record: editnewSetting }));
109
- if (!conf && isBtn)
110
- setShowWarning(true);
111
- setShowModal(false);
112
- }, DisableConfirm: (editNew === 'Edit' && !hasChanged) || errors.length > 0, ConfirmShowToolTip: errors.length > 0, ConfirmToolTipContent: errors.map(function (t, i) { return React.createElement("p", { key: i },
113
- gpa_symbols_1.CrossMark,
114
- " ",
115
- t,
116
- " "); }) },
117
- React.createElement("div", { className: "row" },
118
- React.createElement("div", { className: "col" },
119
- React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'Name', Label: 'Setting Name', Feedback: 'A unique Name is required.', Valid: function (field) { return editnewSetting.Name != null && editnewSetting.Name.length > 0 && allSettings.findIndex(function (s) { return s.Name === editnewSetting.Name && s.ID !== editnewSetting.ID; }) < 0; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } }),
120
- React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'Value', Label: 'Value', Feedback: 'Value is required.', Valid: function (field) { return editnewSetting.Value != null && editnewSetting.Value.length > 0; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } }),
121
- React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'DefaultValue', Label: 'Default Value', Valid: function (field) { return true; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } })))),
122
- React.createElement(react_interactive_1.Warning, { Title: 'Delete Setting', Message: 'This will Delete this Setting from the System. This can have unintended consequences and cause the System to crash. Are you sure you want to continue?', Show: showWarning, CallBack: function (conf) { if (conf)
123
- dispatch(props.SettingsSlice.DBAction({ verb: 'DELETE', record: editnewSetting })); setShowWarning(false); } })));
124
- }
125
- exports.default = Setting;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // Setting.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
+ // 04/28/2021 - C. Lackner
21
+ // Generated original version of source code.
22
+ // ******************************************************************************************************
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ var __importDefault = (this && this.__importDefault) || function (mod) {
47
+ return (mod && mod.__esModule) ? mod : { "default": mod };
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ var React = __importStar(require("react"));
51
+ var react_forms_1 = require("@gpa-gemstone/react-forms");
52
+ var react_table_1 = __importDefault(require("@gpa-gemstone/react-table"));
53
+ var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
54
+ var react_interactive_1 = require("@gpa-gemstone/react-interactive");
55
+ var react_redux_1 = require("react-redux");
56
+ function Setting(props) {
57
+ var dispatch = (0, react_redux_1.useDispatch)();
58
+ var search = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchFilters);
59
+ var searchStatus = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchStatus);
60
+ var data = (0, react_redux_1.useSelector)(props.SettingsSlice.SearchResults);
61
+ var allSettings = (0, react_redux_1.useSelector)(props.SettingsSlice.Data);
62
+ var status = (0, react_redux_1.useSelector)(props.SettingsSlice.Status);
63
+ var _a = React.useState('Name'), sortField = _a[0], setSortField = _a[1];
64
+ var _b = React.useState(true), ascending = _b[0], setAscending = _b[1];
65
+ var emptySetting = { ID: 0, Name: '', Value: '', DefaultValue: '' };
66
+ var _c = React.useState(emptySetting), editnewSetting = _c[0], setEditNewSetting = _c[1];
67
+ var _d = React.useState('New'), editNew = _d[0], setEditNew = _d[1];
68
+ var _e = React.useState(false), showModal = _e[0], setShowModal = _e[1];
69
+ var _f = React.useState(false), showWarning = _f[0], setShowWarning = _f[1];
70
+ var _g = React.useState(false), hasChanged = _g[0], setHasChanged = _g[1];
71
+ var _h = React.useState([]), errors = _h[0], setErrors = _h[1];
72
+ React.useEffect(function () {
73
+ if (status === 'unintiated' || status === 'changed')
74
+ dispatch(props.SettingsSlice.Fetch());
75
+ }, [dispatch, status]);
76
+ React.useEffect(function () {
77
+ if (searchStatus === 'unintiated' || status === 'changed')
78
+ dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: sortField, ascending: ascending }));
79
+ }, [dispatch, searchStatus, ascending, sortField, search]);
80
+ React.useEffect(function () { setHasChanged(false); }, [showModal]);
81
+ React.useEffect(function () {
82
+ var e = [];
83
+ if (editnewSetting.Name == null || editnewSetting.Name.length === 0)
84
+ e.push('A Name is required');
85
+ if (editnewSetting.Name != null && editnewSetting.Name.length > 0 && allSettings.findIndex(function (s) { return s.Name.toLowerCase() === editnewSetting.Name.toLowerCase() && s.ID !== editnewSetting.ID; }) > -1)
86
+ e.push('A Settign with this Name already exists.');
87
+ if (editnewSetting.Value == null || editnewSetting.Value.length === 0)
88
+ e.push('A Value is required');
89
+ setErrors(e);
90
+ }, [editnewSetting]);
91
+ var searchFields = [
92
+ { key: 'Name', label: 'Name', type: 'string', isPivotField: false },
93
+ { key: 'DefaultValue', label: 'Default Value', type: 'string', isPivotField: false },
94
+ { key: 'Value', label: 'Value', type: 'string', isPivotField: false }
95
+ ];
96
+ if (status === 'error')
97
+ return React.createElement("div", { style: { width: '100%', height: '100%' } },
98
+ React.createElement(react_interactive_1.ServerErrorIcon, { Show: true, Label: 'A Server Error Occured. Please Reload the Application' }));
99
+ return (React.createElement(React.Fragment, null,
100
+ React.createElement(react_interactive_1.LoadingScreen, { Show: status === 'loading' }),
101
+ React.createElement("div", { style: { width: '100%', height: '100%' } },
102
+ React.createElement(react_interactive_1.SearchBar, { CollumnList: searchFields, SetFilter: function (flds) { return dispatch(props.SettingsSlice.DBSearch({ filter: flds, sortField: sortField, ascending: ascending })); }, Direction: 'left', defaultCollumn: { key: 'Name', label: 'Name', type: 'string', isPivotField: false }, Width: '50%', Label: 'Search', ShowLoading: searchStatus === 'loading', ResultNote: searchStatus === 'error' ? 'Could not complete Search' : 'Found ' + data.length + ' Settings', GetEnum: function () {
103
+ return function () { };
104
+ } },
105
+ React.createElement("li", { className: "nav-item", style: { width: '15%', paddingRight: 10 } },
106
+ React.createElement("fieldset", { className: "border", style: { padding: '10px', height: '100%' } },
107
+ React.createElement("legend", { className: "w-auto", style: { fontSize: 'large' } }, "Actions:"),
108
+ React.createElement("form", null,
109
+ React.createElement("button", { className: "btn btn-primary", onClick: function (event) { setEditNewSetting(emptySetting); setEditNew('New'); setShowModal(true); event.preventDefault(); } }, "Add Setting"))))),
110
+ React.createElement("div", { style: { width: '100%', height: 'calc( 100% - 136px)' } },
111
+ React.createElement(react_table_1.default, { cols: [
112
+ { key: 'Name', field: 'Name', label: 'Setting Name', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
113
+ { key: 'Value', field: 'Value', label: 'Current Value', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
114
+ { key: 'DefaultValue', field: 'DefaultValue', label: 'Default Value', headerStyle: { width: '20%' }, rowStyle: { width: '20%' } },
115
+ { key: 'scroll', label: '', headerStyle: { width: 17, padding: 0 }, rowStyle: { width: 0, padding: 0 } },
116
+ ], tableClass: "table table-hover", data: data, sortKey: sortField, ascending: ascending, onSort: function (d) {
117
+ if (d.colKey === 'scroll' || d.colField === undefined)
118
+ return;
119
+ if (d.colField === sortField)
120
+ setAscending(!ascending);
121
+ else {
122
+ setAscending(true);
123
+ setSortField(d.colField);
124
+ }
125
+ if (d.colField === sortField)
126
+ dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: sortField, ascending: true }));
127
+ else
128
+ dispatch(props.SettingsSlice.DBSearch({ filter: search, sortField: d.colField, ascending: ascending }));
129
+ }, onClick: function (item) { setEditNewSetting(item.row); setShowModal(true); setEditNew('Edit'); }, theadStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, tbodyStyle: { display: 'block', overflowY: 'scroll', maxHeight: window.innerHeight - 300, width: '100%' }, rowStyle: { fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }, selected: function () { return false; } }))),
130
+ React.createElement(react_interactive_1.Modal, { Title: editNew === 'Edit' ? editnewSetting.Name + ' - Setting' : 'Add New Setting', Show: showModal, ShowX: true, Size: 'lg', ShowCancel: editNew === 'Edit', ConfirmText: 'Save', CancelText: 'Delete', CallBack: function (conf, isBtn) {
131
+ if (conf && editNew === 'New')
132
+ dispatch(props.SettingsSlice.DBAction({ verb: 'POST', record: editnewSetting }));
133
+ if (conf && editNew === 'Edit')
134
+ dispatch(props.SettingsSlice.DBAction({ verb: 'PATCH', record: editnewSetting }));
135
+ if (!conf && isBtn)
136
+ setShowWarning(true);
137
+ setShowModal(false);
138
+ }, DisableConfirm: (editNew === 'Edit' && !hasChanged) || errors.length > 0, ConfirmShowToolTip: errors.length > 0, ConfirmToolTipContent: errors.map(function (t, i) { return React.createElement("p", { key: i },
139
+ gpa_symbols_1.CrossMark,
140
+ " ",
141
+ t,
142
+ " "); }) },
143
+ React.createElement("div", { className: "row" },
144
+ React.createElement("div", { className: "col" },
145
+ React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'Name', Label: 'Setting Name', Feedback: 'A unique Name is required.', Valid: function (field) { return editnewSetting.Name != null && editnewSetting.Name.length > 0 && allSettings.findIndex(function (s) { return s.Name === editnewSetting.Name && s.ID !== editnewSetting.ID; }) < 0; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } }),
146
+ React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'Value', Label: 'Value', Feedback: 'Value is required.', Valid: function (field) { return editnewSetting.Value != null && editnewSetting.Value.length > 0; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } }),
147
+ React.createElement(react_forms_1.Input, { Record: editnewSetting, Field: 'DefaultValue', Label: 'Default Value', Valid: function (field) { return true; }, Setter: function (record) { setEditNewSetting(record); setHasChanged(true); } })))),
148
+ React.createElement(react_interactive_1.Warning, { Title: 'Delete Setting', Message: 'This will Delete this Setting from the System. This can have unintended consequences and cause the System to crash. Are you sure you want to continue?', Show: showWarning, CallBack: function (conf) { if (conf)
149
+ dispatch(props.SettingsSlice.DBAction({ verb: 'DELETE', record: editnewSetting })); setShowWarning(false); } })));
150
+ }
151
+ exports.default = Setting;