From e347ea36ce5bdd353d63ea42612ea9d2015d8d1e Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 18 Apr 2023 11:18:14 +0300 Subject: [PATCH 01/36] nodejs: "params" in links deleted, added class for actions --- .../nodejs/views/index.ejs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/web/documentserver-example/nodejs/views/index.ejs b/web/documentserver-example/nodejs/views/index.ejs index 5de68c48..f9e965a0 100755 --- a/web/documentserver-example/nodejs/views/index.ejs +++ b/web/documentserver-example/nodejs/views/index.ejs @@ -48,16 +48,16 @@
- + + From 7be2a5a50795b406e5fd1549de5af580436940fc Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 27 Apr 2023 14:22:58 +0300 Subject: [PATCH 11/36] nodejs: remove serverUrl --- web/documentserver-example/nodejs/app.js | 3 +-- .../nodejs/helpers/wopi/wopiRouting.js | 1 - .../nodejs/views/index.ejs | 4 ++-- .../nodejs/views/wopiIndex.ejs | 18 +++++++++--------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 3ab2a8a4..9ac31e2c 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -1,4 +1,4 @@ -/** +/** * * (c) Copyright Ascensio System SIA 2023 * @@ -106,7 +106,6 @@ app.get('/', (req, res) => { // define a handler for default page storedFiles: req.DocManager.getStoredFiles(), params: req.DocManager.getCustomParams(), users, - serverUrl: req.DocManager.getServerUrl(), languages: configServer.get('languages'), }); } catch (ex) { diff --git a/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js b/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js index a9f980a9..ca462307 100755 --- a/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js +++ b/web/documentserver-example/nodejs/helpers/wopi/wopiRouting.js @@ -80,7 +80,6 @@ exports.registerRoutes = function registerRoutes(app) { storedFiles: wopiEnable ? files : [], params: req.DocManager.getCustomParams(), users, - serverUrl: req.DocManager.getServerUrl(), preloaderUrl: siteUrl + configServer.get('preloaderUrl'), convertExts: configServer.get('convertedDocs'), editedExts, diff --git a/web/documentserver-example/nodejs/views/index.ejs b/web/documentserver-example/nodejs/views/index.ejs index 5de68c48..a6754e55 100755 --- a/web/documentserver-example/nodejs/views/index.ejs +++ b/web/documentserver-example/nodejs/views/index.ejs @@ -32,7 +32,7 @@
@@ -107,7 +107,7 @@ diff --git a/web/documentserver-example/nodejs/views/wopiIndex.ejs b/web/documentserver-example/nodejs/views/wopiIndex.ejs index ef3eaf62..3b46b491 100755 --- a/web/documentserver-example/nodejs/views/wopiIndex.ejs +++ b/web/documentserver-example/nodejs/views/wopiIndex.ejs @@ -35,7 +35,7 @@
@@ -51,16 +51,16 @@ @@ -100,7 +100,7 @@ @@ -148,7 +148,7 @@ <% if (storedFiles[i].defaultAction) { %> - + <%} else { %> <% } %> @@ -158,7 +158,7 @@ <% if (storedFiles[i].actions && storedFiles[i].actions.length > 0) { %> <% for (var j = 0; j < storedFiles[i].actions.length; j++) { %> - + <%= storedFiles[i].actions[j].name %> @@ -167,7 +167,7 @@ <% } %> - + Download From afec51b29666776666b39be948926b87e485295e Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 1 Dec 2022 12:09:08 +0300 Subject: [PATCH 12/36] nodejs: setUsers for region protection --- CHANGELOG.md | 1 + web/documentserver-example/nodejs/app.js | 1 + .../nodejs/helpers/users.js | 19 +++++++++++++++++-- .../nodejs/views/editor.ejs | 19 ++++++++++++++++--- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cf48548..0d36f52b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- nodejs: setUsers for region protection - si skin languages - fix "no" skin languages - anonymous can't change viewer to edit diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 446636a2..9d674217 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -1019,6 +1019,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/csv", }, usersForMentions: user.id != "uid-0" ? users.getUsersForMentions(user.id) : null, + usersForProtect: user.id != "uid-0" ? users.getUsersForProtect(user.id) : null, }; if (cfgSignatureEnable) { diff --git a/web/documentserver-example/nodejs/helpers/users.js b/web/documentserver-example/nodejs/helpers/users.js index e815f8b5..7e8b0aca 100644 --- a/web/documentserver-example/nodejs/helpers/users.js +++ b/web/documentserver-example/nodejs/helpers/users.js @@ -77,7 +77,7 @@ var users = [ remove: ["group-2"] }, ["group-2", ""], true, [], descr_user_2, false), // own and without group - new User("uid-3", "Hamish Mitchell", "mitchell@example.com", + new User("uid-3", "Hamish Mitchell", null, "group-3", ["group-2"], { view: ["group-3", "group-2"], edit: ["group-2"], @@ -119,7 +119,7 @@ users.getUser = function (id) { return result ? result : this[0]; }; -// get a list of users with their name and email +// get a list of users with their name and email for mentions users.getUsersForMentions = function (id) { var result = []; this.forEach(user => { @@ -133,4 +133,19 @@ users.getUsersForMentions = function (id) { return result; }; +// get a list of users with their name, id and email for protect +users.getUsersForProtect = function (id) { + var result = []; + this.forEach(user => { + if (user.id != id && user.name != null) { + result.push({ + email: user.email, + id: user.id, + name: user.name + }); + } + }); + return result; +}; + module.exports = users; diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 8a4a0d27..d8d4140f 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -139,9 +139,22 @@ docEditor.setMailMergeRecipients(<%- JSON.stringify(dataMailMergeRecipients) %>); // insert recipient data for mail merge into the file }; - var onRequestUsers = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%- JSON.stringify(usersForMentions) %> + var onRequestUsers = function (event) { + if (event && event.data){ + var c = event.data.c; + } + + switch (c) { + case "protect": + var users = <%- JSON.stringify(usersForProtect) %>; + break; + default: + users = <%- JSON.stringify(usersForMentions) %>; + } + + docEditor.setUsers({ + "c": c, + "users": users, }); }; From 35798a79166e79ad4726792a39df7e728b518fe5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 10 May 2023 10:33:16 +0300 Subject: [PATCH 13/36] nodejs: hasOwnProperty() used instead of hasOwn() for NodeJS v.14 --- web/documentserver-example/nodejs/.eslintrc.js | 1 + web/documentserver-example/nodejs/app.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/.eslintrc.js b/web/documentserver-example/nodejs/.eslintrc.js index 34f60535..8ca48270 100644 --- a/web/documentserver-example/nodejs/.eslintrc.js +++ b/web/documentserver-example/nodejs/.eslintrc.js @@ -16,5 +16,6 @@ module.exports = { 'no-continue': 'off', 'no-extend-native': ['error', { exceptions: ['String'] }], 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], + 'no-prototype-builtins': 'off', }, }; diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 10611e97..50cfafa5 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -807,7 +807,7 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c // check jwt token if (cfgSignatureEnable && cfgSignatureUseForRequest) { let body = null; - if (Object.hasOwn(req.body, 'token')) { // if request body has its own token + if (req.body.hasOwnProperty('token')) { // if request body has its own token body = documentService.readToken(req.body.token); // read and verify it } else { const checkJwtHeaderRes = documentService.checkJwtHeader(req); // otherwise, check jwt token headers @@ -835,7 +835,7 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c return; } - if (Object.hasOwn(req.body, 'status')) { // if the request body has status parameter + if (req.body.hasOwnProperty('status')) { // if the request body has status parameter await processTrack(res, req.body, fName, uAddress); // track file changes } else { await readbody(req, res, fName, uAddress); // otherwise, read request body first From d2491ae6b708f3271c17510c63965b60b741788e Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Thu, 27 Apr 2023 17:55:30 +0300 Subject: [PATCH 14/36] edited language name zh --- web/documentserver-example/nodejs/config/default.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/config/default.json b/web/documentserver-example/nodejs/config/default.json index dd138d5d..a9e8205c 100644 --- a/web/documentserver-example/nodejs/config/default.json +++ b/web/documentserver-example/nodejs/config/default.json @@ -54,8 +54,8 @@ "be": "Belarusian", "bg": "Bulgarian", "ca": "Catalan", - "zh": "Chinese", - "zh-TW": "Chinese (Taiwan)", + "zh": "Chinese (Simplified)", + "zh-TW": "Chinese (Traditional)", "cs": "Czech", "da": "Danish", "nl": "Dutch", From 63e7461995a66f22a6c0b912c6c429312dab1916 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:44:52 +0300 Subject: [PATCH 15/36] csharp: edited language name zh --- web/documentserver-example/csharp/settings.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp/settings.config b/web/documentserver-example/csharp/settings.config index 7a1309fa..5151c44f 100644 --- a/web/documentserver-example/csharp/settings.config +++ b/web/documentserver-example/csharp/settings.config @@ -17,7 +17,7 @@ - + From 2d0e6c0d3feecb642283b29b7178a46cb313bd28 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:45:19 +0300 Subject: [PATCH 16/36] csharp-mvc: edited language name zh --- web/documentserver-example/csharp-mvc/web.appsettings.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/csharp-mvc/web.appsettings.config b/web/documentserver-example/csharp-mvc/web.appsettings.config index 6fba18e6..9edc93d4 100644 --- a/web/documentserver-example/csharp-mvc/web.appsettings.config +++ b/web/documentserver-example/csharp-mvc/web.appsettings.config @@ -18,7 +18,7 @@ - + From a60c594505aee97ca461c48a9d3654ba26ed33e1 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:45:51 +0300 Subject: [PATCH 17/36] java: edited language name zh --- .../java/src/main/resources/settings.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/java/src/main/resources/settings.properties b/web/documentserver-example/java/src/main/resources/settings.properties index ab1fc5f6..8a404ee0 100644 --- a/web/documentserver-example/java/src/main/resources/settings.properties +++ b/web/documentserver-example/java/src/main/resources/settings.properties @@ -16,7 +16,7 @@ files.docservice.url.api=web-apps/apps/api/documents/api.js files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html files.docservice.url.example= -files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language +files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language files.docservice.secret= files.docservice.header=Authorization From dbf6766897eb0ba63d5c31b64cc869031ce87195 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:46:09 +0300 Subject: [PATCH 18/36] java-spring: edited language name zh --- .../java-spring/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/java-spring/src/main/resources/application.properties b/web/documentserver-example/java-spring/src/main/resources/application.properties index 034592c8..d870c28c 100755 --- a/web/documentserver-example/java-spring/src/main/resources/application.properties +++ b/web/documentserver-example/java-spring/src/main/resources/application.properties @@ -28,7 +28,7 @@ files.docservice.token-use-for-request=true files.docservice.verify-peer-off=true -files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language +files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language spring.datasource.url=jdbc:h2:mem:usersdb spring.datasource.driverClassName=org.h2.Driver From f9ed5edf89b859bc336b36bda82a41ad041bf8e2 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:46:25 +0300 Subject: [PATCH 19/36] php: edited language name zh --- web/documentserver-example/php/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/php/config.json b/web/documentserver-example/php/config.json index 1900f8f6..e2313ced 100644 --- a/web/documentserver-example/php/config.json +++ b/web/documentserver-example/php/config.json @@ -51,8 +51,8 @@ "be": "Belarusian", "bg": "Bulgarian", "ca": "Catalan", - "zh": "Chinese", - "zh-TW": "Chinese (Taiwan)", + "zh": "Chinese (Simplified)", + "zh-TW": "Chinese (Traditional)", "cs": "Czech", "da": "Danish", "nl": "Dutch", From 707122013f55da119f4c3079ee3bc91423bad131 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:46:42 +0300 Subject: [PATCH 20/36] python: edited language name zh --- web/documentserver-example/python/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/config.py b/web/documentserver-example/python/config.py index 9de56251..0d8c38bc 100644 --- a/web/documentserver-example/python/config.py +++ b/web/documentserver-example/python/config.py @@ -67,8 +67,8 @@ LANGUAGES = { 'be': 'Belarusian', 'bg': 'Bulgarian', 'ca': 'Catalan', - 'zh': 'Chinese', - 'zh-TW': 'Chinese (Taiwan)', + 'zh': 'Chinese (Simplified)', + 'zh-TW': 'Chinese (Traditional)', 'cs': 'Czech', 'da': 'Danish', 'nl': 'Dutch', From 9a1110a56e584aba73a2e60792edae5345500728 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 28 Apr 2023 14:46:56 +0300 Subject: [PATCH 21/36] ruby: edited language name zh --- web/documentserver-example/ruby/config/application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index 5cba2595..52796ffe 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -59,8 +59,8 @@ module OnlineEditorsExampleRuby 'be' => 'Belarusian', 'bg' => 'Bulgarian', 'ca' => 'Catalan', - 'zh' => 'Chinese', - 'zh-TW' => 'Chinese (Taiwan)', + 'zh' => 'Chinese (Simplified)', + 'zh-TW' => 'Chinese (Traditional)', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', From 8dcf75f3fbd518326dee7bdb9d42fba2cc180ea2 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 11 May 2023 14:06:48 +0300 Subject: [PATCH 22/36] nodejs: get history data by request --- web/documentserver-example/nodejs/app.js | 97 +++++-------------- .../nodejs/helpers/docManager.js | 72 ++++++++++++++ .../nodejs/views/editor.ejs | 43 +++++--- 3 files changed, 126 insertions(+), 86 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 10611e97..d64a364e 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -848,8 +848,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document const fileName = fileUtility.getFileName(req.query.fileName); let { fileExt } = req.query; - const history = []; - const historyData = []; const lang = req.DocManager.getLang(); const user = users.getUser(req.query.userid); const userDirectUrl = req.query.directUrl === 'true'; @@ -927,76 +925,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document } const submitForm = mode === 'fillForms' && userid === 'uid-1' && !1; - let countVersion = 1; - - const historyPath = req.DocManager.historyPath(fileName, userAddress); - let changes = null; - let keyVersion = key; - - if (historyPath !== '') { - countVersion = req.DocManager.countVersion(historyPath) + 1; // get the number of file versions - for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions - if (i < countVersion) { - const keyPath = req.DocManager.keyPath(fileName, userAddress, i); - if (!fileSystem.existsSync(keyPath)) continue; - keyVersion = `${fileSystem.readFileSync(keyPath)}`; - } else { - keyVersion = key; - } - // write all the file history information - history.push(req.DocManager.getHistory(fileName, changes, keyVersion, i)); - - const userUrl = i === countVersion ? directUrl : (`${req.DocManager.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 : (`${req.DocManager.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 - if (i > 1 && req.DocManager.existsSync(req.DocManager.diffPath(fileName, userAddress, i - 1))) { - historyD.previous = { // write information about previous file version - fileType: historyData[i - 2].fileType, - key: historyData[i - 2].key, - url: historyData[i - 2].url, - directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl, - }; - const changesUrl = `${req.DocManager.getServerUrl(true)}/history?fileName=` - + `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`; - historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object - } - - historyData.push(historyD); - - if (i < countVersion) { - // get the path to the file with document changes - const changesFile = req.DocManager.changesPath(fileName, userAddress, i); - changes = req.DocManager.getChanges(changesFile); // get changes made in the file - } - } - } else { // if history path is empty - // write the history information about the last file version - history.push(req.DocManager.getHistory(fileName, changes, keyVersion, countVersion)); - historyData.push({ - fileType: fileExt.slice(1), - version: countVersion, - key, - url, - directUrl: !userDirectUrl ? null : directUrl, - }); - } - - if (cfgSignatureEnable) { - for (let i = 0; i < historyData.length; i++) { - // sign token with given data using signature secret - historyData[i].token = jwt.sign(historyData[i], cfgSignatureSecret, { expiresIn: cfgSignatureSecretExpiresIn }); - } - } - // file config data const argss = { apiUrl: siteUrl + configServer.get('apiUrl'), @@ -1006,7 +934,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document uri: url, directUrl: !userDirectUrl ? null : directUrl, uriUser: directUrl, - version: countVersion, created: new Date().toDateString(), favorite: user.favorite != null ? user.favorite : 'null', }, @@ -1049,8 +976,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document instanceId: userid !== 'uid-0' ? req.DocManager.getInstanceId() : null, protect: !user.deniedPermissions.includes('protect'), }, - history, - historyData, dataInsertImage: { fileType: 'png', url: `${req.DocManager.getServerUrl(true)}/images/logo.png`, @@ -1129,6 +1054,28 @@ app.post('/rename', (req, res) => { // define a handler for renaming file documentService.commandRequest('meta', dockey, result, meta); }); +app.post('/historyObj', (req, res) => { + req.DocManager = new DocManager(req, res); + const { fileName } = req.body; + const { requestType } = req.body || null; + const { directUrl } = req.body || null; + const historyObj = req.DocManager.getHistoryObject(fileName, null, directUrl); + + if (cfgSignatureEnable) { + for (let i = 0; i < historyObj.historyData.length; i++) { + // sign token with given data using signature secret + historyObj.historyData[i].token = jwt.sign( + historyObj.historyData[i], + cfgSignatureSecret, + { expiresIn: cfgSignatureSecretExpiresIn }, + ); + } + } + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.write(JSON.stringify(historyObj)); + res.end(); +}); + wopiApp.registerRoutes(app); // "Not found" error with 404 status diff --git a/web/documentserver-example/nodejs/helpers/docManager.js b/web/documentserver-example/nodejs/helpers/docManager.js index 43a4ff9d..0a52e819 100644 --- a/web/documentserver-example/nodejs/helpers/docManager.js +++ b/web/documentserver-example/nodejs/helpers/docManager.js @@ -438,6 +438,78 @@ DocManager.prototype.countVersion = function countVersion(directory) { return i; }; +DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = 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 = []; + const historyData = []; + let countVersion = 1; + let changes = null; + let keyVersion = key; + + if (historyPath !== '') { + countVersion = this.countVersion(historyPath) + 1; // get the number of file versions + for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions + if (i < countVersion) { + const keyPath = this.keyPath(fileName, userAddress, i); + if (!fileSystem.existsSync(keyPath)) continue; + keyVersion = `${fileSystem.readFileSync(keyPath)}`; + } else { + keyVersion = key; + } + // 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 + if (i > 1 && this.existsSync(this.diffPath(fileName, userAddress, i - 1))) { + historyD.previous = { // write information about previous file version + 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}`; + historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object + } + + historyData.push(historyD); + + if (i < countVersion) { + // get the path to the file with document changes + const changesFile = this.changesPath(fileName, userAddress, i); + changes = this.getChanges(changesFile); // get changes made in the file + } + } + } else { // if history path is empty + // write the history information about the last file version + history.push(this.getHistory(fileName, changes, keyVersion, countVersion)); + historyData.push({ + fileType: fileExt.slice(1), + version: countVersion, + key, + url, + directUrl: !userDirectUrl ? null : directUrl, + }); + } + + return { history, historyData, countVersion }; +}; // get file history information DocManager.prototype.getHistory = function getHistory(fileName, content, keyVersion, version) { let oldVersion = false; diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index d8d4140f..b1575c02 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -72,20 +72,41 @@ }; var onRequestHistory = function (event) { // the user is trying to show the document version history - var historyObj = <%- JSON.stringify(history) %> || null; - + const fileName = "<%- file.name %>" || null; + const directUrl = "<%- file.directUrl %>" || null; + const data = { + fileName, + directUrl + }; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "historyObj"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(data)); + xhr.onload = function () { + const response = JSON.parse(xhr.responseText); docEditor.refreshHistory( // show the document version history - { - currentVersion: "<%- file.version %>", - history: historyObj - }); + { + currentVersion: response.countVersion, + history: response.history + }); + } }; - var onRequestHistoryData = function (data) { // the user is trying to click the specific document version in the document version history - var version = data.data; - var historyData = <%- JSON.stringify(historyData) %> || null; - - docEditor.setHistoryData(historyData[version-1]); // send the link to the document for viewing the version history + var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history + const fileName = "<%- file.name %>" || null; + const directUrl = "<%- file.directUrl %>" || null; + const version = event.data; + const data = { + fileName, + directUrl + }; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "historyObj"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(data)); + xhr.onload = function () { + docEditor.setHistoryData(JSON.parse(xhr.responseText).historyData[version-1]); // send the link to the document for viewing the version history + } }; var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history From f914afcc537995caa729741d48e0bdd25fa5932d Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 11 May 2023 15:14:07 +0300 Subject: [PATCH 23/36] nodejs: remove row without reload --- .../nodejs/public/javascripts/jscript.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/public/javascripts/jscript.js b/web/documentserver-example/nodejs/public/javascripts/jscript.js index bc1b6538..07a1434d 100644 --- a/web/documentserver-example/nodejs/public/javascripts/jscript.js +++ b/web/documentserver-example/nodejs/public/javascripts/jscript.js @@ -293,7 +293,8 @@ if (typeof jQuery != "undefined") { }); jq(document).on("click", ".delete-file", function () { - var fileName = jq(this).attr("data"); + const currentElement = jq(this); + var fileName = currentElement.attr("data"); var requestAddress = "file?filename=" + fileName; @@ -303,7 +304,12 @@ if (typeof jQuery != "undefined") { type: "delete", url: requestAddress, complete: function (data) { - document.location.reload(true); + if (JSON.parse(data.responseText).success) { + const parentRow = currentElement.parents('tr')[0]; + if (parentRow) { + parentRow.remove(); + } + } } }); }); From 68db498dfdf007a144c8b854f9d972950243de52 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 11 May 2023 14:06:48 +0300 Subject: [PATCH 24/36] nodejs: get history data by request --- web/documentserver-example/nodejs/app.js | 96 ++++--------------- .../nodejs/helpers/docManager.js | 72 ++++++++++++++ .../nodejs/views/editor.ejs | 43 ++++++--- 3 files changed, 125 insertions(+), 86 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 10611e97..f6cb1152 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -848,8 +848,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document const fileName = fileUtility.getFileName(req.query.fileName); let { fileExt } = req.query; - const history = []; - const historyData = []; const lang = req.DocManager.getLang(); const user = users.getUser(req.query.userid); const userDirectUrl = req.query.directUrl === 'true'; @@ -927,76 +925,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document } const submitForm = mode === 'fillForms' && userid === 'uid-1' && !1; - let countVersion = 1; - - const historyPath = req.DocManager.historyPath(fileName, userAddress); - let changes = null; - let keyVersion = key; - - if (historyPath !== '') { - countVersion = req.DocManager.countVersion(historyPath) + 1; // get the number of file versions - for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions - if (i < countVersion) { - const keyPath = req.DocManager.keyPath(fileName, userAddress, i); - if (!fileSystem.existsSync(keyPath)) continue; - keyVersion = `${fileSystem.readFileSync(keyPath)}`; - } else { - keyVersion = key; - } - // write all the file history information - history.push(req.DocManager.getHistory(fileName, changes, keyVersion, i)); - - const userUrl = i === countVersion ? directUrl : (`${req.DocManager.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 : (`${req.DocManager.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 - if (i > 1 && req.DocManager.existsSync(req.DocManager.diffPath(fileName, userAddress, i - 1))) { - historyD.previous = { // write information about previous file version - fileType: historyData[i - 2].fileType, - key: historyData[i - 2].key, - url: historyData[i - 2].url, - directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl, - }; - const changesUrl = `${req.DocManager.getServerUrl(true)}/history?fileName=` - + `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`; - historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object - } - - historyData.push(historyD); - - if (i < countVersion) { - // get the path to the file with document changes - const changesFile = req.DocManager.changesPath(fileName, userAddress, i); - changes = req.DocManager.getChanges(changesFile); // get changes made in the file - } - } - } else { // if history path is empty - // write the history information about the last file version - history.push(req.DocManager.getHistory(fileName, changes, keyVersion, countVersion)); - historyData.push({ - fileType: fileExt.slice(1), - version: countVersion, - key, - url, - directUrl: !userDirectUrl ? null : directUrl, - }); - } - - if (cfgSignatureEnable) { - for (let i = 0; i < historyData.length; i++) { - // sign token with given data using signature secret - historyData[i].token = jwt.sign(historyData[i], cfgSignatureSecret, { expiresIn: cfgSignatureSecretExpiresIn }); - } - } - // file config data const argss = { apiUrl: siteUrl + configServer.get('apiUrl'), @@ -1006,7 +934,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document uri: url, directUrl: !userDirectUrl ? null : directUrl, uriUser: directUrl, - version: countVersion, created: new Date().toDateString(), favorite: user.favorite != null ? user.favorite : 'null', }, @@ -1049,8 +976,6 @@ app.get('/editor', (req, res) => { // define a handler for editing document instanceId: userid !== 'uid-0' ? req.DocManager.getInstanceId() : null, protect: !user.deniedPermissions.includes('protect'), }, - history, - historyData, dataInsertImage: { fileType: 'png', url: `${req.DocManager.getServerUrl(true)}/images/logo.png`, @@ -1129,6 +1054,27 @@ app.post('/rename', (req, res) => { // define a handler for renaming file documentService.commandRequest('meta', dockey, result, meta); }); +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); + + if (cfgSignatureEnable) { + for (let i = 0; i < historyObj.historyData.length; i++) { + // sign token with given data using signature secret + historyObj.historyData[i].token = jwt.sign( + historyObj.historyData[i], + cfgSignatureSecret, + { expiresIn: cfgSignatureSecretExpiresIn }, + ); + } + } + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.write(JSON.stringify(historyObj)); + res.end(); +}); + wopiApp.registerRoutes(app); // "Not found" error with 404 status diff --git a/web/documentserver-example/nodejs/helpers/docManager.js b/web/documentserver-example/nodejs/helpers/docManager.js index 43a4ff9d..0a52e819 100644 --- a/web/documentserver-example/nodejs/helpers/docManager.js +++ b/web/documentserver-example/nodejs/helpers/docManager.js @@ -438,6 +438,78 @@ DocManager.prototype.countVersion = function countVersion(directory) { return i; }; +DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = 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 = []; + const historyData = []; + let countVersion = 1; + let changes = null; + let keyVersion = key; + + if (historyPath !== '') { + countVersion = this.countVersion(historyPath) + 1; // get the number of file versions + for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions + if (i < countVersion) { + const keyPath = this.keyPath(fileName, userAddress, i); + if (!fileSystem.existsSync(keyPath)) continue; + keyVersion = `${fileSystem.readFileSync(keyPath)}`; + } else { + keyVersion = key; + } + // 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 + if (i > 1 && this.existsSync(this.diffPath(fileName, userAddress, i - 1))) { + historyD.previous = { // write information about previous file version + 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}`; + historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object + } + + historyData.push(historyD); + + if (i < countVersion) { + // get the path to the file with document changes + const changesFile = this.changesPath(fileName, userAddress, i); + changes = this.getChanges(changesFile); // get changes made in the file + } + } + } else { // if history path is empty + // write the history information about the last file version + history.push(this.getHistory(fileName, changes, keyVersion, countVersion)); + historyData.push({ + fileType: fileExt.slice(1), + version: countVersion, + key, + url, + directUrl: !userDirectUrl ? null : directUrl, + }); + } + + return { history, historyData, countVersion }; +}; // get file history information DocManager.prototype.getHistory = function getHistory(fileName, content, keyVersion, version) { let oldVersion = false; diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index d8d4140f..b1575c02 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -72,20 +72,41 @@ }; var onRequestHistory = function (event) { // the user is trying to show the document version history - var historyObj = <%- JSON.stringify(history) %> || null; - + const fileName = "<%- file.name %>" || null; + const directUrl = "<%- file.directUrl %>" || null; + const data = { + fileName, + directUrl + }; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "historyObj"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(data)); + xhr.onload = function () { + const response = JSON.parse(xhr.responseText); docEditor.refreshHistory( // show the document version history - { - currentVersion: "<%- file.version %>", - history: historyObj - }); + { + currentVersion: response.countVersion, + history: response.history + }); + } }; - var onRequestHistoryData = function (data) { // the user is trying to click the specific document version in the document version history - var version = data.data; - var historyData = <%- JSON.stringify(historyData) %> || null; - - docEditor.setHistoryData(historyData[version-1]); // send the link to the document for viewing the version history + var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history + const fileName = "<%- file.name %>" || null; + const directUrl = "<%- file.directUrl %>" || null; + const version = event.data; + const data = { + fileName, + directUrl + }; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "historyObj"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(data)); + xhr.onload = function () { + docEditor.setHistoryData(JSON.parse(xhr.responseText).historyData[version-1]); // send the link to the document for viewing the version history + } }; var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history From 11f166525ee3a77418ad1dc5eb23daa9b4f001ed Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 12 May 2023 12:56:24 +0300 Subject: [PATCH 25/36] nodejs: onRequestRestore method on front --- .../nodejs/views/editor.ejs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index b1575c02..44d15139 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -113,6 +113,43 @@ document.location.reload(); }; + 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, + fileName, + }; + let xhr = new XMLHttpRequest(); + xhr.open("PUT", "restore"); + xhr.setRequestHeader('Content-Type', 'application/json'); + xhr.send(JSON.stringify(restoreData)); + xhr.onload = function () { + const response = JSON.parse(xhr.responseText); + if (response.success && !response.error) { + const dataForHistory = { + fileName, + directUrl + }; + let xhr = new XMLHttpRequest(); + xhr.open("POST", "historyObj"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(dataForHistory)); + xhr.onload = function () { + const response = JSON.parse(xhr.responseText); + docEditor.refreshHistory( // show the document version history + { + currentVersion: response.countVersion, + history: response.history + }); + } + } else { + innerAlert(response.error); + } + } + } + var onError = function (event) { // an error or some other specific event occurs if (event) innerAlert(event.data); @@ -256,6 +293,7 @@ config.events.onRequestHistory = onRequestHistory; config.events.onRequestHistoryData = onRequestHistoryData; config.events.onRequestHistoryClose = onRequestHistoryClose; + config.events.onRequestRestore = onRequestRestore; config.events.onRequestRename = onRequestRename; config.events.onRequestUsers = onRequestUsers; config.events.onRequestSendNotify = onRequestSendNotify; From f123cbcce364526869e2c9d4159f2877cf2b1d54 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 12 May 2023 13:00:48 +0300 Subject: [PATCH 26/36] nodejs: handler for restore file version --- web/documentserver-example/nodejs/app.js | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index d64a364e..916f9a10 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -548,6 +548,40 @@ app.post('/reference', (req, res) => { // define a handler for renaming file result(data); }); +app.put('/restore', (req, res) => { // define a handler for restore file version + const { fileName } = req.body; + const result = {}; + if (fileName) { + req.DocManager = new DocManager(req, res); + const userAddress = req.DocManager.curUserHostAddress(); + const key = req.DocManager.getKey(fileName); + const { version } = req.body; + const filePath = req.DocManager.storagePath(fileName, userAddress); + const historyPath = req.DocManager.historyPath(fileName, userAddress); + const newVersion = req.DocManager.countVersion(historyPath) + 1; + const versionPath = `${historyPath}\\${version}\\prev${fileUtility.getFileExtension(fileName)}`; + const newVersionPath = `${historyPath}\\${newVersion}`; + + if (fileSystem.existsSync(versionPath)) { + req.DocManager.createDirectory(newVersionPath); + req.DocManager.copyFile(filePath, `${newVersionPath}\\prev${fileUtility.getFileExtension(fileName)}`); + fileSystem.writeFileSync(`${newVersionPath}\\key.txt`, key); + req.DocManager.copyFile(versionPath, filePath); + result.success = true; + } else { + result.success = false; + result.error = 'Version path does not exists'; + } + } else { + result.success = false; + result.error = 'Filename is empty'; + } + + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.write(JSON.stringify(result)); + res.end(); +}); + app.post('/track', async (req, res) => { // define a handler for tracking file changes req.DocManager = new DocManager(req, res); From 7c773895508c5a8b386ebe72fd8b260bbe66b67e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Apr 2023 06:18:54 +0000 Subject: [PATCH 27/36] build(deps): bump nokogiri in /web/documentserver-example/ruby Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.14.3. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.14.3) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- web/documentserver-example/ruby/Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/Gemfile.lock b/web/documentserver-example/ruby/Gemfile.lock index e398c96e..85bfc38a 100644 --- a/web/documentserver-example/ruby/Gemfile.lock +++ b/web/documentserver-example/ruby/Gemfile.lock @@ -128,13 +128,13 @@ GEM net-protocol timeout nio4r (2.5.8) - nokogiri (1.13.10-x64-mingw-ucrt) + nokogiri (1.14.3-x64-mingw-ucrt) racc (~> 1.4) - nokogiri (1.13.10-x86_64-linux) + nokogiri (1.14.3-x86_64-linux) racc (~> 1.4) psych (4.0.5) stringio - racc (1.6.1) + racc (1.6.2) rack (2.2.6.4) rack-cors (1.1.1) rack (>= 2.0.0) From 8f0edf90e64e7fec6152c47a709a90bae78b79a9 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 17 May 2023 12:43:33 +0300 Subject: [PATCH 28/36] nodejs: request in onRequestHistory only --- .../nodejs/views/editor.ejs | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index b1575c02..6108c925 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -39,6 +39,7 @@ var docEditor; var config; + let historyObject; var innerAlert = function (message, inEditor) { if (console && console.log) @@ -83,30 +84,18 @@ xhr.setRequestHeader("Content-Type", "application/json"); xhr.send(JSON.stringify(data)); xhr.onload = function () { - const response = JSON.parse(xhr.responseText); - docEditor.refreshHistory( // show the document version history - { - currentVersion: response.countVersion, - history: response.history - }); + historyObject = JSON.parse(xhr.responseText); + docEditor.refreshHistory( // show the document version history + { + currentVersion: historyObject.countVersion, + history: historyObject.history + }); } }; var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history - const fileName = "<%- file.name %>" || null; - const directUrl = "<%- file.directUrl %>" || null; const version = event.data; - const data = { - fileName, - directUrl - }; - let xhr = new XMLHttpRequest(); - xhr.open("POST", "historyObj"); - xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(data)); - xhr.onload = function () { - docEditor.setHistoryData(JSON.parse(xhr.responseText).historyData[version-1]); // send the link to the document for viewing the version history - } + docEditor.setHistoryData(historyObject.historyData[version-1]); // send the link to the document for viewing the version history }; var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history From 1ebfe499162ac1ecd02ac99b36773dcfab4dfd63 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 17 May 2023 12:54:15 +0300 Subject: [PATCH 29/36] nodejs: fix properties for IE --- web/documentserver-example/nodejs/views/editor.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 6108c925..4da4812e 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -76,8 +76,8 @@ const fileName = "<%- file.name %>" || null; const directUrl = "<%- file.directUrl %>" || null; const data = { - fileName, - directUrl + fileName: fileName, + directUrl: directUrl }; let xhr = new XMLHttpRequest(); xhr.open("POST", "historyObj"); From d86e737493b81d545128af47f52b221240155dda Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 17 May 2023 12:59:55 +0300 Subject: [PATCH 30/36] nodejs: fix properties for IE, historyObject used in requestRestore --- web/documentserver-example/nodejs/views/editor.ejs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 787472fd..d197194b 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -107,8 +107,8 @@ const fileName = "<%- file.name %>" || null; const directUrl = "<%- file.directUrl %>" || null; const restoreData = { - version, - fileName, + version: version, + fileName: fileName, }; let xhr = new XMLHttpRequest(); xhr.open("PUT", "restore"); @@ -118,19 +118,19 @@ const response = JSON.parse(xhr.responseText); if (response.success && !response.error) { const dataForHistory = { - fileName, - directUrl + fileName: fileName, + directUrl: directUrl }; let xhr = new XMLHttpRequest(); xhr.open("POST", "historyObj"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.send(JSON.stringify(dataForHistory)); xhr.onload = function () { - const response = JSON.parse(xhr.responseText); + historyObject = JSON.parse(xhr.responseText); docEditor.refreshHistory( // show the document version history { - currentVersion: response.countVersion, - history: response.history + currentVersion: historyObject.countVersion, + history: historyObject.history }); } } else { From 44832008a8d29be40c286ba840d40d68bc4aeae6 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 17 May 2023 13:24:28 +0300 Subject: [PATCH 31/36] nodejs: reload the page if deleted line is the last one --- .../nodejs/public/javascripts/jscript.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/documentserver-example/nodejs/public/javascripts/jscript.js b/web/documentserver-example/nodejs/public/javascripts/jscript.js index 07a1434d..87dd709b 100644 --- a/web/documentserver-example/nodejs/public/javascripts/jscript.js +++ b/web/documentserver-example/nodejs/public/javascripts/jscript.js @@ -309,6 +309,10 @@ if (typeof jQuery != "undefined") { if (parentRow) { parentRow.remove(); } + const remainingRows = jq('tr.tableRow'); + if (remainingRows.length === 0) { + document.location.reload(true); + } } } }); From 5f4764060c3444e9ddf792cc4a2bcceb7bbab426 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 18 May 2023 11:22:17 +0500 Subject: [PATCH 32/36] changelog: history request --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d36f52b..3c11a40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- nodejs: getting history by a separate request - nodejs: setUsers for region protection - si skin languages - fix "no" skin languages From c516631360c6296009c756754874ffaa24c90290 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 18 May 2023 13:31:50 +0300 Subject: [PATCH 33/36] nodejs: fix remove for IE --- web/documentserver-example/nodejs/public/javascripts/jscript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/public/javascripts/jscript.js b/web/documentserver-example/nodejs/public/javascripts/jscript.js index 87dd709b..68a1c3b3 100644 --- a/web/documentserver-example/nodejs/public/javascripts/jscript.js +++ b/web/documentserver-example/nodejs/public/javascripts/jscript.js @@ -307,7 +307,7 @@ if (typeof jQuery != "undefined") { if (JSON.parse(data.responseText).success) { const parentRow = currentElement.parents('tr')[0]; if (parentRow) { - parentRow.remove(); + jq(parentRow).remove(); } const remainingRows = jq('tr.tableRow'); if (remainingRows.length === 0) { From c0437b152fb66a2cc34e65b03ba7b4f3fa01b169 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 18 May 2023 18:10:44 +0500 Subject: [PATCH 34/36] remove row to changelog --- CHANGELOG.md | 1 + web/documentserver-example/nodejs/public/javascripts/jscript.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c11a40e..7573ed0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- nodejs: delete file without reloading the page - nodejs: getting history by a separate request - nodejs: setUsers for region protection - si skin languages diff --git a/web/documentserver-example/nodejs/public/javascripts/jscript.js b/web/documentserver-example/nodejs/public/javascripts/jscript.js index 94feea15..d4bd46f7 100644 --- a/web/documentserver-example/nodejs/public/javascripts/jscript.js +++ b/web/documentserver-example/nodejs/public/javascripts/jscript.js @@ -98,7 +98,7 @@ if (typeof jQuery != "undefined") { } }); }); - + var timer = null; var checkConvert = function (filePass) { filePass = filePass ? filePass : null; From f1dae067466dc4fbb994aa1cb6450a7892f04c03 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 22 May 2023 15:44:45 +0500 Subject: [PATCH 35/36] changelog: restore file --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7573ed0a..1ca73013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - nodejs: delete file without reloading the page - nodejs: getting history by a separate request +- nodejs: restore from history - nodejs: setUsers for region protection - si skin languages - fix "no" skin languages From 668df46ec334f9d05504cb8bda00710f7cd012e7 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 1 Jun 2023 15:39:39 +0300 Subject: [PATCH 36/36] nodejs: fix(dd3255779f4ee4b245d622698a4c60ad2d2e081c) --- web/documentserver-example/nodejs/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index f981d1fb..725a4c04 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -343,11 +343,11 @@ app.post('/convert', (req, res) => { // define a handler for converting files const result = {}; // write file name, step and error values to the result object if they are defined - if (filename) result.filename = filename; + if (result.filename !== null) result.filename = filename; - if (step) result.step = step; + if (result.filenameep !== null) result.step = step; - if (error) result.error = error; + if (result.error !== null) result.error = error; response.setHeader('Content-Type', 'application/json'); response.write(JSON.stringify(result));