Merge "feat: Support download file progress and abort download"
This commit is contained in:
commit
2127390852
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
`Feature #1990355 <https://bugs.launchpad.net/skyline-console/+bug/1990355>`_:
|
||||||
|
|
||||||
|
Support progress add abort when use modal form to download file:
|
||||||
|
|
||||||
|
* Support showing download progress when download file.
|
||||||
|
|
||||||
|
* Support abort request when download file.
|
@ -268,6 +268,10 @@ export default class BaseForm extends React.Component {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get progressType() {
|
||||||
|
return 'upload';
|
||||||
|
}
|
||||||
|
|
||||||
getRightExtraSpan() {
|
getRightExtraSpan() {
|
||||||
return {
|
return {
|
||||||
left: 18,
|
left: 18,
|
||||||
@ -368,7 +372,11 @@ export default class BaseForm extends React.Component {
|
|||||||
onCancel = () => {
|
onCancel = () => {
|
||||||
if (this.isSubmitting && this.cancel) {
|
if (this.isSubmitting && this.cancel) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
Notify.success(t('Cancel upload successfully.'));
|
const message =
|
||||||
|
this.progressType === 'download'
|
||||||
|
? t('Cancel download successfully.')
|
||||||
|
: t('Cancel upload successfully.');
|
||||||
|
Notify.success(message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -478,6 +486,21 @@ export default class BaseForm extends React.Component {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onDownloadProgress = (progressEvent) => {
|
||||||
|
const { loaded, total } = progressEvent;
|
||||||
|
const percent = Math.floor((loaded / total) * 100);
|
||||||
|
this.setState({
|
||||||
|
percent,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getDownloadRequestConf = () => {
|
||||||
|
return {
|
||||||
|
onDownloadProgress: this.onDownloadProgress,
|
||||||
|
cancelToken: this.cancelToken,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
checkContextValue() {
|
checkContextValue() {
|
||||||
const { context } = this.props;
|
const { context } = this.props;
|
||||||
const names = this.nameForStateUpdate;
|
const names = this.nameForStateUpdate;
|
||||||
@ -653,9 +676,13 @@ export default class BaseForm extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { percent } = this.state;
|
const { percent } = this.state;
|
||||||
|
const message =
|
||||||
|
this.progressType === 'download'
|
||||||
|
? t('Download progress')
|
||||||
|
: t('Upload progress');
|
||||||
return (
|
return (
|
||||||
<div className={styles['submit-tip']}>
|
<div className={styles['submit-tip']}>
|
||||||
{t('Upload progress')}
|
{message}
|
||||||
<div className={styles['progress-wrapper']}>
|
<div className={styles['progress-wrapper']}>
|
||||||
<Progress percent={percent} size="small" />
|
<Progress percent={percent} size="small" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding-top: @body-padding;
|
padding-top: @body-padding;
|
||||||
overflow: hidden;
|
// overflow: hidden;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
|
||||||
:global {
|
:global {
|
||||||
|
@ -297,6 +297,7 @@
|
|||||||
"Cancel Download": "Cancel Download",
|
"Cancel Download": "Cancel Download",
|
||||||
"Cancel Select": "Cancel Select",
|
"Cancel Select": "Cancel Select",
|
||||||
"Cancel Transfer": "Cancel Transfer",
|
"Cancel Transfer": "Cancel Transfer",
|
||||||
|
"Cancel download successfully.": "Cancel download successfully.",
|
||||||
"Cancel upload successfully.": "Cancel upload successfully.",
|
"Cancel upload successfully.": "Cancel upload successfully.",
|
||||||
"Capacity & Type": "Capacity & Type",
|
"Capacity & Type": "Capacity & Type",
|
||||||
"Capacity (GiB)": "Capacity (GiB)",
|
"Capacity (GiB)": "Capacity (GiB)",
|
||||||
@ -773,6 +774,7 @@
|
|||||||
"Download all data": "Download all data",
|
"Download all data": "Download all data",
|
||||||
"Download canceled!": "Download canceled!",
|
"Download canceled!": "Download canceled!",
|
||||||
"Download current data": "Download current data",
|
"Download current data": "Download current data",
|
||||||
|
"Download progress": "Download progress",
|
||||||
"Downloading": "Downloading",
|
"Downloading": "Downloading",
|
||||||
"Draining": "Draining",
|
"Draining": "Draining",
|
||||||
"Driver": "Driver",
|
"Driver": "Driver",
|
||||||
|
@ -297,6 +297,7 @@
|
|||||||
"Cancel Download": "取消下载",
|
"Cancel Download": "取消下载",
|
||||||
"Cancel Select": "取消选择",
|
"Cancel Select": "取消选择",
|
||||||
"Cancel Transfer": "取消云硬盘转让",
|
"Cancel Transfer": "取消云硬盘转让",
|
||||||
|
"Cancel download successfully.": "取消下载成功。",
|
||||||
"Cancel upload successfully.": "取消上传成功。",
|
"Cancel upload successfully.": "取消上传成功。",
|
||||||
"Capacity & Type": "容量和类型",
|
"Capacity & Type": "容量和类型",
|
||||||
"Capacity (GiB)": "容量 (GiB)",
|
"Capacity (GiB)": "容量 (GiB)",
|
||||||
@ -773,6 +774,7 @@
|
|||||||
"Download all data": "下载所有数据",
|
"Download all data": "下载所有数据",
|
||||||
"Download canceled!": "下载已取消!",
|
"Download canceled!": "下载已取消!",
|
||||||
"Download current data": "下载当前数据",
|
"Download current data": "下载当前数据",
|
||||||
|
"Download progress": "下载进度",
|
||||||
"Downloading": "下载中",
|
"Downloading": "下载中",
|
||||||
"Draining": "满载",
|
"Draining": "满载",
|
||||||
"Driver": "驱动",
|
"Driver": "驱动",
|
||||||
|
Loading…
Reference in New Issue
Block a user