diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 0ba6da0..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.github/.DS_Store b/.github/.DS_Store deleted file mode 100644 index 2738c1d..0000000 Binary files a/.github/.DS_Store and /dev/null differ diff --git a/.github/workflows/.DS_Store b/.github/workflows/.DS_Store deleted file mode 100644 index 420b0cc..0000000 Binary files a/.github/workflows/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index e69de29..fb83c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ + +.DS_Store diff --git a/admin-api-frontend/.gitignore b/admin-api-frontend/.gitignore index 4d29575..6384470 100644 --- a/admin-api-frontend/.gitignore +++ b/admin-api-frontend/.gitignore @@ -21,3 +21,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +*.env + +node_modules/ \ No newline at end of file diff --git a/admin-api-frontend/package-lock.json b/admin-api-frontend/package-lock.json index 4fb2bc8..78195c9 100644 --- a/admin-api-frontend/package-lock.json +++ b/admin-api-frontend/package-lock.json @@ -17,6 +17,8 @@ "@typescript-eslint/parser": "^7.4.0", "bootstrap": "^5.3.3", "framer-motion": "^11.0.5", + "os-browserify": "^0.3.0", + "path-browserify": "^1.0.1", "react": "^18.2.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.2.0", @@ -35,9 +37,9 @@ } }, "node_modules/@adobe/css-tools": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.1.tgz", - "integrity": "sha512-/62yikz7NLScCGAAST5SHdnjaDJQBDq0M2muyRTpf2VQhw6StBg2ALiu73zSJQ4fMVLA+0uBhBHAle7Wg+2kSg==" + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.3.3.tgz", + "integrity": "sha512-rE0Pygv0sEZ4vBWHlAgJLGDU7Pm8xoO6p3wsEceb7GYAjScrOHpEo8KK/eVkAcnSM+slAEtXjA2JpdjLp4fJQQ==" }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", @@ -9658,14 +9660,6 @@ "tslib": "^2.0.3" } }, - "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "engines": { - "node": ">=10" - } - }, "node_modules/dotenv-expand": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", @@ -11039,9 +11033,9 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", @@ -15602,6 +15596,11 @@ "node": ">= 0.8.0" } }, + "node_modules/os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==" + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -15709,6 +15708,11 @@ "tslib": "^2.0.3" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -17699,6 +17703,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/react-style-singleton": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.2.1.tgz", diff --git a/admin-api-frontend/package.json b/admin-api-frontend/package.json index 03422c9..7d1f11f 100644 --- a/admin-api-frontend/package.json +++ b/admin-api-frontend/package.json @@ -13,6 +13,8 @@ "@typescript-eslint/parser": "^7.4.0", "bootstrap": "^5.3.3", "framer-motion": "^11.0.5", + "os-browserify": "^0.3.0", + "path-browserify": "^1.0.1", "react": "^18.2.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.2.0", diff --git a/admin-api-frontend/src/api.js b/admin-api-frontend/src/api.js new file mode 100644 index 0000000..b1626e2 --- /dev/null +++ b/admin-api-frontend/src/api.js @@ -0,0 +1,6 @@ +import axios from "axios"; +// import { useState } from "react"; + +export default axios.create({ + baseURL: `${BASE_URL}/api/v1/`, +}); diff --git a/admin-api-frontend/src/components/AddRolesForm/index.tsx b/admin-api-frontend/src/components/AddRolesForm/index.tsx index 10771f0..6985633 100644 --- a/admin-api-frontend/src/components/AddRolesForm/index.tsx +++ b/admin-api-frontend/src/components/AddRolesForm/index.tsx @@ -1,29 +1,33 @@ import React, { useState } from "react"; import { Input, Button } from "@nextui-org/react"; +import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx"; +import { loginRequest } from "../../authConfig.js"; const AddRolesForm = () => { + const BASE_URL = process.env.REACT_APP_BASE_URL; + const [netID, setNetID] = useState(""); const [roles, setRoles] = useState(""); - const [rolesSplit, setRolesSplit] = useState([]); - - const handleNetIDChange = (event) => { - setNetID(event.target.value); - }; - const handleRolesChange = (event) => { - setRoles(event.target.value); - setRolesSplit(event.target.value.split(",")); + const { execute } = useFetchWithMsal(loginRequest); + const handleAddRolesThroughUpdate = async () => { + try { + execute( + "PUT", + `${BASE_URL}/default/api/v1/update_user?netid=${netID}&newRoles=${roles}&newPerms=`, + null + ).then((response) => { + console.log(response); + }); + } catch (error) { + console.log(error); + } }; const handleSubmit = (event) => { if (netID !== "" && roles !== "") { - console.log(netID); - console.log(rolesSplit); - console.log(permissionsSplit); - // Do something with the netID, roles and permissions - event.preventDefault(); - setRolesSplit([]); + handleAddRolesThroughUpdate(); setNetID(""); setRoles(""); } @@ -33,19 +37,19 @@ const AddRolesForm = () => {

