1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

update onlyoffice convert

This commit is contained in:
lian
2021-09-18 12:35:23 +08:00
parent 5eba921f2a
commit 8192e64175
9 changed files with 113 additions and 99 deletions

View File

@@ -369,28 +369,16 @@ class DirentListItem extends React.Component {
}
onConvertWithONLYOFFICE = ()=> {
let repoID = this.props.repoID;
let user = username;
let fileUri = this.getDirentPath(this.props.dirent)
fetch(siteRoot+'onlyoffice/convert', {
method: 'POST',
body: JSON.stringify({
username: user,
fileUri: fileUri,
repo_id: repoID,
}),
headers: {
'Content-Type': 'application/json'
}
}).then(res => {
if(res.status >= 400) throw new Error()
//Replace with changes in the state
//like this one => this.addNodeToTree(name, parentPath, 'file');
window.location.reload();
})
.catch(() => {
toaster.danger('Could not convert the file');
})
let filePath = this.getDirentPath(this.props.dirent)
seafileAPI.onlyofficeConvert(repoID, filePath).then(res => {
this.props.loadDirentList(res.data.parent_dir)
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
}
onItemDownload = (e) => {

View File

@@ -49,6 +49,7 @@ const propTypes = {
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string,
showDirentDetail: PropTypes.func.isRequired,
loadDirentList: PropTypes.func.isRequired,
};
class DirentListView extends React.Component {
@@ -645,6 +646,7 @@ class DirentListView extends React.Component {
showDirentDetail={this.props.showDirentDetail}
onItemsMove={this.props.onItemsMove}
onShowDirentsDraggablePreview={this.onShowDirentsDraggablePreview}
loadDirentList={this.props.loadDirentList}
/>
);
})}