mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 15:38:15 +00:00
Feature/onlyoffice converter (#4937)
* onlyoffice-converter: initial setup * onlyoffice-converter: hardcoded converter * onlyoffice-converter: converter v0.1 * onlyoffice-converter: config tweaks * onlyoffice-connector: jwt typo fix * format * onlyoffice-converter: async fix * onlyoffice-converter: jwt fix Co-authored-by: Dmitrii Vershinin <dmitry.vershinin@onlyoffice.com>
This commit is contained in:
@@ -272,6 +272,9 @@ class DirentListItem extends React.Component {
|
||||
case 'Open via Client':
|
||||
this.onOpenViaClient();
|
||||
break;
|
||||
case 'Convert with ONLYOFFICE':
|
||||
this.onConvertWithONLYOFFICE();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -365,6 +368,31 @@ class DirentListItem extends React.Component {
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
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');
|
||||
})
|
||||
}
|
||||
|
||||
onItemDownload = (e) => {
|
||||
e.nativeEvent.stopImmediatePropagation();
|
||||
let dirent = this.props.dirent;
|
||||
|
Reference in New Issue
Block a user