Add Roles

-
-
+
+
setNetID(event.target.value)} />
-
+
setRoles(event.target.value)} />
diff --git a/admin-api-frontend/src/components/CreateUserForm/index.tsx b/admin-api-frontend/src/components/CreateUserForm/index.tsx index 5cb7720..e21a48c 100644 --- a/admin-api-frontend/src/components/CreateUserForm/index.tsx +++ b/admin-api-frontend/src/components/CreateUserForm/index.tsx @@ -1,38 +1,34 @@ import React, { useState } from "react"; import { Input, Button } from "@nextui-org/react"; +import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx"; +import { loginRequest } from "../../authConfig.js"; const CreateUserForm = () => { + const BASE_URL = process.env.REACT_APP_BASE_URL; + const [netID, setNetID] = useState(""); const [roles, setRoles] = useState(""); - const [rolesSplit, setRolesSplit] = useState([]); - const [permissions, setPermissions] = useState(""); - const [permissionsSplit, setPermissionsSplit] = useState([]); - - const handleNetIDChange = (event) => { - setNetID(event.target.value); - }; - const handleRolesChange = (event) => { - setRoles(event.target.value); - setRolesSplit(event.target.value.split(",")); - }; - - const handlePermissionsChange = (event) => { - setPermissions(event.target.value); - setPermissionsSplit(event.target.value.split(",")); + const { execute } = useFetchWithMsal(loginRequest); + const handleCreateUser = async () => { + try { + execute( + "PUT", + `${BASE_URL}/default/api/v1/create_user?netid=${netID}&permStr=${permissions}&roleStr=${roles}`, + null + ).then((response) => { + console.log(response); + }); + } catch (error) { + console.log(error); + } }; const handleSubmit = (event) => { if (netID !== "" && roles !== "") { - console.log(netID); - console.log(rolesSplit); - console.log(permissionsSplit); - // Do something with the netID, roles and permissions - + handleCreateUser(); event.preventDefault(); - setRolesSplit([]); - setPermissionsSplit([]); setNetID(""); setRoles(""); setPermissions(""); @@ -43,26 +39,26 @@ const CreateUserForm = () => {

Create User

-
-
+
+
setNetID(event.target.value)} />
-
+
setRoles(event.target.value)} />
-
+
setPermissions(event.target.value)} />
diff --git a/admin-api-frontend/src/components/DeleteUserForm/index.tsx b/admin-api-frontend/src/components/DeleteUserForm/index.tsx index abd06e0..e0e1355 100644 --- a/admin-api-frontend/src/components/DeleteUserForm/index.tsx +++ b/admin-api-frontend/src/components/DeleteUserForm/index.tsx @@ -1,18 +1,31 @@ import React, { useState } from "react"; import { Input, Button } from "@nextui-org/react"; +import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx"; +import { loginRequest } from "../../authConfig.js"; const DeleteUserForm = () => { + const BASE_URL = process.env.REACT_APP_BASE_URL; + const [netID, setNetID] = useState(""); - const handleNetIDChange = (event) => { - setNetID(event.target.value); + const { execute } = useFetchWithMsal(loginRequest); + const handleDeleteUser = async () => { + try { + execute( + "DELETE", + `${BASE_URL}/default/api/v1/delete_user?netid=${netID}`, + null + ).then((response) => { + console.log(response); + }); + } catch (error) { + console.log(error); + } }; const handleSubmit = (event) => { if (netID !== "") { - console.log(netID); - // Do something with the netID - + handleDeleteUser(); event.preventDefault(); setNetID(""); } @@ -22,12 +35,12 @@ const DeleteUserForm = () => {

