From b664680915967eac1d5df02c7d77b59f4cdf87f9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 13:40:45 +0300 Subject: [PATCH] [SSE] Change applying the license (disable editing when connections are over the limitations). [PE] Refactoring. --- .../main/app/controller/Main.js | 2 +- .../main/app/view/DocumentHolder.js | 3 ++ .../main/app/controller/DocumentHolder.js | 3 ++ .../main/app/controller/Main.js | 39 ++++++++++++++++--- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 22a587dd6..15e6badc4 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -739,7 +739,7 @@ define([ value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { - Common.localStorage.setItem("de-license-warning", now); + Common.localStorage.setItem("pe-license-warning", now); Common.UI.info({ width: 500, title: this.textNoLicenseTitle, diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 297ea9580..df4466f13 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -186,6 +186,9 @@ define([ var fillViewMenuProps = function(selectedElements) { if (!selectedElements || !_.isArray(selectedElements)) return; + if (!me.viewModeMenu) + me.createDelayedElementsViewer(); + var menu_props = {}, menu_to_show = null; _.each(selectedElements, function(element, index) { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 1ca136c2b..18be70765 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1492,6 +1492,9 @@ define([ iscellmenu = (seltype==Asc.c_oAscSelectionType.RangeCells) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram, iscelledit = this.api.isCellEdited; + if (!documentHolder.viewModeMenu) + documentHolder.createDelayedElementsViewer(); + if (!showMenu && !documentHolder.viewModeMenu.isVisible()) return; documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9bf081dbd..381c47285 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -355,6 +355,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); }, @@ -707,6 +708,8 @@ define([ if (me.appOptions.canBrandingExt) Common.NotificationCenter.trigger('document:ready', 'main'); + + me.applyLicense(); } }, 50); } else { @@ -741,17 +744,34 @@ define([ if (typeof document.hidden !== 'undefined' && document.hidden) { document.addEventListener('visibilitychange', checkWarns); } else checkWarns(); + }, + onLicenseChanged: function(params) { + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return; + + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady) + this.applyLicense(); + }, + + applyLicense: function() { if (this._state.licenseWarning) { - value = Common.localStorage.getItem("de-license-warning"); + this.disableEditing(true); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("sse-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { - Common.localStorage.setItem("de-license-warning", now); + Common.localStorage.setItem("sse-license-warning", now); Common.UI.info({ width: 500, title: this.textNoLicenseTitle, - msg : this.warnNoLicense, + msg : this._state.licenseWarning, buttons: [ {value: 'buynow', caption: this.textBuyNow}, {value: 'contact', caption: this.textContactUs} @@ -768,6 +788,14 @@ define([ } }, + disableEditing: function(disable) { + var app = this.getApplication(); + if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + app.getController('RightMenu').getView('RightMenu').clearSelection(); + app.getController('Toolbar').DisableToolbar(disable); + } + }, + onOpenDocument: function(progress) { var elem = document.getElementById('loadmask-text'); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); @@ -831,8 +859,6 @@ define([ this.appOptions.forcesave = this.appOptions.canForcesave; this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly); - this._state.licenseWarning = !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; - this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -2103,7 +2129,8 @@ define([ txtStyle_Total: 'Total', txtStyle_Currency: 'Currency', txtStyle_Percent: 'Percent', - txtStyle_Comma: 'Comma' + txtStyle_Comma: 'Comma', + warnNoLicenseUsers: '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.' } })(), SSE.Controllers.Main || {})) });