add search animation
This commit is contained in:
@@ -85,7 +85,7 @@ export async function searchUserFiles(fileId: string) {
|
|||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE_URL}/api/v1/files/${fileId}/similar?auth_token=${token}`, {
|
const response = await fetch(`${API_BASE_URL}/api/v1/files/${fileId}/similar?similarityLevels=DUPLICATE,SIMILARITY&auth_token=${token}`, {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2948,6 +2948,11 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
&:hover:not(:disabled) {
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
|
box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
|
||||||
@@ -2962,6 +2967,10 @@
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
|
|
||||||
|
&.show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.global-spinner {
|
.global-spinner {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import { SearchedUserFilesList } from '@/app/ui/search/searched-user-files-list'
|
|||||||
import { SearchedGlobalFilesList } from '@/app/ui/search/searched-global-files-list';
|
import { SearchedGlobalFilesList } from '@/app/ui/search/searched-global-files-list';
|
||||||
import { useCallback, useState, useImperativeHandle } from 'react';
|
import { useCallback, useState, useImperativeHandle } from 'react';
|
||||||
import { searchUserFiles, searchGlobalFiles } from '@/app/actions/fileEntity';
|
import { searchUserFiles, searchGlobalFiles } from '@/app/actions/fileEntity';
|
||||||
|
import { fa } from 'zod/v4/locales';
|
||||||
|
|
||||||
export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: any }) {
|
export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: any }) {
|
||||||
const [searchedUserFiles, setSearchedUserFiles] = useState<string[]>([]);
|
const [searchedUserFiles, setSearchedUserFiles] = useState<string[]>([]);
|
||||||
const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState<boolean>(false);
|
const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState<boolean>(false);
|
||||||
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<string[]>([]);
|
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<string[]>([]);
|
||||||
const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState<boolean>(false);
|
const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState<boolean>(false);
|
||||||
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
clearList: () => {
|
clearList: () => {
|
||||||
@@ -36,6 +38,10 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
|||||||
}, [fileId])
|
}, [fileId])
|
||||||
|
|
||||||
const handlerSearchGlobalFile = useCallback(async (fileId: string): Promise<void> => {
|
const handlerSearchGlobalFile = useCallback(async (fileId: string): Promise<void> => {
|
||||||
|
setLoading(true);
|
||||||
|
setSearchedGlobalFilesShowNull(false);
|
||||||
|
setSearchedGlobalFiles([]);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let result = await searchGlobalFiles(fileId);
|
let result = await searchGlobalFiles(fileId);
|
||||||
@@ -46,6 +52,8 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [fileId])
|
}, [fileId])
|
||||||
@@ -144,6 +152,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
|||||||
type="button"
|
type="button"
|
||||||
className="global-search-btn"
|
className="global-search-btn"
|
||||||
id="global-search-btn"
|
id="global-search-btn"
|
||||||
|
disabled={loading ? true : false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (fileId) {
|
if (fileId) {
|
||||||
handlerSearchGlobalFile(fileId)
|
handlerSearchGlobalFile(fileId)
|
||||||
@@ -153,7 +162,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
|
|||||||
Найти в интернете
|
Найти в интернете
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="global-loading" id="global-loading">
|
<div className={`global-loading ${loading ? 'show' : ''}`} id="global-loading">
|
||||||
<div className="global-spinner"></div>
|
<div className="global-spinner"></div>
|
||||||
<div className="global-loading-text" id="global-loading-text">
|
<div className="global-loading-text" id="global-loading-text">
|
||||||
Поиск изображений в интернете...
|
Поиск изображений в интернете...
|
||||||
|
|||||||
Reference in New Issue
Block a user