From 73525ef2b24778ec9bb6ba29da21173bf5e04903 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 11 Apr 2017 14:37:45 +0300 Subject: [PATCH] [DE] Check server version --- .../main/app/controller/Main.js | 26 ++++++++++++++++++- apps/documenteditor/main/app_dev.js | 1 + apps/documenteditor/main/locale/en.json | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 017417c59..59b0fdd72 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -135,6 +135,7 @@ define([ this.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(this.onDocumentContentReady, this)); this.api.asc_registerCallback('asc_onOpenDocumentProgress', _.bind(this.onOpenDocument, this)); this.api.asc_registerCallback('asc_onDocumentUpdateVersion', _.bind(this.onUpdateVersion, this)); + this.api.asc_registerCallback('asc_onServerVersion', _.bind(this.onServerVersion, this)); this.api.asc_registerCallback('asc_onAdvancedOptions', _.bind(this.onAdvancedOptions, this)); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this)); @@ -984,6 +985,8 @@ define([ return; } + if ( this.onServerVersion(params.asc_getBuildVersion()) ) return; + this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; if (params.asc_getRights() !== Asc.c_oRights.Edit) @@ -1538,6 +1541,25 @@ define([ }); }, + onServerVersion: function(buildVersion) { + if (this.changeServerVersion) return true; + + if (DocsAPI.DocEditor.version() !== buildVersion && !window.compareVersions) { + this.changeServerVersion = true; + Common.UI.warning({ + title: this.titleServerVersion, + msg: this.errorServerVersion, + callback: function() { + _.defer(function() { + Common.Gateway.updateVersion(); + }) + } + }); + return true; + } + return false; + }, + /** coauthoring begin **/ // fillUserStore: function(users){ // if (!_.isEmpty(users)){ @@ -2087,7 +2109,9 @@ define([ errorSessionAbsolute: 'The document editing session has expired. Please reload the page.', errorSessionIdle: 'The document has not been edited for quite a long time. Please reload the page.', errorSessionToken: 'The connection to the server has been interrupted. Please reload the page.', - errorAccessDeny: 'You are trying to perform an action you do not have rights for.
Please contact your Document Server administrator.' + errorAccessDeny: 'You are trying to perform an action you do not have rights for.
Please contact your Document Server administrator.', + titleServerVersion: 'Editor updated', + errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app_dev.js b/apps/documenteditor/main/app_dev.js index e37fe92a4..d15f17707 100644 --- a/apps/documenteditor/main/app_dev.js +++ b/apps/documenteditor/main/app_dev.js @@ -189,6 +189,7 @@ require([ ,'common/main/lib/controller/ExternalMergeEditor' ,'common/main/lib/controller/ReviewChanges' ], function() { + window.compareVersions = true; app.start(); }); }, function(err) { diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index c424049fc..5b83871eb 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -315,6 +315,8 @@ "DE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "DE.Controllers.Main.warnNoLicense": "You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", + "DE.Controllers.Main.titleServerVersion": "Editor updated", + "DE.Controllers.Main.errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.", "DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked", "DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled", "DE.Controllers.Statusbar.zoomText": "Zoom {0}%",