Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #96

Merged
merged 20 commits into from
Nov 17, 2022
Merged

Dev #96

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0dd95ee
feat: download, checkpw route postpage화
ananjaemin Nov 17, 2022
af2ee7c
remove: checkpw redux 삭제
ananjaemin Nov 17, 2022
40c1779
docs: checkpw redux삭제에 따른 코드 삭제
ananjaemin Nov 17, 2022
0b369e1
feat: post page화에 따른 코드 변경 및 추가
ananjaemin Nov 17, 2022
eb74bbb
Merge pull request #87 from tempfiles-Team/62-파일별-다운로드-페이지-라우팅
ananjaemin Nov 17, 2022
822019d
fix: test code 삭제
ananjaemin Nov 17, 2022
90176db
fix: uploadDate표기 문제 해결
ananjaemin Nov 17, 2022
ef9d533
Merge pull request #88 from tempfiles-Team/85-파일-업로드-날짜가-이상해요
ananjaemin Nov 17, 2022
8a6b285
feat: enter event 추가
ananjaemin Nov 17, 2022
1128bd8
Merge pull request #90 from tempfiles-Team/67-checkpw-창에서-엔터로-입력-전송
ananjaemin Nov 17, 2022
9b9f8d9
feat: file이 없을경우 텍스트 추가
ananjaemin Nov 17, 2022
cb97549
fix: test code
ananjaemin Nov 17, 2022
2bac6fc
Merge pull request #91 from tempfiles-Team/35-filelist-page-file이-없을때
ananjaemin Nov 17, 2022
5450c8d
docs: 신고 버튼 삭제
ananjaemin Nov 17, 2022
785114d
Merge pull request #92 from tempfiles-Team/86-신고-기능-삭제
ananjaemin Nov 17, 2022
b335756
feat: skeleton UI loading 추가
ananjaemin Nov 17, 2022
4aecd99
Merge pull request #94 from tempfiles-Team/89-checkpw-페이지-로딩-추가
ananjaemin Nov 17, 2022
7437004
feat: statetext 추가
ananjaemin Nov 17, 2022
2fbd88c
fix: 오타수정,feat: upload 완료시 백엔드 처리 텍스트 띄우기
ananjaemin Nov 17, 2022
92b6149
Merge pull request #95 from tempfiles-Team/93-upload-로딩후-백엔드-작업-로딩-추가
ananjaemin Nov 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const App: React.FC = () => (
<Route path="/delete" element={<DeletePage />} />
<Route path="/filelist" element={<FileListPage />} />
<Route path="/api/*" element={<ApiPage />} />
<Route path="/checkpw" element={<CheckPasswordPage />} />
<Route path="/checkpw/:checkfileid" element={<CheckPasswordPage />} />
<Route path="*" element={<NotFoundPage />} />
</Route>
</Routes>
Expand Down
6 changes: 4 additions & 2 deletions src/components/common/Progress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ type ProgressBarProps = {
value: number;
fileName: string;
typing: string;
stateText: string;
};

export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing }) => {
export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing, stateText }) => {
const likecontainer = useRef();
useEffect(() => {
Lottie.loadAnimation({
Expand All @@ -26,7 +27,8 @@ export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing }
<S.ProgressAnimationBox ref={likecontainer} />
<S.ProgressBar width={value} />
<S.ProgressText>
{fileName} uploading{typing}
{fileName} {stateText}
{typing}
</S.ProgressText>
</S.ProgressContainer>
);
Expand Down
103 changes: 71 additions & 32 deletions src/pages/checkpw/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { useParams } from 'react-router-dom';
import { toast } from 'react-toastify';
import { bindActionCreators } from 'redux';

import { FileBox, Button } from '../../components';
import { FileBox, Button, SkeletonUI } from '../../components';
import { actionCreators } from '../../state';
import { RootState } from '../../state/reducers';
import { getDate } from '../../utils';
import * as S from './styled';

export const CheckPasswordPage: React.FC = () => {
const checkPasswordFileProps = useSelector((state: RootState) => state.CheckPasswordFileProps);
const [password, setPassword] = useState('');
const { year, month, day } = getDate(checkPasswordFileProps.uploadDate);
const [loading, setLoading] = useState(true);
const { checkfileid } = useParams<{ checkfileid: string }>();
const [fileProps, setFileProps] = useState({
filename: '',
size: '',
uploadDate: { year: 0, month: 0, day: 0 },
});
// const { year, month, day } = getDate(checkPasswordFileProps.uploadDate);
const dispatch = useDispatch();
const { SetDownloadFileProps } = bindActionCreators(actionCreators, dispatch);

Expand All @@ -30,15 +35,14 @@ export const CheckPasswordPage: React.FC = () => {
} else {
await axios({
method: 'get',
url: `${process.env.REACT_APP_BACKEND_BASEURL}/checkpw/${checkPasswordFileProps.fileId}?pw=${password}`,
url: `${process.env.REACT_APP_BACKEND_BASEURL}/checkpw/${checkfileid}?pw=${password}`,
})
.then((res) => {
SetDownloadFileProps({
fileId: checkPasswordFileProps.fileId,
isEncrypted: checkPasswordFileProps.isEncrypted,
isEncrypted: true,
token: res.data.token,
});
navigate('/download');
navigate(`/download/${checkfileid}`);
toast.success('통과!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
Expand All @@ -53,33 +57,68 @@ export const CheckPasswordPage: React.FC = () => {
});
}
};

useEffect(() => {
if (checkPasswordFileProps.filename === null || checkPasswordFileProps.fileId === null) {
navigate('/');
}
});
const getFileProps = async () => {
await axios({
method: 'get',
url: `${process.env.REACT_APP_BACKEND_BASEURL}/file/${checkfileid}`,
})
.then((res) => {
setLoading(false);
setFileProps({
filename: res.data.filename,
size: res.data.size,
uploadDate: getDate(res.data.uploadDate),
});
})
.catch((err) => {
console.log(err);
navigate('/');
toast.error('error 문의해주세요...', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
});
};
getFileProps();
}, [checkfileid, navigate]);
return (
<S.CheckPasswordPageContainer>
<FileBox>
파일이름:{checkPasswordFileProps.filename} / 크기:{checkPasswordFileProps.size} / 업로드된
날짜: {year}-{month}-{day}
</FileBox>
<S.PasswordInputSection>
<S.CheckPasswordInput
onChange={(text) => {
setPassword(text.target.value.replace(/(\s*)/g, ''));
}}
placeholder="비밀번호를 입력해주세요."
/>
{!loading ? (
<>
<FileBox>
파일이름:{fileProps.filename} / 크기:{fileProps.size} / 업로드된 날짜:{' '}
{fileProps.uploadDate.year}-{fileProps.uploadDate.month}-{fileProps.uploadDate.day}
</FileBox>
<S.PasswordInputSection>
<S.CheckPasswordInput
onKeyPress={(e: any) => {
if (e.key === 'Enter') {
passwordCheck();
}
}}
onChange={(text) => {
setPassword(text.target.value.replace(/(\s*)/g, ''));
}}
placeholder="비밀번호를 입력해주세요."
/>

<Button
click={() => {
passwordCheck();
}}
bgColor="var(--color-button-primary)"
label="전송"
/>
</S.PasswordInputSection>
<Button
click={() => {
passwordCheck();
}}
bgColor="var(--color-button-primary)"
label="전송"
/>
</S.PasswordInputSection>
</>
) : (
<>
<SkeletonUI width="80rem" height="4.6rem" margin="0rem" />
<SkeletonUI width="66rem" height="6rem" margin="4rem" />
</>
)}
</S.CheckPasswordPageContainer>
);
};
40 changes: 15 additions & 25 deletions src/pages/download/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,24 @@ export const DownloadPage: React.FC = () => {
await axios({
method: 'get',
url: `${process.env.REACT_APP_BACKEND_BASEURL}/file/${fileid}${
downloadFileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''
downloadFileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ``
}`,
})
.then((res) => {
setLoading(false);
setFileProps({
filename: res.data.filename,
// fileId: res.data.fileId,
size: getFileSize(res.data.size),
uploadDate: getDate(res.data.uploadDate),
download_url: res.data.download_url,
delete_url: res.data.delete_url,
isEncrypted: res.data.isEncrypted,
});
if (res.data.isEncrypted && !res.data.provide_token) {
navigate(`/checkpw/${fileid}`);
} else {
setFileProps({
filename: res.data.filename,
// fileId: res.data.fileId,
size: getFileSize(res.data.size),
uploadDate: getDate(res.data.uploadDate),
download_url: res.data.download_url,
delete_url: res.data.delete_url,
isEncrypted: res.data.isEncrypted,
});
}
})
.catch((err) => {
navigate('/');
Expand Down Expand Up @@ -87,11 +91,7 @@ export const DownloadPage: React.FC = () => {
</a>
<Button
click={() => {
navigator.clipboard.writeText(
`${fileProps.download_url}${
fileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''
}`,
);
navigator.clipboard.writeText(window.location.href);
toast.success('복사 완료', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
Expand All @@ -107,16 +107,6 @@ export const DownloadPage: React.FC = () => {
bgColor="var(--color-button-secondary)"
label="파일삭제"
/>
<Button
click={() => {
toast.success('제작중!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-secondary)"
label="신고"
/>
</S.DownloadPageButtonSection>
</>
) : (
Expand Down
66 changes: 33 additions & 33 deletions src/pages/filelist/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import * as S from './styled';
export const FileListPage: React.FC = () => {
const navigate = useNavigate();
const [loading, setLoading] = useState(false);
const [listZero, setListZero] = useState(false); //test: true
const SkeletonUIRandomWidth = ['50', '55', '60', '65', '70', '75', '80'];
const dispatch = useDispatch();
const { SetDownloadFileProps, SetCheckPasswordFileProps } = bindActionCreators(
actionCreators,
dispatch,
);
const { SetDownloadFileProps } = bindActionCreators(actionCreators, dispatch);
const [fileList, setFileList] = useState<any[]>();
const getFileList = async () => {
await axios({
Expand All @@ -26,6 +24,9 @@ export const FileListPage: React.FC = () => {
})
.then((res) => {
setFileList(res.data.list); //파일리스트 요소 갯수에 따른 핸들링 추가예정
if (res.data.numberOfList === 0) {
setListZero(true);
}
setTimeout(() => {
setLoading(true); //loading 확인하고싶으면 false로 바꿔주세요.
}, 1000);
Expand All @@ -42,35 +43,34 @@ export const FileListPage: React.FC = () => {
{loading ? (
<>
<S.FileListPageContainer>
{fileList?.map((item, index) => (
<FileListBox
key={index}
filename={getShortFileName(item.filename)}
fileId={item.fileId}
size={getFileSize(item.size)}
uploadDate={getDate(item.uploadDate)}
isEncrypted={item.isEncrypted}
click={() => {
if (item.isEncrypted) {
SetCheckPasswordFileProps({
filename: item.filename,
fileId: item.fileId,
size: getFileSize(item.size),
uploadDate: item.uploadDate,
isEncrypted: item.isEncrypted,
});
navigate('/checkpw');
} else {
SetDownloadFileProps({
fileId: item.fileId,
isEncrypted: item.isEncrypted,
token: null,
});
navigate(`/download/${item.fileId}`);
}
}}
/>
))}
{!listZero ? (
<>
{fileList?.map((item, index) => (
<FileListBox
key={index}
filename={getShortFileName(item.filename)}
fileId={item.fileId}
size={getFileSize(item.size)}
uploadDate={getDate(item.uploadDate)}
isEncrypted={item.isEncrypted}
click={() => {
if (item.isEncrypted) {
navigate(`/checkpw/${item.fileId}`);
} else {
SetDownloadFileProps({
fileId: item.fileId,
isEncrypted: item.isEncrypted,
token: null,
});
navigate(`/download/${item.fileId}`);
}
}}
/>
))}
</>
) : (
<S.FileListZero>업로드된 파일이 없습니다.</S.FileListZero>
)}
</S.FileListPageContainer>
<S.FileListPageBoxShoadow />
</>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/filelist/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ export const FileListPageBoxShoadow = styled.div`
top: -2.5rem; //-25px
background: linear-gradient(180deg, rgba(40, 42, 58, 0) 0%, #282a3a 45.31%);
`;

export const FileListZero = styled.div`
font-size: 3rem;
font-weight: 700;
margin: 5rem;
`;
10 changes: 7 additions & 3 deletions src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import { bindActionCreators } from 'redux';

// eslint-disable-next-line
import { CheckBox, PasswordInput, UpLoadButton, FileFind, Progress } from '../../components';
import { actionCreators } from '../../state';
import { getFileSize } from '../../utils';
Expand All @@ -15,7 +14,8 @@ export const MainPage: React.FC = () => {
const typingText = ['.', '..', '...'];
const [typingCount, setTypingCount] = useState(0);
const [uploading, setUploading] = useState(true);
const [progressValue, serProgressValue] = useState(0);
const [progressValue, setProgressValue] = useState(0);
const [progressStateText, setProgressStateText] = useState('uploading');

const [retentionPeriod, setRetentionPeriod] = useState(false);
const [downloadCount, setDownloadCount] = useState(false);
Expand Down Expand Up @@ -59,7 +59,10 @@ export const MainPage: React.FC = () => {
},
onUploadProgress(progress) {
setUploading(false);
serProgressValue(Math.floor((progress.loaded / progress.total) * 100));
setProgressValue(Math.floor((progress.loaded / progress.total) * 100));
if (Math.floor((progress.loaded / progress.total) * 100) === 100) {
setProgressStateText('백엔드 처리중');
}
},
})
.then(async (res) => {
Expand Down Expand Up @@ -152,6 +155,7 @@ export const MainPage: React.FC = () => {
value={progressValue}
fileName={fileProps.filename}
typing={typingText[typingCount]}
stateText={progressStateText}
/>
)}
</S.MainPageContainer>
Expand Down
1 change: 0 additions & 1 deletion src/state/action-types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export enum ActionType {
DeleteFileProps = 'DeleteFileProps',
DownloadFileProps = 'DownloadFileProps',
CheckPasswordFileProps = 'CheckPasswordFileProps',
}
7 changes: 0 additions & 7 deletions src/state/actions-creators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,3 @@ export const SetDownloadFileProps = (props: any) => (dispatch: Dispatch<Action>)
props: props,
});
};

export const SetCheckPasswordFileProps = (props: any) => (dispatch: Dispatch<Action>) => {
dispatch({
type: ActionType.CheckPasswordFileProps,
props: props,
});
};
Loading