mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-25 19:52:48 +00:00
feat(dashboard): filter file by shared link, direct link, uploading status
This commit is contained in:
parent
b7bfbffda5
commit
2827c6bc2e
|
|
@ -1284,7 +1284,11 @@
|
|||
"After import, the physical file will be taken over by Cloudreve, please do not modify it externally afterwards.",
|
||||
"Do not import the same file multiple times.",
|
||||
"If the user's file conflicts, this file will be skipped."
|
||||
]
|
||||
],
|
||||
"otherConditions": "Other conditions",
|
||||
"shareLinkExisted": "Has share link",
|
||||
"directLinkExisted": "Has direct link",
|
||||
"isUploading": "Is uploading"
|
||||
},
|
||||
"entity": {
|
||||
"refenenceCount": "Reference count",
|
||||
|
|
|
|||
|
|
@ -1270,7 +1270,11 @@
|
|||
"インポート後、物理ファイルはCloudreveに移行されます。外部での変更はお控えください。",
|
||||
"同じファイルを複数回インポートしないでください。",
|
||||
"ユーザーのファイルが衝突した場合、このファイルはスキップされます。"
|
||||
]
|
||||
],
|
||||
"otherConditions": "その他の条件",
|
||||
"shareLinkExisted": "共有リンクが存在",
|
||||
"directLinkExisted": "直接リンクが存在",
|
||||
"isUploading": "アップロード中"
|
||||
},
|
||||
"entity": {
|
||||
"refenenceCount": "参照回数",
|
||||
|
|
|
|||
|
|
@ -1269,7 +1269,11 @@
|
|||
"导入后,物理文件将由 Cloudreve 接管,后续请不要在外部修改此文件;",
|
||||
"不要重复导入相同的文件;",
|
||||
"如果用户文件冲突,此文件会被跳过;"
|
||||
]
|
||||
],
|
||||
"otherConditions": "其他条件",
|
||||
"shareLinkExisted": "存在分享链接",
|
||||
"directLinkExisted": "存在中转直链",
|
||||
"isUploading": "上传中"
|
||||
},
|
||||
"entity": {
|
||||
"refenenceCount": "引用次数",
|
||||
|
|
|
|||
|
|
@ -1266,7 +1266,11 @@
|
|||
"匯入後,物理檔案將由 Cloudreve 接管,後續請不要在外部修改此檔案;",
|
||||
"不要重複匯入相同的檔案;",
|
||||
"如果使用者檔案衝突,此檔案會被跳過;"
|
||||
]
|
||||
],
|
||||
"otherConditions": "其他條件",
|
||||
"shareLinkExisted": "有分享連結",
|
||||
"directLinkExisted": "有中轉直鏈",
|
||||
"isUploading": "上傳中"
|
||||
},
|
||||
"entity": {
|
||||
"refenenceCount": "引用次數",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Box, Button, Popover, PopoverProps, Stack } from "@mui/material";
|
||||
import { Box, Button, Checkbox, Popover, PopoverProps, Stack, styled } from "@mui/material";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DenseFilledTextField } from "../../Common/StyledComponents";
|
||||
import { DenseFilledTextField, SmallFormControlLabel } from "../../Common/StyledComponents";
|
||||
import SettingForm from "../../Pages/Setting/SettingForm";
|
||||
import SinglePolicySelectionInput from "../Common/SinglePolicySelectionInput";
|
||||
|
||||
|
|
@ -12,9 +12,21 @@ export interface FileFilterPopoverProps extends PopoverProps {
|
|||
setOwner: (owner: string) => void;
|
||||
name: string;
|
||||
setName: (name: string) => void;
|
||||
hasShareLink: boolean;
|
||||
setHasShareLink: (hasShareLink: boolean) => void;
|
||||
hasDirectLink: boolean;
|
||||
setHasDirectLink: (hasDirectLink: boolean) => void;
|
||||
isUploading: boolean;
|
||||
setIsUploading: (isUploading: boolean) => void;
|
||||
clearFilters: () => void;
|
||||
}
|
||||
|
||||
const StyledCheckbox = styled(Checkbox)(({ theme }) => ({
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
paddingLeft: 0,
|
||||
}));
|
||||
|
||||
const FileFilterPopover = ({
|
||||
storagePolicy,
|
||||
setStoragePolicy,
|
||||
|
|
@ -22,6 +34,12 @@ const FileFilterPopover = ({
|
|||
setOwner,
|
||||
name,
|
||||
setName,
|
||||
hasShareLink,
|
||||
setHasShareLink,
|
||||
hasDirectLink,
|
||||
setHasDirectLink,
|
||||
isUploading,
|
||||
setIsUploading,
|
||||
clearFilters,
|
||||
onClose,
|
||||
open,
|
||||
|
|
@ -33,6 +51,9 @@ const FileFilterPopover = ({
|
|||
const [localStoragePolicy, setLocalStoragePolicy] = useState(storagePolicy);
|
||||
const [localOwner, setLocalOwner] = useState(owner);
|
||||
const [localName, setLocalName] = useState(name);
|
||||
const [localHasShareLink, setLocalHasShareLink] = useState(hasShareLink);
|
||||
const [localHasDirectLink, setLocalHasDirectLink] = useState(hasDirectLink);
|
||||
const [localIsUploading, setLocalIsUploading] = useState(isUploading);
|
||||
|
||||
// Initialize local state when popup opens
|
||||
useEffect(() => {
|
||||
|
|
@ -40,6 +61,9 @@ const FileFilterPopover = ({
|
|||
setLocalStoragePolicy(storagePolicy);
|
||||
setLocalOwner(owner);
|
||||
setLocalName(name);
|
||||
setLocalHasShareLink(hasShareLink);
|
||||
setLocalHasDirectLink(hasDirectLink);
|
||||
setLocalIsUploading(isUploading);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
|
|
@ -48,6 +72,9 @@ const FileFilterPopover = ({
|
|||
setStoragePolicy(localStoragePolicy);
|
||||
setOwner(localOwner);
|
||||
setName(localName);
|
||||
setHasShareLink(localHasShareLink);
|
||||
setHasDirectLink(localHasDirectLink);
|
||||
setIsUploading(localIsUploading);
|
||||
onClose?.({}, "backdropClick");
|
||||
};
|
||||
|
||||
|
|
@ -56,6 +83,9 @@ const FileFilterPopover = ({
|
|||
setLocalStoragePolicy("");
|
||||
setLocalOwner("");
|
||||
setLocalName("");
|
||||
setLocalHasShareLink(false);
|
||||
setLocalHasDirectLink(false);
|
||||
setLocalIsUploading(false);
|
||||
clearFilters();
|
||||
onClose?.({}, "backdropClick");
|
||||
};
|
||||
|
|
@ -113,6 +143,44 @@ const FileFilterPopover = ({
|
|||
/>
|
||||
</SettingForm>
|
||||
|
||||
<SettingForm title={t("file.otherConditions")} noContainer lgWidth={12}>
|
||||
<Stack spacing={0.5}>
|
||||
<SmallFormControlLabel
|
||||
control={
|
||||
<StyledCheckbox
|
||||
disableRipple
|
||||
size="small"
|
||||
checked={localHasShareLink}
|
||||
onChange={(e) => setLocalHasShareLink(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={t("file.shareLinkExisted")}
|
||||
/>
|
||||
<SmallFormControlLabel
|
||||
control={
|
||||
<StyledCheckbox
|
||||
disableRipple
|
||||
size="small"
|
||||
checked={localHasDirectLink}
|
||||
onChange={(e) => setLocalHasDirectLink(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={t("file.directLinkExisted")}
|
||||
/>
|
||||
<SmallFormControlLabel
|
||||
control={
|
||||
<StyledCheckbox
|
||||
disableRipple
|
||||
size="small"
|
||||
checked={localIsUploading}
|
||||
onChange={(e) => setLocalIsUploading(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={t("file.isUploading")}
|
||||
/>
|
||||
</Stack>
|
||||
</SettingForm>
|
||||
|
||||
<Box display="flex" justifyContent="space-between">
|
||||
<Button variant="outlined" size="small" onClick={handleResetFilters}>
|
||||
{t("user.reset")}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { batchDeleteFiles, getFlattenFileList } from "../../../api/api";
|
||||
import { File } from "../../../api/dashboard";
|
||||
import { Metadata } from "../../../api/explorer";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { confirmOperation } from "../../../redux/thunks/dialog";
|
||||
import { NoWrapTableCell, SecondaryButton, StyledTableContainerPaper } from "../../Common/StyledComponents";
|
||||
|
|
@ -42,6 +43,9 @@ import { ImportFileDialog } from "./ImportFileDialog";
|
|||
export const StoragePolicyQuery = "storage_policy";
|
||||
export const OwnerQuery = "owner";
|
||||
export const NameQuery = "name";
|
||||
export const HasDirectLinkQuery = "has_direct_link";
|
||||
export const SharedQuery = "shared";
|
||||
export const UploadingQuery = "uploading";
|
||||
|
||||
const FileSetting = () => {
|
||||
const { t } = useTranslation("dashboard");
|
||||
|
|
@ -61,6 +65,9 @@ const FileSetting = () => {
|
|||
const [storagePolicy, setStoragePolicy] = useQueryState(StoragePolicyQuery, { defaultValue: "" });
|
||||
const [owner, setOwner] = useQueryState(OwnerQuery, { defaultValue: "" });
|
||||
const [name, setName] = useQueryState(NameQuery, { defaultValue: "" });
|
||||
const [hasDirectLink, setHasDirectLink] = useQueryState(HasDirectLinkQuery, { defaultValue: "" });
|
||||
const [shared, setShared] = useQueryState(SharedQuery, { defaultValue: "" });
|
||||
const [uploading, setUploading] = useQueryState(UploadingQuery, { defaultValue: "" });
|
||||
const [count, setCount] = useState(0);
|
||||
const [selected, setSelected] = useState<readonly number[]>([]);
|
||||
const [createNewOpen, setCreateNewOpen] = useState(false);
|
||||
|
|
@ -83,11 +90,14 @@ const FileSetting = () => {
|
|||
setStoragePolicy("");
|
||||
setOwner("");
|
||||
setName("");
|
||||
}, [setStoragePolicy, setOwner, setName]);
|
||||
setHasDirectLink("");
|
||||
setShared("");
|
||||
setUploading("");
|
||||
}, [setStoragePolicy, setOwner, setName, setHasDirectLink, setShared, setUploading]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchFiles();
|
||||
}, [page, pageSize, orderBy, orderDirection, storagePolicy, owner, name]);
|
||||
}, [page, pageSize, orderBy, orderDirection, storagePolicy, owner, name, hasDirectLink, shared, uploading]);
|
||||
|
||||
const fetchFiles = () => {
|
||||
setLoading(true);
|
||||
|
|
@ -102,6 +112,9 @@ const FileSetting = () => {
|
|||
file_policy: storagePolicy,
|
||||
file_user: owner,
|
||||
file_name: name,
|
||||
file_direct_link: hasDirectLink === "true" ? "true" : "",
|
||||
file_shared: shared === "true" ? "true" : "",
|
||||
file_metadata: uploading === "true" ? Metadata.upload_session_id : "",
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
|
@ -170,8 +183,8 @@ const FileSetting = () => {
|
|||
};
|
||||
|
||||
const hasActiveFilters = useMemo(() => {
|
||||
return !!(storagePolicy || owner || name);
|
||||
}, [storagePolicy, owner, name]);
|
||||
return !!(storagePolicy || owner || name || hasDirectLink || shared || uploading);
|
||||
}, [storagePolicy, owner, name, hasDirectLink, shared, uploading]);
|
||||
|
||||
const handleFileDialogOpen = (id: number) => {
|
||||
setFileDialogID(id);
|
||||
|
|
@ -220,6 +233,12 @@ const FileSetting = () => {
|
|||
name={name}
|
||||
setName={setName}
|
||||
clearFilters={clearFilters}
|
||||
hasDirectLink={hasDirectLink === "true"}
|
||||
setHasDirectLink={(value: boolean) => setHasDirectLink(value ? "true" : "")}
|
||||
hasShareLink={shared === "true"}
|
||||
setHasShareLink={(value: boolean) => setShared(value ? "true" : "")}
|
||||
isUploading={uploading === "true"}
|
||||
setIsUploading={(value: boolean) => setUploading(value ? "true" : "")}
|
||||
/>
|
||||
|
||||
<SecondaryButton onClick={fetchFiles} disabled={loading} variant={"contained"} startIcon={<ArrowSync />}>
|
||||
|
|
|
|||
Loading…
Reference in New Issue