Compare commits

...

1 Commits

Author SHA1 Message Date
985f96228f feat(nodejs): removed directUrl 2024-04-16 15:39:44 +07:00
6 changed files with 5 additions and 42 deletions

View File

@ -528,7 +528,6 @@ app.post('/reference', (req, res) => { // define a handler for renaming file
if (req.body.link.indexOf(req.DocManager.getServerUrl()) === -1) {
result({
url: req.body.link,
directUrl: req.body.link,
});
return;
}
@ -558,7 +557,6 @@ app.post('/reference', (req, res) => { // define a handler for renaming file
fileType: fileUtility.getFileExtension(fileName).slice(1),
key: req.DocManager.getKey(fileName),
url: req.DocManager.getDownloadUrl(fileName, true),
directUrl: req.body.directUrl ? req.DocManager.getDownloadUrl(fileName) : null,
referenceData: {
fileKey: JSON.stringify({ fileName, userAddress: req.DocManager.curUserHostAddress() }),
instanceId: req.DocManager.getServerUrl(),
@ -952,7 +950,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
const fileName = fileUtility.getFileName(req.query.fileName);
const lang = req.DocManager.getLang();
const userDirectUrl = req.query.directUrl === 'true';
let actionData = 'null';
if (req.query.action) {
@ -1019,7 +1016,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document
}
const key = req.DocManager.getKey(fileName);
const url = req.DocManager.getDownloadUrl(fileName, true);
const directUrl = req.DocManager.getDownloadUrl(fileName);
let mode = req.query.mode || 'edit'; // mode: view/edit/review/comment/fillForms/embedded
let canEdit = fileUtility.getEditExtensions().indexOf(fileExt.slice(1)) !== -1; // check if this file can be edited
@ -1048,8 +1044,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document
name: fileName,
ext: fileUtility.getFileExtension(fileName, true),
uri: url,
directUrl: !userDirectUrl ? null : directUrl,
uriUser: directUrl,
uriUser: url,
created: new Date().toDateString(),
favorite: user.favorite != null ? user.favorite : 'null',
},
@ -1097,19 +1092,14 @@ app.get('/editor', (req, res) => { // define a handler for editing document
dataInsertImage: {
fileType: 'svg',
url: `${req.DocManager.getServerUrl(true)}/images/logo.svg`,
directUrl: !userDirectUrl ? null : `${req.DocManager.getServerUrl()}/images/logo.svg`,
},
dataDocument: {
fileType: 'docx',
url: `${req.DocManager.getServerUrl(true)}/assets/document-templates/sample/sample.docx`,
directUrl: !userDirectUrl
? null
: `${req.DocManager.getServerUrl()}/assets/document-templates/sample/sample.docx`,
},
dataSpreadsheet: {
fileType: 'csv',
url: `${req.DocManager.getServerUrl(true)}/csv`,
directUrl: !userDirectUrl ? null : `${req.DocManager.getServerUrl()}/csv`,
},
usersForMentions: user.id !== 'uid-0' ? users.getUsersForMentions(user.id) : null,
usersForProtect,
@ -1178,8 +1168,7 @@ app.post('/rename', (req, res) => { // define a handler for renaming file
app.post('/historyObj', (req, res) => {
req.DocManager = new DocManager(req, res);
const { fileName } = req.body;
const { directUrl } = req.body || null;
const historyObj = req.DocManager.getHistoryObject(fileName, null, directUrl);
const historyObj = req.DocManager.getHistoryObject(fileName, null);
if (cfgSignatureEnable) {
for (let i = 0; i < historyObj.historyData.length; i++) {

View File

@ -67,9 +67,6 @@ DocManager.prototype.getCustomParams = function getCustomParams() {
const { lang } = this.req.query; // language
params += (lang ? `&lang=${this.getLang()}` : '');
const { directUrl } = this.req.query; // directUrl
params += (directUrl ? `&directUrl=${directUrl === 'true'}` : '');
const { fileName } = this.req.query; // file name
params += (fileName ? `&fileName=${fileName}` : '');
@ -446,11 +443,10 @@ DocManager.prototype.countVersion = function countVersion(directory) {
return i;
};
DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = null) {
DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null) {
const userAddress = userAddr || this.curUserHostAddress();
const historyPath = this.historyPath(fileName, userAddress);
const key = this.getKey(fileName);
const directUrl = this.getDownloadUrl(fileName);
const fileExt = fileUtility.getFileExtension(fileName);
const url = this.getDownloadUrl(fileName, true);
const history = [];
@ -472,15 +468,12 @@ DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, user
// write all the file history information
history.push(this.getHistory(fileName, changes, keyVersion, i));
const userUrl = i === countVersion ? directUrl : (`${this.getServerUrl(false)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`);
const historyD = {
fileType: fileExt.slice(1),
version: i,
key: keyVersion,
url: i === countVersion ? url : (`${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
directUrl: !userDirectUrl ? null : userUrl,
};
// check if the path to the file with document versions differences exists
@ -489,7 +482,6 @@ DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, user
fileType: historyData[i - 2].fileType,
key: historyData[i - 2].key,
url: historyData[i - 2].url,
directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl,
};
const changesUrl = `${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`;
@ -512,7 +504,6 @@ DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, user
version: countVersion,
key,
url,
directUrl: !userDirectUrl ? null : directUrl,
});
}

View File

@ -18,7 +18,6 @@
var language;
var userid;
var directUrl;
var formatManager;
window.onload = function () {
@ -46,7 +45,6 @@ if (typeof jQuery != "undefined") {
userid = getUrlVars()["userid"];
language = getUrlVars()["lang"];
directUrl = getUrlVars()["directUrl"] == "true";
mustReload = false;
@ -60,13 +58,6 @@ if (typeof jQuery != "undefined") {
else
userid = jq("#user").val();
if (directUrl)
jq("#directUrl").prop("checked", directUrl);
else
directUrl = jq("#directUrl").prop("checked");
jq(function () {
jq('#fileupload').fileupload({
dataType: 'json',

View File

@ -1,5 +1,4 @@
"document": {
"directUrl": "<%- file.directUrl %>",
"fileType": "<%- file.ext %>",
"info": {
"owner": "Me",

View File

@ -79,10 +79,8 @@
var onRequestHistory = function (event) { // the user is trying to show the document version history
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const data = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
@ -110,7 +108,6 @@
var onRequestRestore = function (event) { // the user is trying to restore file version
const version = event.data.version;
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const restoreData = {
version: version,
fileName: fileName,
@ -124,7 +121,6 @@
if (response.success && !response.error) {
const dataForHistory = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
@ -259,8 +255,6 @@
var requestReference = function(data, callback) {
innerAlert(data);
data.directUrl = !!config.document.directUrl;
let xhr = new XMLHttpRequest();
xhr.open("POST", "reference");
xhr.setRequestHeader("Content-Type", "application/json");
@ -295,7 +289,6 @@
}
if (firstXlsxName) {
let data = {
directUrl : "<%- file.directUrl %>" || false,
path : firstXlsxName
};
let xhr = new XMLHttpRequest();

View File

@ -99,8 +99,8 @@
<tr>
<td valign="middle">
<label class="side-option">
<input id="directUrl" type="checkbox" class="checkbox collectable" name="directUrl" />Try opening on client
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
<input id="" type="checkbox" class="checkbox collectable" name="" />Try opening on client
<img id="" class="info info-tooltip" data-id="" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
</label>
</td>
</tr>