Delete User

-
-
+
+
setNetID(event.target.value)} />
diff --git a/admin-api-frontend/src/components/GetUserInfoForm/index.tsx b/admin-api-frontend/src/components/GetUserInfoForm/index.tsx index 45e2af6..a2d77cc 100644 --- a/admin-api-frontend/src/components/GetUserInfoForm/index.tsx +++ b/admin-api-frontend/src/components/GetUserInfoForm/index.tsx @@ -1,19 +1,33 @@ import React, { useState } from "react"; import { Input, Button } from "@nextui-org/react"; +import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx"; +import { loginRequest } from "../../authConfig.js"; const GetUserInfoForm = () => { + const BASE_URL = process.env.REACT_APP_BASE_URL; + const [netID, setNetID] = useState(""); - const handleNetIDChange = (event) => { - setNetID(event.target.value); + const { execute } = useFetchWithMsal(loginRequest); + + const handleGetUser = async () => { + try { + execute( + "GET", + `${BASE_URL}/default/api/v1/get_user?netid=${netID}`, + null + ).then((response) => { + console.log(response); + }); + } catch (error) { + console.log(error); + } }; const handleSubmit = (event) => { if (netID !== "") { - console.log(netID); - // Do something with the netID - event.preventDefault(); + handleGetUser(); setNetID(""); } }; @@ -22,12 +36,12 @@ const GetUserInfoForm = () => {

Get User

-
-
+
+
setNetID(event.target.value)} />
diff --git a/admin-api-frontend/src/components/RemoveRolesForm/index.tsx b/admin-api-frontend/src/components/RemoveRolesForm/index.tsx index dc1aa32..a21288b 100644 --- a/admin-api-frontend/src/components/RemoveRolesForm/index.tsx +++ b/admin-api-frontend/src/components/RemoveRolesForm/index.tsx @@ -1,29 +1,36 @@ import React, { useState } from "react"; import { Input, Button } from "@nextui-org/react"; +import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx"; +import { loginRequest } from "../../authConfig.js"; const RemoveRolesForm = () => { + const BASE_URL = process.env.REACT_APP_BASE_URL; + const [netID, setNetID] = useState(""); const [roles, setRoles] = useState(""); - const [rolesSplit, setRolesSplit] = useState([]); - const handleNetIDChange = (event) => { - setNetID(event.target.value); - }; + const { execute } = useFetchWithMsal(loginRequest); - const handleRolesChange = (event) => { - setRoles(event.target.value); - setRolesSplit(event.target.value.split(",")); + // This does not actually remove the roles, it just adds. We need to make a + // New lambda function for this endpoint + const handleRemoveRolesThroughUpdate = async () => { + try { + execute( + "PUT", + `${BASE_URL}/default/api/v1/update_user?netid=${netID}&newRoles=${roles}`, + null + ).then((response) => { + console.log(response); + }); + } catch (error) { + console.log(error); + } }; const handleSubmit = (event) => { if (netID !== "" && roles !== "") { - console.log(netID); - console.log(rolesSplit); - console.log(permissionsSplit); - // Do something with the netID, roles and permissions - event.preventDefault(); - setRolesSplit([]); + handleRemoveRolesThroughUpdate(); setNetID(""); setRoles(""); } @@ -33,19 +40,19 @@ const RemoveRolesForm = () => {

Remove Roles

-
-
+
+
setNetID(event.target.value)} />
-
+
setRoles(event.target.value)} />
diff --git a/backend/.DS_Store b/backend/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/backend/.DS_Store and /dev/null differ diff --git a/cloudformation/.DS_Store b/cloudformation/.DS_Store deleted file mode 100644 index a699bcd..0000000 Binary files a/cloudformation/.DS_Store and /dev/null differ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..529ea4e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,102 @@ +{ + "name": "admin-api", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^1.6.7" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", + "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", + "dependencies": { + "follow-redirects": "^1.15.4", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea70625 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "axios": "^1.6.7" + } +}