aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-05-25 23:30:16 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-05-25 23:30:16 -0500
commitb34d1d9dfbe379d2f1397b0d2503ec73c4fd9a0d (patch)
treefcd96a4e82c12b059c9d69e89deea7f89d1c58e1 /src/web
parent378df649f87732a3adaae3b0402ff71360c8a969 (diff)
downloadslskd-b34d1d9dfbe379d2f1397b0d2503ec73c4fd9a0d.tar.gz
rough in Share components
Diffstat (limited to 'src/web')
-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