2023-09-23 20:24:43 +08:00
|
|
|
import { IconFileStack } from '@tabler/icons-solidjs'
|
|
|
|
import { Component, For } from 'solid-js'
|
|
|
|
import { ConfigTitle, Modal } from '~/components'
|
2023-09-15 23:43:55 +08:00
|
|
|
import {
|
|
|
|
LOGS_TABLE_MAX_ROWS_LIST,
|
2023-09-19 00:35:58 +08:00
|
|
|
LOG_LEVEL,
|
2023-09-15 23:43:55 +08:00
|
|
|
TAILWINDCSS_SIZE,
|
|
|
|
} from '~/constants'
|
2023-09-22 17:14:35 +08:00
|
|
|
import { useI18n } from '~/i18n'
|
2023-09-15 23:43:55 +08:00
|
|
|
import {
|
2023-09-16 15:38:42 +08:00
|
|
|
logLevel,
|
2023-09-15 23:43:55 +08:00
|
|
|
logMaxRows,
|
|
|
|
logsTableSize,
|
|
|
|
setLogLevel,
|
|
|
|
setLogMaxRows,
|
|
|
|
setLogsTableSize,
|
|
|
|
} from '~/signals'
|
|
|
|
|
2023-09-23 20:24:43 +08:00
|
|
|
export const LogsSettingsModal: Component<{
|
|
|
|
ref?: (el: HTMLDialogElement) => void
|
|
|
|
}> = (props) => {
|
2023-09-23 01:38:36 +08:00
|
|
|
const [t] = useI18n()
|
2023-09-15 23:43:55 +08:00
|
|
|
|
|
|
|
return (
|
2023-09-23 20:24:43 +08:00
|
|
|
<Modal
|
|
|
|
ref={(el) => props.ref?.(el)}
|
|
|
|
icon={<IconFileStack size={24} />}
|
|
|
|
title={t('logsSettings')}
|
|
|
|
>
|
|
|
|
<div class="flex flex-col gap-4">
|
2023-09-15 23:43:55 +08:00
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('tableSize')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full"
|
|
|
|
value={logsTableSize()}
|
|
|
|
onChange={(e) =>
|
|
|
|
setLogsTableSize(e.target.value as TAILWINDCSS_SIZE)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<For each={Object.values(TAILWINDCSS_SIZE)}>
|
|
|
|
{(value) => <option value={value}>{t(value)}</option>}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('logLevel')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full"
|
2023-09-16 15:38:42 +08:00
|
|
|
value={logLevel()}
|
2023-09-15 23:43:55 +08:00
|
|
|
onChange={(e) => setLogLevel(e.target.value as LOG_LEVEL)}
|
|
|
|
>
|
|
|
|
<For
|
|
|
|
each={[
|
|
|
|
LOG_LEVEL.Info,
|
|
|
|
LOG_LEVEL.Error,
|
|
|
|
LOG_LEVEL.Warning,
|
|
|
|
LOG_LEVEL.Debug,
|
|
|
|
LOG_LEVEL.Silent,
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{(level) => <option value={level}>{t(level)}</option>}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('logMaxRows')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full"
|
|
|
|
value={logMaxRows()}
|
|
|
|
onChange={(e) => setLogMaxRows(parseInt(e.target.value))}
|
|
|
|
>
|
|
|
|
<For each={LOGS_TABLE_MAX_ROWS_LIST}>
|
|
|
|
{(rows) => <option value={rows}>{rows}</option>}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-23 20:24:43 +08:00
|
|
|
</Modal>
|
2023-09-15 23:43:55 +08:00
|
|
|
)
|
|
|
|
}
|