[DE] Change applying the license (disable editing when connections are over the limitations).

This commit is contained in:
Julia Radzhabova 2017-11-22 15:20:51 +03:00
parent 9fd0a90c38
commit a90f108209
5 changed files with 46 additions and 78 deletions

View file

@ -94,7 +94,7 @@ define([
Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this));
Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this));
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this));
}, },
setConfig: function (data, api) { setConfig: function (data, api) {
this.setApi(api); this.setApi(api);
@ -111,7 +111,7 @@ define([
this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, this)); this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, this));
this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this)); this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this));
} }
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiServerDisconnect, this));
} }
}, },
@ -624,6 +624,10 @@ define([
})).show(); })).show();
}, },
onApiServerDisconnect: function() {
this.SetDisabled(true);
},
textInserted: '<b>Inserted:</b>', textInserted: '<b>Inserted:</b>',
textDeleted: '<b>Deleted:</b>', textDeleted: '<b>Deleted:</b>',
textParaInserted: '<b>Paragraph Inserted</b> ', textParaInserted: '<b>Paragraph Inserted</b> ',

View file

@ -331,6 +331,7 @@ define([
} }
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); 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_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
@ -934,6 +935,9 @@ define([
$(document).on('contextmenu', _.bind(me.onContextMenu, me)); $(document).on('contextmenu', _.bind(me.onContextMenu, me));
if (this._state.licenseWarning) { if (this._state.licenseWarning) {
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
value = Common.localStorage.getItem("de-license-warning"); value = Common.localStorage.getItem("de-license-warning");
value = (value!==null) ? parseInt(value) : 0; value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime(); var now = (new Date).getTime();
@ -942,7 +946,7 @@ define([
Common.UI.info({ Common.UI.info({
width: 500, width: 500,
title: this.textNoLicenseTitle, title: this.textNoLicenseTitle,
msg : this.warnNoLicense, msg : this._state.licenseWarning,
buttons: [ buttons: [
{value: 'buynow', caption: this.textBuyNow}, {value: 'buynow', caption: this.textBuyNow},
{value: 'contact', caption: this.textContactUs} {value: 'contact', caption: this.textContactUs}
@ -959,6 +963,13 @@ define([
} }
}, },
onLicenseChanged: function(params) {
var licType = params.asc_getLicenseType();
if ((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;
}
},
onOpenDocument: function(progress) { onOpenDocument: function(progress) {
var elem = document.getElementById('loadmask-text'); var elem = document.getElementById('loadmask-text');
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
@ -1030,8 +1041,6 @@ define([
this.appOptions.canDownloadOrigin = this.permissions.download !== false && (type && typeof type[1] === 'string'); this.appOptions.canDownloadOrigin = this.permissions.download !== false && (type && typeof type[1] === 'string');
this.appOptions.canDownload = this.permissions.download !== false && (!type || typeof type[1] !== 'string'); this.appOptions.canDownload = this.permissions.download !== false && (!type || typeof type[1] !== 'string');
this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object'); this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object');
if (this.appOptions.canBranding) if (this.appOptions.canBranding)
appHeader.setBranding(this.editorConfig.customization); appHeader.setBranding(this.editorConfig.customization);
@ -2121,7 +2130,8 @@ define([
txtStyle_Intense_Quote: 'Intense Quote', txtStyle_Intense_Quote: 'Intense Quote',
txtStyle_List_Paragraph: 'List Paragraph', txtStyle_List_Paragraph: 'List Paragraph',
saveTextText: 'Saving document...', saveTextText: 'Saving document...',
saveTitleText: 'Saving Document' saveTitleText: 'Saving Document',
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).<br>If you need more please consider purchasing a commercial license.'
} }
})(), DE.Controllers.Main || {})) })(), DE.Controllers.Main || {}))

View file

@ -2761,6 +2761,7 @@ define([
onApiCoAuthoringDisconnect: function(disableDownload) { onApiCoAuthoringDisconnect: function(disableDownload) {
this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload}); this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload});
this.editMode = false; this.editMode = false;
this.DisableToolbar(true, true);
}, },
DisableToolbar: function(disable, viewMode, reviewmode) { DisableToolbar: function(disable, viewMode, reviewmode) {

View file

@ -86,7 +86,6 @@ define([
me.btnZoomDown.updateHint(me.tipZoomOut + Common.Utils.String.platformKey('Ctrl+-')); me.btnZoomDown.updateHint(me.tipZoomOut + Common.Utils.String.platformKey('Ctrl+-'));
me.btnZoomUp.updateHint(me.tipZoomIn + Common.Utils.String.platformKey('Ctrl++')); me.btnZoomUp.updateHint(me.tipZoomIn + Common.Utils.String.platformKey('Ctrl++'));
if ( config.isEdit ) {
me.btnLanguage.updateHint(me.tipSetLang); me.btnLanguage.updateHint(me.tipSetLang);
me.btnLanguage.cmpEl.on({ me.btnLanguage.cmpEl.on({
'show.bs.dropdown': function () { 'show.bs.dropdown': function () {
@ -106,7 +105,6 @@ define([
} }
}); });
me.langMenu.on('item:click', _.bind(_clickLanguage, this)); me.langMenu.on('item:click', _.bind(_clickLanguage, this));
}
me.cntZoom.updateHint(me.tipZoomFactor); me.cntZoom.updateHint(me.tipZoomFactor);
me.cntZoom.cmpEl.on({ me.cntZoom.cmpEl.on({
@ -325,6 +323,7 @@ define([
if (this.api) { if (this.api) {
this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this)); this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this));
this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this)); this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
} }
return this; return this;
@ -356,7 +355,7 @@ define([
this.langMenu.doLayout(); this.langMenu.doLayout();
if (this.langMenu.items.length>0) { if (this.langMenu.items.length>0) {
this.btnLanguage.setDisabled(false); this.btnLanguage.setDisabled(!!this.mode.isDisconnected);
} }
}, },
@ -390,6 +389,11 @@ define([
this.btnLanguage.setDisabled(disable || !langs); this.btnLanguage.setDisabled(disable || !langs);
}, },
onApiCoAuthoringDisconnect: function() {
this.setMode({isDisconnected:true});
this.SetDisabled(true);
},
pageIndexText : 'Page {0} of {1}', pageIndexText : 'Page {0} of {1}',
goToPageText : 'Go to Page', goToPageText : 'Go to Page',
tipFitPage : 'Fit to Page', tipFitPage : 'Fit to Page',

View file

@ -2089,59 +2089,8 @@ define([
button.setDisabled(true); button.setDisabled(true);
} }
}); });
this.btnCopy.setDisabled(true);
this.btnPaste.setDisabled(true);
this.btnUndo.setDisabled(true);
this.btnRedo.setDisabled(true);
this.btnIncFontSize.setDisabled(true);
this.btnDecFontSize.setDisabled(true);
this.btnBold.setDisabled(true);
this.btnItalic.setDisabled(true);
this.btnUnderline.setDisabled(true);
this.btnStrikeout.setDisabled(true);
this.btnSuperscript.setDisabled(true);
this.btnSubscript.setDisabled(true);
this.btnHighlightColor.setDisabled(true);
this.btnFontColor.setDisabled(true);
this.btnParagraphColor.setDisabled(true);
this.btnMarkers.setDisabled(true);
this.btnNumbers.setDisabled(true);
this.btnMultilevels.setDisabled(true);
this.btnAlignLeft.setDisabled(true);
this.btnAlignCenter.setDisabled(true);
this.btnAlignRight.setDisabled(true);
this.btnAlignJust.setDisabled(true);
this.btnDecLeftOffset.setDisabled(true);
this.btnIncLeftOffset.setDisabled(true);
this.btnLineSpace.setDisabled(true);
this.btnShowHidenChars.setDisabled(true);
this.btnInsertTable.setDisabled(true);
this.btnInsertImage.setDisabled(true);
this.btnInsertChart.setDisabled(true);
this.btnInsertText.setDisabled(true);
this.btnInsertTextArt.setDisabled(true);
this.btnDropCap.setDisabled(true);
this.btnColumns.setDisabled(true);
this.btnInsertHyperlink.setDisabled(true);
this.btnEditHeader.setDisabled(true);
this.btnInsertShape.setDisabled(true);
this.btnInsertEquation.setDisabled(true);
this.btnPageOrient.setDisabled(true);
this.btnPageMargins.setDisabled(true);
this.btnPageSize.setDisabled(true);
this.btnClearStyle.setDisabled(true);
this.btnCopyStyle.setDisabled(true);
this.btnColorSchemas.setDisabled(true);
this.btnMailRecepients.setDisabled(true);
this.btnHorizontalAlign.setDisabled(true);
this.cmbFontName.setDisabled(true);
this.cmbFontSize.setDisabled(true);
this.listStyles.setDisabled(true);
this.btnNotes.setDisabled(true);
if (mode.disableDownload) if (mode.disableDownload)
this.btnPrint.setDisabled(true); this.btnPrint.setDisabled(true);
this.btnsPageBreak.disable(true);
} }
this.mode = mode; this.mode = mode;