From 3595c7e87bbad04fc21f1f0cdf6f98f21a4c8288 Mon Sep 17 00:00:00 2001 From: Forrest Longanecker Date: Mon, 25 Nov 2019 11:07:46 -0800 Subject: [PATCH 1/4] user component now integrated with /api/users GET endpoint --- .../scripts/initial_credentials.dev.sql | 2 +- .../expungeservice/endpoints/usersview.py | 4 +- .../src/components/LoadingSpinner/index.tsx | 17 +++++ src/frontend/src/components/LogIn/index.tsx | 2 +- .../src/components/NotAuthorized/index.tsx | 14 ++++ .../src/components/OeciLogin/index.tsx | 2 +- src/frontend/src/components/Spinner/index.tsx | 9 --- .../TechnicalDifficulties/index.tsx | 14 ++++ src/frontend/src/components/User/index.tsx | 24 +++++-- .../src/components/UserList/index.tsx | 68 +++++++++++++------ src/frontend/src/containers/AllRecords.tsx | 11 +-- src/frontend/src/containers/AllStatus.tsx | 8 ++- src/frontend/src/redux/groups/actions.ts | 50 +++++++++----- src/frontend/src/redux/users/actions.ts | 52 +++----------- src/frontend/src/redux/users/types.ts | 3 +- 15 files changed, 174 insertions(+), 106 deletions(-) create mode 100644 src/frontend/src/components/LoadingSpinner/index.tsx create mode 100644 src/frontend/src/components/NotAuthorized/index.tsx delete mode 100644 src/frontend/src/components/Spinner/index.tsx create mode 100644 src/frontend/src/components/TechnicalDifficulties/index.tsx diff --git a/config/postgres/initdb/scripts/initial_credentials.dev.sql b/config/postgres/initdb/scripts/initial_credentials.dev.sql index dbedf5d47..323a2d8f0 100644 --- a/config/postgres/initdb/scripts/initial_credentials.dev.sql +++ b/config/postgres/initdb/scripts/initial_credentials.dev.sql @@ -1,2 +1,2 @@ SELECT * FROM USERS_CREATE( 'admin@email.com', 'pbkdf2:sha256:150000$c30CjWVB$d1d6d544dfffd2dee5488cfe89cc2f965a8c4cddbf9180ad206f272237a5fa1a', 'Ima Admin', 'Ima Group', true); -SELECT * FROM USERS_CREATE('user@email.com', 'pbkdf2:sha256:150000$K5efuBwy$fcaa41a3203fd8f64b5d4aee241365ffa35e0a3a1c02f605bbc20cbea701cf89', 'Ima User', 'Ima Group' , true); +SELECT * FROM USERS_CREATE('user@email.com', 'pbkdf2:sha256:150000$K5efuBwy$fcaa41a3203fd8f64b5d4aee241365ffa35e0a3a1c02f605bbc20cbea701cf89', 'Ima User', 'Ima Group' , false); diff --git a/src/backend/expungeservice/endpoints/usersview.py b/src/backend/expungeservice/endpoints/usersview.py index 203d1b379..85b15b365 100644 --- a/src/backend/expungeservice/endpoints/usersview.py +++ b/src/backend/expungeservice/endpoints/usersview.py @@ -107,10 +107,10 @@ def get(self, user_id): response_data: Dict[str, List[Dict[str, str]]] = {"users": []} for user_entry in user_db_data: response_data["users"].append({ - "user_id": user_entry["user_id"], + "id": user_entry["user_id"], "email": user_entry["email"], "name": user_entry["name"], - "group_name": user_entry["group_name"], + "group": user_entry["group_name"], "admin": user_entry["admin"], "timestamp": user_entry["date_created"] }) diff --git a/src/frontend/src/components/LoadingSpinner/index.tsx b/src/frontend/src/components/LoadingSpinner/index.tsx new file mode 100644 index 000000000..582526fee --- /dev/null +++ b/src/frontend/src/components/LoadingSpinner/index.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +interface Props { + inputString: string; +} + +class LoadingSpinner extends React.Component { + render() { + return ( +

+ Loading {this.props.inputString}... +

+ ); + } +} + +export default LoadingSpinner; diff --git a/src/frontend/src/components/LogIn/index.tsx b/src/frontend/src/components/LogIn/index.tsx index 9f345c66e..a150129e0 100644 --- a/src/frontend/src/components/LogIn/index.tsx +++ b/src/frontend/src/components/LogIn/index.tsx @@ -153,7 +153,7 @@ class LogIn extends React.Component { ) : null} {this.state.invalidResponse === true ? (

- Technical difficulties try again later. + Technical difficulties, please contact system administrator.

) : null} diff --git a/src/frontend/src/components/NotAuthorized/index.tsx b/src/frontend/src/components/NotAuthorized/index.tsx new file mode 100644 index 000000000..6ebe14c10 --- /dev/null +++ b/src/frontend/src/components/NotAuthorized/index.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +class NotAuthorized extends React.Component { + render() { + return ( +

+ You are not authorized to view this content, please contact system + administraitor. +

+ ); + } +} + +export default NotAuthorized; diff --git a/src/frontend/src/components/OeciLogin/index.tsx b/src/frontend/src/components/OeciLogin/index.tsx index dc9457986..a69b547cf 100644 --- a/src/frontend/src/components/OeciLogin/index.tsx +++ b/src/frontend/src/components/OeciLogin/index.tsx @@ -133,7 +133,7 @@ class OeciLogin extends React.Component { ) : null} {this.state.invalidResponse === true ? (

- Technical difficulties try again later. + Technical difficulties, please contact system administrator.

) : null} diff --git a/src/frontend/src/components/Spinner/index.tsx b/src/frontend/src/components/Spinner/index.tsx deleted file mode 100644 index d27c2fa07..000000000 --- a/src/frontend/src/components/Spinner/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; - -export default function() { - return ( -

- Loading your search results... -

- ); -} diff --git a/src/frontend/src/components/TechnicalDifficulties/index.tsx b/src/frontend/src/components/TechnicalDifficulties/index.tsx new file mode 100644 index 000000000..096156ac7 --- /dev/null +++ b/src/frontend/src/components/TechnicalDifficulties/index.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +class TechnicalDifficulties extends React.Component { + render() { + return ( +

+ Something went wrong, please contact system administraitor to report + technical difficulties. +

+ ); + } +} + +export default TechnicalDifficulties; diff --git a/src/frontend/src/components/User/index.tsx b/src/frontend/src/components/User/index.tsx index a557ec950..7679188af 100644 --- a/src/frontend/src/components/User/index.tsx +++ b/src/frontend/src/components/User/index.tsx @@ -8,14 +8,28 @@ interface Props { class User extends React.Component { public render() { return ( - - - + + + {this.props.user.name} - {this.props.user.role} - {this.props.user.group} + {this.props.user.admin ? 'Admin' : 'Search'} + {this.props.user.group} + +