Updated ui layout.

This commit is contained in:
PJ-Watson
2022-08-05 20:35:00 +01:00
parent 1c784fa5e9
commit 31025f7616

View File

@@ -1,7 +1,11 @@
import { gql } from '@apollo/client' import { gql } from '@apollo/client'
import React, { useRef, useState } from 'react' import React, { useRef, useState } from 'react'
import { useMutation, useQuery } from '@apollo/client' import { useMutation, useQuery } from '@apollo/client'
import { InputLabelDescription, InputLabelTitle } from './SettingsPage' import {
SectionTitle,
InputLabelDescription,
InputLabelTitle,
} from './SettingsPage'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { thumbnailMethodQuery } from './__generated__/thumbnailMethodQuery' import { thumbnailMethodQuery } from './__generated__/thumbnailMethodQuery'
import { import {
@@ -60,133 +64,71 @@ const ThumbnailPreferences = () => {
const methodItems: DropdownItem[] = [ const methodItems: DropdownItem[] = [
{ {
label: t( label: t(
'settings.thumbnails.downsample_method.nearest_neighbor', 'settings.thumbnails.method.filter.nearest_neighbor',
'Nearest Neighbor' 'Nearest Neighbor (default)'
), ),
value: 0, value: 0,
}, },
{ {
label: t('settings.thumbnails.downsample_method.box', 'Box'), label: t('settings.thumbnails.method.filter.box', 'Box'),
value: 1, value: 1,
}, },
{ {
label: t('settings.thumbnails.downsample_method.linear', 'Linear'), label: t('settings.thumbnails.method.filter.linear', 'Linear'),
value: 2, value: 2,
}, },
{ {
label: t( label: t(
'settings.thumbnails.downsample_method.mitchell_netravali', 'settings.thumbnails.method.filter.mitchell_netravali',
'Mitchell-Netravali' 'Mitchell-Netravali'
), ),
value: 3, value: 3,
}, },
{ {
label: t( label: t('settings.thumbnails.method.filter.catmull_rom', 'Catmull-Rom'),
'settings.thumbnails.downsample_method.catmull_rom',
'Catmull-Rom'
),
value: 4, value: 4,
}, },
{ {
label: t('settings.thumbnails.downsample_method.Lanczos', 'Lanczos'), label: t(
'settings.thumbnails.method.filter.Lanczos',
'Lanczos (highest quality)'
),
value: 5, value: 5,
}, },
] ]
// const [enablePeriodicScanner, setEnablePeriodicScanner] = useState(false)
// const [thumbnailMethod, setThumbnailMethod] = useState({
// value: 0,
// unit: TimeUnit.Second,
// })
//
// const scanIntervalServerValue = useRef<number | null>(null)
//
// const scanIntervalQuery = useQuery<scanIntervalQuery>(SCAN_INTERVAL_QUERY, {
// onCompleted(data) {
// const queryScanInterval = data.siteInfo.periodicScanInterval
//
// if (queryScanInterval == 0) {
// setScanInterval({
// unit: TimeUnit.Second,
// value: 0,
// })
// } else {
// setScanInterval(
// convertToAppropriateUnit({
// unit: TimeUnit.Second,
// value: queryScanInterval,
// })
// )
// }
//
// setEnablePeriodicScanner(queryScanInterval > 0)
// },
// })
//
// const [setScanIntervalMutation, { loading: scanIntervalMutationLoading }] =
// useMutation<
// changeScanIntervalMutation,
// changeScanIntervalMutationVariables
// >(SCAN_INTERVAL_MUTATION)
//
// const onScanIntervalCheckboxChange = (checked: boolean) => {
// setEnablePeriodicScanner(checked)
//
// onScanIntervalUpdate(
// checked ? scanInterval : { value: 0, unit: TimeUnit.Second }
// )
// }
//
// const onScanIntervalUpdate = (scanInterval: TimeValue) => {
// const seconds = convertToSeconds(scanInterval)
//
// if (scanIntervalServerValue.current != seconds) {
// setScanIntervalMutation({
// variables: {
// interval: seconds,
// },
// })
// scanIntervalServerValue.current = seconds
// }
// }
return ( return (
<> <div>
<div className="mt-4"> <SectionTitle>
<label htmlFor="thumbnail_method_field"> {t('settings.thumbnails.title', 'Thumbnail preferences')}
<InputLabelTitle> </SectionTitle>
{t('settings.thumbnails.field.label', 'Downsampling method')} <label htmlFor="thumbnail_method_field">
</InputLabelTitle> <InputLabelTitle>
<InputLabelDescription> {t('settings.thumbnails.method.label', 'Downsampling method')}
{t( </InputLabelTitle>
'settings.thumbnails.field.description', <InputLabelDescription>
'The filter to use when generating thumbnails' {t(
)} 'settings.thumbnails.method.description',
</InputLabelDescription> 'The filter to use when generating thumbnails'
</label> )}
<div className="flex gap-2"> </InputLabelDescription>
<Dropdown </label>
aria-label="Method" <Dropdown
items={methodItems} aria-label="Method"
selected={downsampleMethod} items={methodItems}
setSelected={value => { selected={downsampleMethod}
setDownsampleMethod(value) setSelected={value => {
updateDownsampleMethod(value) setDownsampleMethod(value)
}} updateDownsampleMethod(value)
/> }}
</div> />
</div>
<Loader <Loader
active={downsampleMethodQuery.loading || downsampleMutationData.loading} active={downsampleMethodQuery.loading || downsampleMutationData.loading}
size="small" size="small"
style={{ marginLeft: 16 }} style={{ marginLeft: 16 }}
/> />
</> </div>
) )
} }
export default ThumbnailPreferences export default ThumbnailPreferences
// <h3 className="font-semibold text-lg mt-4 mb-2">
// {t('settings.thumbnails.title', 'Thumbnail preferences')}
// </h3>