mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 15:19:06 +00:00
repair mutiple download bug (#4069)
This commit is contained in:
@@ -66,7 +66,7 @@ class DirentListView extends React.Component {
|
|||||||
isMoveDialogShow: false,
|
isMoveDialogShow: false,
|
||||||
isCopyDialogShow: false,
|
isCopyDialogShow: false,
|
||||||
isProgressDialogShow: false,
|
isProgressDialogShow: false,
|
||||||
progress: 0,
|
downloadItems: [],
|
||||||
isMutipleOperation: true,
|
isMutipleOperation: true,
|
||||||
activeDirent: null,
|
activeDirent: null,
|
||||||
isListDropTipShow: false,
|
isListDropTipShow: false,
|
||||||
@@ -245,52 +245,20 @@ class DirentListView extends React.Component {
|
|||||||
location.href= url;
|
location.href= url;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectedDirentNames = selectedDirentList.map(dirent => {
|
let selectedDirentNames = selectedDirentList.map(dirent => {
|
||||||
return dirent.name;
|
return dirent.name;
|
||||||
});
|
});
|
||||||
this.setState({isProgressDialogShow: true, progress: 0});
|
|
||||||
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then(res => {
|
|
||||||
this.zipToken = res.data['zip_token'];
|
|
||||||
this.addDownloadAnimation();
|
|
||||||
this.interval = setInterval(this.addDownloadAnimation, 1000);
|
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addDownloadAnimation = () => {
|
|
||||||
let _this = this;
|
|
||||||
let token = this.zipToken;
|
|
||||||
seafileAPI.queryZipProgress(token).then(res => {
|
|
||||||
let data = res.data;
|
|
||||||
let progress = data.total === 0 ? 100 : (data.zipped / data.total * 100).toFixed(0);
|
|
||||||
this.setState({progress: parseInt(progress)});
|
|
||||||
|
|
||||||
if (data['total'] === data['zipped']) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
progress: 100
|
isProgressDialogShow: true,
|
||||||
|
downloadItems: selectedDirentNames
|
||||||
});
|
});
|
||||||
clearInterval(this.interval);
|
|
||||||
location.href = URLDecorator.getUrl({type: 'download_dir_zip_url', token: token});
|
|
||||||
setTimeout(function() {
|
|
||||||
_this.setState({isProgressDialogShow: false});
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCancelDownload = () => {
|
onCloseZipDownloadDialog = () => {
|
||||||
seafileAPI.cancelZipTask(this.zipToken).then(() => {
|
|
||||||
this.setState({isProgressDialogShow: false});
|
this.setState({isProgressDialogShow: false});
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// common contextmenu handle
|
// common contextmenu handle
|
||||||
@@ -727,7 +695,12 @@ class DirentListView extends React.Component {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
{this.state.isProgressDialogShow &&
|
{this.state.isProgressDialogShow &&
|
||||||
<ZipDownloadDialog progress={this.state.progress} onCancelDownload={this.onCancelDownload} />
|
<ZipDownloadDialog
|
||||||
|
repoID={this.props.repoID}
|
||||||
|
path={this.props.path}
|
||||||
|
target={this.state.downloadItems}
|
||||||
|
toggleDialog={this.onCloseZipDownloadDialog}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user