@gpa-gemstone/common-pages 0.0.123 → 0.0.124

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,174 +0,0 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // ByUser.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
- // 07/14/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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
- if (k2 === undefined) k2 = k;
36
- var desc = Object.getOwnPropertyDescriptor(m, k);
37
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
- desc = { enumerable: true, get: function() { return m[k]; } };
39
- }
40
- Object.defineProperty(o, k2, desc);
41
- }) : (function(o, m, k, k2) {
42
- if (k2 === undefined) k2 = k;
43
- o[k2] = m[k];
44
- }));
45
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
46
- Object.defineProperty(o, "default", { enumerable: true, value: v });
47
- }) : function(o, v) {
48
- o["default"] = v;
49
- });
50
- var __importStar = (this && this.__importStar) || function (mod) {
51
- if (mod && mod.__esModule) return mod;
52
- var result = {};
53
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
54
- __setModuleDefault(result, mod);
55
- return result;
56
- };
57
- var __importDefault = (this && this.__importDefault) || function (mod) {
58
- return (mod && mod.__esModule) ? mod : { "default": mod };
59
- };
60
- Object.defineProperty(exports, "__esModule", { value: true });
61
- var React = __importStar(require("react"));
62
- var react_table_1 = __importDefault(require("@gpa-gemstone/react-table"));
63
- var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
64
- var react_interactive_1 = require("@gpa-gemstone/react-interactive");
65
- var CryptoJS = __importStar(require("crypto-js"));
66
- var _ = __importStar(require("lodash"));
67
- var UserForm_1 = __importDefault(require("./UserForm"));
68
- var react_redux_1 = require("react-redux");
69
- var defaultSearchcols = [
70
- { label: 'First Name', key: 'FirstName', type: 'string', isPivotField: false },
71
- { label: 'Last Name', key: 'LastName', type: 'string', isPivotField: false },
72
- { label: 'Location', key: 'Location', type: 'string', isPivotField: false },
73
- { label: 'Phone', key: 'Phone', type: 'string', isPivotField: false },
74
- { label: 'Email', key: 'Email', type: 'string', isPivotField: false },
75
- ];
76
- function ByUser(props) {
77
- var dispatch = (0, react_redux_1.useDispatch)();
78
- var search = (0, react_redux_1.useSelector)(props.UserSlice.SearchFilters);
79
- var data = (0, react_redux_1.useSelector)(props.UserSlice.SearchResults);
80
- var userStatus = (0, react_redux_1.useSelector)(props.UserSlice.Status);
81
- var searchStatus = (0, react_redux_1.useSelector)(props.UserSlice.SearchStatus);
82
- var sortField = (0, react_redux_1.useSelector)(props.UserSlice.SortField);
83
- var ascending = (0, react_redux_1.useSelector)(props.UserSlice.Ascending);
84
- var currentUserAccount = (0, react_redux_1.useSelector)(props.UserSlice.CurrentUser);
85
- var adlFields = (0, react_redux_1.useSelector)(props.AdditionalFieldSlice.Fields);
86
- var adlFieldStatus = (0, react_redux_1.useSelector)(props.AdditionalFieldSlice.FieldStatus);
87
- var _a = React.useState(defaultSearchcols), filterableList = _a[0], setFilterableList = _a[1];
88
- var _b = React.useState(false), showModal = _b[0], setShowModal = _b[1];
89
- var _c = React.useState([]), userError = _c[0], setUserError = _c[1];
90
- var valueListItems = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Data);
91
- var valueListItemStatus = (0, react_redux_1.useSelector)(props.ValueListItemSlice.Status);
92
- var valueListGroups = (0, react_redux_1.useSelector)(props.ValueListGroupSlice.Data);
93
- var valueListGroupStatus = (0, react_redux_1.useSelector)(props.ValueListGroupSlice.Status);
94
- var _d = React.useState('unintiated'), pageStatus = _d[0], setPageStatus = _d[1];
95
- React.useEffect(function () {
96
- if (userStatus === 'error' || adlFieldStatus === 'error' || valueListItemStatus === 'error' || valueListGroupStatus === 'error')
97
- setPageStatus('error');
98
- else if (userStatus === 'loading' || adlFieldStatus === 'loading' || valueListItemStatus === 'loading' || valueListGroupStatus === 'loading')
99
- setPageStatus('loading');
100
- else
101
- setPageStatus('idle');
102
- }, [userStatus, adlFieldStatus, valueListItemStatus, valueListGroupStatus]);
103
- React.useEffect(function () {
104
- if (adlFieldStatus === 'unintiated' || adlFieldStatus === 'changed')
105
- dispatch(props.AdditionalFieldSlice.FetchField());
106
- }, [dispatch, adlFieldStatus]);
107
- React.useEffect(function () {
108
- dispatch(props.UserSlice.DBSearch({ sortField: sortField, ascending: ascending, filter: search }));
109
- dispatch(props.UserSlice.SetNewUser());
110
- }, [dispatch]);
111
- React.useEffect(function () {
112
- if (valueListItemStatus === 'unintiated' || valueListItemStatus === 'changed')
113
- dispatch(props.ValueListItemSlice.Fetch());
114
- }, [dispatch, valueListItemStatus]);
115
- React.useEffect(function () {
116
- if (valueListGroupStatus === 'unintiated' || valueListGroupStatus === 'changed')
117
- dispatch(props.ValueListGroupSlice.Fetch());
118
- }, [dispatch, valueListGroupStatus]);
119
- React.useEffect(function () {
120
- function ConvertType(type) {
121
- if (type === 'string' || type === 'integer' || type === 'number' || type === 'datetime' || type === 'boolean')
122
- return { type: type };
123
- return { type: 'enum', enum: [{ Label: type, Value: type }] };
124
- }
125
- var ordered = _.orderBy(defaultSearchcols.concat(adlFields.map(function (item) { return (__assign({ label: "[AF] ".concat(item.FieldName), key: item.FieldName }, ConvertType(item.Type))); })), ['label'], ["asc"]);
126
- setFilterableList(ordered);
127
- }, [adlFields]);
128
- if (pageStatus === 'error')
129
- return React.createElement("div", { style: { width: '100%', height: '100%' } },
130
- React.createElement(react_interactive_1.ServerErrorIcon, { Show: true, Label: 'A Server Error Occured. Please Reload the Application' }));
131
- return (React.createElement("div", { style: { width: '100%', height: '100%' } },
132
- React.createElement(react_interactive_1.LoadingScreen, { Show: pageStatus === 'loading' }),
133
- React.createElement(react_interactive_1.SearchBar, { CollumnList: filterableList, SetFilter: function (flds) { return dispatch(props.UserSlice.DBSearch({ sortField: sortField, ascending: ascending, filter: flds })); }, Direction: 'left', defaultCollumn: { label: 'Last Name', key: 'LastName', type: 'string', isPivotField: false }, Width: '50%', Label: 'Search', ShowLoading: searchStatus === 'loading', ResultNote: searchStatus === 'error' ? 'Could not complete Search' : 'Found ' + data.length + ' UserAccounts', GetEnum: function (setOptions, field) {
134
- if (field.type !== 'enum' || field.enum === undefined || field.enum.length !== 1)
135
- return function () { };
136
- var grpName = (field.enum !== undefined ? field.enum[0].Value.toLowerCase() : '');
137
- var grpIndex = valueListGroups.findIndex(function (g) { return g.Name.toLowerCase() === grpName; });
138
- if (grpIndex < 0)
139
- return function () { };
140
- setOptions(valueListItems.filter(function (v) { return v.GroupID === valueListGroups[grpIndex].ID; }).map(function (item) { return ({ Value: item.ID.toString(), Label: item.Value }); }));
141
- return function () { };
142
- } },
143
- React.createElement("li", { className: "nav-item", style: { width: '15%', paddingRight: 10 } },
144
- React.createElement("fieldset", { className: "border", style: { padding: '10px', height: '100%' } },
145
- React.createElement("legend", { className: "w-auto", style: { fontSize: 'large' } }, "Actions:"),
146
- React.createElement("form", null,
147
- React.createElement("button", { className: "btn btn-primary", onClick: function (event) { event.preventDefault(); setShowModal(true); } }, "Add User"))))),
148
- React.createElement("div", { style: { width: '100%', height: 'calc( 100% - 136px)' } },
149
- React.createElement(react_table_1.default, { cols: [
150
- { key: 'Name', field: 'Name', label: 'User Name', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
151
- { key: 'FirstName', field: 'FirstName', label: 'First Name', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
152
- { key: 'LastName', field: 'LastName', label: 'Last Name', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
153
- { key: 'Phone', field: 'Phone', label: 'Phone', headerStyle: { width: '10%' }, rowStyle: { width: '10%' } },
154
- { key: 'Email', field: 'Email', label: 'Email', headerStyle: { width: 'auto' }, rowStyle: { width: 'auto' } },
155
- { key: 'scroll', label: '', headerStyle: { width: 17, padding: 0 }, rowStyle: { width: 0, padding: 0 } },
156
- ], tableClass: "table table-hover", data: data, sortKey: sortField, ascending: ascending, onSort: function (d) {
157
- if (d.colField === undefined)
158
- return;
159
- if (d.colField !== sortField)
160
- dispatch(props.UserSlice.DBSearch({ sortField: sortField, ascending: !ascending, filter: search }));
161
- else
162
- dispatch(props.UserSlice.DBSearch({ sortField: d.colField, ascending: true, filter: search }));
163
- }, onClick: function (d) { return props.OnUserSelect(d.row.ID); }, 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 (item) { return false; } })),
164
- React.createElement(react_interactive_1.Modal, { Show: showModal, Size: 'lg', ShowCancel: false, ShowX: true, ConfirmText: 'Save', Title: 'Add User', CallBack: function (confirm) {
165
- if (confirm)
166
- dispatch(props.UserSlice.DBAction({ verb: 'POST', record: __assign(__assign({}, currentUserAccount), { Password: CryptoJS.SHA256(currentUserAccount.Password + "0").toString(CryptoJS.enc.Base64) }) }));
167
- dispatch(props.UserSlice.SetNewUser());
168
- setShowModal(false);
169
- }, ConfirmShowToolTip: userError.length > 0, ConfirmToolTipContent: userError.map(function (t, i) { return React.createElement("p", { key: i },
170
- gpa_symbols_1.CrossMark,
171
- " ",
172
- t); }), DisableConfirm: userError.length > 0 }, currentUserAccount !== undefined ? React.createElement(UserForm_1.default, { UserAccount: currentUserAccount, Setter: function (u) { return dispatch(props.UserSlice.SetCurrentUser(u)); }, Edit: false, SetErrors: setUserError, UserSlice: props.UserSlice }) : null)));
173
- }
174
- exports.default = ByUser;
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- import { Application, SystemCenter } from '@gpa-gemstone/application-typings';
3
- import { IAdditionalFieldSlice, IGenericSlice, ISecurityRoleSlice, IUserAccountSlice } from '../SliceInterfaces';
4
- interface IProps {
5
- UserID: string;
6
- OnDelete: () => void;
7
- SecurityRoleSlice: ISecurityRoleSlice;
8
- UserSlice: IUserAccountSlice;
9
- AdditionalFieldSlice: IAdditionalFieldSlice<Application.Types.iAdditionalUserField, Application.Types.iAdditionalUserFieldValue>;
10
- ValueListItemSlice: IGenericSlice<SystemCenter.Types.ValueListItem>;
11
- ValueListGroupSlice: IGenericSlice<SystemCenter.Types.ValueListGroup>;
12
- }
13
- declare function User(props: IProps): React.JSX.Element;
14
- export default User;
package/lib/user/User.js DELETED
@@ -1,97 +0,0 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // User.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
- // 07/14/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_interactive_1 = require("@gpa-gemstone/react-interactive");
52
- var UserInfo_1 = __importDefault(require("./UserInfo"));
53
- var UserPermissions_1 = __importDefault(require("./UserPermissions"));
54
- var AdditionalField_1 = __importDefault(require("./AdditionalField"));
55
- var react_redux_1 = require("react-redux");
56
- var react_forms_1 = require("@gpa-gemstone/react-forms");
57
- function User(props) {
58
- var dispatch = (0, react_redux_1.useDispatch)();
59
- var user = (0, react_redux_1.useSelector)(props.UserSlice.CurrentUser);
60
- var status = (0, react_redux_1.useSelector)(props.UserSlice.Status);
61
- var _a = React.useState('userInfo'), tab = _a[0], setTab = _a[1];
62
- var _b = React.useState(false), showWarning = _b[0], setShowWarning = _b[1];
63
- React.useEffect(function () {
64
- dispatch(props.UserSlice.LoadExistingUser(props.UserID));
65
- }, [dispatch, props.UserID]);
66
- if (status === 'error')
67
- return React.createElement("div", { style: { width: '100%', height: '100%' } },
68
- React.createElement(react_interactive_1.ServerErrorIcon, { Show: true, Label: 'A Server Error Occured. Please Reload the Application' }));
69
- var Tabs = [
70
- { Id: "userInfo", Label: "User Info" },
71
- { Id: "permissions", Label: "Permissions" },
72
- { Id: "additionalFields", Label: "Additional Fields" }
73
- ];
74
- return (React.createElement("div", { style: { width: '100%', height: window.innerHeight - 63, maxHeight: window.innerHeight - 63, overflow: 'hidden', padding: 15 } },
75
- React.createElement("div", { className: "row" },
76
- React.createElement("div", { className: "col" },
77
- React.createElement("h2", null, user != null ? "".concat(user.FirstName, " ").concat(user.LastName) : '')),
78
- React.createElement("div", { className: "col" },
79
- React.createElement("button", { className: "btn btn-danger pull-right", hidden: user == null, onClick: function () { return setShowWarning(true); } }, "Delete User"))),
80
- React.createElement(react_interactive_1.LoadingScreen, { Show: status === 'loading' }),
81
- React.createElement("hr", null),
82
- React.createElement(react_interactive_1.TabSelector, { CurrentTab: tab, SetTab: function (t) { return setTab(t); }, Tabs: Tabs }),
83
- React.createElement("div", { className: "tab-content", style: { maxHeight: window.innerHeight - 235, overflow: 'hidden' } },
84
- React.createElement("div", { className: "tab-pane " + (tab === "userInfo" ? " active" : "fade") },
85
- React.createElement(UserInfo_1.default, { UserSlice: props.UserSlice })),
86
- React.createElement("div", { className: "tab-pane " + (tab === "permissions" ? " active" : "fade") }, user == null ? null : React.createElement(UserPermissions_1.default, { UserID: user.ID, RoleSlice: props.SecurityRoleSlice })),
87
- React.createElement("div", { className: "tab-pane " + (tab === "additionalFields" ? " active" : "fade"), style: { maxHeight: window.innerHeight - 215 } },
88
- React.createElement(AdditionalField_1.default, { Id: props.UserID, AdditionalFieldSlice: props.AdditionalFieldSlice, ValueListItemSlice: props.ValueListItemSlice, ValueListGroupSlice: props.ValueListGroupSlice, EmptyField: { ID: -1, IsSecure: false, FieldName: '', Type: 'string' }, GetFieldValueIndex: function (field, values) { return values.findIndex(function (v) { return v.AdditionalUserFieldID === field.ID; }); }, GetFieldIndex: function (value, fields) { return fields.findIndex(function (f) { return f.ID === value.AdditionalUserFieldID; }); }, FieldKeySelector: function (field) { return (field.ID === -1 ? 'new' : field.ID.toString()); }, ValidateField: function () { return []; }, FieldUI: function (fld, setter) { return React.createElement(react_forms_1.CheckBox, { Record: fld, Field: 'IsSecure', Label: "Secure Data", Setter: setter }); }, CreateValue: function (fld) { return ({ Value: '', ID: -1, UserAccountID: props.UserID, AdditionalUserFieldID: fld.ID }); } }))),
89
- React.createElement(react_interactive_1.Warning, { Message: 'This will permanently remove the User. Are you sure you want to continue?', Title: 'Warning', Show: showWarning, CallBack: function (c) {
90
- setShowWarning(false);
91
- if (c) {
92
- dispatch(props.UserSlice.DBAction({ verb: 'DELETE', record: user }));
93
- props.OnDelete();
94
- }
95
- } })));
96
- }
97
- exports.default = User;
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { Application } from '@gpa-gemstone/application-typings';
3
- import { IUserAccountSlice } from '../SliceInterfaces';
4
- interface IProps {
5
- UserAccount: Application.Types.iUserAccount;
6
- Setter: (record: Application.Types.iUserAccount) => void;
7
- Edit: boolean;
8
- SetErrors?: (e: string[]) => void;
9
- UserSlice: IUserAccountSlice;
10
- }
11
- declare function UserForm(props: IProps): React.JSX.Element | null;
12
- export default UserForm;
@@ -1,166 +0,0 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // UserForm.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
- // 07/14/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
- Object.defineProperty(exports, "__esModule", { value: true });
47
- var React = __importStar(require("react"));
48
- var react_forms_1 = require("@gpa-gemstone/react-forms");
49
- var _ = __importStar(require("lodash"));
50
- var react_redux_1 = require("react-redux");
51
- function UserForm(props) {
52
- var dispatch = (0, react_redux_1.useDispatch)();
53
- var _a = React.useState(false), updatedAD = _a[0], setUpdatedAD = _a[1];
54
- var userValidation = (0, react_redux_1.useSelector)(props.UserSlice.ADValidation);
55
- var _b = React.useState([]), userError = _b[0], setUserError = _b[1];
56
- React.useEffect(function () {
57
- if (userValidation === 'Valid' && !props.Edit && updatedAD === false)
58
- dispatch(props.UserSlice.ADUpdate());
59
- }, [userValidation, updatedAD]);
60
- React.useEffect(function () {
61
- if (props.SetErrors !== undefined)
62
- props.SetErrors(userError);
63
- }, [userError, props.SetErrors]);
64
- React.useEffect(function () {
65
- if (props.UserAccount == null)
66
- return;
67
- var e = [];
68
- if (props.UserAccount.Name == null || props.UserAccount.Name.length === 0)
69
- e.push('An AccountName is required.');
70
- if (props.UserAccount.UseADAuthentication && userValidation !== 'Valid')
71
- e.push('The user could not be validated by the AD.');
72
- setUserError(e);
73
- }, [props.UserAccount, userValidation]);
74
- function validUserAccountField(user, field) {
75
- if (field === 'Name')
76
- return user.Name != null && user.Name.length > 0 && user.Name.length <= 200;
77
- else if (field === 'Password')
78
- return user.Password == null || user.Password.length <= 200;
79
- else if (field === 'FirstName')
80
- return user.FirstName == null || user.FirstName.length <= 200;
81
- else if (field === 'LastName')
82
- return user.LastName == null || user.LastName.length <= 200;
83
- else if (field === 'Phone')
84
- return user.Phone == null || user.Phone.length <= 200;
85
- else if (field === 'Email')
86
- return user.Email == null || user.Email.length <= 200;
87
- else if (field === "ChangePasswordOn")
88
- return user.ChangePasswordOn == null;
89
- return false;
90
- }
91
- if (props.UserAccount == null)
92
- return null;
93
- return (React.createElement(React.Fragment, null,
94
- React.createElement("form", null,
95
- React.createElement("div", { className: "row" },
96
- React.createElement("div", { className: "col" },
97
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Disabled: props.Edit, Field: 'Name', Feedback: 'A Name of less than 200 characters is required.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: function (record) {
98
- setUpdatedAD(false);
99
- props.Setter(record);
100
- } }),
101
- React.createElement("div", { className: "row", style: { position: 'absolute', top: 0, left: 100 }, hidden: !props.UserAccount.UseADAuthentication },
102
- React.createElement("span", { id: "resolvingAccount", hidden: userValidation !== 'Resolving' },
103
- React.createElement("i", { style: { height: 10, width: 10, color: 'grey' }, className: "fa fa fa-spin fa-refresh" }),
104
- "\u00A0",
105
- React.createElement("em", { className: "small" }, "Resolving account details...")),
106
- React.createElement("span", { id: "accountValid", hidden: userValidation !== 'Valid' },
107
- React.createElement("i", { style: { height: 20, width: 20, color: 'green' }, className: "fa fa-check-circle" }),
108
- "\u00A0",
109
- React.createElement("em", { className: "small" }, "Resolved account name ")),
110
- React.createElement("span", { id: "accountInvalid", hidden: userValidation !== 'Invalid' },
111
- React.createElement("i", { style: { height: 20, width: 20, color: 'red' }, className: "fa fa-times-circle" }),
112
- "\u00A0",
113
- React.createElement("em", { className: "small" }, "Cannot resolve account name")),
114
- React.createElement("span", { id: "accountUnknown", hidden: userValidation !== 'Unknown' },
115
- React.createElement("i", { style: { height: 20, width: 20, color: 'orange' }, className: "fa fa-exclamation-circle" }),
116
- "\u00A0",
117
- React.createElement("em", { className: "small" }, "Valid account name is not a user or Active Directory access is limited"))),
118
- React.createElement("button", { style: { marginBottom: 10 }, type: "button", className: "btn btn-primary btn-sm", onClick: function (evt) { evt.preventDefault(); dispatch(props.UserSlice.ADUpdate()); }, hidden: userValidation !== 'Valid' || !props.Edit }, "Load Information from AD"),
119
- React.createElement("div", { className: "card" },
120
- React.createElement("div", { className: "card-header" },
121
- React.createElement("div", { className: "row" },
122
- React.createElement("div", { className: "col-xs-4" },
123
- React.createElement("div", { className: "form-check-inline" },
124
- React.createElement("label", { className: "form-check-label" },
125
- React.createElement("input", { disabled: props.Edit, className: 'form-check-input', type: 'radio', checked: props.UserAccount.UseADAuthentication, onChange: function (e) {
126
- var record = _.clone(props.UserAccount);
127
- record.UseADAuthentication = e.target.checked;
128
- props.Setter(record);
129
- } }),
130
- "Active Directory User"))),
131
- React.createElement("div", { className: "col-xs-4" },
132
- React.createElement("div", { className: "form-check-inline" },
133
- React.createElement("label", { className: "form-check-label" },
134
- React.createElement("input", { disabled: props.Edit, className: 'form-check-input', type: 'radio', checked: !props.UserAccount.UseADAuthentication, onChange: function (e) {
135
- var record = _.clone(props.UserAccount);
136
- record.UseADAuthentication = !e.target.checked;
137
- props.Setter(record);
138
- } }),
139
- "Database User"))))),
140
- React.createElement("div", { className: "card-body", hidden: !props.UserAccount.UseADAuthentication },
141
- React.createElement("div", { className: "row" },
142
- React.createElement("div", { className: "col" },
143
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'FirstName', Label: 'First Name', Feedback: 'First Name must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
144
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'LastName', Label: 'Last Name', Feedback: 'Last Name must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter })),
145
- React.createElement("div", { className: "col" },
146
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'Phone', Feedback: 'Phone must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
147
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'Email', Feedback: 'Email must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter })))),
148
- React.createElement("div", { className: "card-body", hidden: props.UserAccount.UseADAuthentication },
149
- React.createElement("div", { className: "row" },
150
- React.createElement("div", { className: "col" },
151
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'Password', Feedback: 'Password must be less than 200 characters.', Type: 'password', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
152
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'FirstName', Label: 'First Name', Feedback: 'First Name must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
153
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'LastName', Label: 'Last Name', Feedback: 'Last Name must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter })),
154
- React.createElement("div", { className: "col" },
155
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'Phone', Feedback: 'Password must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
156
- React.createElement(react_forms_1.Input, { Record: props.UserAccount, Field: 'Email', Feedback: 'Password must be less than 200 characters.', Valid: function (field) { return validUserAccountField(props.UserAccount, field); }, Setter: props.Setter }),
157
- React.createElement(react_forms_1.DatePicker, { Record: props.UserAccount, Field: 'ChangePasswordOn', Label: 'Change Password On', Setter: props.Setter, Valid: function (field) { return validUserAccountField(props.UserAccount, field); } })))),
158
- React.createElement("div", { className: "row" },
159
- React.createElement("div", { className: "col", style: { margin: 10 } },
160
- React.createElement(react_forms_1.CheckBox, { Record: props.UserAccount, Label: 'Locked Out', Field: 'LockedOut', Setter: props.Setter }),
161
- React.createElement(react_forms_1.CheckBox, { Record: props.UserAccount, Field: 'Approved', Setter: props.Setter })),
162
- React.createElement("div", { className: "col-lg-6" },
163
- React.createElement(react_forms_1.CheckBox, { Record: props.UserAccount, Label: 'Phone Confirmed', Field: 'PhoneConfirmed', Setter: props.Setter }),
164
- React.createElement(react_forms_1.CheckBox, { Record: props.UserAccount, Label: 'Email Confirmed', Field: 'EmailConfirmed', Setter: props.Setter })))))))));
165
- }
166
- exports.default = UserForm;
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import { IUserAccountSlice } from '../SliceInterfaces';
3
- interface IProps {
4
- UserSlice: IUserAccountSlice;
5
- }
6
- declare function UserInfo(props: IProps): React.JSX.Element;
7
- export default UserInfo;
@@ -1,123 +0,0 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // UserInfo.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
- // 07/14/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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
- if (k2 === undefined) k2 = k;
36
- var desc = Object.getOwnPropertyDescriptor(m, k);
37
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
- desc = { enumerable: true, get: function() { return m[k]; } };
39
- }
40
- Object.defineProperty(o, k2, desc);
41
- }) : (function(o, m, k, k2) {
42
- if (k2 === undefined) k2 = k;
43
- o[k2] = m[k];
44
- }));
45
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
46
- Object.defineProperty(o, "default", { enumerable: true, value: v });
47
- }) : function(o, v) {
48
- o["default"] = v;
49
- });
50
- var __importStar = (this && this.__importStar) || function (mod) {
51
- if (mod && mod.__esModule) return mod;
52
- var result = {};
53
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
54
- __setModuleDefault(result, mod);
55
- return result;
56
- };
57
- var __importDefault = (this && this.__importDefault) || function (mod) {
58
- return (mod && mod.__esModule) ? mod : { "default": mod };
59
- };
60
- Object.defineProperty(exports, "__esModule", { value: true });
61
- var React = __importStar(require("react"));
62
- var CryptoJS = __importStar(require("crypto-js"));
63
- var UserForm_1 = __importDefault(require("./UserForm"));
64
- var react_interactive_1 = require("@gpa-gemstone/react-interactive");
65
- var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
66
- var react_redux_1 = require("react-redux");
67
- function UserInfo(props) {
68
- var dispatch = (0, react_redux_1.useDispatch)();
69
- var currentUser = (0, react_redux_1.useSelector)(props.UserSlice.CurrentUser);
70
- var _a = React.useState(currentUser), user = _a[0], setUser = _a[1];
71
- var _b = React.useState([]), warnings = _b[0], setWarning = _b[1];
72
- var _c = React.useState('None'), hover = _c[0], setHover = _c[1];
73
- React.useEffect(function () {
74
- if (currentUser == null || user == null)
75
- return;
76
- var encryptedPwd = (user.Password !== currentUser.Password ? CryptoJS.SHA256(user.Password + "0").toString(CryptoJS.enc.Base64) : user.Password);
77
- var w = [];
78
- if (currentUser.FirstName !== user.FirstName)
79
- w.push('Changes to First Name will be lost.');
80
- if (currentUser.LastName !== user.LastName)
81
- w.push('Changes to Last Name will be lost.');
82
- if (currentUser.Phone !== user.Phone)
83
- w.push('Changes to Phone will be lost.');
84
- if (currentUser.Email !== user.Email)
85
- w.push('Changes to Email will be lost.');
86
- if (currentUser.ChangePasswordOn !== user.ChangePasswordOn)
87
- w.push('Changes to Change Password Date will be lost.');
88
- if (currentUser.LockedOut !== user.LockedOut)
89
- w.push('Changes to Account Locked Status will be lost.');
90
- if (currentUser.Approved !== user.Approved)
91
- w.push('Changes Account Approved Status will be lost.');
92
- if (currentUser.PhoneConfirmed !== user.PhoneConfirmed)
93
- w.push('Changes to Phone Confirmed Status will be lost.');
94
- if (currentUser.EmailConfirmed !== user.EmailConfirmed)
95
- w.push('Changes to Email confirmed Status will be lost.');
96
- if (!currentUser.UseADAuthentication && currentUser.Password !== encryptedPwd)
97
- w.push('Changes to Password will be lost.');
98
- setWarning(w);
99
- }, [currentUser, user]);
100
- React.useEffect(function () { setUser(currentUser); }, [currentUser]);
101
- function updateUser() {
102
- var encryptedPwd = (user.Password !== currentUser.Password ? CryptoJS.SHA256(user.Password + "0").toString(CryptoJS.enc.Base64) : user.Password);
103
- dispatch(props.UserSlice.SetCurrentUser(__assign(__assign({}, user), { Name: currentUser.Name, Password: encryptedPwd })));
104
- dispatch(props.UserSlice.DBAction({ verb: 'PATCH', record: __assign(__assign({}, user), { Name: currentUser.Name, Password: encryptedPwd }) }));
105
- }
106
- return (React.createElement("div", { className: "card", style: { marginBottom: 10 } },
107
- React.createElement("div", { className: "card-header" },
108
- React.createElement("div", { className: "row" },
109
- React.createElement("div", { className: "col" },
110
- React.createElement("h4", null, "User Information:")))),
111
- React.createElement("div", { className: "card-body", style: { height: window.innerHeight - 440, maxHeight: window.innerHeight - 440, overflowY: 'auto' } },
112
- React.createElement(UserForm_1.default, { UserAccount: user, Setter: function (u) { return setUser(u); }, Edit: true, UserSlice: props.UserSlice })),
113
- React.createElement("div", { className: "card-footer" },
114
- React.createElement("div", { className: "btn-group mr-2" },
115
- React.createElement("button", { className: "btn btn-primary", onClick: function () { return updateUser(); }, disabled: warnings.length === 0 }, "Update")),
116
- React.createElement("div", { className: "btn-group mr-2" },
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', Theme: 'dark', Target: "Clr" }, warnings.map(function (t, i) { return React.createElement("p", { key: i },
119
- gpa_symbols_1.Warning,
120
- " ",
121
- t); })))));
122
- }
123
- exports.default = UserInfo;
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { ISecurityRoleSlice } from '../SliceInterfaces';
3
- interface IProps {
4
- UserID: string;
5
- RoleSlice: ISecurityRoleSlice;
6
- }
7
- declare function UserPermission(props: IProps): React.JSX.Element;
8
- export default UserPermission;