Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user cabinet & admin panel #107

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ HOST_SERVER_IP=localhost
HOST_SERVER_PORT=5000
HOST_SERVER_PROTOCOL=http
DB_FORCE_TABLES_RECREATION=false
USER_DISK_LIMIT_MB=50
NODE_ENV=development
SECRET_KEY=SECRET
POSTFIX_ENABLED=false
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ services:
DB_HOST: postgres
DB_PORT: 5432
DB_FORCE_TABLES_RECREATION: ${DB_FORCE_TABLES_RECREATION}
USER_DISK_LIMIT_MB: ${USER_DISK_LIMIT_MB}
NODE_ENV: ${NODE_ENV}
HOST_SERVER_PORT: "${HOST_SERVER_PORT}"
HOST_SERVER_IP: "${HOST_SERVER_IP}"
Expand Down
7 changes: 7 additions & 0 deletions web-app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,24 @@
"graphql": "^15.3.0",
"jotai": "^1.10.0",
"jwt-decode": "^3.1.2",
"moment": "^2.30.1",
"next": "latest",
"pretty-bytes": "^6.1.1",
"rc-slider": "^10.0.1",
"react": "latest",
"react-chartjs-2": "^4.3.1",
"react-collapse": "^5.1.1",
"react-datetime": "^3.2.0",
"react-dom": "latest",
"react-hook-form": "^7.43.1",
"react-hook-form-persist": "^3.0.0",
"react-outside-click-handler": "^1.3.0",
"react-paginate": "^8.1.3",
"react-select": "^5.4.0",
"react-spring": "^9.5.2",
"react-toastify": "^9.1.1",
"recharts": "^2.12.5",
"svg-arc": "^1.0.2",
"uuid": "^8.3.2",
"validator": "^13.7.0",
"yup": "^0.32.11"
Expand All @@ -72,6 +78,7 @@
"@types/react-collapse": "^5.0.1",
"@types/react-dom": "18.0.6",
"@types/react-outside-click-handler": "^1.3.1",
"@types/recharts": "^1.8.29",
"@types/uuid": "^8.3.4",
"@types/validator": "^13.7.10",
"@typescript-eslint/eslint-plugin": "^6.5.0",
Expand Down
3 changes: 3 additions & 0 deletions web-app/client/src/assets/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web-app/client/src/assets/icons/email.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web-app/client/src/assets/icons/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web-app/client/src/assets/icons/filter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web-app/client/src/assets/icons/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web-app/client/src/assets/icons/ordering.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions web-app/client/src/assets/icons/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 13 additions & 9 deletions web-app/client/src/atoms/MFDTaskAtom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { atom } from 'jotai';
import { MFDSortBy, OrderBy, Pagination } from 'types/globalTypes';
import {
MFDOrderingParameter,
OrderDirection,
Pagination,
} from 'types/globalTypes';

export type MFDHighlight = {
index: number;
Expand All @@ -24,8 +28,8 @@ type MFDTaskAtom = {
clusterIndex: number;
cluster: MFDCluster;
pagination: Pagination;
sortBy: MFDSortBy;
orderBy: OrderBy;
parameter: MFDOrderingParameter;
orderDirection: OrderDirection;
};

export const MFDAtomDefaultValues: MFDTaskAtom = {
Expand All @@ -44,16 +48,16 @@ export const MFDAtomDefaultValues: MFDTaskAtom = {
offset: 0,
limit: 0,
},
sortBy: MFDSortBy.MAXIMUM_DISTANCE,
orderBy: OrderBy.ASC,
parameter: MFDOrderingParameter.MAXIMUM_DISTANCE,
orderDirection: OrderDirection.ASC,
};

export const MFDAtomDefaultValuesWithParams = (
taskID: string,
clusterIndex = 0,
limit = 0,
sortBy = MFDSortBy.MAXIMUM_DISTANCE,
orderBy = OrderBy.ASC,
parameter = MFDOrderingParameter.MAXIMUM_DISTANCE,
orderDirection = OrderDirection.ASC,
) => ({
...MFDAtomDefaultValues,
taskID,
Expand All @@ -62,8 +66,8 @@ export const MFDAtomDefaultValuesWithParams = (
offset: 0,
limit,
},
sortBy,
orderBy,
parameter,
orderDirection,
});

const MFDAtom = atom<MFDTaskAtom>(MFDAtomDefaultValues);
Expand Down
12 changes: 3 additions & 9 deletions web-app/client/src/components/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
} from '@graphql/operations/mutations/__generated__/logOut';
import { LOG_OUT } from '@graphql/operations/mutations/logOut';
import { getAnonymousPermissions } from '@graphql/operations/queries/__generated__/getAnonymousPermissions';
import {
getUser,
getUserVariables,
} from '@graphql/operations/queries/__generated__/getUser';
import { getUser } from '@graphql/operations/queries/__generated__/getUser';
import { GET_ANONYMOUS_PERMISSIONS } from '@graphql/operations/queries/getAnonymousPermissions';
import { GET_USER } from '@graphql/operations/queries/getUser';
import parseUserPermissions from '@utils/parseUserPermissions';
Expand Down Expand Up @@ -45,7 +42,7 @@ export const AuthContext = createContext<AuthContextType | null>(null);
export const AuthContextProvider: FC<PropsWithChildren> = ({ children }) => {
const [user, setUser] = useState<User | undefined>();

const [getUser] = useLazyQuery<getUser, getUserVariables>(GET_USER);
const [getUser] = useLazyQuery<getUser>(GET_USER);
const [getAnonymousPermissions] = useLazyQuery<getAnonymousPermissions>(
GET_ANONYMOUS_PERMISSIONS,
);
Expand Down Expand Up @@ -87,9 +84,6 @@ export const AuthContextProvider: FC<PropsWithChildren> = ({ children }) => {
}

const response = await getUser({
variables: {
userID: user.id,
},
fetchPolicy: 'network-only',
});

Expand All @@ -102,7 +96,7 @@ export const AuthContextProvider: FC<PropsWithChildren> = ({ children }) => {
email,
isVerified: accountStatus === 'EMAIL_VERIFIED',
permissions: parseUserPermissions(permissions),
datasets: datasets || [],
datasets: datasets.data || [],
});
} else {
showError('Your authentication expired.', 'Please, log in again.');
Expand Down
Loading
Loading