[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('spelling:turn', this.onTurnSpelling.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) {
this.setApi(api);
@ -111,7 +111,7 @@ define([
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_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiServerDisconnect, this));
}
},
@ -624,6 +624,10 @@ define([
})).show();
},
onApiServerDisconnect: function() {
this.SetDisabled(true);
},
textInserted: '<b>Inserted:</b>',
textDeleted: '<b>Deleted:</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_onLicenseChanged', _.bind(this.onLicenseChanged, this));
this.api.asc_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
@ -934,6 +935,9 @@ define([
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
if (this._state.licenseWarning) {
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
value = Common.localStorage.getItem("de-license-warning");
value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime();
@ -942,7 +946,7 @@ define([
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}
@ -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) {
var elem = document.getElementById('loadmask-text');
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.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');
if (this.appOptions.canBranding)
appHeader.setBranding(this.editorConfig.customization);
@ -2121,7 +2130,8 @@ define([
txtStyle_Intense_Quote: 'Intense Quote',
txtStyle_List_Paragraph: 'List Paragraph',
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 || {}))

View file

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

View file

@ -86,27 +86,25 @@ define([
me.btnZoomDown.updateHint(me.tipZoomOut + 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.cmpEl.on({
'show.bs.dropdown': function () {
_.defer(function () {
me.btnLanguage.cmpEl.find('ul').focus();
}, 100);
},
'hide.bs.dropdown': function () {
_.defer(function () {
me.api.asc_enableKeyEvents(true);
}, 100);
},
'click': function (e) {
if (me.btnLanguage.isDisabled()) {
return false;
}
me.btnLanguage.updateHint(me.tipSetLang);
me.btnLanguage.cmpEl.on({
'show.bs.dropdown': function () {
_.defer(function () {
me.btnLanguage.cmpEl.find('ul').focus();
}, 100);
},
'hide.bs.dropdown': function () {
_.defer(function () {
me.api.asc_enableKeyEvents(true);
}, 100);
},
'click': function (e) {
if (me.btnLanguage.isDisabled()) {
return false;
}
});
me.langMenu.on('item:click', _.bind(_clickLanguage, this));
}
}
});
me.langMenu.on('item:click', _.bind(_clickLanguage, this));
me.cntZoom.updateHint(me.tipZoomFactor);
me.cntZoom.cmpEl.on({
@ -325,6 +323,7 @@ define([
if (this.api) {
this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this));
this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
}
return this;
@ -356,7 +355,7 @@ define([
this.langMenu.doLayout();
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);
},
onApiCoAuthoringDisconnect: function() {
this.setMode({isDisconnected:true});
this.SetDisabled(true);
},
pageIndexText : 'Page {0} of {1}',
goToPageText : 'Go to Page',
tipFitPage : 'Fit to Page',

View file

@ -2089,59 +2089,8 @@ define([
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)
this.btnPrint.setDisabled(true);
this.btnsPageBreak.disable(true);
}
this.mode = mode;