edit get files extensions query
This commit is contained in:
@@ -2,18 +2,17 @@ import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
|||||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||||
import PageTitle from '@/app/ui/page-title';
|
import PageTitle from '@/app/ui/page-title';
|
||||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||||
|
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||||
|
|
||||||
const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
export default async function Page() {
|
||||||
const FILE_TYPE = "AUDIO"
|
const FILE_TYPE = "audio";
|
||||||
const MAX_SIZE = 1048576000;
|
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageTitle title="audio-protection" />
|
<PageTitle title="audio-protection" />
|
||||||
<ProtectionSummary />
|
<ProtectionSummary />
|
||||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||||
{/* <TestSection /> */}
|
{/* <TestSection /> */}
|
||||||
<FilesTable />
|
<FilesTable />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
||||||
|
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||||
import PageTitle from '@/app/ui/page-title';
|
import PageTitle from '@/app/ui/page-title';
|
||||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
|
||||||
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||||
|
|
||||||
const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
|
||||||
const FILE_TYPE = "IMAGE"
|
|
||||||
const MAX_SIZE = 1048576000;
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
/* const allowedFilesExtensions = await getAllowedFilesExtensions(FILE_TYPE);
|
const FILE_TYPE = "image";
|
||||||
console.log(allowedFilesExtensions);
|
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||||
console.log(allowedFilesExtensions); */
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageTitle title="image-protection" />
|
<PageTitle title="image-protection" />
|
||||||
<ProtectionSummary />
|
<ProtectionSummary />
|
||||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||||
{/* <TestSection /> */}
|
{/* <TestSection /> */}
|
||||||
<FilesTable />
|
<FilesTable />
|
||||||
{/* <ProtectedFilesTable /> */}
|
{/* <ProtectedFilesTable /> */}
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
||||||
import UploadSectionVideo from '@/app/ui/marking-page/upload-section-video';
|
|
||||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||||
import PageTitle from '@/app/ui/page-title';
|
import PageTitle from '@/app/ui/page-title';
|
||||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||||
|
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||||
|
|
||||||
const ALLOWED_EXTENSIONS: string[] = ['mp4', 'avi', 'webm', 'mkv', 'flv', 'wmv', 'mov'];
|
export default async function Page() {
|
||||||
const FILE_TYPE = "VIDEO"
|
const FILE_TYPE = "video";
|
||||||
const MAX_SIZE = 1048576000;
|
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageTitle title="video-protection" />
|
<PageTitle title="video-protection" />
|
||||||
<ProtectionSummary />
|
<ProtectionSummary />
|
||||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||||
{/* <TestSection /> */}
|
{/* <TestSection /> */}
|
||||||
<FilesTable />
|
<FilesTable />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -187,10 +187,9 @@ export async function getAllowedFilesExtensions(type: string) {
|
|||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
let parsed = await response.json();
|
let parsed = await response.json();
|
||||||
console.log(parsed);
|
|
||||||
|
|
||||||
if (parsed.message_desc === 'Operation successful') {
|
if (parsed.message_desc === 'Operation successful') {
|
||||||
return parsed.message_body.file_extension;
|
return parsed.message_body;
|
||||||
} else {
|
} else {
|
||||||
console.log('error cancel getAllowedFilesExtensions');
|
console.log('error cancel getAllowedFilesExtensions');
|
||||||
throw parsed;
|
throw parsed;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
let SUPPORTED_FORMATS: string[] = [];
|
let SUPPORTED_FORMATS: string[] = [];
|
||||||
|
|
||||||
switch (fileType) {
|
switch (fileType) {
|
||||||
case 'IMAGE':
|
case 'image':
|
||||||
SUPPORTED_FORMATS = [
|
SUPPORTED_FORMATS = [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/jpg',
|
'image/jpg',
|
||||||
@@ -56,7 +56,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
'image/x-icon'
|
'image/x-icon'
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'VIDEO':
|
case 'video':
|
||||||
SUPPORTED_FORMATS = [
|
SUPPORTED_FORMATS = [
|
||||||
'video/mp4',
|
'video/mp4',
|
||||||
'video/mpeg',
|
'video/mpeg',
|
||||||
@@ -70,7 +70,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
'video/3gpp2'
|
'video/3gpp2'
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'AUDIO':
|
case 'audio':
|
||||||
SUPPORTED_FORMATS = [
|
SUPPORTED_FORMATS = [
|
||||||
'audio/mpeg',
|
'audio/mpeg',
|
||||||
'audio/wav',
|
'audio/wav',
|
||||||
@@ -159,7 +159,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
try {
|
try {
|
||||||
let dimensions = undefined;
|
let dimensions = undefined;
|
||||||
|
|
||||||
if (fileType === "IMAGE") {
|
if (fileType === "image") {
|
||||||
dimensions = await getImageDimensions(file) as { width: number, height: number };
|
dimensions = await getImageDimensions(file) as { width: number, height: number };
|
||||||
if (dimensions.width < 150 || dimensions.height < 150 ||
|
if (dimensions.width < 150 || dimensions.height < 150 ||
|
||||||
dimensions.width > 10000 || dimensions.height > 10000) {
|
dimensions.width > 10000 || dimensions.height > 10000) {
|
||||||
@@ -389,7 +389,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
{t('select-files-to-protect')}
|
{t('select-files-to-protect')}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{fileType === "IMAGE" && (
|
{fileType === "image" && (
|
||||||
<p className="description">
|
<p className="description">
|
||||||
Разрешение изображение: 100x100 - 10000x10000
|
Разрешение изображение: 100x100 - 10000x10000
|
||||||
</p>
|
</p>
|
||||||
@@ -439,7 +439,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{fileType === 'IMAGE' && (
|
{fileType === 'image' && (
|
||||||
<img
|
<img
|
||||||
src={selectedFile.preview}
|
src={selectedFile.preview}
|
||||||
alt="Предпросмотр загруженного изображения"
|
alt="Предпросмотр загруженного изображения"
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import {
|
|||||||
QueryClientProvider,
|
QueryClientProvider,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
export function makeQueryClient() {
|
import { getQueryClient } from '@/app/providers/getQueryClient';
|
||||||
|
|
||||||
|
/* export function makeQueryClient() {
|
||||||
return new QueryClient({
|
return new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
@@ -25,7 +27,7 @@ function getQueryClient() {
|
|||||||
if (!browserQueryClient) browserQueryClient = makeQueryClient()
|
if (!browserQueryClient) browserQueryClient = makeQueryClient()
|
||||||
return browserQueryClient
|
return browserQueryClient
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
export default function Providers({ children }: { children: React.ReactNode }) {
|
export default function Providers({ children }: { children: React.ReactNode }) {
|
||||||
const queryClient = getQueryClient();
|
const queryClient = getQueryClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user