style: usage download button
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import PageTools from '@/components/page-tools';
|
|
||||||
import { ExportOutlined } from '@ant-design/icons';
|
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Col, DatePicker, Row, Select } from 'antd';
|
import { Col, DatePicker, Row, Select } from 'antd';
|
||||||
import { FC, memo, useContext, useState } from 'react';
|
import { FC, memo, useContext, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { DashboardContext } from '../../config/dashboard-context';
|
import { DashboardContext } from '../../config/dashboard-context';
|
||||||
@@ -51,7 +49,6 @@ const UsageInner: FC<{ paddingRight: string }> = ({ paddingRight }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PageTools style={{ margin: '0px 0px' }} left={false} />
|
|
||||||
<Row style={{ width: '100%' }} gutter={[0, 20]}>
|
<Row style={{ width: '100%' }} gutter={[0, 20]}>
|
||||||
<Col
|
<Col
|
||||||
xs={24}
|
xs={24}
|
||||||
@@ -59,7 +56,7 @@ const UsageInner: FC<{ paddingRight: string }> = ({ paddingRight }) => {
|
|||||||
md={24}
|
md={24}
|
||||||
lg={24}
|
lg={24}
|
||||||
xl={16}
|
xl={16}
|
||||||
style={{ paddingRight: paddingRight }}
|
style={{ paddingRight: paddingRight, marginTop: 12 }}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -73,13 +70,6 @@ const UsageInner: FC<{ paddingRight: string }> = ({ paddingRight }) => {
|
|||||||
{intl.formatMessage({ id: 'dashboard.usage' })}
|
{intl.formatMessage({ id: 'dashboard.usage' })}
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
<FilterWrapper>
|
<FilterWrapper>
|
||||||
<Button
|
|
||||||
type="text"
|
|
||||||
icon={<ExportOutlined />}
|
|
||||||
onClick={handleExport}
|
|
||||||
>
|
|
||||||
{intl.formatMessage({ id: 'common.button.export' })}
|
|
||||||
</Button>
|
|
||||||
<div className="selection">
|
<div className="selection">
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
style={{ width: 240 }}
|
style={{ width: 240 }}
|
||||||
@@ -104,12 +94,13 @@ const UsageInner: FC<{ paddingRight: string }> = ({ paddingRight }) => {
|
|||||||
</FilterWrapper>
|
</FilterWrapper>
|
||||||
</div>
|
</div>
|
||||||
<RequestTokenInner
|
<RequestTokenInner
|
||||||
|
onExport={handleExport}
|
||||||
requestData={requestTokenData.requestData}
|
requestData={requestTokenData.requestData}
|
||||||
xAxisData={requestTokenData.xAxisData}
|
xAxisData={requestTokenData.xAxisData}
|
||||||
tokenData={requestTokenData.tokenData}
|
tokenData={requestTokenData.tokenData}
|
||||||
></RequestTokenInner>
|
></RequestTokenInner>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} sm={24} md={24} lg={24} xl={8}>
|
<Col xs={24} sm={24} md={24} lg={24} xl={8} style={{ marginTop: 12 }}>
|
||||||
<TitleWrapper>
|
<TitleWrapper>
|
||||||
{intl.formatMessage({ id: 'dashboard.topusers' })}
|
{intl.formatMessage({ id: 'dashboard.topusers' })}
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
|
|||||||
@@ -1,11 +1,23 @@
|
|||||||
import CardWrapper from '@/components/card-wrapper';
|
import CardWrapper from '@/components/card-wrapper';
|
||||||
import { SimpleCard } from '@/components/card-wrapper/simple-card';
|
import { SimpleCard } from '@/components/card-wrapper/simple-card';
|
||||||
import MixLineBar from '@/components/echarts/mix-line-bar';
|
import MixLineBar from '@/components/echarts/mix-line-bar';
|
||||||
|
import { ExportOutlined } from '@ant-design/icons';
|
||||||
|
import { useIntl } from '@umijs/max';
|
||||||
|
import { Button } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { baseColorMap } from '../../config';
|
import { baseColorMap } from '../../config';
|
||||||
|
|
||||||
|
const DownloadButton = styled(Button)`
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
z-index: 10;
|
||||||
|
`;
|
||||||
|
|
||||||
interface RequestTokenInnerProps {
|
interface RequestTokenInnerProps {
|
||||||
|
onExport?: () => void;
|
||||||
requestData: {
|
requestData: {
|
||||||
name: string;
|
name: string;
|
||||||
color: string;
|
color: string;
|
||||||
@@ -50,10 +62,19 @@ const legendData = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const RequestTokenInner: React.FC<RequestTokenInnerProps> = (props) => {
|
const RequestTokenInner: React.FC<RequestTokenInnerProps> = (props) => {
|
||||||
const { requestData, tokenData, xAxisData } = props;
|
const { requestData, tokenData, xAxisData, onExport } = props;
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardWrapper style={{ width: '100%' }}>
|
<CardWrapper style={{ width: '100%', position: 'relative' }}>
|
||||||
|
<DownloadButton
|
||||||
|
type="text"
|
||||||
|
icon={<ExportOutlined />}
|
||||||
|
size="small"
|
||||||
|
onClick={onExport}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'common.button.export' })}
|
||||||
|
</DownloadButton>
|
||||||
<SimpleCard dataList={dataList} height={80}></SimpleCard>
|
<SimpleCard dataList={dataList} height={80}></SimpleCard>
|
||||||
<MixLineBar
|
<MixLineBar
|
||||||
chartData={{
|
chartData={{
|
||||||
|
|||||||
@@ -196,8 +196,8 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
* unitl the evaluate result is ready
|
* unitl the evaluate result is ready
|
||||||
*/
|
*/
|
||||||
form.current?.setFieldsValue?.({
|
form.current?.setFieldsValue?.({
|
||||||
file_name: item.fakeName,
|
|
||||||
...modelInfo,
|
...modelInfo,
|
||||||
|
file_name: item.fakeName,
|
||||||
categories: getCategory(item)
|
categories: getCategory(item)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -233,9 +233,9 @@ const AddModal: FC<AddModalProps> = (props) => {
|
|||||||
form.current?.getFieldValue?.('backend_parameters') || [];
|
form.current?.getFieldValue?.('backend_parameters') || [];
|
||||||
|
|
||||||
form.current?.setFieldsValue?.({
|
form.current?.setFieldsValue?.({
|
||||||
file_name: item.fakeName,
|
|
||||||
...defaultSpec,
|
...defaultSpec,
|
||||||
...modelInfo,
|
...modelInfo,
|
||||||
|
file_name: item.fakeName,
|
||||||
backend_parameters:
|
backend_parameters:
|
||||||
formBackendParameters.length > 0
|
formBackendParameters.length > 0
|
||||||
? formBackendParameters
|
? formBackendParameters
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ interface HFModelFileProps {
|
|||||||
ref: any;
|
ref: any;
|
||||||
gpuOptions?: any[];
|
gpuOptions?: any[];
|
||||||
onSelectFile?: (file: any, evaluate?: boolean) => void;
|
onSelectFile?: (file: any, evaluate?: boolean) => void;
|
||||||
displayEvaluateStatus?: (data: {
|
|
||||||
show?: boolean;
|
|
||||||
flag: Record<string, boolean>;
|
|
||||||
}) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pattern = /^(.*)-(\d+)-of-(\d+)\.(.*)$/;
|
const pattern = /^(.*)-(\d+)-of-(\d+)\.(.*)$/;
|
||||||
@@ -54,7 +50,7 @@ const includeReg = /\.(safetensors|gguf)$/i;
|
|||||||
const filterRegGGUF = /\.(gguf)$/i;
|
const filterRegGGUF = /\.(gguf)$/i;
|
||||||
|
|
||||||
const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
||||||
const { collapsed, modelSource, isDownload, displayEvaluateStatus } = props;
|
const { collapsed, modelSource, isDownload } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [isEvaluating, setIsEvaluating] = useState(false);
|
const [isEvaluating, setIsEvaluating] = useState(false);
|
||||||
const [dataSource, setDataSource] = useState<any>({
|
const [dataSource, setDataSource] = useState<any>({
|
||||||
@@ -260,12 +256,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
resultList,
|
resultList,
|
||||||
(item: any) => item.path === currentPathRef.current
|
(item: any) => item.path === currentPathRef.current
|
||||||
);
|
);
|
||||||
displayEvaluateStatus?.({
|
|
||||||
show: false,
|
|
||||||
flag: {
|
|
||||||
file: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (currentItem) {
|
if (currentItem) {
|
||||||
handleSelectModelFile(currentItem, true);
|
handleSelectModelFile(currentItem, true);
|
||||||
}
|
}
|
||||||
@@ -273,12 +264,6 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
setIsEvaluating(false);
|
setIsEvaluating(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsEvaluating(false);
|
setIsEvaluating(false);
|
||||||
displayEvaluateStatus?.({
|
|
||||||
show: false,
|
|
||||||
flag: {
|
|
||||||
file: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -630,6 +630,7 @@ export const useSelectModel = (data: { gpuOptions: any[] }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
repo_id: selectModel.name,
|
repo_id: selectModel.name,
|
||||||
|
file_name: '',
|
||||||
name: name,
|
name: name,
|
||||||
backend: backend
|
backend: backend
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user