aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/web/src/components/System/Shares/Share.js25
-rw-r--r--src/web/src/components/System/Shares/index.js82
2 files changed, 107 insertions, 0 deletions
diff --git a/src/web/src/components/System/Shares/Share.js b/src/web/src/components/System/Shares/Share.js
new file mode 100644
index 00000000..eadcd07b
--- /dev/null
+++ b/src/web/src/components/System/Shares/Share.js
@@ -0,0 +1,25 @@
+import React from 'react';
+
+import {
+ Item,
+} from 'semantic-ui-react';
+
+const Share = ({ share = {}, onBrowse } = {}) => {
+ const { id, remotePath, localPath, mask, alias, isExcluded } = share;
+
+ return (
+ <Item>
+ <Item.Content>
+ <Item.Header as='a' onClick={onBrowse}>{remotePath}</Item.Header>
+ <Item.Meta>Description</Item.Meta>
+ <Item.Description>
+ <pre>
+ {JSON.stringify({ id, localPath, mask, alias, isExcluded }, null, 2)}
+ </pre>
+ </Item.Description>
+ </Item.Content>
+ </Item>
+ );
+};
+
+export default Share; \ No newline at end of file
diff --git a/src/web/src/components/System/Shares/index.js b/src/web/src/components/System/Shares/index.js
new file mode 100644
index 00000000..5f3ae971
--- /dev/null
+++ b/src/web/src/components/System/Shares/index.js
@@ -0,0 +1,82 @@
+import React, { useState, useEffect } from 'react';
+import { toast } from 'react-toastify';
+
+import * as sharesLib from '../../../lib/shares';
+import { LoaderSegment } from '../../Shared';
+import Share from './Share';
+
+import {
+ Modal,
+ Button,
+} from 'semantic-ui-react';
+
+const Index = () => {
+ const [loading, setLoading] = useState(true);
+ const [shares, setShares] = useState([]);
+ const [everything, setEverything] = useState();
+ const [modal, setModal] = useState(false);
+
+ useEffect(() => {
+ getAll();
+ }, []);
+
+ const getAll = async () => {
+ try {
+ setLoading(true);
+ setShares(await sharesLib.getAll());
+ setLoading(false);
+ } catch (error) {
+ console.error(error);
+ toast.error(error?.response?.data ?? error?.message ?? error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const browse = async ({ id }) => {
+ setEverything(await sharesLib.browse({ id }));
+ setModal(true);
+ };
+
+ if (loading) {
+ return LoaderSegment;
+ }
+
+ return (
+ <>
+ <div className='view-code-container'>
+ <ol>
+ {shares.map(share => (
+ <Share share={share} onBrowse={() => browse({ id: share.id })}/>
+ ))}
+ </ol>
+ <pre>
+ {JSON.stringify(everything, null, 2)}
+ </pre>
+ </div>
+ <Modal
+ size='large'
+ open={modal}
+ onClose={() => setModal(false)}
+ style={{ color: 'red' }}
+ >
+ <Modal.Header>Delete Your Account</Modal.Header>
+ <Modal.Content scrolling>
+ <pre>
+ {JSON.stringify(everything, null, 2)}
+ </pre>
+ </Modal.Content>
+ <Modal.Actions>
+ <Button negative onClick={() => setModal(false)}>
+ No
+ </Button>
+ <Button positive onClick={() => setModal(false)}>
+ Yes
+ </Button>
+ </Modal.Actions>
+ </Modal>
+ </>
+ );
+};
+
+export default Index; \ No newline at end of file