From 573391fa9603d8cb79da71c2d3c005d4bb199729 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 3 Nov 2022 19:20:20 -0500 Subject: display share host --- src/web/src/components/System/Shares/ShareTable.js | 2 ++ src/web/src/components/System/Shares/index.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/web/src/components/System/Shares/ShareTable.js b/src/web/src/components/System/Shares/ShareTable.js index d264fc8f..095a8380 100644 --- a/src/web/src/components/System/Shares/ShareTable.js +++ b/src/web/src/components/System/Shares/ShareTable.js @@ -13,6 +13,7 @@ const ShareTable = ({ shares, onClick }) => { + Host Local Path Directories Files @@ -29,6 +30,7 @@ const ShareTable = ({ shares, onClick }) => { } > {shares.map((share, index) => ( + {share.host} onClick(share)}> {share.localPath} diff --git a/src/web/src/components/System/Shares/index.js b/src/web/src/components/System/Shares/index.js index 6759ad6f..0d93a6a3 100644 --- a/src/web/src/components/System/Shares/index.js +++ b/src/web/src/components/System/Shares/index.js @@ -1,5 +1,6 @@ import React, { useState, useEffect } from 'react'; import { toast } from 'react-toastify'; +import { flatten } from 'lodash'; import * as sharesLib from '../../../lib/shares'; import { @@ -39,7 +40,13 @@ const Index = ({ state = {} } = {}) => { const getAll = async () => { try { setLoading(true); - setShares(await sharesLib.getAll()); + + const sharesByHost = await sharesLib.getAll(); + const flattened = Object.entries(sharesByHost).reduce((acc, [host, shares]) => { + return acc.concat(shares.map(share => ({ host, ...share }))); + }, []); + + setShares(flattened); } catch (error) { console.error(error); toast.error(error?.response?.data ?? error?.message ?? error); -- cgit v1.2.3