From 5c355cfdaf17f98af2d9b672b96fbdfd1ae97589 Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Wed, 15 Jun 2022 21:10:00 +0200 Subject: [PATCH] delete website (move to another repository) --- .github/workflows/build-release-binaries.yml | 8 +- .github/workflows/rust.yml | 38 +---- .github/workflows/website.yml | 70 -------- README.md | 40 ++--- website/.editorconfig | 12 -- website/.eslintrc.json | 18 -- website/.gitignore | 34 ---- website/api_utils/axios.ts | 8 - website/api_utils/create-directory.ts | 34 ---- website/api_utils/index.ts | 9 - website/api_utils/list.ts | 34 ---- website/api_utils/login.ts | 32 ---- website/api_utils/register.ts | 32 ---- website/api_utils/upload.ts | 32 ---- website/components/auth/button.tsx | 9 - website/components/auth/error.tsx | 7 - website/components/auth/title.tsx | 35 ---- website/components/container.tsx | 14 -- website/components/footer.tsx | 33 ---- website/components/header.tsx | 45 ----- website/components/home/cards.tsx | 49 ------ website/components/home/description.tsx | 9 - website/components/home/grid.tsx | 11 -- website/components/home/title.tsx | 34 ---- website/components/main.tsx | 11 -- website/components/other/icon-div.tsx | 8 - website/components/other/icon.tsx | 9 - .../components/user/modals/create-folder.tsx | 71 -------- website/components/user/modals/style.tsx | 14 -- website/components/user/modals/upload.tsx | 93 ---------- website/components/user/table.tsx | 37 ---- website/config.ts | 8 - website/next-env.d.ts | 5 - website/next.config.js | 10 -- website/pages/404.tsx | 56 ------ website/pages/500.tsx | 56 ------ website/pages/_app.tsx | 136 --------------- website/pages/_document.tsx | 32 ---- website/pages/index.tsx | 80 --------- website/pages/login.tsx | 97 ----------- website/pages/register.tsx | 97 ----------- website/pages/user/files.tsx | 161 ------------------ website/tsconfig.json | 20 --- website/types/theme.ts | 23 --- 44 files changed, 15 insertions(+), 1656 deletions(-) delete mode 100644 .github/workflows/website.yml delete mode 100644 website/.editorconfig delete mode 100644 website/.eslintrc.json delete mode 100644 website/.gitignore delete mode 100644 website/api_utils/axios.ts delete mode 100644 website/api_utils/create-directory.ts delete mode 100644 website/api_utils/index.ts delete mode 100644 website/api_utils/list.ts delete mode 100644 website/api_utils/login.ts delete mode 100644 website/api_utils/register.ts delete mode 100644 website/api_utils/upload.ts delete mode 100644 website/components/auth/button.tsx delete mode 100644 website/components/auth/error.tsx delete mode 100644 website/components/auth/title.tsx delete mode 100644 website/components/container.tsx delete mode 100644 website/components/footer.tsx delete mode 100644 website/components/header.tsx delete mode 100644 website/components/home/cards.tsx delete mode 100644 website/components/home/description.tsx delete mode 100644 website/components/home/grid.tsx delete mode 100644 website/components/home/title.tsx delete mode 100644 website/components/main.tsx delete mode 100644 website/components/other/icon-div.tsx delete mode 100644 website/components/other/icon.tsx delete mode 100644 website/components/user/modals/create-folder.tsx delete mode 100644 website/components/user/modals/style.tsx delete mode 100644 website/components/user/modals/upload.tsx delete mode 100644 website/components/user/table.tsx delete mode 100644 website/config.ts delete mode 100644 website/next-env.d.ts delete mode 100644 website/next.config.js delete mode 100644 website/pages/404.tsx delete mode 100644 website/pages/500.tsx delete mode 100644 website/pages/_app.tsx delete mode 100644 website/pages/_document.tsx delete mode 100644 website/pages/index.tsx delete mode 100644 website/pages/login.tsx delete mode 100644 website/pages/register.tsx delete mode 100644 website/pages/user/files.tsx delete mode 100644 website/tsconfig.json delete mode 100644 website/types/theme.ts diff --git a/.github/workflows/build-release-binaries.yml b/.github/workflows/build-release-binaries.yml index ccbcc65..f70fb01 100644 --- a/.github/workflows/build-release-binaries.yml +++ b/.github/workflows/build-release-binaries.yml @@ -2,14 +2,10 @@ name: Build release binaries (and publish them if this is a tag) on: push: - paths: - - '**' - - '!website/**' + branches: + - main # pull_request: - # paths: - # - '**' - # - '!website/**' workflow_dispatch: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 103d9c0..8e91dec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,14 +4,8 @@ on: push: branches: - main - paths: - - '**' - - '!website/**' pull_request: - paths: - - '**' - - '!website/**' workflow_dispatch: @@ -49,7 +43,7 @@ jobs: path: | ~/.cargo/registry/cache/ target/ - key: build-${{ runner.os }}-${{ matrix.rust }}-rust-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-${{ matrix.rust }}-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} - name: cargo build uses: actions-rs/cargo@v1 @@ -62,36 +56,6 @@ jobs: command: clippy args: --no-deps -- -D warnings - test: - strategy: - fail-fast: false - matrix: - rust: [stable, nightly] - - name: ${{ matrix.rust }} test - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Rust toolchain - id: rust-toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - - name: Cache - uses: actions/cache@v3 - id: cache - with: - path: | - ~/.cargo/registry/cache/ - target/ - key: test-${{ runner.os }}-${{ matrix.rust }}-rust-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }} - - name: cargo test uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml deleted file mode 100644 index bb3bb8f..0000000 --- a/.github/workflows/website.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Website - -on: - push: - branches: - - main - paths: - - 'website/**' - - pull_request: - paths: - - 'website/**' - - workflow_dispatch: - -jobs: - build: - name: Next.js Build - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - - - name: Install pnpm - uses: pnpm/action-setup@v2 - id: pnpm-install - with: - version: 7 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - run: | - echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - - - name: Cache pnpm - uses: actions/cache@v3 - with: - path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('website/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Cache Next.js - uses: actions/cache@v3 - with: - path: | - ${{ github.workspace }}/website/.next/cache - key: ${{ runner.os }}-nextjs-${{ hashFiles('website/pnpm-lock.yaml') }}-${{ hashFiles('website/**.[jt]s', 'website/**.[jt]sx') }} - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('website/pnpm-lock.yaml') }}- - - - name: Install dependencies - run: pnpm install --prefix website - - - name: Build page - run: pnpm --prefix website run build - - - name: Export page - run: pnpm --prefix website run export - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: website-static - path: website/out/** diff --git a/README.md b/README.md index 0bc9e7a..74190d1 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,31 @@ # HomeDisk cloud server -[![docs-rs]](https://homedisk-doc.vercel.app) -[![total-lines]](https://github.com/MedzikUser/HomeDisk) -[![code-size]](https://github.com/MedzikUser/HomeDisk) -[![CI]](https://github.com/MedzikUser/HomeDisk/actions/workflows/rust.yml) - [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs [total-lines]: https://img.shields.io/tokei/lines/github/MedzikUser/HomeDisk?style=for-the-badge&logo=github&color=fede00 [code-size]: https://img.shields.io/github/languages/code-size/MedzikUser/HomeDisk?style=for-the-badge&color=c8df52&logo=github [CI]: https://img.shields.io/github/workflow/status/MedzikUser/rust-crypto-utils/Rust/main?style=for-the-badge -![](https://i.imgur.com/fOtiSf7.png) +[home-screenshot]: https://cdn.medzik.xyz/fz4QGfS.png +[login-screenshot]: https://cdn.medzik.xyz/vo10bes.png -![](https://i.imgur.com/vLautmq.png) +[![docs-rs]](https://homedisk-doc.vercel.app) +[![total-lines]](https://github.com/MedzikUser/HomeDisk) +[![code-size]](https://github.com/MedzikUser/HomeDisk) +[![CI]](https://github.com/MedzikUser/HomeDisk/actions/workflows/rust.yml) + +![home-screenshot] +![login-screenshot] ## 👨‍💻 Building -First clone the repository: `git clone git@github.com:MedzikUser/HomeDisk.git` +First clone the repository: `git clone https://github.com/MedzikUser/HomeDisk.git` -### Server - -#### Requirements +### Requirements - Rust To build run the command: `cargo build --release` -The compiled binary can be found in `./target/release/cloud` - -### Website - -#### Requirements -- Node.js -- pnpm - -Run these commands to build: - -- Go to directory `./website` -- Install dependencies: `pnpm install` -- Build website: `pnpm run build` -- Export website to static HTML files: `pnpm run export` (Optional) - -If you exported the page to HTML files, they are located in the `./out` directory, -if not, you can start the site with `pnpm run start` +The compiled binary can be found in `./target/release/homedisk` ## 🖴 Creating tables in a SQLite database diff --git a/website/.editorconfig b/website/.editorconfig deleted file mode 100644 index ad4c311..0000000 --- a/website/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# top-most EditorConfig file -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = false diff --git a/website/.eslintrc.json b/website/.eslintrc.json deleted file mode 100644 index 265d318..0000000 --- a/website/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": [ - "eslint:recommended", - "next/core-web-vitals" - ], - "rules": { - "semi": [ - "warn", - "never" - ], - "no-unused-vars": [ - "warn" - ], - "no-unused-expressions": [ - "warn" - ] - } -} diff --git a/website/.gitignore b/website/.gitignore deleted file mode 100644 index 1437c53..0000000 --- a/website/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel diff --git a/website/api_utils/axios.ts b/website/api_utils/axios.ts deleted file mode 100644 index ce1b808..0000000 --- a/website/api_utils/axios.ts +++ /dev/null @@ -1,8 +0,0 @@ -import axios from "axios" -import config from "../config" - -const instance = axios.create({ - baseURL: config.apiUrl, -}) - -export default instance diff --git a/website/api_utils/create-directory.ts b/website/api_utils/create-directory.ts deleted file mode 100644 index 7278bfe..0000000 --- a/website/api_utils/create-directory.ts +++ /dev/null @@ -1,34 +0,0 @@ -import axios from './axios' - -export default async function createDir(path: string, token: string): Promise { - const request = axios.post("/fs/createdir", { - path - }, { - headers: { - Authorization: `Bearer ${token}`, - } - }) - - const response = request - .then(response => { - const { data } = response - return data - }) - .catch(err => { - if (err.response?.data?.error_message) { - const error = err.response.data.error_message - - if (error.toString() == "[object Object]") { - Object.keys(error).forEach(key => { - throw new Error(key) - }) - } - - throw new Error(error) - } - - throw new Error(err) - }) - - return response -} diff --git a/website/api_utils/index.ts b/website/api_utils/index.ts deleted file mode 100644 index 551f66d..0000000 --- a/website/api_utils/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import list from "./list" -import login from "./login" -import register from "./register" -import upload from "./upload" -import createDir from "./create-directory" - -const api = { list, login, register, upload, createDir } - -export default api diff --git a/website/api_utils/list.ts b/website/api_utils/list.ts deleted file mode 100644 index 8f7de65..0000000 --- a/website/api_utils/list.ts +++ /dev/null @@ -1,34 +0,0 @@ -import axios from './axios' - -export default async function list(path: string, token: string): Promise { - const request = axios.post("/fs/list", { - path - }, { - headers: { - Authorization: `Bearer ${token}`, - } - }) - - const response = request - .then(response => { - const { data } = response - return data - }) - .catch(err => { - if (err.response?.data?.error_message) { - const error = err.response.data.error_message - - if (error.toString() == "[object Object]") { - Object.keys(error).forEach(key => { - throw new Error(key) - }) - } - - throw new Error(error) - } - - throw new Error(err) - }) - - return response -} diff --git a/website/api_utils/login.ts b/website/api_utils/login.ts deleted file mode 100644 index a751116..0000000 --- a/website/api_utils/login.ts +++ /dev/null @@ -1,32 +0,0 @@ -import axios from './axios' - -export default async function login(username: string, password: string): Promise { - const request = axios.post("/auth/login", { - username, - password, - }) - - const response = request - .then(response => { - const { data } = response - - return data.LoggedIn.access_token - }) - .catch(err => { - if (err.response?.data?.error_message) { - const error = err.response.data.error_message - - if (error.toString() == "[object Object]") { - Object.keys(error).forEach(key => { - throw new Error(key) - }) - } - - throw new Error(error) - } - - throw new Error(err) - }) - - return response -} diff --git a/website/api_utils/register.ts b/website/api_utils/register.ts deleted file mode 100644 index e37dd0d..0000000 --- a/website/api_utils/register.ts +++ /dev/null @@ -1,32 +0,0 @@ -import axios from './axios' - -export default async function register(username: string, password: string): Promise { - const request = axios.post("/auth/register", { - username, - password, - }) - - const response = request - .then(response => { - const { data } = response - - return data.LoggedIn.access_token - }) - .catch(err => { - if (err.response?.data?.error_message) { - const error = err.response.data.error_message - - if (error.toString() == "[object Object]") { - Object.keys(error).forEach(key => { - throw new Error(key) - }) - } - - throw new Error(error) - } - - throw new Error(err) - }) - - return response -} diff --git a/website/api_utils/upload.ts b/website/api_utils/upload.ts deleted file mode 100644 index 0b9a744..0000000 --- a/website/api_utils/upload.ts +++ /dev/null @@ -1,32 +0,0 @@ -import axios from './axios' - -export default async function list(path: string, formData: FormData, token: string): Promise { - const request = axios.post(`/fs/upload?path=${path}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - } - }) - - const response = request - .then(response => { - const { data } = response - return data - }) - .catch(err => { - if (err.response?.data?.error_message) { - const error = err.response.data.error_message - - if (error.toString() == "[object Object]") { - Object.keys(error).forEach(key => { - throw new Error(key) - }) - } - - throw new Error(error) - } - - throw new Error(err) - }) - - return response -} diff --git a/website/components/auth/button.tsx b/website/components/auth/button.tsx deleted file mode 100644 index 0b1bfe8..0000000 --- a/website/components/auth/button.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { Button } from "@mui/material" -import styled from "styled-components" - -const SubmitButton = styled(Button)` - margin-top: 1rem; - align-content: "center"; -` - -export default SubmitButton diff --git a/website/components/auth/error.tsx b/website/components/auth/error.tsx deleted file mode 100644 index 278cfa9..0000000 --- a/website/components/auth/error.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import styled from "styled-components" - -const ErrorComponent = styled.div` - color: ${({ theme }) => theme.colors.error}; -` - -export default ErrorComponent diff --git a/website/components/auth/title.tsx b/website/components/auth/title.tsx deleted file mode 100644 index 1a58120..0000000 --- a/website/components/auth/title.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import styled from "styled-components" - -const Title = styled.h1` - margin: 0; - line-height: 1.15; - font-size: 2rem; - text-align: center; - margin-bottom: 1rem; - - a { - color: ${({ theme }) => theme.pages.index.title.a}; - text-decoration: none; - animation: animate 1.5s linear infinite; - } - - @keyframes animate { - 0% { - opacity: 0; - } - 50% { - opacity: 1; - } - 100% { - opacity: 0; - } - } - - a:hover, - a:focus, - a:active { - text-decoration: underline; - } -` - -export default Title diff --git a/website/components/container.tsx b/website/components/container.tsx deleted file mode 100644 index ebd4b96..0000000 --- a/website/components/container.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import styled from 'styled-components' - -const Container = styled.div` - height: 100%; - min-height: 100vh; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - background-color: ${({ theme }) => theme.colors.background}; - color: ${({ theme }) => theme.colors.color}; -` - -export default Container diff --git a/website/components/footer.tsx b/website/components/footer.tsx deleted file mode 100644 index eecdc06..0000000 --- a/website/components/footer.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { GitHub } from "@mui/icons-material" -import { IconButton } from "@mui/material" -import styled from "styled-components" -import { links } from "../config" - -const StyledFooter = styled.footer` - width: 100%; - height: 100px; - border-top: 1px solid ${({ theme }) => theme.footer.borderTop}; - display: flex; - justify-content: center; - align-items: center; - background-color: ${({ theme }) => theme.colors.background}; - color: ${({ theme }) => theme.colors.color}; - - a { - display: flex; - justify-content: center; - align-items: cente; - } -` - -export default function Footer() { - return ( - - - - - - - - ) -} diff --git a/website/components/header.tsx b/website/components/header.tsx deleted file mode 100644 index edaf63c..0000000 --- a/website/components/header.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { faMoon, faSignOut, faSun } from "@fortawesome/free-solid-svg-icons" -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import { RocketLaunch } from "@mui/icons-material" -import { AppBar, IconButton, Link, Stack, Toolbar, Typography } from "@mui/material" - -export default function Footer({ toggleTheme, theme}: Props) { - return ( - - - - - - - - - - HomeDisk - - - - toggleTheme()}> - - - - - - - - - - ) -} - -type Props = { - toggleTheme: () => any, - theme: string -} diff --git a/website/components/home/cards.tsx b/website/components/home/cards.tsx deleted file mode 100644 index 806a042..0000000 --- a/website/components/home/cards.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import styled from "styled-components" - -const Card = styled.div` - margin: 1rem; - padding: 1.5rem; - text-align: left; - color: inherit; - text-decoration: none; - border: 1px solid #eaeaea; - border-radius: 10px; - transition: color 0.15s ease, border-color 0.15s ease; - max-width: 300px; - - :hover, - :focus, - :active { - color: #0070f3; - border-color: #0070f3; - } - - h2 { - margin: 0 0 1rem 0; - font-size: 1.5rem; - } - - p { - margin: 0; - font-size: 1.25rem; - line-height: 1.5; - } -` - -const CardSignIn = styled.a` - color: ${({ theme }) => theme.pages.index.cards.signin}; -` - -const CardRegister = styled.a` - color: ${({ theme }) => theme.pages.index.cards.register}; -` - -const CardFiles = styled.a` - color: ${({ theme }) => theme.pages.index.cards.files}; -` - -const CardSettings = styled.a` - color: ${({ theme }) => theme.pages.index.cards.settings}; -` - -export { Card, CardSignIn, CardRegister, CardFiles, CardSettings } diff --git a/website/components/home/description.tsx b/website/components/home/description.tsx deleted file mode 100644 index 9b3a7c7..0000000 --- a/website/components/home/description.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import styled from "styled-components" - -const Description = styled.p` - line-height: 1.5; - font-size: 1.5rem; - text-align: center; -` - -export default Description diff --git a/website/components/home/grid.tsx b/website/components/home/grid.tsx deleted file mode 100644 index 11c2cc8..0000000 --- a/website/components/home/grid.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import styled from "styled-components" - -const Grid = styled.div` - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - max-width: 800px; -` - -export default Grid diff --git a/website/components/home/title.tsx b/website/components/home/title.tsx deleted file mode 100644 index 4fa454b..0000000 --- a/website/components/home/title.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import styled from "styled-components" - -const Title = styled.h1` - margin: 0; - line-height: 1.15; - font-size: 4rem; - text-align: center; - - a { - color: ${({ theme }) => theme.pages.index.title.a}; - text-decoration: none; - animation: animate 1.5s linear infinite; - } - - @keyframes animate { - 0% { - opacity: 0; - } - 50% { - opacity: 1; - } - 100% { - opacity: 0; - } - } - - a:hover, - a:focus, - a:active { - text-decoration: underline; - } -` - -export default Title diff --git a/website/components/main.tsx b/website/components/main.tsx deleted file mode 100644 index 7bc3b77..0000000 --- a/website/components/main.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import styled from 'styled-components' - -const Main = styled.main` - flex: 1; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -` - -export default Main diff --git a/website/components/other/icon-div.tsx b/website/components/other/icon-div.tsx deleted file mode 100644 index 80583c8..0000000 --- a/website/components/other/icon-div.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import styled from "styled-components" - -const IconDiv = styled.div` - padding-right: 5px; - padding-left: 5px; -` - -export default IconDiv diff --git a/website/components/other/icon.tsx b/website/components/other/icon.tsx deleted file mode 100644 index 59f3b9d..0000000 --- a/website/components/other/icon.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import styled from "styled-components" - -const Icon = styled(FontAwesomeIcon)` - padding-right: 5px; - padding-left: 5px; -` - -export default Icon diff --git a/website/components/user/modals/create-folder.tsx b/website/components/user/modals/create-folder.tsx deleted file mode 100644 index 196bd2f..0000000 --- a/website/components/user/modals/create-folder.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { useState } from 'react' -import { Backdrop, Box, Button, Fade, Link, Modal, TextField } from "@mui/material" -import { useCookies } from "react-cookie" -import api from '../../../api_utils' -import style from './style' - -function CreateFolderModal({ open, setOpen, refresh }: Props) { - const [name, setName] = useState("") - - const [cookies] = useCookies(["token"]) - - const handleChange: React.ChangeEventHandler = event => { - const value = event.target.value - setName(value) - } - - // handle click "Enter (Return)" - const handleKeyPress = (event: React.KeyboardEvent) => { - if (event.keyCode === 13 || event.which === 13 || event.charCode === 13) { - handle() - } - } - - const handle = () => { - setOpen(false) - - const request = api.createDir(name, cookies.token) - - request - .then(refresh) - } - - return ( - setOpen(false)} - closeAfterTransition - BackdropComponent={Backdrop} - BackdropProps={{ - timeout: 500, - }} - > - - - - - - - - - - - ) -} - -export type Props = { - open: boolean, - setOpen: React.Dispatch>, - refresh: () => void, -} - -export default CreateFolderModal diff --git a/website/components/user/modals/style.tsx b/website/components/user/modals/style.tsx deleted file mode 100644 index 8ca4c1d..0000000 --- a/website/components/user/modals/style.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const style = { - position: 'absolute' as 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - width: 400, - bgcolor: 'background.paper', - color: 'primary.main', - border: '2px solid #fff', - boxShadow: 24, - p: 4 -} - -export default style diff --git a/website/components/user/modals/upload.tsx b/website/components/user/modals/upload.tsx deleted file mode 100644 index 5ca5ba8..0000000 --- a/website/components/user/modals/upload.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, { useState } from 'react' -import { Backdrop, Box, Button, Fade, Link, Modal } from "@mui/material" -import { useCookies } from "react-cookie" -import { toast } from 'react-toastify' -import api from '../../../api_utils' -import style from './style' - -function UploadModal({ open, setOpen, path, refresh }: Props) { - const [file, setFile]: [FileList | null | undefined, React.Dispatch>] = useState() - - const [cookies] = useCookies(["token"]) - - const onFileChange: React.ChangeEventHandler = event => { - setFile(event.target.files) - console.log(file) - } - - const handleUpload = () => { - const formData = new FormData() - - if (file == null || typeof file == "undefined") { - return - } - - formData.append( - "file", - file[0] - ) - - const filePath = `${path}/${file[0].name}` - - const request = api.upload(filePath, formData, cookies.token) - - toast.promise( - request, - { - pending: 'Uploading file...', - success: { - delay: 500, - render() { - refresh() - setOpen(false) - - return "File uploaded!" - } - }, - error: { - delay: 500, - render(err) { - if (err.data.response?.data?.error_message) { - return err.data.response.data.error_message.toString() - } else { - return err.data.toString() - } - } - } - } - ) - } - - return ( - setOpen(false)} - closeAfterTransition - BackdropComponent={Backdrop} - BackdropProps={{ - timeout: 500, - }} - > - - - - - - - - - - - ) -} - -export type Props = { - open: boolean, - setOpen: React.Dispatch>, - path: string, - refresh: () => void, -} - -export default UploadModal diff --git a/website/components/user/table.tsx b/website/components/user/table.tsx deleted file mode 100644 index 86299dd..0000000 --- a/website/components/user/table.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import styled from "styled-components" - -const Table = styled.table` - border: 1px solid; - width: 80vw; - border-collapse: collapse; - - thead { - background-color: #01754b; - color: white; - } - - tr, - td { - border: 1px solid #000; - padding: 8px; - } - - td:first-child { - width: 50%; - } - - td:last-child { - width: 20%; - } - - - a { - text-decoration: none; - } - - a:hover { - cursor: pointer; - } -` - -export default Table diff --git a/website/config.ts b/website/config.ts deleted file mode 100644 index 32a2eff..0000000 --- a/website/config.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const links = { - github: "https://github.com/HomeDisk/cloud" -} - -export default { - apiUrl: "/api", - links, -} diff --git a/website/next-env.d.ts b/website/next-env.d.ts deleted file mode 100644 index 4f11a03..0000000 --- a/website/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/website/next.config.js b/website/next.config.js deleted file mode 100644 index b398b1b..0000000 --- a/website/next.config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - async rewrites() { - return [ - { - source: '/api/:slug*', - destination: 'http://127.0.0.1:8080/:slug*' - } - ] - } -} diff --git a/website/pages/404.tsx b/website/pages/404.tsx deleted file mode 100644 index a5ef996..0000000 --- a/website/pages/404.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Button } from '@mui/material' -import Head from 'next/head' -import styled from 'styled-components' - -const Title = styled.h1` - margin: 0; - line-height: 1.15; - font-size: 1.5rem; - text-align: center; - - a { - color: ${({ theme }) => theme.pages.index.title.a}; - text-decoration: none; - animation: animate 1.5s linear infinite; - } - - @keyframes animate { - 0% { - opacity: 0; - } - 50% { - opacity: 1; - } - 100% { - opacity: 0; - } - } - - a:hover, - a:focus, - a:active { - text-decoration: underline; - } -` - -const StyledButton = styled(Button)` - margin-top: 1rem; -` - -export default function NotFound() { - return ( - <> - - 404 - HomeDisk - - - - 404 | This page could not be found - - - - Go to Home Page - - - ) -} diff --git a/website/pages/500.tsx b/website/pages/500.tsx deleted file mode 100644 index fdc419f..0000000 --- a/website/pages/500.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Button } from '@mui/material' -import Head from 'next/head' -import styled from 'styled-components' - -const Title = styled.h1` - margin: 0; - line-height: 1.15; - font-size: 1.5rem; - text-align: center; - - a { - color: ${({ theme }) => theme.pages.index.title.a}; - text-decoration: none; - animation: animate 1.5s linear infinite; - } - - @keyframes animate { - 0% { - opacity: 0; - } - 50% { - opacity: 1; - } - 100% { - opacity: 0; - } - } - - a:hover, - a:focus, - a:active { - text-decoration: underline; - } -` - -const StyledButton = styled(Button)` - margin-top: 1rem; -` - -export default function NotFound() { - return ( - <> - - 500 - HomeDisk - - - - 500 | Server-side error occurred - - - - Go to Home Page - - - ) -} diff --git a/website/pages/_app.tsx b/website/pages/_app.tsx deleted file mode 100644 index aa3e47e..0000000 --- a/website/pages/_app.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { ThemeProvider as MuiThemeProvider, createTheme as muiCreateTheme, PaletteMode } from '@mui/material' -import { useEffect, useState } from 'react' -import { useCookies } from 'react-cookie' -import { ToastContainer } from 'react-toastify' -import { createGlobalStyle, ThemeProvider } from 'styled-components' -import Container from '../components/container' -import Footer from '../components/footer' -import Header from '../components/header' -import Main from '../components/main' -import "react-toastify/dist/ReactToastify.css" - -const GlobalStyle = createGlobalStyle` - html, - body { - padding: 0; - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, - Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; - } - - a { - color: inherit; - text-decoration: none; - } - - * { - box-sizing: border-box; - } -` - -const lightTheme = { - colors: { - background: "#ffffff", - color: "#000000", - error: "#f85b5b" - }, - pages: { - index: { - cards: { - signin: "#0a60cf", - register: "#a06800", - files: "#3d8011", - settings: "#75006f" - }, - title: { - a: "#a109c0" - } - } - }, - footer: { - borderTop: "#eaeaea" - } -} - -const darkTheme = { - colors: { - background: "#131212", - color: "#ffffff", - error: "#f85b5b" - }, - pages: { - index: { - cards: { - signin: "#0a60cf", - register: "#a06800", - files: "#54ad19", - settings: "#c90dbf" - }, - title: { - a: "#a109c0" - } - } - }, - footer: { - borderTop: "#161616" - } -} - -export default function App({ Component, pageProps }) { - const [cookies, setCookies] = useCookies(["theme"]) - - const [theme, setTheme] = useState(lightTheme) - const [themeName, setThemeName]: [PaletteMode, any] = useState("light") - - useEffect(() => { - if (!cookies.theme) setCookies("theme", "light") - - if (cookies.theme == "dark"){ - setTheme(darkTheme) - setThemeName("dark") - } - }, [setCookies, setTheme, setThemeName, cookies]) - - const toggleTheme = () => { - if (cookies.theme == "light") { - setTheme(darkTheme) - setThemeName("dark") - - setCookies("theme", "dark") - } - if (cookies.theme == "dark") { - setTheme(lightTheme) - setThemeName("light") - - setCookies("theme", "light") - } - } - - const muiThene = muiCreateTheme({ - palette: { - mode: themeName, - }, - }) - - return ( - <> - - - - - - - -
- -
- -
- -