mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
server add/edit refactor, allow jellyfin prefer instant mix
This commit is contained in:
parent
eb0ccec0bc
commit
6df270ba34
5 changed files with 91 additions and 30 deletions
|
|
@ -21,7 +21,7 @@ import { Stack } from '/@/shared/components/stack/stack';
|
|||
import { TextInput } from '/@/shared/components/text-input/text-input';
|
||||
import { Text } from '/@/shared/components/text/text';
|
||||
import { toast } from '/@/shared/components/toast/toast';
|
||||
import { AuthenticationResponse } from '/@/shared/types/domain-types';
|
||||
import { AuthenticationResponse, ServerListItem } from '/@/shared/types/domain-types';
|
||||
import { DiscoveredServerItem, ServerType, toServerType } from '/@/shared/types/types';
|
||||
|
||||
const autodiscover = isElectron() ? window.api.autodiscover : null;
|
||||
|
|
@ -99,7 +99,8 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
|||
legacyAuth: false,
|
||||
name: (localSettings ? localSettings.env.SERVER_NAME : window.SERVER_NAME) ?? '',
|
||||
password: '',
|
||||
savePassword: false,
|
||||
preferInstantMix: undefined,
|
||||
savePassword: undefined,
|
||||
type:
|
||||
(localSettings
|
||||
? localSettings.env.SERVER_TYPE
|
||||
|
|
@ -151,17 +152,28 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
|||
});
|
||||
}
|
||||
|
||||
const serverItem = {
|
||||
const serverItem: ServerListItem = {
|
||||
credential: data.credential,
|
||||
id: nanoid(),
|
||||
name: values.name,
|
||||
ndCredential: data.ndCredential,
|
||||
type: values.type as ServerType,
|
||||
url: values.url.replace(/\/$/, ''),
|
||||
userId: data.userId,
|
||||
username: data.username,
|
||||
};
|
||||
|
||||
if (values.preferInstantMix !== undefined) {
|
||||
serverItem.preferInstantMix = values.preferInstantMix;
|
||||
}
|
||||
|
||||
if (values.savePassword !== undefined) {
|
||||
serverItem.savePassword = values.savePassword;
|
||||
}
|
||||
|
||||
if (data.ndCredential !== undefined) {
|
||||
serverItem.ndCredential = data.ndCredential;
|
||||
}
|
||||
|
||||
addServer(serverItem);
|
||||
setCurrentServer(serverItem);
|
||||
closeAllModals();
|
||||
|
|
@ -271,6 +283,21 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => {
|
|||
{...form.getInputProps('legacyAuth', { type: 'checkbox' })}
|
||||
/>
|
||||
)}
|
||||
{form.values.type === ServerType.JELLYFIN && (
|
||||
<Checkbox
|
||||
description={t('form.addServer.input', {
|
||||
context: 'preferInstantMixDescription',
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'preferInstantMix',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('preferInstantMix', {
|
||||
type: 'checkbox',
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<Group grow justify="flex-end">
|
||||
{onCancel && (
|
||||
<Button onClick={onCancel} variant="subtle">
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ export const EditServerForm = ({ isUpdate, onCancel, password, server }: EditSer
|
|||
legacyAuth: false,
|
||||
name: server?.name,
|
||||
password: password || '',
|
||||
savePassword: server.savePassword || false,
|
||||
preferInstantMix: server.preferInstantMix,
|
||||
savePassword: server.savePassword,
|
||||
type: server?.type,
|
||||
url: server?.url,
|
||||
username: server?.username,
|
||||
|
|
@ -85,17 +86,28 @@ export const EditServerForm = ({ isUpdate, onCancel, password, server }: EditSer
|
|||
});
|
||||
}
|
||||
|
||||
const serverItem = {
|
||||
const serverItem: ServerListItem = {
|
||||
credential: data.credential,
|
||||
id: server.id,
|
||||
name: values.name,
|
||||
ndCredential: data.ndCredential,
|
||||
savePassword: values.savePassword,
|
||||
type: values.type,
|
||||
url: values.url,
|
||||
userId: data.userId,
|
||||
username: data.username,
|
||||
};
|
||||
|
||||
if (values.preferInstantMix !== undefined) {
|
||||
serverItem.preferInstantMix = values.preferInstantMix;
|
||||
}
|
||||
|
||||
if (values.savePassword !== undefined) {
|
||||
serverItem.savePassword = values.savePassword;
|
||||
}
|
||||
|
||||
if (data.ndCredential !== undefined) {
|
||||
serverItem.ndCredential = data.ndCredential;
|
||||
}
|
||||
|
||||
updateServer(server.id, serverItem);
|
||||
toast.success({
|
||||
message: t('form.updateServer.title', { postProcess: 'sentenceCase' }),
|
||||
|
|
@ -188,6 +200,21 @@ export const EditServerForm = ({ isUpdate, onCancel, password, server }: EditSer
|
|||
})}
|
||||
/>
|
||||
)}
|
||||
{form.values.type === ServerType.JELLYFIN && (
|
||||
<Checkbox
|
||||
description={t('form.addServer.input', {
|
||||
context: 'preferInstantMixDescription',
|
||||
postProcess: 'sentenceCase',
|
||||
})}
|
||||
label={t('form.addServer.input', {
|
||||
context: 'preferInstantMix',
|
||||
postProcess: 'titleCase',
|
||||
})}
|
||||
{...form.getInputProps('preferInstantMix', {
|
||||
type: 'checkbox',
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<Group justify="flex-end">
|
||||
<Button onClick={onCancel} variant="subtle">
|
||||
{t('common.cancel', { postProcess: 'titleCase' })}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue