WoL Update
This commit is contained in:
@@ -4,11 +4,12 @@ import {
|
||||
Group,
|
||||
Menu,
|
||||
MultiSelect,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
Tooltip,
|
||||
} from '@mantine/core';
|
||||
import { runWakeCommand, useCommonHooks, useQueryAPI } from 'hooks';
|
||||
import { useCommonHooks, useMutationAPI, useQueryAPI } from 'hooks';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { FaDice } from 'react-icons/fa';
|
||||
import { FiMenu, FiMonitor, FiSettings, FiShuffle } from 'react-icons/fi';
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
|
||||
function SettingsButton() {
|
||||
const { data, isFetched } = useQueryAPI({ endpoint: 'api/appCategories' });
|
||||
const { mutateAsync: wakeRequest } = useMutationAPI();
|
||||
const [categories, setCategories] = useState([{ value: 'All', label: 'All' }]);
|
||||
const navigate = useNavigate();
|
||||
const {
|
||||
@@ -36,19 +38,30 @@ function SettingsButton() {
|
||||
bookmarkFilter,
|
||||
setBookmarkFilter,
|
||||
isMobile,
|
||||
wolClients,
|
||||
notify,
|
||||
} = useCommonHooks();
|
||||
|
||||
const [selectedClient, setSelectedClient] = useState<any>(wolClients?.[0]);
|
||||
|
||||
const handleWakeRequest = () => {
|
||||
wakeRequest({
|
||||
method: 'POST',
|
||||
endpoint: 'api/wakeClient',
|
||||
body: selectedClient || wolClients?.[0],
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
const list: [any] =
|
||||
data.map((category: any) => {
|
||||
return { value: category.filterName, label: category.filterName };
|
||||
}) || [];
|
||||
const list: [any] = data.map((category: any) => {
|
||||
return { value: category.filterName, label: category.filterName };
|
||||
});
|
||||
list.unshift({ value: 'All', label: 'All' });
|
||||
setCategories(list);
|
||||
}
|
||||
}, [data, isFetched]);
|
||||
|
||||
return (
|
||||
<Menu
|
||||
classNames={menuClasses}
|
||||
@@ -88,16 +101,35 @@ function SettingsButton() {
|
||||
<Button
|
||||
classNames={buttonClasses}
|
||||
className={buttonClasses.wakeButton}
|
||||
disabled={!wolClients?.length}
|
||||
onClick={() => {
|
||||
runWakeCommand();
|
||||
handleWakeRequest();
|
||||
notify('Wake command sent');
|
||||
}}
|
||||
>
|
||||
<Stack gap={0} align='center'>
|
||||
<FiMonitor size={40} />
|
||||
<Text>Dakota</Text>
|
||||
</Stack>
|
||||
</Button>
|
||||
<Select
|
||||
labelProps={{ display: 'none' }}
|
||||
placeholder='Pick a host...'
|
||||
defaultValue={wolClients?.[0]?.hostname}
|
||||
data={
|
||||
wolClients?.map((wolClient: any) => {
|
||||
return {
|
||||
value: wolClient.hostname,
|
||||
label: `${wolClient.hostname} (${wolClient.macAddress})`,
|
||||
hostname: wolClient.hostname,
|
||||
macAddress: wolClient.macAddress,
|
||||
};
|
||||
}) || []
|
||||
}
|
||||
classNames={selectClasses}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
onChange={(_value, option: any) => setSelectedClient(option)}
|
||||
onLoad={(option: any) => setSelectedClient(option)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack
|
||||
gap={0}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
FiEdit,
|
||||
FiGlobe,
|
||||
FiMail,
|
||||
FiMonitor,
|
||||
FiSearch,
|
||||
FiUser,
|
||||
} from 'react-icons/fi';
|
||||
@@ -19,6 +20,7 @@ import Messages from './components/Messages';
|
||||
import Personalization from './components/Personalization';
|
||||
import SearchProviders from './components/SearchProviders';
|
||||
import Themes from './components/Themes';
|
||||
import WolClients from './components/WolClients';
|
||||
|
||||
export function Settings() {
|
||||
const { isMobile } = useCommonHooks();
|
||||
@@ -60,6 +62,9 @@ export function Settings() {
|
||||
<Tabs.Tab value='providers'>
|
||||
{isMobile ? <FiSearch /> : 'Search Providers'}
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value='wolClients'>
|
||||
{isMobile ? <FiMonitor /> : 'WoL Clients'}
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
<Tabs.Panel value='personalization'>
|
||||
<Personalization />
|
||||
@@ -82,6 +87,9 @@ export function Settings() {
|
||||
<Tabs.Panel value='providers'>
|
||||
<SearchProviders />
|
||||
</Tabs.Panel>
|
||||
<Tabs.Panel value='wolClients'>
|
||||
<WolClients />
|
||||
</Tabs.Panel>
|
||||
</Tabs>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
26
src/pages/settings/components/WolClients.tsx
Normal file
26
src/pages/settings/components/WolClients.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Stack, Text } from '@mantine/core';
|
||||
import { DataTable, WolClientColumns } from 'components';
|
||||
import { useCommonHooks } from 'hooks';
|
||||
import { textClasses } from 'styles';
|
||||
|
||||
const WolClientSettings = () => {
|
||||
const endpoint = 'api/wolClients';
|
||||
const { wolClientsData, wolClientsIsFetching, wolClientsIsLoading } = useCommonHooks();
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Text className={textClasses.settingsSubTitle} classNames={textClasses}>
|
||||
WoL Clients
|
||||
</Text>
|
||||
<DataTable
|
||||
tableName='WoL Clients'
|
||||
columns={WolClientColumns()}
|
||||
tableData={wolClientsData}
|
||||
isFetching={wolClientsIsFetching}
|
||||
isLoading={wolClientsIsLoading}
|
||||
endpoint={endpoint}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
export default WolClientSettings;
|
||||
Reference in New Issue
Block a user