Skip to content

Commit

Permalink
feat: Ace timeout preference
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweck committed Dec 17, 2024
1 parent 6db811c commit 472d0cd
Show file tree
Hide file tree
Showing 9 changed files with 537 additions and 450 deletions.
12 changes: 6 additions & 6 deletions package-asar-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ace-gui",
"productName": "Ace by DAISY",
"description": "Ace, the EPUB accessibility checker by the DAISY Consortium (desktop application)",
"version": "1.3.3-alpha.4",
"version": "1.3.3-alpha.5",
"author": {
"name": "DAISY Consortium",
"organization": "DAISY Consortium",
Expand All @@ -14,11 +14,11 @@
"license": "MIT",
"main": "main-bundle.js",
"dependencies": {
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.4",
"@daisy/ace-core": "1.3.3-alpha.4",
"@daisy/ace-localize": "1.3.3-alpha.4",
"@daisy/ace-logger": "1.3.3-alpha.4",
"@daisy/epub-utils": "1.3.3-alpha.4",
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.5",
"@daisy/ace-core": "1.3.3-alpha.5",
"@daisy/ace-localize": "1.3.3-alpha.5",
"@daisy/ace-logger": "1.3.3-alpha.5",
"@daisy/epub-utils": "1.3.3-alpha.5",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
Expand Down
12 changes: 6 additions & 6 deletions package-asar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ace-gui",
"productName": "Ace by DAISY",
"description": "Ace, the EPUB accessibility checker by the DAISY Consortium (desktop application)",
"version": "1.3.3-alpha.4",
"version": "1.3.3-alpha.5",
"author": {
"name": "DAISY Consortium",
"organization": "DAISY Consortium",
Expand All @@ -14,11 +14,11 @@
"license": "MIT",
"main": "main-bundle.js",
"dependencies": {
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.4",
"@daisy/ace-core": "1.3.3-alpha.4",
"@daisy/ace-localize": "1.3.3-alpha.4",
"@daisy/ace-logger": "1.3.3-alpha.4",
"@daisy/epub-utils": "1.3.3-alpha.4",
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.5",
"@daisy/ace-core": "1.3.3-alpha.5",
"@daisy/ace-localize": "1.3.3-alpha.5",
"@daisy/ace-logger": "1.3.3-alpha.5",
"@daisy/epub-utils": "1.3.3-alpha.5",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ace-gui",
"description": "Ace, the EPUB accessibility checker by the DAISY Consortium (desktop application)",
"version": "1.3.3-alpha.4",
"version": "1.3.3-alpha.5",
"engines": {
"node": ">=18.0.0",
"yarn": "^1.22.0",
Expand Down Expand Up @@ -143,11 +143,11 @@
"i18n-check": "sync-i18n --files 'src/shared/l10n/locales/*.json' --primary en --languages fr es pt_BR da ja de --space 4 --finalnewline --newkeysempty"
},
"dependencies": {
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.4",
"@daisy/ace-core": "1.3.3-alpha.4",
"@daisy/ace-localize": "1.3.3-alpha.4",
"@daisy/ace-logger": "1.3.3-alpha.4",
"@daisy/epub-utils": "1.3.3-alpha.4",
"@daisy/ace-axe-runner-electron": "1.3.3-alpha.5",
"@daisy/ace-core": "1.3.3-alpha.5",
"@daisy/ace-localize": "1.3.3-alpha.5",
"@daisy/ace-logger": "1.3.3-alpha.5",
"@daisy/epub-utils": "1.3.3-alpha.5",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
Expand Down
7 changes: 7 additions & 0 deletions src/main/store-persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function initPersistentStore() {
const reportsOverwrite = electronStore.get('reports.overwrite');
const initialState = {
preferences: {
timeout: electronStore.get('timeout') || defaultPreferences.timeout,
language: initialLanguage,
reports: {
"dir": electronStore.get('reports.dir') || defaultPreferences.reports.dir,
Expand All @@ -67,6 +68,12 @@ export function initPersistentStore() {

const prefs = state.preferences;

if (prefs.timeout) {
electronStore.set('timeout', prefs.timeout);
} else {
electronStore.set('timeout', defaultPreferences.timeout);
}

if (prefs.language) {
electronStore.set('language', prefs.language);
} else {
Expand Down
43 changes: 34 additions & 9 deletions src/renderer/components/PreferencesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormHelperText from '@material-ui/core/FormHelperText';
import InputLabel from '@material-ui/core/InputLabel';
import OutlinedInput from '@material-ui/core/OutlinedInput';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import { hideModal } from './../../shared/actions/modal';
import { savePreferences } from './../../shared/actions/preferences';
Expand Down Expand Up @@ -109,6 +110,13 @@ class PreferencesModal extends React.Component {
this.setState(newState);
};

handleChangeTimeout = arg => (event) => {
const newState = {
timeout: event.target.value
};
this.setState(newState);
};

selectReportDir = () => {
ipcRenderer.send(IPC_EVENT_showFolderBrowseDialog);
ipcRenderer.once(IPC_EVENT_showFolderBrowseDialog, (event, dir) => {
Expand All @@ -133,7 +141,7 @@ class PreferencesModal extends React.Component {
const openFile = this.props.openFile;
const inputPath = this.props.inputPath;
const epubBaseDir = this.props.epubBaseDir;

setTimeout(() => {
openFile(epubBaseDir || inputPath);
}, 500);
Expand Down Expand Up @@ -166,7 +174,7 @@ class PreferencesModal extends React.Component {
classes={{ root: classes.prefsGroup }}
>
<Typography variant="h6">{localize("preferences.internalReportStorage")}</Typography>
<FormControl
<FormControl
aria-describedby="preferences-dialog-reports-dir-helper-text"
variant="outlined"
margin="dense"
Expand All @@ -176,20 +184,20 @@ class PreferencesModal extends React.Component {
ref={ref => { this.labelRef = ReactDOM.findDOMNode(ref) }}
classes={{ root: classes.browseControlInputLabel }}
>{localize("preferences.reportsDataDirectory")}</InputLabel>
<OutlinedInput
<OutlinedInput
id="preferences-dialog-reports-input"
value={this.state.reports.dir}
onChange={this.handleChange({group: 'reports', key: 'dir'})}
disabled
labelWidth={this.labelRef ? this.labelRef.offsetWidth : 0}
classes={{
classes={{
root: classes.browseControlInput,
notchedOutline: classes.browseControlInputOutline,
disabled: classes.browseControlInputDisabled,
}}
/>
</div>
<Button variant="outlined"
<Button variant="outlined"
classes={{ root: classes.browseControlButton}}
onClick={this.selectReportDir}
>{localize("preferences.reportsDataDirectoryButton")}</Button>
Expand All @@ -207,7 +215,7 @@ class PreferencesModal extends React.Component {
onChange={this.handleChange({group: 'reports', key: 'organize'})}
control={<Checkbox/>}
/>
<FormHelperText
<FormHelperText
id="preferences-dialog-reports-organize-helper-text"
variant='outlined'
classes={{ contained: classes.checkboxControlHelperText }}
Expand All @@ -223,7 +231,7 @@ class PreferencesModal extends React.Component {
onChange={this.handleChange({group: 'reports', key: 'overwrite'})}
control={<Checkbox/>}
/>
<FormHelperText
<FormHelperText
id="preferences-dialog-reports-overwrite-helper-text"
variant='outlined'
classes={{ contained: classes.checkboxControlHelperText }}
Expand All @@ -245,13 +253,30 @@ class PreferencesModal extends React.Component {
>
{languageSelectMenuItems}
</Select>
<FormHelperText
<FormHelperText
id="preferences-dialog-user-interface-language-helper-text"
variant='outlined'
classes={{ contained: classes.checkboxControlHelperText }}
>{localize("preferences.userInterfaceLanguageTip")}</FormHelperText>
</FormControl>
</FormControl>

<FormControl variant="outlined" margin="dense" fullWidth
classes={{ root: classes.prefsGroup }}
>
<Typography variant="h6">{localize("preferences.timeout")}</Typography>
<FormControl
margin="dense">
<TextField
id="preferences-dialog-timeout-input"
value={this.state.timeout}
onChange={this.handleChangeTimeout()}
classes={{
root: classes.browseControlInput,
}}
/>
</FormControl>
</FormControl>
</DialogContent>
<DialogActions classes={{ root: classes.dialogActions }}>
<Button onClick={() => this.props.hideModal()}>
Expand Down Expand Up @@ -282,4 +307,4 @@ function mapDispatchToProps(dispatch) {
return bindActionCreators({openFile, hideModal, savePreferences}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(PreferencesModal));
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(PreferencesModal));
6 changes: 3 additions & 3 deletions src/shared/actions/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function runAce(inputPath) {
return (dispatch, getState) => {

inputPath = fs.existsSync(inputPath) ? fs.realpathSync(inputPath) : inputPath;

// if (!axeRunner) {
// dispatch(setProcessing(PROCESSING_TYPE.ACE, false))
// dispatch(addMessage("!axeRunner Electron renderer process?"));
Expand All @@ -59,10 +59,10 @@ export function runAce(inputPath) {
logger.initLogger({ verbose: true, silent: false, fileName: "ace-gui.log" });

function doAce(epubPath) {
ace(epubPath, {outdir: outdir.value, lang: language, verbose: true, silent: false, initLogger: false}, axeRunner)
ace(epubPath, {outdir: outdir.value, lang: language, verbose: true, silent: false, initLogger: false, timeout: getState().preferences.timeout || undefined}, axeRunner)
.then((res) => {
dispatch(addMessage(localize("message.checkcomplete")));

let reportPath = path.join(outdir.value, 'report.json');
dispatch(openReport(reportPath, inputPath, epubPath));
})
Expand Down
1 change: 1 addition & 0 deletions src/shared/default-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { localizer } from './l10n/localize';
const { getDefaultLanguage } = localizer;

export const defaultPreferences = {
timeout: 240000,
language: getDefaultLanguage(),
reports: {
dir: tmp.dirSync({ unsafeCleanup: true }).name,
Expand Down
1 change: 1 addition & 0 deletions src/shared/l10n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"reportsDataDirectoryButton": "Browse",
"reportsDataDirectoryTip": "(where Ace stores reports internally)",
"save": "Save",
"timeout": "Timeout",
"title": "Ace Preferences",
"userInterfaceLanguage": "Language",
"userInterfaceLanguageTip": "(select the language for UI labels and messages)"
Expand Down
Loading

0 comments on commit 472d0cd

Please sign in to comment.