diff --git a/src/components/Tables/Base/Download/index.jsx b/src/components/Tables/Base/Download/index.jsx index fcbdf6e4..1a131cc1 100644 --- a/src/components/Tables/Base/Download/index.jsx +++ b/src/components/Tables/Base/Download/index.jsx @@ -21,6 +21,7 @@ import { get, isObject, isArray } from 'lodash'; import { Parser } from 'json2csv'; import { toLocalTimeFilter } from 'utils/index'; import Notify from 'components/Notify'; +import Confirm from 'components/Confirm'; import styles from './index.less'; export default class index extends Component { @@ -31,12 +32,14 @@ export default class index extends Component { getValueRenderFunc: PropTypes.func.isRequired, resourceName: PropTypes.string, getData: PropTypes.func, + totalMax: PropTypes.number, }; static defaultProps = { columns: [], datas: [], total: 0, + totalMax: 10000, resourceName: '', getData: () => Promise.resolve({ @@ -144,8 +147,26 @@ export default class index extends Component { }); } + confirmExportMax = () => { + const { totalMax, total } = this.props; + Confirm.warn({ + title: t('Are you sure to download data?'), + content: t( + 'The total amount of data is { total }, and the interface can support downloading { totalMax } pieces of data. If you need to download all the data, please contact the administrator.', + { totalMax, total } + ), + onCancel: this.onConfirmCancel, + onOk: this.beginDownload, + }); + }; + downloadAllData = () => { - this.beginDownload(); + const { total, totalMax } = this.props; + if (total && total > totalMax) { + this.confirmExportMax(); + } else { + this.beginDownload(); + } }; getFileName = (all) => { @@ -236,15 +257,16 @@ export default class index extends Component { getDownloadDataForAll = async () => { const { current, allData, isDownloading } = this.state; + const { totalMax } = this.props; // todo: api response counts - const counts = this.total || 0; + const counts = Math.min(this.total || 0, totalMax); if (!isDownloading) { return; } const { getData } = this.props; const items = await getData({ page: current, limit: this.pageSize }); const newDatas = [...allData, ...items]; - const isFinish = items.length < this.pageSize; + const isFinish = items.length < this.pageSize || newDatas.length >= counts; if (isFinish) { this.setState( { diff --git a/src/locales/en.json b/src/locales/en.json index 08b07b1c..91d84e97 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -101,6 +101,7 @@ "Architecture": "Architecture", "Are you sure to cancel transfer volume { name }? ": "Are you sure to cancel transfer volume { name }? ", "Are you sure to delete instance { name }? ": "Are you sure to delete instance { name }? ", + "Are you sure to download data?": "Are you sure to download data?", "Are you sure to forbidden domain { name }? Forbidden the domain will have negative effect, and users associated with the domain will not be able to log in if they are only assigned to the domain": "Are you sure to forbidden domain { name }? Forbidden the domain will have negative effect, and users associated with the domain will not be able to log in if they are only assigned to the domain", "Are you sure to forbidden project { name }? Forbidden the project will have negative effect, and users associated with the project will not be able to log in if they are only assigned to the project": "Are you sure to forbidden project { name }? Forbidden the project will have negative effect, and users associated with the project will not be able to log in if they are only assigned to the project", "Are you sure to forbidden user { name }? Forbidden the user will not allow login in ": "Are you sure to forbidden user { name }? Forbidden the user will not allow login in ", @@ -1576,6 +1577,7 @@ "The start source is a template used to create an instance. You can choose an image or a bootable volume.": "The start source is a template used to create an instance. You can choose an image or a bootable volume.", "The starting number must be less than the ending number": "The starting number must be less than the ending number", "The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure": "The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure", + "The total amount of data is { total }, and the interface can support downloading { totalMax } pieces of data. If you need to download all the data, please contact the administrator.": "The total amount of data is { total }, and the interface can support downloading { totalMax } pieces of data. If you need to download all the data, please contact the administrator.", "The trait name of the flavor needs to correspond to the trait of the scheduling node; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all necessary traits (for example: the trait of the scheduling node has HW_CPU_X86_VMX trait, and the flavor adds HW_CPU_X86_VMX, it can be scheduled to this node for necessary traits).": "The trait name of the flavor needs to correspond to the trait of the scheduling node; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all necessary traits (for example: the trait of the scheduling node has HW_CPU_X86_VMX trait, and the flavor adds HW_CPU_X86_VMX, it can be scheduled to this node for necessary traits).", "The trait of the scheduled node needs to correspond to the trait of the flavor used by the ironic instance; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all the necessary traits (for example, the ironic instance which use the flavor that has HW_CPU_X86_VMX as a necessary trait, can be scheduled to the node which has the trait of HW_CPU_X86_VMX).": "The trait of the scheduled node needs to correspond to the trait of the flavor used by the ironic instance; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all the necessary traits (for example, the ironic instance which use the flavor that has HW_CPU_X86_VMX as a necessary trait, can be scheduled to the node which has the trait of HW_CPU_X86_VMX).", "The user has been disabled, please contact the administrator": "The user has been disabled, please contact the administrator", diff --git a/src/locales/zh.json b/src/locales/zh.json index 5dc06ed5..e0f07884 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -101,6 +101,7 @@ "Architecture": "架构", "Are you sure to cancel transfer volume { name }? ": "确认要取消{ name }云硬盘转让?", "Are you sure to delete instance { name }? ": "确认要删除云主机{ name } ?", + "Are you sure to download data?": "确认要下载数据?", "Are you sure to forbidden domain { name }? Forbidden the domain will have negative effect, and users associated with the domain will not be able to log in if they are only assigned to the domain": "确认要禁用域{name}?禁用域后,该域下面的项目和用户都会被禁止,用户将无法登陆", "Are you sure to forbidden project { name }? Forbidden the project will have negative effect, and users associated with the project will not be able to log in if they are only assigned to the project": "确认要禁用项目{name}?禁用项目后将会产生负面影响,项目关联的用户如果只分配给该项目,将无法登陆", "Are you sure to forbidden user { name }? Forbidden the user will not allow login in ": "确定禁用用户{name}? 禁用后用户将无法登陆", @@ -1576,6 +1577,7 @@ "The start source is a template used to create an instance. You can choose an image or a bootable volume.": "启动源是用来创建云主机的模板, 您可以选择镜像或者可启动的卷。", "The starting number must be less than the ending number": "起始数字必须小于结束数字", "The timeout period of waiting for the return of the health check request, the check timeout will be judged as a check failure": "等待健康检查请求返回的超时时间,检查超时将会被判定为一次检查失败", + "The total amount of data is { total }, and the interface can support downloading { totalMax } pieces of data. If you need to download all the data, please contact the administrator.": "数据总量为{ total },界面可支持下载{ totalMax }条数据,如需下载全部数据,请联系管理员。", "The trait name of the flavor needs to correspond to the trait of the scheduling node; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all necessary traits (for example: the trait of the scheduling node has HW_CPU_X86_VMX trait, and the flavor adds HW_CPU_X86_VMX, it can be scheduled to this node for necessary traits).": "云主机类型的特性名称需要与调度节点的特性对应;通过给裸机实例注入必需特性,计算服务将只调度实例到具有所有必需特性的裸金属节点(比如:调度节点的有 HW_CPU_X86_VMX的特性,云主机类型添加HW_CPU_X86_VMX为必需特性,可以调度到此节点)。", "The trait of the scheduled node needs to correspond to the trait of the flavor used by the ironic instance; by injecting the necessary traits into the ironic instance, the computing service will only schedule the instance to the bare metal node with all the necessary traits (for example, the ironic instance which use the flavor that has HW_CPU_X86_VMX as a necessary trait, can be scheduled to the node which has the trait of HW_CPU_X86_VMX).": "被调度节点的特性需要与裸机实例使用的云主机类型的特性对应;通过给裸机实例注入必需特性,计算服务将只调度实例到具有所有必需特性的裸金属节点(比如:调度节点的有 HW_CPU_X86_VMX的特性, 云主机类型添加HW_CPU_X86_VMX为必要特性,可以调度到此节点)。", "The user has been disabled, please contact the administrator": "用户已被禁用,请联系管理员",