diff --git a/README.md b/README.md index 9462dd0..c8d4c2b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Advanced PassGen -![Advanced PassGen](https://i.imgur.com/rhp4mO9.png) +![Advanced PassGen](https://i.imgur.com/WcaJL2t.png) ![GitHub](https://img.shields.io/badge/language-JavaScript+Rust-green) ![GitHub](https://img.shields.io/github/license/CodeDead/Advanced-PassGen) diff --git a/package.json b/package.json index df9e4b9..3d88729 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@mui/icons-material": "^5.11.11", "@mui/material": "^5.11.11", "@mui/x-data-grid": "^6.0.0", - "@shopify/react-web-worker": "^5.0.8", + "@shopify/react-web-worker": "^5.0.9", "@tauri-apps/api": "^1.2.0", "crypto-js": "^4.1.1", "react": "^18.2.0", diff --git a/src/components/App/index.jsx b/src/components/App/index.jsx index eb1c21b..7994ebf 100644 --- a/src/components/App/index.jsx +++ b/src/components/App/index.jsx @@ -33,7 +33,6 @@ import packageJson from '../../../package.json'; import LoadingBar from '../LoadingBar'; const Home = lazy(() => import('../../routes/Home')); -const Advanced = lazy(() => import('../../routes/Advanced')); const Generate = lazy(() => import('../../routes/Generate')); const About = lazy(() => import('../../routes/About')); const Settings = lazy(() => import('../../routes/Settings')); @@ -142,7 +141,6 @@ const App = () => { }> } /> - } /> } /> } /> } /> diff --git a/src/components/ClippedDrawer/index.jsx b/src/components/ClippedDrawer/index.jsx index bdaec06..4c421a3 100644 --- a/src/components/ClippedDrawer/index.jsx +++ b/src/components/ClippedDrawer/index.jsx @@ -9,7 +9,6 @@ import ListItemButton from '@mui/material/ListItemButton'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import HomeIcon from '@mui/icons-material/Home'; -import BuildIcon from '@mui/icons-material/Build'; import ListIcon from '@mui/icons-material/List'; import LightbulbIcon from '@mui/icons-material/Lightbulb'; import InfoIcon from '@mui/icons-material/Info'; @@ -71,17 +70,6 @@ const ClippedDrawer = ({ open, onClose }) => { handleNavigate('/advanced')} - > - - - - - - - - handleNavigate('/generate')} > @@ -95,7 +83,7 @@ const ClippedDrawer = ({ open, onClose }) => { handleNavigate('/advisor')} > @@ -106,7 +94,7 @@ const ClippedDrawer = ({ open, onClose }) => { handleNavigate('/vault')} > @@ -120,7 +108,7 @@ const ClippedDrawer = ({ open, onClose }) => { handleNavigate('/settings')} > @@ -147,7 +135,7 @@ const ClippedDrawer = ({ open, onClose }) => { handleNavigate('/about')} > diff --git a/src/routes/About/index.jsx b/src/routes/About/index.jsx index ab28897..ef38a7c 100644 --- a/src/routes/About/index.jsx +++ b/src/routes/About/index.jsx @@ -29,7 +29,7 @@ const About = () => { }; useEffect(() => { - d1(setPageIndex(6)); + d1(setPageIndex(5)); }, []); return ( diff --git a/src/routes/Advanced/index.jsx b/src/routes/Advanced/index.jsx deleted file mode 100644 index 0569343..0000000 --- a/src/routes/Advanced/index.jsx +++ /dev/null @@ -1,182 +0,0 @@ -import React, { useContext, useEffect } from 'react'; -import Card from '@mui/material/Card'; -import CardContent from '@mui/material/CardContent'; -import Container from '@mui/material/Container'; -import Grid from '@mui/material/Grid'; -import TextField from '@mui/material/TextField'; -import Button from '@mui/material/Button'; -import { useNavigate } from 'react-router-dom'; -import FormControlLabel from '@mui/material/FormControlLabel'; -import Checkbox from '@mui/material/Checkbox'; -import FormGroup from '@mui/material/FormGroup'; -import { createWorkerFactory, useWorker } from '@shopify/react-web-worker'; -import { setError, setLoading, setPageIndex } from '../../reducers/MainReducer/Actions'; -import { MainContext } from '../../contexts/MainContextProvider'; -import { PasswordContext } from '../../contexts/PasswordContextProvider'; -import { - generatePasswordArray, - getFullCharacterSet, - setAllowDuplicates, - setCharacterSet, - setPasswords, - setUseAdvanced, -} from '../../reducers/PasswordReducer/Actions'; -import LoadingBar from '../../components/LoadingBar'; - -const createWorker = createWorkerFactory(() => import('../../utils/PasswordGenerator/index')); - -const Advanced = () => { - const [state1, d1] = useContext(MainContext); - const [state2, d2] = useContext(PasswordContext); - - const { languageIndex, loading } = state1; - const { - characterSet, useAdvanced, allowDuplicates, smallLetters, capitalLetters, spaces, - specialCharacters, numbers, brackets, min, max, amount, - } = state2; - - const language = state1.languages[languageIndex]; - - const navigate = useNavigate(); - const worker = useWorker(createWorker); - - const simpleCharacterSet = getFullCharacterSet( - characterSet, - useAdvanced, - smallLetters, - capitalLetters, - spaces, - numbers, - specialCharacters, - brackets, - ); - - const cannotGenerate = !simpleCharacterSet || simpleCharacterSet.length === 0 - || min > max || max < min; - - /** - * Generate passwords - */ - const generatePasswords = () => { - if (cannotGenerate) { - return; - } - - d1(setLoading(true)); - generatePasswordArray(min, max, simpleCharacterSet, amount, allowDuplicates, worker) - .then((res) => { - d2(setPasswords(res)); - navigate('/generate'); - }) - .catch((err) => { - d1(setError(err)); - }) - .finally(() => { - d1(setLoading(false)); - }); - }; - - /** - * Change whether duplicates are allowed or not - * @param event The event argument - */ - const handleDuplicateChange = (event) => { - d2(setAllowDuplicates(event.target.checked)); - }; - - /** - * Change wether advanced options are being used or not - * @param event The event argument - */ - const handleAdvancedChange = (event) => { - d2(setUseAdvanced(event.target.checked)); - }; - - /** - * Change the character set - * @param event The event argument - */ - const handleCharacterSetChange = (event) => { - d2(setCharacterSet(event.target.value)); - }; - - /** - * Go to the home page - */ - const goHome = () => { - navigate('/'); - }; - - useEffect(() => { - d1(setPageIndex(1)); - }, []); - - if (loading) { - return ( - - ); - } - - return ( - - - - - - - - )} - label={language.allowDuplicates} - /> - - )} - label={language.useCustomCharacterSet} - /> - - - - - - - - - - - - ); -}; - -export default Advanced; diff --git a/src/routes/Advisor/index.jsx b/src/routes/Advisor/index.jsx index 86a08fb..ba9abf4 100644 --- a/src/routes/Advisor/index.jsx +++ b/src/routes/Advisor/index.jsx @@ -27,7 +27,7 @@ const Advisor = () => { }; useEffect(() => { - d1(setPageIndex(3)); + d1(setPageIndex(2)); }, []); return ( diff --git a/src/routes/Generate/index.jsx b/src/routes/Generate/index.jsx index 0235b26..67f496f 100644 --- a/src/routes/Generate/index.jsx +++ b/src/routes/Generate/index.jsx @@ -198,7 +198,7 @@ const Generate = () => { }; useEffect(() => { - d1(setPageIndex(2)); + d1(setPageIndex(1)); }, []); const passwordRows = []; @@ -231,7 +231,7 @@ const Generate = () => { editable: false, valueFormatter: (params) => { const valueFormatted = Number(params.value).toLocaleString(); - return `${valueFormatted} %`; + return `${valueFormatted}%`; }, }, ]; @@ -240,7 +240,7 @@ const Generate = () => { - + { } }; + /** + * Change whether duplicates are allowed or not + * @param event The event argument + */ + const handleDuplicateChange = (event) => { + d2(setAllowDuplicates(event.target.checked)); + }; + + /** + * Change wether advanced options are being used or not + * @param event The event argument + */ + const handleAdvancedChange = (event) => { + d2(setUseAdvanced(event.target.checked)); + }; + + /** + * Change the character set + * @param event The event argument + */ + const handleCharacterSetChange = (event) => { + d2(setCharacterSet(event.target.value)); + }; + useEffect(() => { d1(setPageIndex(0)); }, []); @@ -235,25 +267,62 @@ const Home = () => { + + } + aria-controls="panel1a-content" + id="panel1a-header" + > + + {language.advanced} + + + + + + + + )} + label={language.allowDuplicates} + /> + + )} + label={language.useCustomCharacterSet} + /> + + + + + + + + - ); }; diff --git a/src/routes/Settings/index.jsx b/src/routes/Settings/index.jsx index 57fc2d5..527c4fd 100644 --- a/src/routes/Settings/index.jsx +++ b/src/routes/Settings/index.jsx @@ -137,7 +137,7 @@ const Settings = () => { }; useEffect(() => { - d1(setPageIndex(5)); + d1(setPageIndex(4)); }, []); return ( @@ -151,7 +151,7 @@ const Settings = () => { aria-controls="panel1a-content" id="panel1a-header" > - + {language.general} @@ -221,7 +221,7 @@ const Settings = () => { aria-controls="panel1bh-content" id="panel1bh-header" > - + {language.theme} diff --git a/src/routes/Vault/index.jsx b/src/routes/Vault/index.jsx index d6c3807..e6683ac 100644 --- a/src/routes/Vault/index.jsx +++ b/src/routes/Vault/index.jsx @@ -276,7 +276,7 @@ const Vault = () => { }; useEffect(() => { - d1(setPageIndex(4)); + d1(setPageIndex(3)); }, []); let gridItems = null; @@ -324,12 +324,10 @@ const Vault = () => { return ( + + {language.vault} + - - - {language.vault} - - {vault ? ( diff --git a/yarn.lock b/yarn.lock index 697b89d..df2ef60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -979,26 +979,26 @@ __metadata: languageName: node linkType: hard -"@shopify/react-hooks@npm:^3.0.2": - version: 3.0.2 - resolution: "@shopify/react-hooks@npm:3.0.2" +"@shopify/react-hooks@npm:^3.0.3": + version: 3.0.3 + resolution: "@shopify/react-hooks@npm:3.0.3" peerDependencies: react: ">=16.8.0 <19.0.0" - checksum: ffa87eb6f735ffc19d468272863c8a2ae80fa2c4154e2c392718da3eb34f83515b8f1a8843b80853b80cb2a53e95296f3db4aee222ba181b43f5a3b82eec43c9 + checksum: 0106cacc3bdee6af18b5c931bb3602bc1e78b36be6707d570a45b0abebb27e3522a1a7cb4ee79d1cf46ac6fd3a089501fa2c833945524b2ff0273a7381198825 languageName: node linkType: hard -"@shopify/react-web-worker@npm:^5.0.8": - version: 5.0.8 - resolution: "@shopify/react-web-worker@npm:5.0.8" +"@shopify/react-web-worker@npm:^5.0.9": + version: 5.0.9 + resolution: "@shopify/react-web-worker@npm:5.0.9" dependencies: - "@shopify/react-hooks": ^3.0.2 + "@shopify/react-hooks": ^3.0.3 "@shopify/useful-types": ^5.1.1 "@shopify/web-worker": ^6.0.1 peerDependencies: react: ">=16.8.0 <19.0.0" react-dom: ">=16.8.0 <19.0.0" - checksum: 8a7c4995843aad3956722709c3939cf64805b82464d06e34516c9029bc5a71c56e4defb706414f497c7f7a8d5ed11538e4e7d319c93bc1f61a9a46648a908b81 + checksum: bee402931186fd0d7b45dfd4af0f07b1b529b8d0ba50a0a94c327079d431c8ff02351ec8450b59956eb33607f29daff209a4ff1f6c65aab79047b80ec3dc377f languageName: node linkType: hard @@ -1402,7 +1402,7 @@ __metadata: "@mui/icons-material": ^5.11.11 "@mui/material": ^5.11.11 "@mui/x-data-grid": ^6.0.0 - "@shopify/react-web-worker": ^5.0.8 + "@shopify/react-web-worker": ^5.0.9 "@tauri-apps/api": ^1.2.0 "@tauri-apps/cli": ^1.2.3 "@vitejs/plugin-react": ^3.1.0