This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/packages/siaviewnode-client/pages/index.tsx

111 lines
3.1 KiB
TypeScript
Raw Normal View History

2019-12-03 21:08:23 +00:00
/** @jsx jsx */
2020-01-28 12:43:05 +00:00
import { AppBar, Button, Card, CardContent, Container, Input, Link, Tab, Tabs, Typography } from "@material-ui/core";
import * as R from "ramda";
import { useState } from "react";
import { Box, Flex, jsx } from "theme-ui";
import Dropzone from "../src/components/Dropzone";
import { TabPanel } from "../src/components/TabPanel";
2019-12-03 21:08:23 +00:00
const Index = () => {
2019-12-20 18:11:54 +00:00
const [value, setValue] = useState(1)
const [linkfileUrl, setInput] = useState("")
2019-12-20 17:01:28 +00:00
const handleChange = (event, newValue) => {
setValue(newValue)
}
2019-12-20 18:11:54 +00:00
const directView = () => {
2020-01-23 19:38:31 +00:00
const removeHead = R.compose(R.tail, R.split("sia://"))
const hash = removeHead(linkfileUrl)[0]
2019-12-20 18:11:54 +00:00
if (window) {
2020-01-28 11:35:39 +00:00
var win = window.open(`/${hash}`, "_blank")
2019-12-20 18:11:54 +00:00
win.focus()
}
}
2019-12-03 21:08:23 +00:00
return (
<>
<Box color="white">
<Container>
<Flex sx={{ alignItems: "center", height: 120 }}>
<Box>
2020-01-28 12:43:05 +00:00
<Typography sx={{ fontWeight: 700 }}>
<Link href="/">
Sia Skynet
</Link>
</Typography>
2019-12-03 21:08:23 +00:00
</Box>
<Box sx={{ ml: "auto" }}>
<Button href="/stats">
Statistics
</Button>
2019-12-03 21:08:23 +00:00
<Button href="https://sia.tech/" target="_blank">
About Sia
</Button>
</Box>
</Flex>
</Container>
</Box>
2019-12-20 17:01:28 +00:00
<Box>
<Container>
<AppBar position="static">
<Tabs
value={value}
onChange={handleChange}
aria-label="simple tabs example"
2019-12-03 21:08:23 +00:00
>
2019-12-20 17:01:28 +00:00
<Tab label="Upload" />
<Tab label="Download" />
</Tabs>
</AppBar>
</Container>
</Box>
<Container>
<TabPanel value={value} index={0}>
<Card sx={{ width: "100%" }}>
<CardContent>
<Dropzone />
</CardContent>
</Card>
</TabPanel>
</Container>
<Container>
<TabPanel value={value} index={1}>
<Card sx={{ width: "100%" }}>
2019-12-20 18:11:54 +00:00
<CardContent>
<Flex
sx={{
height: 400,
justifyContent: "center",
alignItems: "center",
flexDirection: "column"
}}
>
<p>Download a file by pasting in a Sia linkfile below:</p>
<Box sx={{ width: "60%" }}>
<Input
2020-01-23 19:38:31 +00:00
placeholder="sia://"
2019-12-20 18:11:54 +00:00
value={linkfileUrl}
onChange={e => setInput(e.target.value)}
sx={{ width: "100%" }}
/>
</Box>
<Box sx={{ mt: 3 }}>
<Button
variant="contained"
color="primary"
onClick={directView}
>
Download
</Button>
</Box>
</Flex>
</CardContent>
2019-12-20 17:01:28 +00:00
</Card>
</TabPanel>
2019-12-03 21:08:23 +00:00
</Container>
</>
)
}
export default Index