diff --git a/package.json b/package.json index 8f03780..f1e863d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "no-copy-frontend", - "version": "0.24.0", + "version": "0.25.0", "private": true, "scripts": { "dev": "next dev -p 2999", diff --git a/src/app/actions/action.ts b/src/app/actions/action.ts index 360af1a..fbe5e68 100644 --- a/src/app/actions/action.ts +++ b/src/app/actions/action.ts @@ -9,7 +9,7 @@ export async function getUserData() { const token = await getSessionData('token'); /* для теста */ - if (userEmail === "test" && token === "1111") { + if (userEmail === 'test' && token === '1111') { return testUserData; } /* для теста */ @@ -18,9 +18,9 @@ export async function getUserData() { const response = await fetch(`${API_BASE_URL}/v1/api/user?email=${userEmail}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json", - "Authorization": `Bearer ${token}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token}`, } }); @@ -42,13 +42,13 @@ export async function getUserFilesInfo() { version: 1, msg_id: 20005, message_body: { - action: "user_files_info", + action: 'user_files_info', token: token } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/auth.ts b/src/app/actions/auth.ts index 15b4213..6d9c697 100644 --- a/src/app/actions/auth.ts +++ b/src/app/actions/auth.ts @@ -11,9 +11,9 @@ export async function logout() { await fetch(`${API_BASE_URL}/v1/api/auth/logout`, { method: 'POST', headers: { - "Content-Type": "application/json", - "Accept": "application/json", - "Authorization": `Bearer ${token}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token}`, } }); } catch (error) { @@ -36,8 +36,8 @@ export async function authorization( const password = formData.get('password'); /* для теста */ - if (email === "test" && password === "test") { - await createSession("1111", "test"); + if (email === 'test' && password === 'test') { + await createSession('1111', 'test'); redirect('/pages/dashboard'); } /* для теста */ @@ -81,8 +81,8 @@ export async function authorization( } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { @@ -211,8 +211,8 @@ export async function registration( } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -302,8 +302,8 @@ export async function tokenLifeExtension() { const response = await fetch(`${API_BASE_URL}/api/v1/data`, { method: 'POST', headers: { - "Content-Type": "application/json", - "Accept": "application/json", + 'Content-Type': 'application/json', + 'Accept': 'application/json', }, body: JSON.stringify({ version: 1, diff --git a/src/app/actions/definitions.ts b/src/app/actions/definitions.ts index cbd260d..c06b06a 100644 --- a/src/app/actions/definitions.ts +++ b/src/app/actions/definitions.ts @@ -1,5 +1,5 @@ import * as z from 'zod' -import { createValidationSchema } from "@/app/lib/validation-config-parser"; +import { createValidationSchema } from '@/app/lib/validation-config-parser'; import validationConfig from '@/app/lib/validation-config.json'; export type FormState = diff --git a/src/app/actions/fileEntity.ts b/src/app/actions/fileEntity.ts index e9607f9..7df3af3 100644 --- a/src/app/actions/fileEntity.ts +++ b/src/app/actions/fileEntity.ts @@ -21,8 +21,8 @@ export async function getUserFilesData(page: number, pageSize: number) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -59,8 +59,8 @@ export async function removeUserFile(fileId: string, fullDelete: number) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -120,8 +120,46 @@ export async function searchGlobalFiles(fileId: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }); + + if (response.ok) { + let parsed = await response.json(); + + if (parsed.message_code === 0) { + return parsed.message_body; + } else { + throw parsed; + } + } else { + throw (`${response.status}`); + } + + } catch (error) { + return error + } +} + +export async function viewFileInfo(fileId: string) { + const token = await getSessionData('token'); + + try { + const response = await fetch(`${API_BASE_URL}/api/v1/data`, { + method: 'POST', + body: JSON.stringify({ + version: 1, + msg_id: 20005, + message_body: { + action: 'file_info', + file_id: fileId, + token: token + } + }), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/fileUpload.ts b/src/app/actions/fileUpload.ts index cc304d0..c3fb85b 100644 --- a/src/app/actions/fileUpload.ts +++ b/src/app/actions/fileUpload.ts @@ -18,7 +18,7 @@ export async function fileUpload(messageBody: initMessageBody) { return; } const message = messageBody; - message.action = "init"; + message.action = 'init'; message.token = token; try { @@ -30,8 +30,8 @@ export async function fileUpload(messageBody: initMessageBody) { message_body: message }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -68,13 +68,13 @@ export async function cancelUpload(udloadId: string) { version: 1, msg_id: 20004, message_body: { - action: "cancel", + action: 'cancel', upload_id: udloadId, } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -138,8 +138,8 @@ export async function checkChunkStatus(upload_id: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -173,8 +173,8 @@ export async function getAllowedFilesExtensions(type: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/vkAuth.ts b/src/app/actions/vkAuth.ts index dd88ae4..78b4738 100644 --- a/src/app/actions/vkAuth.ts +++ b/src/app/actions/vkAuth.ts @@ -15,8 +15,8 @@ export async function vkAuthorization(data : any, codeVerifier: string) { const response = await fetch(`${API_BASE_URL}/api/v1/vk/authorization/${code}/${state}/${codeVerifier}/${device_id}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { diff --git a/src/app/actions/yandexAuth.ts b/src/app/actions/yandexAuth.ts index f39588f..0623101 100644 --- a/src/app/actions/yandexAuth.ts +++ b/src/app/actions/yandexAuth.ts @@ -15,8 +15,8 @@ export async function YandexAuthorization(data: any, codeVerifier: string) { const response = await fetch(`${API_BASE_URL}/api/v1/yandex/authorization/${code}/${state}/${codeVerifier}/${device_id}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { diff --git a/src/app/components/tanstakTable.tsx b/src/app/components/tanstakTable.tsx index 8045053..4ca918f 100644 --- a/src/app/components/tanstakTable.tsx +++ b/src/app/components/tanstakTable.tsx @@ -15,11 +15,12 @@ import { IconImageFile, IconVideoFile, IconAudioFile, IconEye, IconDoubleArrowRi import { useTranslations, useLocale } from 'next-intl'; import DropDownList from '@/app/components/dropDownList'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { getUserFilesData, removeUserFile } from '@/app/actions/fileEntity'; +import { getUserFilesData, removeUserFile, viewFileInfo } from '@/app/actions/fileEntity'; import ModalWindow from '@/app/components/modalWindow'; import { toast } from 'sonner'; import { pluralize } from '@/app/lib/pluralize'; import { convertBytes } from '@/app/lib/convertBytes'; +import { FileInfoModalWindow } from '@/app/ui/modal-windows/file-info-modal-window'; type FileType = 'image' | 'video' | 'audio'; @@ -423,30 +424,12 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { cell: ({ row }) => (
- -
-
- {/* */}
+
+ {row.original.protectStatus === 'PROTECTED' && ( + + )} + +
), @@ -467,9 +475,19 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { [] ); - // Обработчики действий - const handleView = (file: FileItem) => { + const handleView = async (file: FileItem) => { console.log(`Просмотр файла: ${file.fileName}`); + console.log(file); + + const fileInfo = await viewFileInfo(file.id); + console.log(fileInfo); + + setOpenWindowChildren(() => { + return ( + + ) + }) + setOpenWindow(true); }; const handleDownload = async (file: FileItem) => { diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss index c10f9c9..e806e77 100644 --- a/src/app/styles/pages-styles.scss +++ b/src/app/styles/pages-styles.scss @@ -769,10 +769,15 @@ } } - .table-action-download { + .table-action-download, + .table-action-delete, + .table-action-view { display: flex; - background-color: #3b72e0; align-items: center; + } + + .table-action-download { + background-color: #3b72e0; &:hover { background-color: #2d56a8; @@ -780,14 +785,20 @@ } .table-action-delete { - display: flex; background-color: #e80a14; - align-items: center; &:hover { background-color: #9f0712; } } + + .table-action-view { + background-color: #2b7fff; + + &:hover { + background-color: #155dfc; + } + } } } } @@ -3482,4 +3493,45 @@ } } } +} + +.file-info-modal-window { + width: 50vw; + min-width: 400px; + + &-close-button { + position: absolute; + top: 15px; + right: 20px; + background: none; + border: none; + font-size: 24px; + cursor: pointer; + color: #64748b; + } + + &-section { + margin-bottom: 25px; + } + + &-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 15px; + } + + &-item { + background: v.$bg-light; + padding: 15px; + border-radius: 8px; + } + + &-title { + font-weight: 600; + color: v.$text-p; + } + + &-content { + color: v.$text-s; + } } \ No newline at end of file diff --git a/src/app/ui/modal-windows/file-info-modal-window.tsx b/src/app/ui/modal-windows/file-info-modal-window.tsx new file mode 100644 index 0000000..510d2b4 --- /dev/null +++ b/src/app/ui/modal-windows/file-info-modal-window.tsx @@ -0,0 +1,139 @@ +export function FileInfoModalWindow({ fileInfo, setWindowClose, setWindowChildren }: any) { + + const exampleTest = { + ownerName: 'string', + ownerMail: 'string', + ownerCompany: 'string', + fileName: 'string', + fileSize: 'number', + fileUploadDate: 'number', + fileFormat: 'string', + protectStatus: 'string', + checksCount: 'number' + } + + function closeHandler() { + setWindowChildren(null); + setWindowClose(false); + } + + return ( +
+ +
+

+ Результат проверки +

+ +
+
+ +

+ Информация о владельце +

+
+
+
+ Имя +
+
+ {fileInfo.ownerName ? fileInfo.ownerName : '-'} +
+
+
+
+ Email +
+
+ {fileInfo.ownerMail ? fileInfo.ownerMail : '-'} +
+
+
+
+ Компания +
+
+ {fileInfo.ownerCompany ? fileInfo.ownerCompany : '-'} +
+
+
+ +

+ Информация о файле +

+
+
+
+ Имя файла +
+
+ {fileInfo.fileName ? fileInfo.fileName : '-'} +
+
+
+
+ Размер +
+
+ {fileInfo.fileSize ? fileInfo.fileSize : '-'} +
+
+
+
+ Загружен +
+
+ {fileInfo.fileUploadDate ? fileInfo.fileUploadDate : '-'} +
+
+
+
+ Формат +
+
+ {fileInfo.fileFormat ? fileInfo.fileFormat : '-'} +
+
+
+ +

+ Детали защиты +

+
+
+
+ Статус защиты +
+
+ {fileInfo.protectStatus ? fileInfo.protectStatus : '-'} +
+
+
+
+ Количество проверок +
+
+ {fileInfo.checksCount ? fileInfo.checksCount : '-'} +
+
+
+ +
+
+ ) +} \ No newline at end of file diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 9d9ddda..73405c0 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -18,6 +18,7 @@ "violations-few": "Violations", "violations": "Violations", "check": "Check", + "make-check": "Check", "checks": "Checks", "checks-few": "Checks", "documents": "Documents", @@ -201,7 +202,8 @@ "PROCESSING": "Processing", "PROTECTED": "Protected", "FAILED": "Failed", - "FAILED_SAVE": "Failed save" + "FAILED_SAVE": "Failed save", + "view": "View" }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index f97c9c2..cd62fbe 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -18,6 +18,7 @@ "violations-few": "Нарушения", "violations": "Нарушений", "check": "Проверка", + "make-check": "Проверить", "checks": "Проверок", "checks-few": "Проверки", "documents": "Документы", @@ -201,7 +202,8 @@ "PROCESSING": "Обработка", "PROTECTED": "Защищено", "FAILED": "Ошибка", - "FAILED_SAVE": "Сохранение не удалось" + "FAILED_SAVE": "Сохранение не удалось", + "view": "Посмотреть" }, "Login-register-form": { "and": "и",