-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
266 additions
and
161 deletions.
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,151 @@ | ||
import React from 'react'; | ||
import Page from 'components/Page'; | ||
import globalize from 'lib/globalize'; | ||
import Alert from '@mui/material/Alert'; | ||
import Box from '@mui/material/Box'; | ||
import Button from '@mui/material/Button'; | ||
import Stack from '@mui/material/Stack'; | ||
import TextField from '@mui/material/TextField'; | ||
import Typography from '@mui/material/Typography'; | ||
import { type ActionFunctionArgs, Form, useActionData } from 'react-router-dom'; | ||
import { ActionData } from 'types/actionData'; | ||
import { useIsSubmitting } from 'hooks/useIsSubmitting'; | ||
import { useConfiguration } from 'hooks/useConfiguration'; | ||
import Loading from 'components/loading/LoadingComponent'; | ||
import ServerConnections from 'components/ServerConnections'; | ||
import { getConfigurationApi } from '@jellyfin/sdk/lib/utils/api/configuration-api'; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const api = ServerConnections.getCurrentApi(); | ||
if (!api) throw new Error('No Api instance available'); | ||
|
||
const { data: config } = await getConfigurationApi(api).getConfiguration(); | ||
const formData = await request.formData(); | ||
|
||
const minResumePercentage = formData.get('MinResumePercentage')?.toString(); | ||
const maxResumePercentage = formData.get('MaxResumePercentage')?.toString(); | ||
const minAudiobookResume = formData.get('MinAudiobookResume')?.toString(); | ||
const maxAudiobookResume = formData.get('MaxAudiobookResume')?.toString(); | ||
const minResumeDuration = formData.get('MinResumeDuration')?.toString(); | ||
|
||
if (minResumePercentage) config.MinResumePct = parseInt(minResumePercentage, 10); | ||
if (maxResumePercentage) config.MaxResumePct = parseInt(maxResumePercentage, 10); | ||
if (minAudiobookResume) config.MinAudiobookResume = parseInt(minAudiobookResume, 10); | ||
if (maxAudiobookResume) config.MaxAudiobookResume = parseInt(maxAudiobookResume, 10); | ||
if (minResumeDuration) config.MinResumeDurationSeconds = parseInt(minResumeDuration, 10); | ||
|
||
await getConfigurationApi(api) | ||
.updateConfiguration({ serverConfiguration: config }); | ||
|
||
return { | ||
isSaved: true | ||
}; | ||
}; | ||
|
||
const Resume = () => { | ||
const actionData = useActionData() as ActionData | undefined; | ||
const { isSubmitting, onSubmit } = useIsSubmitting(actionData); | ||
|
||
const { isPending: isConfigurationPending, data: config } = useConfiguration(); | ||
|
||
if (isConfigurationPending) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<Page | ||
id='playbackConfigurationPage' | ||
title={globalize.translate('ButtonResume')} | ||
className='mainAnimatedPage type-interior' | ||
> | ||
<Box className='content-primary'> | ||
<Form method='POST' onSubmit={onSubmit}> | ||
<Stack spacing={3}> | ||
<Typography variant='h2'> | ||
{globalize.translate('ButtonResume')} | ||
</Typography> | ||
|
||
{!isSubmitting && actionData?.isSaved && ( | ||
<Alert severity='success'> | ||
{globalize.translate('SettingsSaved')} | ||
</Alert> | ||
)} | ||
|
||
<TextField | ||
label={globalize.translate('LabelMinResumePercentage')} | ||
name='MinResumePercentage' | ||
type='number' | ||
defaultValue={config?.MinResumePct} | ||
inputProps={{ | ||
min: 0, | ||
max: 100, | ||
required: true | ||
}} | ||
helperText={globalize.translate('LabelMinResumePercentageHelp')} | ||
/> | ||
|
||
<TextField | ||
label={globalize.translate('LabelMaxResumePercentage')} | ||
name='MaxResumePercentage' | ||
type='number' | ||
defaultValue={config?.MaxResumePct} | ||
inputProps={{ | ||
min: 1, | ||
max: 100, | ||
required: true | ||
}} | ||
helperText={globalize.translate('LabelMaxResumePercentageHelp')} | ||
/> | ||
|
||
<TextField | ||
label={globalize.translate('LabelMinAudiobookResume')} | ||
name='MinAudiobookResume' | ||
type='number' | ||
defaultValue={config?.MinAudiobookResume} | ||
inputProps={{ | ||
min: 0, | ||
max: 100, | ||
required: true | ||
}} | ||
helperText={globalize.translate('LabelMinAudiobookResumeHelp')} | ||
/> | ||
|
||
<TextField | ||
label={globalize.translate('LabelMaxAudiobookResume')} | ||
name='MaxAudiobookResume' | ||
type='number' | ||
defaultValue={config?.MaxAudiobookResume} | ||
inputProps={{ | ||
min: 1, | ||
max: 100, | ||
required: true | ||
}} | ||
helperText={globalize.translate('LabelMaxAudiobookResumeHelp')} | ||
/> | ||
|
||
<TextField | ||
label={globalize.translate('LabelMinResumeDuration')} | ||
name='MinResumeDuration' | ||
type='number' | ||
defaultValue={config?.MinResumeDurationSeconds} | ||
inputProps={{ | ||
min: 0, | ||
required: true | ||
}} | ||
helperText={globalize.translate('LabelMinResumeDurationHelp')} | ||
/> | ||
|
||
<Button | ||
type='submit' | ||
size='large' | ||
> | ||
{globalize.translate('Save')} | ||
</Button> | ||
</Stack> | ||
</Form> | ||
</Box> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default Resume; |
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,90 @@ | ||
import React from 'react'; | ||
import Page from 'components/Page'; | ||
import globalize from 'lib/globalize'; | ||
import Alert from '@mui/material/Alert'; | ||
import Box from '@mui/material/Box'; | ||
import Button from '@mui/material/Button'; | ||
import Stack from '@mui/material/Stack'; | ||
import TextField from '@mui/material/TextField'; | ||
import Typography from '@mui/material/Typography'; | ||
import { type ActionFunctionArgs, Form, useActionData } from 'react-router-dom'; | ||
import ServerConnections from 'components/ServerConnections'; | ||
import { getConfigurationApi } from '@jellyfin/sdk/lib/utils/api/configuration-api'; | ||
import { useConfiguration } from 'hooks/useConfiguration'; | ||
import Loading from 'components/loading/LoadingComponent'; | ||
import { ActionData } from 'types/actionData'; | ||
import { useIsSubmitting } from 'hooks/useIsSubmitting'; | ||
|
||
export const action = async ({ request }: ActionFunctionArgs) => { | ||
const api = ServerConnections.getCurrentApi(); | ||
if (!api) throw new Error('No Api instance available'); | ||
|
||
const { data: config } = await getConfigurationApi(api).getConfiguration(); | ||
const formData = await request.formData(); | ||
|
||
const bitrateLimit = formData.get('StreamingBitrateLimit')?.toString(); | ||
config.RemoteClientBitrateLimit = Math.trunc(1e6 * parseFloat(bitrateLimit || '0')); | ||
|
||
await getConfigurationApi(api) | ||
.updateConfiguration({ serverConfiguration: config }); | ||
|
||
return { | ||
isSaved: true | ||
}; | ||
}; | ||
|
||
const Streaming = () => { | ||
const actionData = useActionData() as ActionData | undefined; | ||
const { isSubmitting, onSubmit } = useIsSubmitting(actionData); | ||
|
||
const { isPending: isConfigurationPending, data: defaultConfiguration } = useConfiguration(); | ||
|
||
if (isConfigurationPending) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<Page | ||
id='streamingSettingsPage' | ||
title={globalize.translate('TabStreaming')} | ||
className='mainAnimatedPage type-interior' | ||
> | ||
<Box className='content-primary'> | ||
<Form method='POST' onSubmit={onSubmit}> | ||
<Stack spacing={3}> | ||
<Typography variant='h2'> | ||
{globalize.translate('TabStreaming')} | ||
</Typography> | ||
|
||
{!isSubmitting && actionData?.isSaved && ( | ||
<Alert severity='success'> | ||
{globalize.translate('SettingsSaved')} | ||
</Alert> | ||
)} | ||
|
||
<TextField | ||
type='number' | ||
inputMode='decimal' | ||
inputProps={{ | ||
min: 0, | ||
step: 0.25 | ||
}} | ||
name='StreamingBitrateLimit' | ||
label={globalize.translate('LabelRemoteClientBitrateLimit')} | ||
helperText={globalize.translate('LabelRemoteClientBitrateLimitHelp')} | ||
defaultValue={defaultConfiguration?.RemoteClientBitrateLimit ? defaultConfiguration?.RemoteClientBitrateLimit / 1e6 : ''} | ||
/> | ||
<Button | ||
type='submit' | ||
size='large' | ||
> | ||
{globalize.translate('Save')} | ||
</Button> | ||
</Stack> | ||
</Form> | ||
</Box> | ||
</Page> | ||
); | ||
}; | ||
|
||
export default Streaming; |
Oops, something went wrong.