diff --git a/src/App.tsx b/src/App.tsx
index 33cc913..aefb385 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -32,6 +32,9 @@ function App() {
const { data: themePlaylists, isFetched: isThemePlaylistsFetched } = useQueryAPI({
endpoint: 'api/themePlaylists',
});
+ const { data: personalData, isFetched: isPersonalDataFetched } = useQueryAPI({
+ endpoint: 'api/personalData',
+ });
const {
theme,
setTheme,
@@ -78,7 +81,7 @@ function App() {
);
useEffect(() => {
- if (allThemes && themeName) {
+ if (allThemes && themeName && personalData) {
if (currentThemePlaylist === 'All') {
if (themeName === 'random') {
handleThemeChange(allThemes, false);
@@ -124,6 +127,7 @@ function App() {
allThemes,
currentThemePlaylist,
isThemePlaylistsFetched,
+ isPersonalDataFetched,
]);
return (
<>
diff --git a/src/components/SettingsHeader.tsx b/src/components/SettingsHeader.tsx
index a396b15..8287594 100644
--- a/src/components/SettingsHeader.tsx
+++ b/src/components/SettingsHeader.tsx
@@ -40,7 +40,7 @@ export function SettingsHeader({
highlightList: string[];
description: string;
};
- searchValue: string | number;
+ searchValue: string | number | undefined;
setSearchValue: (searchValue: string | number) => void;
searchPlaceholder: string | undefined;
isLoading: boolean;
diff --git a/src/hooks/useAPI.tsx b/src/hooks/useAPI.tsx
index ca5f882..0a5e350 100644
--- a/src/hooks/useAPI.tsx
+++ b/src/hooks/useAPI.tsx
@@ -137,6 +137,10 @@ export function useMutationAPI() {
queryClient.refetchQueries({ queryKey: ['GET', 'api/themes'] });
endpoint === 'api/providers' &&
queryClient.refetchQueries({ queryKey: ['GET', 'api/providers/default'] });
+ endpoint === 'api/personalData' &&
+ queryClient.refetchQueries({ queryKey: ['GET', 'api/personalData'] });
+ queryClient.refetchQueries({ queryKey: ['GET', 'api/wolEnabled'] });
+ queryClient.refetchQueries({ queryKey: ['GET', 'api/guacamoleEnabled'] });
},
});
}
diff --git a/src/pages/homepage/Homepage.tsx b/src/pages/homepage/Homepage.tsx
index 5e42548..db12367 100644
--- a/src/pages/homepage/Homepage.tsx
+++ b/src/pages/homepage/Homepage.tsx
@@ -220,6 +220,7 @@ export function Homepage() {
closeWeatherModal={closeWeatherModal}
openWeatherModal={openWeatherModal}
position='top'
+ personal={personal as PersonalData}
/>
)}
diff --git a/src/pages/homepage/components/Search/Search.tsx b/src/pages/homepage/components/Search/Search.tsx
index 83256eb..380d173 100644
--- a/src/pages/homepage/components/Search/Search.tsx
+++ b/src/pages/homepage/components/Search/Search.tsx
@@ -21,13 +21,13 @@ import type {
CurrentWeather,
ExtendedForecast,
GuacamoleClient,
+ PersonalData,
Provider,
SearchHistoryItem,
} from 'types';
import RecommendedApplications from './components/RecommendedApplications';
import RecommendedBookmarks from './components/RecommendedBookmarks';
import SearchSelectItem from './components/SearchSelectItem';
-import { FaComputer } from 'react-icons/fa6';
export default function Search({
current,
@@ -36,6 +36,7 @@ export default function Search({
closeWeatherModal,
openWeatherModal,
position,
+ personal,
}: {
current: CurrentWeather;
extendedForecast: ExtendedForecast[];
@@ -43,17 +44,19 @@ export default function Search({
closeWeatherModal: () => void;
openWeatherModal: () => void;
position: string;
+ personal: PersonalData;
}) {
const { ref, height } = useElementSize();
const allIcons: any = { ...fa6, ...vsc, ...si };
const { data: providerData, isFetched: providerDataIsFetched } = useQueryAPI({
endpoint: 'api/providers',
});
- const [providers, setProviders] = useState([]);
- const [guacamoleClients, setGuacamoleClients] = useState([]);
const { data: applicationData, isFetching: isApplicationDataFetching } = useQueryAPI({
endpoint: 'api/enabledApplications',
});
+ const { data: guacamoleHostData, isFetched: guacamoleHostDataIsFetched } = useQueryAPI({
+ endpoint: 'api/guacamoleHost',
+ });
const { data: guacamoleClientData, isFetched: guacamoleClientDataIsFetched } =
useQueryAPI({
endpoint: 'api/guacamoleClients',
@@ -65,6 +68,9 @@ export default function Search({
useQueryAPI({
endpoint: 'api/providers/default',
});
+ const [providers, setProviders] = useState([]);
+ const [guacamoleHost, setGuacamoleHost] = useState('');
+ const [guacamoleClients, setGuacamoleClients] = useState([]);
const [applications, setApplications] = useState([]);
const [filteredApplications, setFilteredApplications] = useState([]);
const [bookmarks, setBookmarks] = useState([]);
@@ -130,7 +136,7 @@ export default function Search({
};
const handleGuacamoleClientLaunchItem = ({ option }: { option: any }) => {
- const validUrl = `https://sean.bet/guacamole/#/client/${option.clientIdentifier}`;
+ const validUrl = `${guacamoleHost}/#/client/${option.clientIdentifier}`;
open(validUrl, '_self');
};
@@ -175,7 +181,7 @@ export default function Search({
(client: GuacamoleClient) =>
client.clientName.toLowerCase() === item.target.value.toLowerCase().substr(1),
);
- open(`https://sean.bet/guacamole/#/client/${client?.clientIdentifier}`, '_self');
+ open(`${guacamoleHost}/#/client/${client?.clientIdentifier}`, '_self');
} else if (urlPattern.test(item.target.value)) {
if (/^(https?:\/\/).*/i.test(item.target.value))
globalThis.location = item.target.value;
@@ -301,7 +307,7 @@ export default function Search({
} else {
setProviderLabel('Invalid function');
}
- } else if (item.target.value.startsWith('>')) {
+ } else if (item.target.value.startsWith('>') && personal.enableGuacamole === 1) {
if (
guacamoleClients?.find(
(client: GuacamoleClient) =>
@@ -335,7 +341,7 @@ export default function Search({
};
});
}
- if (splittedSearch[0].startsWith('>')) {
+ if (splittedSearch[0].startsWith('>') && personal.enableGuacamole === 1) {
return guacamoleClientData
.filter((guacamoleClient: GuacamoleClient) =>
guacamoleClient.clientName
@@ -380,15 +386,16 @@ export default function Search({
};
const renderItem: any = (item: any) => {
- const Icon = item.option.icon ?
- (allIcons[
- item.option.icon
- ? item.option.icon
- : item.option.prefix === '/g'
- ? 'FaGoogle'
- : (providers.find((p: Provider) => p.prefix === item.option.prefix)?.icon ??
- '')
- ]) : (allIcons['FaComputer']);
+ const Icon = item.option.icon
+ ? allIcons[
+ item.option.icon
+ ? item.option.icon
+ : item.option.prefix === '/g'
+ ? 'FaGoogle'
+ : (providers.find((p: Provider) => p.prefix === item.option.prefix)?.icon ??
+ '')
+ ]
+ : allIcons.FaComputer;
return (searchValue as string).startsWith('!') ? (
- ) : (searchValue as string).startsWith('>') ? (
+ ) : (searchValue as string).startsWith('>') && personal.enableGuacamole === 1 ? (
{
+ if (guacamoleHostData && guacamoleHostDataIsFetched) {
+ setGuacamoleHost(guacamoleHostData[0].guacamoleHost);
+ }
+ }, [guacamoleClientData, guacamoleClientDataIsFetched]);
+
useEffect(() => {
if (guacamoleClientData && guacamoleClientDataIsFetched) {
setGuacamoleClients(guacamoleClientData);
diff --git a/src/pages/homepage/components/SettingsButton/SettingsButton.tsx b/src/pages/homepage/components/SettingsButton/SettingsButton.tsx
index 2831d4c..be0e357 100644
--- a/src/pages/homepage/components/SettingsButton/SettingsButton.tsx
+++ b/src/pages/homepage/components/SettingsButton/SettingsButton.tsx
@@ -16,8 +16,11 @@ function SettingsButton() {
const { data: wolClientData, isFetched: wolClientDataIsFetched } = useQueryAPI({
endpoint: 'api/wolClients',
});
+ const { data: wolEnabledData, isFetched: wolEnabledDataIsFetched } = useQueryAPI({
+ endpoint: 'api/wolEnabled',
+ });
const [wolClients, setWolClients] = useState([]);
-
+ const [enabled, setEnabled] = useState(0);
const { mutateAsync } = useMutationAPI();
const [categories, setCategories] = useState([{ value: 'All', label: 'All' }]);
const [selectedClient, setSelectedClient] = useState(wolClientData?.[0]);
@@ -67,6 +70,11 @@ function SettingsButton() {
}
}, [wolClientData, wolClientDataIsFetched]);
+ useEffect(() => {
+ if (wolEnabledData && wolEnabledDataIsFetched) {
+ setEnabled(wolEnabledData[0].enableWol);
+ }
+ }, [wolEnabledData, wolEnabledDataIsFetched]);
return (