Skip to content
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
14 changes: 11 additions & 3 deletions src/components/App/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, {
useContext, useEffect, useState, lazy, Suspense,
useContext,
useEffect,
useState,
lazy,
Suspense,
} from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import { createTheme, ThemeProvider } from '@mui/material/styles';
Expand All @@ -17,7 +21,11 @@ import TopBar from '../TopBar';
import ClippedDrawer from '../ClippedDrawer';
import UpdateDialog from '../UpdateDialog';
import {
openWebSite, setCheckedForUpdates, setError, setLoading, setUpdate,
openWebSite,
setCheckedForUpdates,
setError,
setLoading,
setUpdate,
} from '../../reducers/MainReducer/Actions';
import Updater from '../../utils/Updater';
import AlertDialog from '../AlertDialog';
Expand Down Expand Up @@ -176,7 +184,7 @@ const App = () => {
{language.downloadApp}
</Typography>
<Button
onClick={() => window.open('https://codedead.com/software/advanced-passgen')}
onClick={() => openWebSite('https://codedead.com/software/advanced-passgen')}
size="small"
color="secondary"
>
Expand Down
27 changes: 16 additions & 11 deletions src/components/CreatePasswordDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);

const simpleCharacterSet = getFullCharacterSet(
characterSet,
useAdvanced,
smallLetters,
capitalLetters,
spaces,
numbers,
specialCharacters,
brackets,
);

const cannotGenerate = !simpleCharacterSet || simpleCharacterSet.length === 0
|| min > max || max < min;

