-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow show_covers setting to be managed in Web App
- Loading branch information
Showing
7 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { useTheme } from '@mui/material/styles'; | ||
|
||
import { | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
Divider, | ||
Grid, | ||
} from '@mui/material'; | ||
import ShowCovers from './show-covers'; | ||
|
||
const SettingsGeneral = () => { | ||
const { t } = useTranslation(); | ||
const theme = useTheme(); | ||
const spacer = { marginBottom: theme.spacing(2) } | ||
|
||
return ( | ||
<Card> | ||
<CardHeader | ||
title={t('settings.general.title')} | ||
/> | ||
<Divider /> | ||
<CardContent> | ||
<Grid | ||
container | ||
direction="column" | ||
sx={{ '& > .MuiGrid-root:not(:last-child)': spacer }} | ||
> | ||
<ShowCovers /> | ||
</Grid> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default SettingsGeneral; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useContext } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
Box, | ||
Grid, | ||
Switch, | ||
Typography, | ||
} from '@mui/material'; | ||
|
||
import AppSettingsContext from '../../../context/appsettings/context'; | ||
import request from '../../../utils/request'; | ||
|
||
const ShowCovers = () => { | ||
const { t } = useTranslation(); | ||
|
||
const { | ||
settings, | ||
setSettings, | ||
} = useContext(AppSettingsContext); | ||
|
||
const { | ||
show_covers, | ||
} = settings; | ||
|
||
const updateShowCoversSetting = async (show_covers) => { | ||
await request('setAppSettings', { settings: { show_covers }}); | ||
} | ||
|
||
const handleSwitch = (event) => { | ||
setSettings({ show_covers: event.target.checked}); | ||
updateShowCoversSetting(event.target.checked); | ||
} | ||
|
||
return ( | ||
<Grid container direction="column" justifyContent="center"> | ||
<Grid container direction="row" justifyContent="space-between" alignItems="center"> | ||
<Typography> | ||
{t(`settings.general.show_covers.title`)} | ||
</Typography> | ||
<Box sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
marginLeft: '0', | ||
}}> | ||
<Switch | ||
checked={show_covers} | ||
onChange={handleSwitch} | ||
/> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default ShowCovers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters