fix: stuff

This commit is contained in:
diced 2022-10-27 21:26:54 -07:00
parent e2fd27cbba
commit 68d346e69d
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1
7 changed files with 32 additions and 5 deletions

View file

@ -19,8 +19,13 @@ jobs:
id: cache-restore
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}
path: |
node_modules
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
if: steps.cache-restore.outputs.cache-hit != 'true'

View file

@ -32,6 +32,8 @@ A ShareX/file upload server that is easy to use, packed with features, and with
- Fully customizable Discord webhook notifications
- OAuth2 registration (Discord and GitHub)
- User invites
- File Chunking (for large files)
- File deletion once it reaches a certain amount of views
- Easy setup instructions on [docs](https://zipl.vercel.app/) (One command install `docker-compose up -d`)
# Usage

View file

@ -5,6 +5,7 @@ import Image from 'next/image';
export default function DiscordIcon({ ...props }) {
return (
<Image
alt='discord'
src='https://assets-global.website-files.com/6257adef93867e50d84d30e2/62595384f934b806f37f4956_145dc557845548a36a82337912ca3ac5.svg'
width={24}
height={24}

View file

@ -5,6 +5,7 @@ import Image from 'next/image';
export default function FlameshotIcon({ ...props }) {
return (
<Image
alt='flameshot'
src='https://raw.githubusercontent.com/flameshot-org/flameshot/master/data/img/app/flameshot.svg'
width={24}
height={24}

View file

@ -3,5 +3,7 @@
import Image from 'next/image';
export default function ShareXIcon({ ...props }) {
return <Image src='https://getsharex.com/img/ShareX_Logo.svg' width={24} height={24} {...props} />;
return (
<Image alt='sharex' src='https://getsharex.com/img/ShareX_Logo.svg' width={24} height={24} {...props} />
);
}

View file

@ -1,4 +1,4 @@
import { Button, Group, PasswordInput, Select, Tabs, Title, Tooltip } from '@mantine/core';
import { Button, Group, NumberInput, PasswordInput, Select, Tabs, Title, Tooltip } from '@mantine/core';
import { Prism } from '@mantine/prism';
import { Language } from 'prism-react-renderer';
import { showNotification, updateNotification } from '@mantine/notifications';
@ -17,6 +17,7 @@ export default function Upload() {
const [lang, setLang] = useState('txt');
const [password, setPassword] = useState('');
const [expires, setExpires] = useState('never');
const [maxViews, setMaxViews] = useState<number>(undefined);
const handleUpload = async () => {
const file = new File([value], 'text.' + lang);
@ -97,6 +98,7 @@ export default function Upload() {
expires !== 'never' && req.setRequestHeader('Expires-At', 'date=' + expires_at.toISOString());
password !== '' && req.setRequestHeader('Password', password);
maxViews && maxViews !== 0 && req.setRequestHeader('Max-Views', String(maxViews));
req.send(body);
};
@ -139,6 +141,9 @@ export default function Upload() {
icon={<TypeIcon />}
searchable
/>
<Tooltip label='After the file reaches this amount of views, it will be deleted automatically. Leave blank for no limit.'>
<NumberInput placeholder='Max Views' min={0} value={maxViews} onChange={(x) => setMaxViews(x)} />
</Tooltip>
<Tooltip label='Add a password to your files (optional, leave blank for none)'>
<PasswordInput
style={{ width: '252px' }}

View file

@ -9,6 +9,7 @@ import {
Title,
Card,
Center,
NumberInput,
} from '@mantine/core';
import { useForm } from '@mantine/form';
import { showNotification } from '@mantine/notifications';
@ -32,6 +33,7 @@ export default function Urls() {
initialValues: {
url: '',
vanity: '',
maxViews: undefined,
},
});
@ -47,17 +49,25 @@ export default function Urls() {
return form.setFieldError('url', 'Invalid URL');
}
const data = {
const data: {
url: string;
vanity?: string;
} = {
url: cleanURL,
vanity: cleanVanity === '' ? null : cleanVanity,
};
const headers = {};
if (values.maxViews && values.maxViews !== 0) headers['Max-Views'] = values.maxViews;
setCreateOpen(false);
const res = await fetch('/api/shorten', {
method: 'POST',
headers: {
Authorization: user.token,
'Content-Type': 'application/json',
...headers,
},
body: JSON.stringify(data),
});
@ -92,6 +102,7 @@ export default function Urls() {
<form onSubmit={form.onSubmit((v) => onSubmit(v))}>
<TextInput id='url' label='URL' {...form.getInputProps('url')} />
<TextInput id='vanity' label='Vanity' {...form.getInputProps('vanity')} />
<NumberInput id='maxViews' label='Max Views' {...form.getInputProps('maxViews')} />
<Group position='right' mt='md'>
<Button onClick={() => setCreateOpen(false)}>Cancel</Button>