u
This commit is contained in:
@@ -8,6 +8,8 @@ import Tabs from '@mui/material/Tabs';
|
|||||||
import NumbersIcon from '@mui/icons-material/Numbers';
|
import NumbersIcon from '@mui/icons-material/Numbers';
|
||||||
import PrintOutlinedIcon from '@mui/icons-material/PrintOutlined';
|
import PrintOutlinedIcon from '@mui/icons-material/PrintOutlined';
|
||||||
import TuneIcon from '@mui/icons-material/Tune';
|
import TuneIcon from '@mui/icons-material/Tune';
|
||||||
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
import NumberSettingsPanel from './NumberSettingsPanel';
|
import NumberSettingsPanel from './NumberSettingsPanel';
|
||||||
import PrinterSettingsPanel from './PrinterSettingsPanel';
|
import PrinterSettingsPanel from './PrinterSettingsPanel';
|
||||||
import SettingsKeysPanel from './SettingsKeysPanel';
|
import SettingsKeysPanel from './SettingsKeysPanel';
|
||||||
@@ -46,9 +48,42 @@ export default class SettingsDialog extends Component {
|
|||||||
const { open, onClose } = this.props;
|
const { open, onClose } = this.props;
|
||||||
const { tab } = this.state;
|
const { tab } = this.state;
|
||||||
|
|
||||||
|
const paperSx = {
|
||||||
|
height: '85vh',
|
||||||
|
minHeight: '85vh',
|
||||||
|
maxHeight: '85vh',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppDialog open={open} onClose={onClose} maxWidth="md" fullWidth>
|
<AppDialog
|
||||||
<DialogTitle>Einstellungen</DialogTitle>
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
maxWidth="md"
|
||||||
|
fullWidth
|
||||||
|
slotProps={{ paper: { sx: paperSx } }}
|
||||||
|
PaperProps={{ sx: paperSx }}
|
||||||
|
>
|
||||||
|
<DialogTitle
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
py: 1.5,
|
||||||
|
px: 3,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Einstellungen
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
aria-label="Schließen"
|
||||||
|
onClick={onClose}
|
||||||
|
sx={{ color: 'text.secondary' }}
|
||||||
|
>
|
||||||
|
<CloseIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</DialogTitle>
|
||||||
<Tabs
|
<Tabs
|
||||||
value={tab}
|
value={tab}
|
||||||
onChange={this.handleTabChange}
|
onChange={this.handleTabChange}
|
||||||
@@ -59,14 +94,14 @@ export default class SettingsDialog extends Component {
|
|||||||
<Tab key={t.id} icon={t.icon} iconPosition="start" label={t.label} value={t.id} />
|
<Tab key={t.id} icon={t.icon} iconPosition="start" label={t.label} value={t.id} />
|
||||||
))}
|
))}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers sx={{ flex: 1, minHeight: 0 }}>
|
||||||
<Box sx={{ display: 'grid' }}>
|
<Box sx={{ display: 'grid' }}>
|
||||||
{TABS.map((t) => (
|
{TABS.map((t) => (
|
||||||
<Box
|
<Box
|
||||||
key={t.id}
|
key={t.id}
|
||||||
sx={{
|
sx={{
|
||||||
gridArea: '1 / 1',
|
gridArea: '1 / 1',
|
||||||
visibility: t.id === tab ? undefined : 'hidden',
|
display: t.id === tab ? 'block' : 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<t.Panel />
|
<t.Panel />
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ const SETTABLE_KEYS = [
|
|||||||
'keys.tavily',
|
'keys.tavily',
|
||||||
'keys.openrouter',
|
'keys.openrouter',
|
||||||
'keys.serper',
|
'keys.serper',
|
||||||
|
'default-model',
|
||||||
|
'systemprompt-prefix',
|
||||||
|
'systemprompt-suffix',
|
||||||
];
|
];
|
||||||
|
|
||||||
const KEY_LABELS = {
|
const KEY_LABELS = {
|
||||||
@@ -35,8 +38,21 @@ const KEY_LABELS = {
|
|||||||
'keys.tavily': 'Tavily API-Key',
|
'keys.tavily': 'Tavily API-Key',
|
||||||
'keys.openrouter': 'OpenRouter API-Key',
|
'keys.openrouter': 'OpenRouter API-Key',
|
||||||
'keys.serper': 'Serper API-Key',
|
'keys.serper': 'Serper API-Key',
|
||||||
|
'default-model': 'Modellslug',
|
||||||
|
'systemprompt-prefix': 'Prä Prompt',
|
||||||
|
'systemprompt-suffix': 'Post Prompt',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MULTILINE_KEYS = new Set([
|
||||||
|
'systemprompt-prefix',
|
||||||
|
'systemprompt-suffix',
|
||||||
|
]);
|
||||||
|
|
||||||
|
const EXCLUDED_KEYS = new Set([
|
||||||
|
'labelprinter.addr',
|
||||||
|
'labelprinter.type',
|
||||||
|
]);
|
||||||
|
|
||||||
function keyLabel(key) {
|
function keyLabel(key) {
|
||||||
return KEY_LABELS[key] ?? key;
|
return KEY_LABELS[key] ?? key;
|
||||||
}
|
}
|
||||||
@@ -177,25 +193,43 @@ export default class SettingsKeysPanel extends Component {
|
|||||||
<TableContainer>
|
<TableContainer>
|
||||||
<Table size="small">
|
<Table size="small">
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{SETTABLE_KEYS.map((key) => {
|
{SETTABLE_KEYS.filter((k) => !EXCLUDED_KEYS.has(k)).map((key) => {
|
||||||
const row = settings.find((s) => s.key === key);
|
const row = settings.find((s) => s.key === key);
|
||||||
const draft = row ? drafts[row.key] : null;
|
const draft = row ? drafts[row.key] : null;
|
||||||
if (!row || !draft) return null;
|
if (!row || !draft) return null;
|
||||||
|
const isMultiline = MULTILINE_KEYS.has(row.key);
|
||||||
return (
|
return (
|
||||||
<TableRow key={row.key} hover>
|
<TableRow key={row.key} hover>
|
||||||
<TableCell>
|
<TableCell
|
||||||
|
sx={{
|
||||||
|
width: 180,
|
||||||
|
verticalAlign: 'top',
|
||||||
|
pt: 1.5,
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Typography variant="body2">{keyLabel(row.key)}</Typography>
|
<Typography variant="body2">{keyLabel(row.key)}</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell sx={{ verticalAlign: 'top' }}>
|
||||||
<TextField
|
<TextField
|
||||||
size="small"
|
size="small"
|
||||||
|
fullWidth
|
||||||
|
multiline={isMultiline}
|
||||||
|
minRows={isMultiline ? 2 : undefined}
|
||||||
|
maxRows={isMultiline ? 6 : undefined}
|
||||||
value={draft.value}
|
value={draft.value}
|
||||||
disabled={draft.busy}
|
disabled={draft.busy}
|
||||||
onChange={(e) => this.handleChange(row.key, 'value', e.target.value)}
|
onChange={(e) => this.handleChange(row.key, 'value', e.target.value)}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (!isMultiline && e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
void this.handleSave(row.key);
|
||||||
|
}
|
||||||
|
}}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right">
|
<TableCell align="right" sx={{ verticalAlign: 'top', pt: 1, width: 60 }}>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
spacing={0}
|
spacing={0}
|
||||||
|
|||||||
Reference in New Issue
Block a user