mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
nodejs: refresh file config
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
- nodejs: refresh config
|
||||||
- nodejs: support vsdx in visio editor
|
- nodejs: support vsdx in visio editor
|
||||||
- nodejs: support pages, numbers, key formats
|
- nodejs: support pages, numbers, key formats
|
||||||
- golang: new integration example
|
- golang: new integration example
|
||||||
|
|||||||
@ -1012,6 +1012,53 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/config', async (req, res) => {
|
||||||
|
try {
|
||||||
|
req.DocManager = new DocManager(req, res);
|
||||||
|
const fileName = fileUtility.getFileName(req.query.fileName);
|
||||||
|
|
||||||
|
const userAddress = req.DocManager.curUserHostAddress();
|
||||||
|
// if the file with a given name doesn't exist
|
||||||
|
if (!req.DocManager.existsSync(req.DocManager.storagePath(fileName, userAddress))) {
|
||||||
|
throw new Error(`File not found: ${fileName}`); // display error message
|
||||||
|
}
|
||||||
|
|
||||||
|
// file config data
|
||||||
|
const data = {
|
||||||
|
document: {
|
||||||
|
key: req.DocManager.getKey(fileName),
|
||||||
|
title: fileName,
|
||||||
|
url: req.DocManager.getDownloadUrl(fileName, true),
|
||||||
|
referenceData: {
|
||||||
|
fileKey: JSON.stringify({ fileName, userAddress: req.DocManager.curUserHostAddress() }),
|
||||||
|
instanceId: req.DocManager.getInstanceId(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
editorConfig: {
|
||||||
|
callbackUrl: req.DocManager.getCallback(fileName),
|
||||||
|
mode: 'edit',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (req.query.directUrl === 'true') {
|
||||||
|
data.document.directUrl = req.DocManager.getDownloadUrl(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cfgSignatureEnable) {
|
||||||
|
// sign token with given data using signature secret
|
||||||
|
data.token = jwt.sign(data, cfgSignatureSecret, { expiresIn: cfgSignatureSecretExpiresIn });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.write(JSON.stringify(data));
|
||||||
|
} catch (ex) {
|
||||||
|
console.log(ex);
|
||||||
|
res.status(500);
|
||||||
|
res.write('error');
|
||||||
|
}
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/editor', (req, res) => { // define a handler for editing document
|
app.get('/editor', (req, res) => { // define a handler for editing document
|
||||||
try {
|
try {
|
||||||
req.DocManager = new DocManager(req, res);
|
req.DocManager = new DocManager(req, res);
|
||||||
|
|||||||
@ -353,6 +353,17 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var onRequestRefreshFile = function(event) {
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", "config?fileName=" + encodeURIComponent(config.document.title) +
|
||||||
|
"&directUrl=" + !!config.document.directUrl);
|
||||||
|
xhr.send();
|
||||||
|
xhr.onload = function () {
|
||||||
|
innerAlert(xhr.responseText);
|
||||||
|
docEditor.refreshFile(JSON.parse(xhr.responseText));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var onDocumentReady = function(){
|
var onDocumentReady = function(){
|
||||||
fixSize();
|
fixSize();
|
||||||
};
|
};
|
||||||
@ -372,6 +383,7 @@
|
|||||||
"onRequestSelectDocument": onRequestSelectDocument,
|
"onRequestSelectDocument": onRequestSelectDocument,
|
||||||
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
|
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
|
||||||
"onRequestOpen": onRequestOpen,
|
"onRequestOpen": onRequestOpen,
|
||||||
|
"onRequestRefreshFile": onRequestRefreshFile,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (<%- JSON.stringify(editor.userid) %> != null) {
|
if (<%- JSON.stringify(editor.userid) %> != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user