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

This commit is contained in:
Julia Radzhabova 2017-11-22 17:41:40 +03:00
parent 20cc14ae5c
commit 620c4ab5c2
3 changed files with 40 additions and 7 deletions

View file

@ -319,6 +319,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);
@ -695,6 +696,8 @@ define([
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
me.applyLicense();
}
}, 50);
} else {
@ -715,9 +718,24 @@ define([
Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'});
$(document).on('contextmenu', _.bind(me.onContextMenu, me));
},
onLicenseChanged: function(params) {
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("pe-license-warning");
this.disableEditing(true);
Common.NotificationCenter.trigger('api:disconnect');
var value = Common.localStorage.getItem("pe-license-warning");
value = (value!==null) ? parseInt(value) : 0;
var now = (new Date).getTime();
if (now - value > 86400000) {
@ -725,7 +743,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}
@ -742,6 +760,15 @@ 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);
app.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
}
},
onOpenDocument: function(progress) {
var elem = document.getElementById('loadmask-text');
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
@ -788,8 +815,6 @@ define([
this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly);
this.appOptions.trialMode = params.asc_getLicenseMode();
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);
@ -1910,7 +1935,8 @@ define([
textChangesSaved: 'All changes saved',
saveTitleText: 'Saving Document',
saveTextText: 'Saving document...',
txtLoading: 'Loading...'
txtLoading: 'Loading...',
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.'
}
})(), PE.Controllers.Main || {}))
});

View file

@ -217,7 +217,8 @@ define([
var onContextMenu = function(event){
_.delay(function(){
if (event.get_Type() == Asc.c_oAscContextMenuTypes.Thumbnails) {
showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event);
if (me.mode.isEdit)
showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event);
} else {
showObjectMenu.call(me, event);
}

View file

@ -303,6 +303,7 @@ define([
this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this));
this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this));
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this));
}
return this;
@ -344,7 +345,7 @@ define([
this.langMenu.doLayout();
if (this.langMenu.items.length>0) {
this.btnLanguage.setDisabled(false || this._state.no_paragraph);
this.btnDocLanguage.setDisabled(false);
this.btnDocLanguage.setDisabled(!!this.mode.isDisconnected);
}
},
@ -388,6 +389,11 @@ define([
this.btnLanguage.setDisabled(this._state.no_paragraph);
},
onApiCoAuthoringDisconnect: function() {
this.setMode({isDisconnected:true});
this.SetDisabled(true);
},
pageIndexText : 'Slide {0} of {1}',
goToPageText : 'Go to Slide',
tipFitPage : 'Fit to Slide',