chore: cleanup file checkbox

This commit is contained in:
jialin
2025-03-26 11:59:49 +08:00
parent 93c9ffe109
commit 671fce2961
8 changed files with 166 additions and 60 deletions
+10 -4
View File
@@ -45,10 +45,16 @@ export async function queryModelFilesList(params: Global.SearchParams) {
});
}
export async function deleteModelFile(id: string | number) {
return request<Global.PageResponse<ModelFile>>(`${MODEL_FILES_API}/${id}`, {
method: 'DELETE'
});
export async function deleteModelFile(
id: string | number,
params: { checked: boolean }
) {
return request<Global.PageResponse<ModelFile>>(
`${MODEL_FILES_API}/${id}?cleanup=${params.checked}`,
{
method: 'DELETE'
}
);
}
export async function updateModelFile(id: string | number, data: any) {
+54 -13
View File
@@ -44,6 +44,7 @@ import dayjs from 'dayjs';
import { useAtom } from 'jotai';
import _ from 'lodash';
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import {
useGenerateFormEditInitialValues,
useGenerateModelFileOptions
@@ -69,6 +70,26 @@ import {
const filterPattern = /^(.*?)(?:-\d+-of-\d+)?(\.gguf)?$/;
const PathWrapper = styled.div`
position: relative;
display: flex;
align-items: center;
height: 100%;
.btn-wrapper {
position: absolute;
background: var(--color-bg-1);
right: 0;
display: none;
align-items: center;
}
&:hover {
.btn-wrapper {
display: flex;
background: var(--ant-table-row-hover-bg);
}
}
`;
const getWorkerName = (
id: number,
workersList: Global.BaseOption<number>[]
@@ -76,6 +97,7 @@ const getWorkerName = (
const worker = workersList.find((item) => item.value === id);
return worker?.label || '';
};
const InstanceStatusTag = (props: { data: ListItem }) => {
const { data } = props;
if (!data.state) {
@@ -272,10 +294,18 @@ const ModelFiles = () => {
const handleSelect = async (val: any, record: ListItem) => {
try {
if (val === 'delete') {
handleDelete({
...record,
name: record.local_path
});
handleDelete(
{
...record,
name: record.local_path
},
{
checkConfig: {
checkText: 'resources.modelfiles.delete.tips',
defautlChecked: record.source !== modelSourceMap.local_path_value
}
}
);
} else if (val === 'retry') {
await retryDownloadModelFile(record.id);
showSuccess();
@@ -357,6 +387,15 @@ const ModelFiles = () => {
restoreScrollHeight();
};
const handleDeleteByBatch = () => {
handleDeleteBatch({
checkConfig: {
checkText: 'resources.modelfiles.delete.tips',
defautlChecked: false
}
});
};
const handleCreateModel = async (data: any) => {
try {
const result = getSourceRepoConfigValue(openDeployModal.source, data);
@@ -430,17 +469,19 @@ const ModelFiles = () => {
}
return (
record.resolved_paths?.length > 0 && (
<span className="flex-center">
<PathWrapper>
<AutoTooltip ghost>
<span>{record.resolved_paths?.[0]}</span>
</AutoTooltip>
<CopyButton
text={record.resolved_paths?.[0]}
type="link"
btnStyle={{ width: 18, paddingInline: 2 }}
></CopyButton>
{renderParts(record)}
</span>
<span className="btn-wrapper">
<CopyButton
text={record.resolved_paths?.[0]}
type="link"
btnStyle={{ width: 18, paddingInline: 2 }}
></CopyButton>
{renderParts(record)}
</span>
</PathWrapper>
)
);
}
@@ -534,7 +575,7 @@ const ModelFiles = () => {
<Button
icon={<DeleteOutlined />}
danger
onClick={handleDeleteBatch}
onClick={handleDeleteByBatch}
disabled={!rowSelection.selectedRowKeys.length}
>
<span>