diff --git a/jams-react-client/.env b/jams-react-client/.env deleted file mode 100644 index b885521b4e7252a90cf35f123870a39b9911d36e..0000000000000000000000000000000000000000 --- a/jams-react-client/.env +++ /dev/null @@ -1 +0,0 @@ -NODE_PATH=./src diff --git a/jams-react-client/package.json b/jams-react-client/package.json index 456e7b1ce53506f79b00e5cd06c09b1dbfe84913..a1e773dac69cb8cfb797fe30e50fb118c0523f79 100644 --- a/jams-react-client/package.json +++ b/jams-react-client/package.json @@ -34,7 +34,7 @@ "yup": "^0.29.3" }, "scripts": { - "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && NODE_PATH=./src react-scripts start", + "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start", "build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build && ./node_modules/.bin/i18next-scanner", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", diff --git a/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js b/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js index 710cc0fb9d8c05bbd0bdd9e65fd7b7bfb42d28b4..e3ef2f6f73bc7f9be411bafdebb62934c53d68a1 100644 --- a/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js +++ b/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js @@ -1,6 +1,5 @@ import { defaultFont, - primaryColor, dangerColor, grayColor, infoColor, diff --git a/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js b/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js index eb2a6ca5da3d805216941f99ba00006664da7d40..3866e6b45a551a510c8c21adf2c58316d026c4a6 100644 --- a/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js +++ b/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js @@ -10,7 +10,6 @@ import { warningColor, dangerColor, whiteColor, - grayColor, blackColor, hexToRgb, } from "assets/jss/material-dashboard-react.js"; diff --git a/jams-react-client/src/components/Devices/Devices.js b/jams-react-client/src/components/Devices/Devices.js index 3a2d3ed787d806e201f43fb76a28dee702d596b3..cbeef3cea6257212f379c8f5fe8e0f7298dba2a1 100755 --- a/jams-react-client/src/components/Devices/Devices.js +++ b/jams-react-client/src/components/Devices/Devices.js @@ -58,7 +58,7 @@ export default function Devices(props) { if (auth.hasAdminScope()) { axios(configApiCall(api_path_get_admin_devices, "GET", userData, null)) .then((response) => { - if (response.data.length == 0) { + if (response.data.length === 0) { setDevices([]); } else { var resultSet = JSON.parse( @@ -77,7 +77,7 @@ export default function Devices(props) { } else { axios(configApiCall(api_path_get_auth_devices, "GET", null, null)) .then((response) => { - if (response.data.length == 0) { + if (response.data.length === 0) { setDevices([]); } else { var resultSet = JSON.parse( @@ -94,7 +94,7 @@ export default function Devices(props) { }); } }); - }, [selectedDevice]); + }, [history, selectedDevice, userData]); function getDeviceStatus(device) { if (!device.revoked) { diff --git a/jams-react-client/src/components/Drawer/Drawer.js b/jams-react-client/src/components/Drawer/Drawer.js index f063cb9c6a8cb1ebc8ecb77c11f0f61be14c3407..d1f6ab5e722fcadc559f22338cc771bc53f2b008 100644 --- a/jams-react-client/src/components/Drawer/Drawer.js +++ b/jams-react-client/src/components/Drawer/Drawer.js @@ -1,4 +1,4 @@ -import React, { useEffect, useCallback } from "react"; +import React, { useCallback } from "react"; import clsx from "clsx"; import { makeStyles } from "@material-ui/core/styles"; import CustomInput from "components/CustomInput/CustomInput.js"; diff --git a/jams-react-client/src/components/Footer/Footer.js b/jams-react-client/src/components/Footer/Footer.js index 8dc03ebc7bd761f250a4ad9e6504a278a12ab683..bade958c89aa42264952b413028dceeff927ca96 100755 --- a/jams-react-client/src/components/Footer/Footer.js +++ b/jams-react-client/src/components/Footer/Footer.js @@ -1,10 +1,6 @@ -/*eslint-disable*/ import React from "react"; -import PropTypes from "prop-types"; // @material-ui/core components import { makeStyles } from "@material-ui/core/styles"; -import ListItem from "@material-ui/core/ListItem"; -import List from "@material-ui/core/List"; // core components import styles from "assets/jss/material-dashboard-react/components/footerStyle.js"; @@ -24,6 +20,7 @@ export default function Footer(props) { <a href="https://savoirfairelinux.com" target="_blank" + rel="noopener noreferrer" className={classes.a} > Savoir-faire Linux Inc. diff --git a/jams-react-client/src/components/LanguagePicker/LanguagePicker.js b/jams-react-client/src/components/LanguagePicker/LanguagePicker.js index 826b6fdabb1aa5d61d1563f6f51a919f6965ce01..bafb52121d61c3b0ccda46babb4ddc36c0adce0e 100644 --- a/jams-react-client/src/components/LanguagePicker/LanguagePicker.js +++ b/jams-react-client/src/components/LanguagePicker/LanguagePicker.js @@ -36,16 +36,15 @@ export default function LanguagePicker(props) { { code: "en", name: "English" }, ]; - let exists = false; - translates_languages.map((option) => { - if (option.code === language) { - exists = true; - } - }); + const exists = translates_languages + .map((option) => option.code) + .includes(language); + if (!exists) { setLanguage("en"); i18n.changeLanguage("en"); } + setLanguages(translates_languages); }); }, [language]); diff --git a/jams-react-client/src/components/Sidebar/Sidebar.js b/jams-react-client/src/components/Sidebar/Sidebar.js index 8b35ed6907ef8f9021b5c37383bcfff06fad0883..06f493954070a84e023d2ada1ae3dbb780263fc3 100755 --- a/jams-react-client/src/components/Sidebar/Sidebar.js +++ b/jams-react-client/src/components/Sidebar/Sidebar.js @@ -1,4 +1,3 @@ -/*eslint-disable*/ import React, { useEffect, useState } from "react"; import { Link, useHistory } from "react-router-dom"; import classNames from "classnames"; @@ -46,7 +45,7 @@ export default function Sidebar(props) { function activeRoute(routeName) { return window.location.href.indexOf(routeName) > -1 ? true : false; } - const { color, logo, image, logoText, routes } = props; + const { color, logo, image, routes } = props; var brand = ( <Link to={"/"}> diff --git a/jams-react-client/src/layouts/BaseLayout.js b/jams-react-client/src/layouts/BaseLayout.js index a2678595cb91ef1220cf311f0629d784a1d3aeb9..31478b817c48ad7e9a810423da98f6f6c94d7a4e 100644 --- a/jams-react-client/src/layouts/BaseLayout.js +++ b/jams-react-client/src/layouts/BaseLayout.js @@ -1,5 +1,4 @@ import React, { useEffect, useState } from "react"; -import { Switch, Route, Redirect } from "react-router-dom"; // creates a beautiful scrollbar import PerfectScrollbar from "perfect-scrollbar"; import "perfect-scrollbar/css/perfect-scrollbar.css"; @@ -52,9 +51,6 @@ export default function Admin(props) { // ref to help us initialize PerfectScrollbar on windows devices const mainPanel = React.createRef(); // states and functions - const [image, setImage] = useState(bgImage); - const [color, setColor] = useState("blue"); - const [fixedClasses, setFixedClasses] = useState("dropdown"); const [mobileOpen, setMobileOpen] = useState(false); const [open, setOpen] = useState(false); const [message, setMessage] = useState(false); @@ -242,10 +238,10 @@ export default function Admin(props) { routes={Routes} logoText={"Jams"} logo={logo} - image={image} + image={bgImage} handleDrawerToggle={handleDrawerToggle} open={mobileOpen} - color={color} + color="blue" handleQuery={handleQuery} updating={updating} snackbarMessage={snackbarMessage} diff --git a/jams-react-client/src/layouts/ListLayout.js b/jams-react-client/src/layouts/ListLayout.js index 74dc94e0204f1fec94b94467f2f5b10ec2512c97..9d35c245e3b13cd00d3105c63f46072a0fdb5205 100644 --- a/jams-react-client/src/layouts/ListLayout.js +++ b/jams-react-client/src/layouts/ListLayout.js @@ -1,5 +1,4 @@ import React, { useEffect, useState } from "react"; -import { Switch, Route, Redirect } from "react-router-dom"; // creates a beautiful scrollbar import PerfectScrollbar from "perfect-scrollbar"; import "perfect-scrollbar/css/perfect-scrollbar.css"; @@ -53,9 +52,6 @@ export default function Admin(props) { // ref to help us initialize PerfectScrollbar on windows devices const mainPanel = React.createRef(); // states and functions - const [image, setImage] = useState(bgImage); - const [color, setColor] = useState("blue"); - const [fixedClasses, setFixedClasses] = useState("dropdown"); const [mobileOpen, setMobileOpen] = useState(false); const [open, setOpen] = useState(false); const [message, setMessage] = useState(false); @@ -245,10 +241,10 @@ export default function Admin(props) { routes={Routes} logoText={"Jams"} logo={logo} - image={image} + image={bgImage} handleDrawerToggle={handleDrawerToggle} open={mobileOpen} - color={color} + color="blue" handleQuery={handleQuery} updating={updating} snackbarMessage={snackbarMessage} diff --git a/jams-react-client/src/views/Blueprints/Blueprints.js b/jams-react-client/src/views/Blueprints/Blueprints.js index 4eb1f5d9c843a84adea24ad3ef107c7d013aa120..8e944601b0cd969e92cf9bfbeff01e7b6da33c3f 100644 --- a/jams-react-client/src/views/Blueprints/Blueprints.js +++ b/jams-react-client/src/views/Blueprints/Blueprints.js @@ -35,8 +35,6 @@ import LinearProgress from "@material-ui/core/LinearProgress"; import headerLinksStyle from "assets/jss/material-dashboard-react/components/headerLinksStyle.js"; -import Blueprint from "views/Blueprint/Blueprint"; - import Dialog from "@material-ui/core/Dialog"; import DialogActions from "@material-ui/core/DialogActions"; import DialogContent from "@material-ui/core/DialogContent"; @@ -135,7 +133,7 @@ export default function Blueprints() { return () => { clearInterval(timer); }; - }, [open, openRemoveDialog]); + }, [history, open, openRemoveDialog]); function redirectToBlueprint(e, blueprintNameRedirect) { e.preventDefault(); @@ -397,7 +395,8 @@ export default function Blueprints() { </h3> <ul> <li> - {JSON.parse(blueprint.policyData).rendezVous == true ? ( + {JSON.parse(blueprint.policyData).rendezVous === + true ? ( <p> <GroupIcon fontSize="small" diff --git a/jams-react-client/src/views/Contacts/Contacts.js b/jams-react-client/src/views/Contacts/Contacts.js index 65d04d008c853e89bf0ce3780db668256612da00..c169a52e444a3277cae13ec49d0cc2f04983a4f5 100644 --- a/jams-react-client/src/views/Contacts/Contacts.js +++ b/jams-react-client/src/views/Contacts/Contacts.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { Link, useHistory } from "react-router-dom"; +import { useHistory } from "react-router-dom"; // @material-ui/core components import { makeStyles } from "@material-ui/core/styles"; // core components @@ -147,7 +147,7 @@ export default function Users(props) { at the moment the admin sees his contacts in each user profile he visits */ let orginalContacts = response.data; - orginalContacts.map((contact) => { + for (const contact of orginalContacts) { contact.display = ""; axios( configApiCall( @@ -171,7 +171,7 @@ export default function Users(props) { contact.organization = response.data.organization; }); }); - }); + } setContacts(orginalContacts); setLoading(false); }) diff --git a/jams-react-client/src/views/Groups/EditGroup.js b/jams-react-client/src/views/Groups/EditGroup.js index a31cab71a0c4a87ebbbb9be91fc2fc9cade64300..0c0c24e874d0e0e9977c664e0b2b10a69d00eac4 100644 --- a/jams-react-client/src/views/Groups/EditGroup.js +++ b/jams-react-client/src/views/Groups/EditGroup.js @@ -146,11 +146,9 @@ export default function EditGroup(props) { axios(configApiCall(api_path_blueprints + "?name=*", "GET", null, null)) .then((response) => { setBlueprints(response.data); - let index = 0; - response.data.map((blueprint) => { - if (blueprint.name == group["blueprint"]) - setSelectedBlueprint({ value: index, label: blueprint.name }); - index += 1; + response.data.forEach((blueprint, i) => { + if (blueprint.name === group["blueprint"]) + setSelectedBlueprint({ value: i, label: blueprint.name }); }); }) .catch((error) => { @@ -427,7 +425,7 @@ export default function EditGroup(props) { onClick={() => { updateGroup(); }} - disabled={groupNameExits || name == newName} + disabled={groupNameExits || name === newName} > <SaveIcon /> </IconButton> diff --git a/jams-react-client/src/views/Groups/Groups.js b/jams-react-client/src/views/Groups/Groups.js index f97d87c9d918869e77804fd8a91abfde2595081c..ac1336432559d782b6047cd215d8ecf0b21997c3 100644 --- a/jams-react-client/src/views/Groups/Groups.js +++ b/jams-react-client/src/views/Groups/Groups.js @@ -36,7 +36,6 @@ import { } from "globalUrls"; import AddCircleOutlineIcon from "@material-ui/icons/AddCircleOutline"; -import EditGroup from "views/Groups/EditGroup"; import FormControl from "@material-ui/core/FormControl"; import Input from "@material-ui/core/Input"; diff --git a/jams-react-client/src/views/Settings/Settings.js b/jams-react-client/src/views/Settings/Settings.js index d58e0d1b69ff8aad2c0b47fe60bbb66a811b90fb..60b331e1e6db2295aa63d17107d74ddaed0467db 100644 --- a/jams-react-client/src/views/Settings/Settings.js +++ b/jams-react-client/src/views/Settings/Settings.js @@ -54,25 +54,6 @@ function Alert(props) { return <MuiAlert elevation={6} variant="filled" {...props} />; } -const styles = { - cardCategoryWhite: { - color: "rgba(255,255,255,.62)", - margin: "0", - fontSize: "14px", - marginTop: "0", - marginBottom: "0", - }, - cardTitleWhite: { - color: "#FFFFFF", - marginTop: "0px", - minHeight: "auto", - fontWeight: "300", - fontFamily: "'Roboto', 'Helvetica', 'Arial', sans-serif", - marginBottom: "3px", - textDecoration: "none", - }, -}; - export default function Settings(props) { const [value, setValue] = useState(0); const [error, setError] = useState(false); diff --git a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js index ed7b2b0d051b7fdea5ca8d6a05bcc7ad5df4dd5f..519ed68cbf289d0a2936dc92fe8f6de48edcd998 100644 --- a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js +++ b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js @@ -450,7 +450,7 @@ export default function DisplayUserProfile(props) { return () => { clearInterval(timer); }; - }, []); + }, [history, props.username]); const getUserStatus = () => { if (revoked === false) { diff --git a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js index fedd866d86249c4eb4e444a07956049c05069701..58b3e3d6f663ceb5db0d562a0ab0d97f69046dc3 100644 --- a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js +++ b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js @@ -505,16 +505,16 @@ export default function EditCreateUserProfile(props) { ) ), faxNumber: Yup.string().matches( - /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, + /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, i18next.t("fax_not_valid", "Fax number not valid!") ), phoneNumber: Yup.string().matches( - /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, + /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, i18next.t("phone_not_valid", "Phone number not valid!") ), phoneNumberExtension: Yup.number().positive().integer(), mobileNumber: Yup.string().matches( - /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, + /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/, i18next.t("mobile_not_valid", "Mobile number not valid!") ), }); diff --git a/jams-react-client/src/views/UserProfile/UserProfile.js b/jams-react-client/src/views/UserProfile/UserProfile.js index 101064602001b36a96c320903063d434ba954f03..a84be1bb29bc1ad2025ed38440df97c41657be47 100755 --- a/jams-react-client/src/views/UserProfile/UserProfile.js +++ b/jams-react-client/src/views/UserProfile/UserProfile.js @@ -19,8 +19,6 @@ import DisplayUserProfile from "./DisplayUserProfile"; import i18next from "i18next"; -import auth from "auth.js"; - function TabPanel(props) { const { children, value, index, ...other } = props; @@ -68,7 +66,7 @@ export default function UserProfile(props) { if (props.username === "null") { history.push("/"); } - }, []); + }, [history, props.username]); return ( <div> diff --git a/jams-react-client/src/views/Users/Users.js b/jams-react-client/src/views/Users/Users.js index 65a0429d5eb18f8258ea0cfe72ffd08ecb94ba06..15723108808334c788adc2f05299e94a5424af5a 100644 --- a/jams-react-client/src/views/Users/Users.js +++ b/jams-react-client/src/views/Users/Users.js @@ -14,12 +14,10 @@ import Card from "components/Card/Card.js"; import CardAvatar from "components/Card/CardAvatar.js"; import CardBody from "components/Card/CardBody.js"; -import UserProfile from "views/UserProfile/UserProfile.js"; import InfoIcon from "@material-ui/icons/Info"; import BusinessOutlinedIcon from "@material-ui/icons/BusinessOutlined"; import Search from "@material-ui/icons/Search"; import Checkbox from "@material-ui/core/Checkbox"; -import FormGroup from "@material-ui/core/FormGroup"; import FormControlLabel from "@material-ui/core/FormControlLabel"; import axios from "axios"; import configApiCall from "api.js"; @@ -28,7 +26,6 @@ import { api_path_get_user_directory_search } from "globalUrls"; import AddCircleOutlineIcon from "@material-ui/icons/AddCircleOutline"; import jami from "assets/img/faces/jami.png"; import noProfilePicture from "assets/img/faces/no-profile-picture.png"; -import EditCreateUserProfile from "views/UserProfile/EditCreateUserProfile"; import LinearProgress from "@material-ui/core/LinearProgress"; import headerLinksStyle from "assets/jss/material-dashboard-react/components/headerLinksStyle.js"; import { debounce } from "lodash"; @@ -78,8 +75,6 @@ export default function Users(props) { const [users, setUsers] = useState([]); const [noUsersFound, setNoUsersFound] = useState(false); const [noMatchFound, setNoMatchFound] = useState(false); - const [selectedUsername, setSelectedUsername] = useState(""); - const [createUser, setCreateUser] = useState(false); const [loading, setLoading] = useState(false); const [progress, setProgress] = useState(0); const [showRevokedUsers, setShowRevokedUsers] = useState(false); @@ -128,7 +123,7 @@ export default function Users(props) { return () => { clearInterval(timer); }; - }, []); + }, [history]); const searchUsers = (value, page = "1") => { setSelectedPage(page);