/**
* Close the dialog
*/
Expand Down Expand Up @@ -79,17 +93,7 @@ const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
* Generate passwords
*/
const generatePassword = () => {
const simpleCharacterSet = getFullCharacterSet(
characterSet,
useAdvanced,
smallLetters,
capitalLetters,
spaces,
numbers,
specialCharacters,
brackets,
);
if (!simpleCharacterSet || simpleCharacterSet.length === 0 || min > max || max < min) {
if (cannotGenerate) {
return;
}

Expand Down Expand Up @@ -179,6 +183,7 @@ const CreatePasswordDialog = ({ open, onCreate, onClose }) => {
color="primary"
size="large"
sx={{ width: '100%', height: '100%' }}
disabled={cannotGenerate}
onClick={generatePassword}
>
<RefreshIcon fontSize="inherit" />
Expand Down
27 changes: 16 additions & 11 deletions src/components/EditPasswordDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ const EditPasswordDialog = ({
const [password, setPassword] = useState(data && data.password ? data.password : '');
const [showPassword, setShowPassword] = useState(false);

const simpleCharacterSet = getFullCharacterSet(
characterSet,
useAdvanced,
smallLetters,
capitalLetters,
spaces,
numbers,
specialCharacters,
brackets,
);

const cannotGenerate = !simpleCharacterSet || simpleCharacterSet.length === 0
|| min > max || max < min;

/**
* Close the dialog
*/
Expand Down Expand Up @@ -77,17 +91,7 @@ const EditPasswordDialog = ({
* Generate passwords
*/
const generatePassword = () => {
const simpleCharacterSet = getFullCharacterSet(
characterSet,
useAdvanced,
smallLetters,
capitalLetters,
spaces,
numbers,
specialCharacters,
brackets,
);
if (!simpleCharacterSet || simpleCharacterSet.length === 0 || min > max || max < min) {
if (cannotGenerate) {
return;
}

Expand Down Expand Up @@ -177,6 +181,7 @@ const EditPasswordDialog = ({
color="primary"
size="large"
sx={{ width: '100%', height: '100%' }}
disabled={cannotGenerate}
onClick={generatePassword}
>
<RefreshIcon fontSize="inherit" />
Expand Down
1 change: 1 addition & 0 deletions src/components/LinearProgressWithLabel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const LinearProgressWithLabel = ({ value }) => (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Box sx={{ width: '100%', mr: 1 }}>
<LinearProgress
style={{ height: 10 }}
variant="determinate"
value={value}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/components/SelectFileDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const SelectFileDialog = ({
}
};

/**
* Accept and read the file
* @param e The event argument
*/
const handleFileChange = (e) => {
e.preventDefault();
const reader = new FileReader();
Expand Down
18 changes: 16 additions & 2 deletions src/routes/About/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ const About = () => {
const { languageIndex } = state;
const language = state.languages[languageIndex];

/**
* Open the license page
*/
const openLicense = () => {
openWebSite('https://codedead.com/Software/Advanced%20PassGen/gpl.pdf');
};

/**
* Open the home page
*/
const openHomePage = () => {
openWebSite('https://codedead.com/');
};

useEffect(() => {
d1(setPageIndex(6));
}, []);
Expand All @@ -34,15 +48,15 @@ const About = () => {
variant="contained"
style={{ float: 'left' }}
sx={{ mt: 2 }}
onClick={() => openWebSite('https://codedead.com/Software/Advanced%20PassGen/gpl.pdf')}
onClick={openLicense}
>
{language.license}
</Button>
<Button
variant="contained"
style={{ float: 'right' }}
sx={{ mt: 2 }}
onClick={() => openWebSite('https://codedead.com/')}
onClick={openHomePage}
>
{language.website}
</Button>
Expand Down
73 changes: 55 additions & 18 deletions src/routes/Advanced/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { setError, setLoading, setPageIndex } from '../../reducers/MainReducer/A
import { MainContext } from '../../contexts/MainContextProvider';
import { PasswordContext } from '../../contexts/PasswordContextProvider';
import {
generatePasswordArray, getFullCharacterSet,
generatePasswordArray,
getFullCharacterSet,
setAllowDuplicates,
setCharacterSet, setPasswords,
setCharacterSet,
setPasswords,
setUseAdvanced,
} from '../../reducers/PasswordReducer/Actions';
import LoadingBar from '../../components/LoadingBar';
Expand All @@ -38,22 +40,25 @@ const Advanced = () => {
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 = () => {
const simpleCharacterSet = getFullCharacterSet(
characterSet,
useAdvanced,
smallLetters,
capitalLetters,
spaces,
numbers,
specialCharacters,
brackets,
);

if (!simpleCharacterSet || simpleCharacterSet.length === 0 || min > max || max < min) {
if (cannotGenerate) {
return;
}

Expand All @@ -71,6 +76,37 @@ const Advanced = () => {
});
};

/**
* 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));
}, []);
Expand All @@ -92,7 +128,7 @@ const Advanced = () => {
control={(
<Checkbox
checked={allowDuplicates}
onChange={(e) => d2(setAllowDuplicates(e.target.checked))}
onChange={handleDuplicateChange}
/>
)}
label={language.allowDuplicates}
Expand All @@ -101,7 +137,7 @@ const Advanced = () => {
control={(
<Checkbox
checked={useAdvanced}
onChange={(e) => d2(setUseAdvanced(e.target.checked))}
onChange={handleAdvancedChange}
/>
)}
label={language.useCustomCharacterSet}
Expand All @@ -114,7 +150,7 @@ const Advanced = () => {
disabled={!useAdvanced}
value={characterSet}
fullWidth
onChange={(e) => d2(setCharacterSet(e.target.value))}
onChange={handleCharacterSetChange}
/>
</Grid>
</Grid>
Expand All @@ -125,7 +161,7 @@ const Advanced = () => {
color="primary"
style={{ float: 'left' }}
sx={{ mt: 2 }}
onClick={() => navigate('/')}
onClick={goHome}
>
{language.general}
</Button>
Expand All @@ -134,6 +170,7 @@ const Advanced = () => {
color="primary"
style={{ float: 'right' }}
sx={{ mt: 2 }}
disabled={cannotGenerate}
onClick={generatePasswords}
>
{language.generate}
Expand Down
10 changes: 9 additions & 1 deletion src/routes/Advisor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const Advisor = () => {

const [password, setPassword] = useState('');

/**
* Update the password
* @param event The event argument
*/
const handlePasswordChange = (event) => {
setPassword(event.target.value);
};

useEffect(() => {
d1(setPageIndex(3));
}, []);
Expand All @@ -33,7 +41,7 @@ const Advisor = () => {
<Grid item xs={12} md={12} lg={12}>
<TextField
value={password}
onChange={(e) => setPassword(e.target.value)}
onChange={handlePasswordChange}
label={language.password}
fullWidth
type="password"
Expand Down
Loading