diff --git a/src/pages/api/modules/dashdot/info.ts b/src/pages/api/modules/dashdot/info.ts index 1f7b178a0..83f8cc341 100644 --- a/src/pages/api/modules/dashdot/info.ts +++ b/src/pages/api/modules/dashdot/info.ts @@ -44,6 +44,7 @@ async function Get(req: NextApiRequest, res: NextApiResponse) { ? dashDotUrl.substring(0, dashDotUrl.length - 1) : dashDotUrl; const response = await axios.get(`${url}/info`); + // Return the response return res.status(200).json(response.data); } diff --git a/src/widgets/dashDot/DashDotCompactNetwork.tsx b/src/widgets/dashDot/DashDotCompactNetwork.tsx index c283a6d14..815b136b7 100644 --- a/src/widgets/dashDot/DashDotCompactNetwork.tsx +++ b/src/widgets/dashDot/DashDotCompactNetwork.tsx @@ -9,8 +9,9 @@ interface DashDotCompactNetworkProps { export interface DashDotInfo { storage: { - layout: { size: number }[]; - }; + size: number; + disks: { device: string; brand: string; type: string }[]; + }[]; network: { speedUp: number; speedDown: number; diff --git a/src/widgets/dashDot/DashDotCompactStorage.tsx b/src/widgets/dashDot/DashDotCompactStorage.tsx index 319ffe10c..5b3c7cdfe 100644 --- a/src/widgets/dashDot/DashDotCompactStorage.tsx +++ b/src/widgets/dashDot/DashDotCompactStorage.tsx @@ -17,11 +17,10 @@ export const DashDotCompactStorage = ({ info, widgetId }: DashDotCompactStorageP const { data: storageLoad } = useDashDotStorage(widgetId); const totalUsed = calculateTotalLayoutSize({ - layout: storageLoad?.layout ?? [], - key: 'load', + layout: storageLoad ?? [], }); const totalSize = calculateTotalLayoutSize({ - layout: info?.storage?.layout ?? [], + layout: info?.storage ?? [], key: 'size', }); @@ -44,11 +43,16 @@ const calculateTotalLayoutSize = ({ layout, key, }: CalculateTotalLayoutSizeProps) => - layout.reduce((total, current) => total + (current[key] as number), 0); + layout.reduce((total, current) => { + if (key) { + return total + (current[key] as number); + } + return total + (current as number); + }, 0); interface CalculateTotalLayoutSizeProps { layout: TLayoutItem[]; - key: keyof TLayoutItem; + key?: keyof TLayoutItem; } const useDashDotStorage = (widgetId: string) => { @@ -71,9 +75,5 @@ async function fetchDashDotStorageLoad(configName: string | undefined, widgetId: if (!configName) throw new Error('configName is undefined'); return (await ( await axios.get('/api/modules/dashdot/storage', { params: { configName, widgetId } }) - ).data) as DashDotStorageLoad; -} - -interface DashDotStorageLoad { - layout: { load: number }[]; + ).data) as number[]; }