Added Guacamole Client type

This commit is contained in:
Sean Edmunds
2025-12-30 09:35:50 -06:00
parent c5f71b468c
commit 35efb736fd
3 changed files with 120 additions and 4 deletions

View File

@@ -1,10 +1,25 @@
import { ActionIcon, Card, Group, Stack, Text, TextInput, Tooltip } from '@mantine/core'; import {
ActionIcon,
Card,
Group,
Select,
Stack,
Text,
TextInput,
Tooltip,
} from '@mantine/core';
import { useDebouncedValue, useDisclosure } from '@mantine/hooks'; import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
import { DeleteItemModal } from 'components'; import { DeleteItemModal } from 'components';
import { useCommonHooks, useMutationAPI } from 'hooks'; import { useCommonHooks, useMutationAPI } from 'hooks';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { FiTrash } from 'react-icons/fi'; import { FiTrash } from 'react-icons/fi';
import { cardClasses, textClasses, textInputClasses, toolTipClasses } from 'styles'; import {
cardClasses,
selectClasses,
textClasses,
textInputClasses,
toolTipClasses,
} from 'styles';
import type { GuacamoleClient } from 'types'; import type { GuacamoleClient } from 'types';
function DebouncedGuacamoleClient({ function DebouncedGuacamoleClient({
@@ -17,7 +32,7 @@ function DebouncedGuacamoleClient({
const { handleDelete, isMobile, theme } = useCommonHooks(); const { handleDelete, isMobile, theme } = useCommonHooks();
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false); const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
const { mutateAsync } = useMutationAPI(); const { mutateAsync } = useMutationAPI();
const types: string[] = ['SSH', 'RDP', 'VNC'];
const [client, setClient] = useState<GuacamoleClient>(guacamoleClient); const [client, setClient] = useState<GuacamoleClient>(guacamoleClient);
const [update, setUpdate] = useState<any>({}); const [update, setUpdate] = useState<any>({});
const [debounced] = useDebouncedValue(update, 1000); const [debounced] = useDebouncedValue(update, 1000);
@@ -114,6 +129,48 @@ function DebouncedGuacamoleClient({
: undefined : undefined
} }
/> />
<Select
label={'Category'}
className={selectClasses.settingsItem}
classNames={{
wrapper: selectClasses.menuSelectWrapper,
input: selectClasses.menuSelectInput,
label: selectClasses.menuSelectLabel,
options: selectClasses.menuSelectOptions,
option: selectClasses.menuSelectOption,
dropdown: selectClasses.dropdown,
}}
mt={'.75rem'}
limit={100}
defaultSearchValue={guacamoleClient?.type}
data={types.map((type) => {
return {
label: type,
value: type,
};
})}
defaultValue={guacamoleClient?.type}
comboboxProps={{
zIndex: 3000,
}}
styles={
theme.textShadowsEnabled
? {
label: { boxShadow: '2px 2px var(--mantine-color-border-0)' },
}
: undefined
}
onChange={(value: string | null) => {
setUpdate({
...guacamoleClient,
type: value,
});
}}
searchable
maxDropdownHeight={175}
onDropdownOpen={() => setIsOpen(true)}
onDropdownClose={() => setIsOpen(false)}
/>
</Group> </Group>
</Card> </Card>
); );

View File

@@ -1,10 +1,13 @@
import { import {
Button, Button,
type ComboboxItem,
type ComboboxLikeRenderOptionInput,
Grid, Grid,
GridCol, GridCol,
Group, Group,
LoadingOverlay, LoadingOverlay,
Popover, Popover,
Select,
Stack, Stack,
TextInput, TextInput,
} from '@mantine/core'; } from '@mantine/core';
@@ -13,7 +16,9 @@ import { useDebouncedValue, useDisclosure } from '@mantine/hooks';
import { AddItemModal, NoItemsFound, SettingsHeader } from 'components'; import { AddItemModal, NoItemsFound, SettingsHeader } from 'components';
import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks'; import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { popoverClasses, textInputClasses } from 'styles'; import { FaTerminal } from 'react-icons/fa';
import { FaComputer, FaDesktop } from 'react-icons/fa6';
import { popoverClasses, selectClasses, textInputClasses } from 'styles';
import type { GuacamoleClient } from 'types'; import type { GuacamoleClient } from 'types';
import DebouncedGuacamoleClient from './DebouncedGuacamoleClient'; import DebouncedGuacamoleClient from './DebouncedGuacamoleClient';
import GuacamoleClientSettingsItem from './GuacamoleClientSettingsItem'; import GuacamoleClientSettingsItem from './GuacamoleClientSettingsItem';
@@ -24,6 +29,7 @@ const GuacamoleClients = () => {
clientName: '', clientName: '',
clientIdentifier: '', clientIdentifier: '',
enabled: 1, enabled: 1,
type: 'SSH',
}; };
const form = useForm({ const form = useForm({
initialValues: defaultGuacamoleClient, initialValues: defaultGuacamoleClient,
@@ -32,6 +38,7 @@ const GuacamoleClients = () => {
clientIdentifier: isNotEmpty('Client Identifier is required'), clientIdentifier: isNotEmpty('Client Identifier is required'),
}, },
}); });
const types: string[] = ['SSH', 'RDP', 'VNC'];
const endpoint = 'api/guacamoleClients'; const endpoint = 'api/guacamoleClients';
const { const {
data: guacamoleClientsData, data: guacamoleClientsData,
@@ -119,6 +126,57 @@ const GuacamoleClients = () => {
} }
/> />
</Group> </Group>
<Group w={'100%'} justify='center' pos={'relative'}>
<Select
key={form.key('icon')}
{...form.getInputProps('icon')}
label={'Icon'}
className={selectClasses.settingsItem}
classNames={{
wrapper: selectClasses.menuSelectWrapper,
input: selectClasses.menuSelectInput,
label: selectClasses.menuSelectLabel,
options: selectClasses.menuSelectOptions,
option: selectClasses.menuSelectOption,
dropdown: selectClasses.dropdown,
}}
w={'45%'}
mt={'.75rem'}
limit={100}
placeholder='Search for an icon...'
data={types.map((type) => {
return {
label: type,
value: type,
};
})}
comboboxProps={{
zIndex: 3000,
}}
styles={
theme.textShadowsEnabled
? {
label: { boxShadow: '2px 2px var(--mantine-color-border-0)' },
}
: undefined
}
renderOption={(item: ComboboxLikeRenderOptionInput<ComboboxItem>) => {
return (
<Group>
{item.option.value}
{item.option.value === 'SSH' && <FaTerminal />}
{item.option.value === 'RDP' && <FaComputer />}
{item.option.value === 'VNC' && <FaDesktop />}
</Group>
);
}}
searchable
maxDropdownHeight={175}
onDropdownOpen={() => setIsOpen(true)}
onDropdownClose={() => setIsOpen(false)}
withAsterisk
/>
</Group>
<Group mt={'1rem'}> <Group mt={'1rem'}>
<Button type='submit' color={'green'}> <Button type='submit' color={'green'}>
Save Save

View File

@@ -3,4 +3,5 @@ export interface GuacamoleClient {
clientName: string; clientName: string;
clientIdentifier: string; clientIdentifier: string;
enabled: number; enabled: number;
type: string;
} }