diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 983c42f4..25371648 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -270,7 +270,7 @@ pub async fn all_locations( instance_id: i64, app_state: State<'_, AppState>, ) -> Result, String> { - debug!("Retrieving all locations"); + debug!("Retrieving all locations."); let locations = Location::find_by_instance_id(&app_state.get_pool(), instance_id) .await .map_err(|err| err.to_string())?; @@ -345,7 +345,7 @@ pub async fn update_instance( } } transaction.commit().await.map_err(|err| err.to_string())?; - info!("Updated instance with id: {}.", instance_id); + debug!("Updated instance with id: {}.", instance_id); Ok(()) } else { Err("Instance not found".into()) diff --git a/src/pages/client/components/LocationsList/LocationsList.tsx b/src/pages/client/components/LocationsList/LocationsList.tsx index c1066c29..90d94836 100644 --- a/src/pages/client/components/LocationsList/LocationsList.tsx +++ b/src/pages/client/components/LocationsList/LocationsList.tsx @@ -1,7 +1,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'; import { listen, UnlistenFn } from '@tauri-apps/api/event'; import { useEffect } from 'react'; -import { debug } from 'tauri-plugin-log-api'; +import { debug, error } from 'tauri-plugin-log-api'; import { clientApi } from '../../clientAPI/clientApi'; import { useClientStore } from '../../hooks/useClientStore'; @@ -23,6 +23,7 @@ export const LocationsList = ({ layoutType }: Props) => { queryKey: [clientQueryKeys.getLocations, selectedInstance as number], queryFn: () => getLocations({ instanceId: selectedInstance as number }), enabled: !!selectedInstance, + onError: (e) => error(`Error retrieving locations: ${String(e)}`), }); // listen to connection changes diff --git a/src/pages/client/components/LocationsList/components/LocationCardConnectButton/LocationCardConnectButton.tsx b/src/pages/client/components/LocationsList/components/LocationCardConnectButton/LocationCardConnectButton.tsx index 61c75a7e..83473abc 100644 --- a/src/pages/client/components/LocationsList/components/LocationCardConnectButton/LocationCardConnectButton.tsx +++ b/src/pages/client/components/LocationsList/components/LocationCardConnectButton/LocationCardConnectButton.tsx @@ -2,6 +2,7 @@ import './style.scss'; import classNames from 'classnames'; import { useState } from 'react'; +import { error } from 'tauri-plugin-log-api'; import { useI18nContext } from '../../../../../../i18n/i18n-react'; import SvgIconCheckmarkSmall from '../../../../../../shared/components/svg/IconCheckmarkSmall'; @@ -44,6 +45,7 @@ export const LocationCardConnectButton = ({ location }: Props) => { } catch (e) { setIsLoading(false); toaster.error(LL.common.messages.error()); + error(`Error handling interface: ${e}`); console.error(e); } }; diff --git a/src/pages/client/components/LocationsList/components/LocationsDetailView/LocationsDetailView.tsx b/src/pages/client/components/LocationsList/components/LocationsDetailView/LocationsDetailView.tsx index c261de23..09ef250a 100644 --- a/src/pages/client/components/LocationsList/components/LocationsDetailView/LocationsDetailView.tsx +++ b/src/pages/client/components/LocationsList/components/LocationsDetailView/LocationsDetailView.tsx @@ -2,6 +2,7 @@ import './style.scss'; import { useQuery } from '@tanstack/react-query'; import { useMemo, useState } from 'react'; +import { error } from 'tauri-plugin-log-api'; import { Card } from '../../../../../../shared/defguard-ui/components/Layout/Card/Card'; import { CardTabs } from '../../../../../../shared/defguard-ui/components/Layout/CardTabs/CardTabs'; @@ -34,17 +35,26 @@ export const LocationsDetailView = ({ locations }: Props) => { queryKey: [clientQueryKeys.getLocationStats, activeLocationId as number], queryFn: () => getLocationStats({ locationId: activeLocationId as number }), enabled: !!activeLocationId, + onError: (e) => { + error(`Error retrieving location stats: ${e}`); + }, }); const { data: connectionHistory } = useQuery({ queryKey: [clientQueryKeys.getConnectionHistory, activeLocationId as number], queryFn: () => getConnectionHistory({ locationId: activeLocationId as number }), enabled: !!activeLocationId, + onError: (e) => { + error(`Error retrieving connection history: ${e}`); + }, }); const { data: lastConnection } = useQuery({ queryKey: [clientQueryKeys.getConnections, activeLocationId as number], queryFn: () => getLastConnection({ locationId: activeLocationId as number }), enabled: !!activeLocationId, + onError: (e) => { + error(`Error retrieving last connection: ${e}`); + }, }); const tabs = useMemo( diff --git a/src/pages/client/components/LocationsList/components/LocationsGridView/LocationsGridView.tsx b/src/pages/client/components/LocationsList/components/LocationsGridView/LocationsGridView.tsx index deaec417..0ff4f974 100644 --- a/src/pages/client/components/LocationsList/components/LocationsGridView/LocationsGridView.tsx +++ b/src/pages/client/components/LocationsList/components/LocationsGridView/LocationsGridView.tsx @@ -2,6 +2,7 @@ import './style.scss'; import { useQuery } from '@tanstack/react-query'; import classNames from 'classnames'; +import { error } from 'tauri-plugin-log-api'; import { useI18nContext } from '../../../../../../i18n/i18n-react'; import { Card } from '../../../../../../shared/defguard-ui/components/Layout/Card/Card'; @@ -47,11 +48,17 @@ const GridItem = ({ location }: GridItemProps) => { queryKey: [clientQueryKeys.getConnections, location.id as number], queryFn: () => getLastConnection({ locationId: location.id as number }), enabled: !!location.id, + onError: (e) => { + error(`Error retrieving last connection: ${String(e)}`); + }, }); const { data: locationStats } = useQuery({ queryKey: [clientQueryKeys.getLocationStats, location.id as number], queryFn: () => getLocationStats({ locationId: location.id as number }), enabled: !!location.id, + onError: (e) => { + error(`Error retrieving location stats: ${String(e)}`); + }, }); return ( diff --git a/src/pages/enrollment/steps/DeviceStep/components/DesktopSetup/DesktopSetup.tsx b/src/pages/enrollment/steps/DeviceStep/components/DesktopSetup/DesktopSetup.tsx index cbdd09c2..0f3c443c 100644 --- a/src/pages/enrollment/steps/DeviceStep/components/DesktopSetup/DesktopSetup.tsx +++ b/src/pages/enrollment/steps/DeviceStep/components/DesktopSetup/DesktopSetup.tsx @@ -6,6 +6,7 @@ import { invoke } from '@tauri-apps/api/tauri'; import { isUndefined } from 'lodash-es'; import { useMemo, useState } from 'react'; import { SubmitHandler, useForm } from 'react-hook-form'; +import { error } from 'tauri-plugin-log-api'; import { z } from 'zod'; import { useI18nContext } from '../../../../../../i18n/i18n-react'; @@ -57,13 +58,16 @@ export const DekstopSetup = () => { onError: (e) => { toaster.error(LL.common.messages.error()); console.error(e); + error(String(e)); }, }); const { isLoading: loadingCreateDevice, mutateAsync: createDeviceMutation } = useMutation({ mutationFn: createDevice, - onError: () => {}, + onError: (e) => { + error(String(e)); + }, }); const schema = useMemo( @@ -104,6 +108,7 @@ export const DekstopSetup = () => { .catch((e) => { setIsLoading(false); console.error(e); + error(e); }); }); };