Merge pull request #900 from ONLYOFFICE/feature/user-anonymous

Feature/user anonymous
This commit is contained in:
Julia Radzhabova 2021-05-25 18:34:47 +03:00 committed by GitHub
commit 98d5a0d8fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 298 additions and 26 deletions

View file

@ -0,0 +1,137 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2021
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
!window.common && (window.common = {});
common.localStorage = new (function() {
var _storeName, _filter;
var _store = {};
var ongetstore = function(data) {
if (data.type == 'localstorage') {
_store = data.keys;
}
};
Common.Gateway.on('internalcommand', ongetstore);
var _refresh = function() {
if (!_lsAllowed)
Common.Gateway.internalMessage('localstorage', {cmd:'get', keys:_filter});
};
var _save = function() {
if (!_lsAllowed)
Common.Gateway.internalMessage('localstorage', {cmd:'set', keys:_store});
};
var _setItem = function(name, value, just) {
if (_lsAllowed) {
try
{
localStorage.setItem(name, value);
}
catch (error){}
} else {
_store[name] = value;
if (just===true) {
Common.Gateway.internalMessage('localstorage', {
cmd:'set',
keys: {
name: value
}
});
}
}
};
var _setItemAsBool = function(name, value, just) {
_setItem(name, value ? 1 : 0, just);
};
var _getItem = function(name) {
if (_lsAllowed)
return localStorage.getItem(name);
else
return _store[name]===undefined ? null : _store[name];
};
var _getItemAsBool = function (name, defValue) {
var value = _getItem(name);
defValue = defValue || false;
return (value!==null) ? (parseInt(value) != 0) : defValue;
};
var _getItemExists = function (name) {
var value = _getItem(name);
return value !== null;
};
var _removeItem = function(name) {
if (_lsAllowed)
localStorage.removeItem(name);
else
delete _store[name];
};
try {
var _lsAllowed = !!window.localStorage;
} catch (e) {
_lsAllowed = false;
}
return {
getId: function() {
return _storeName;
},
setId: function(name) {
_storeName = name;
},
getItem: _getItem,
getBool: _getItemAsBool,
setBool: _setItemAsBool,
setItem: _setItem,
removeItem: _removeItem,
setKeysFilter: function(value) {
_filter = value;
},
getKeysFilter: function() {
return _filter;
},
itemExists: _getItemExists,
sync: _refresh,
save: _save
};
})();

View file

@ -74,6 +74,16 @@
},
htmlEncode: function(value) {
return $('<div/>').text(value).html();
},
fillUserInfo: function(info, lang, defname, defid) {
var _user = info || {};
_user.anonymous = !_user.id;
!_user.id && (_user.id = defid);
_user.fullname = !_user.name ? defname : _user.name;
_user.group && (_user.fullname = (_user.group).toString() + AscCommon.UserInfoParser.getSeparator() + _user.fullname);
_user.guest = !_user.name;
return _user;
}
};
})();

View file

@ -741,9 +741,10 @@ Common.Utils.applyCustomizationPlugins = function(plugins) {
});
};
Common.Utils.fillUserInfo = function(info, lang, defname) {
Common.Utils.fillUserInfo = function(info, lang, defname, defid) {
var _user = info || {};
!_user.id && (_user.id = ('uid-' + Date.now()));
_user.anonymous = !_user.id;
!_user.id && (_user.id = defid);
_user.fullname = !_user.name ? defname : _user.name;
_user.group && (_user.fullname = (_user.group).toString() + AscCommon.UserInfoParser.getSeparator() + _user.fullname);
_user.guest = !_user.name;

View file

@ -255,6 +255,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -349,6 +349,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -59,6 +59,10 @@ DE.ApplicationController = new(function(){
return;
}
common.localStorage.setId('text');
common.localStorage.setKeysFilter('de-,asc.text');
common.localStorage.sync();
// Handlers
// -------------------------
@ -92,7 +96,19 @@ DE.ApplicationController = new(function(){
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)),
guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') &&
(typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ?
common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest,
value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null,
user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous,
common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
user.anonymous && common.localStorage.setItem("guest-id", user.id);
_user.put_Id(user.id);
_user.put_FullName(user.fullname);
_user.put_IsAnonymousUser(user.anonymous);
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
@ -634,7 +650,10 @@ DE.ApplicationController = new(function(){
if (api) api.asc_runAutostartMacroses();
}
// Helpers
function onBeforeUnload () {
common.localStorage.save();
}
// Helpers
// -------------------------
function onDocumentResize() {
@ -651,6 +670,7 @@ DE.ApplicationController = new(function(){
$(window).resize(function(){
onDocumentResize();
});
window.onbeforeunload = onBeforeUnload;
var ismodalshown = false;
$(document.body).on('show.bs.modal', '.modal',
@ -735,6 +755,8 @@ DE.ApplicationController = new(function(){
textSubmit: 'Submit',
textSubmited: '<b>Form submitted successfully</b><br>Click to close the tip.',
errorSubmit: 'Submit failed.',
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.'
errorEditingDownloadas: 'An error occurred during the work with the document.<br>Use the \'Download as...\' option to save the file backup copy to your computer hard drive.',
textGuest: 'Guest',
textAnonymous: 'Anonymous'
}
})();

View file

@ -29,6 +29,8 @@
"DE.ApplicationController.unknownErrorText": "Unknown error.",
"DE.ApplicationController.unsupportedBrowserErrorText": "Your browser is not supported.",
"DE.ApplicationController.waitText": "Please, wait...",
"DE.ApplicationController.textGuest": "Guest",
"DE.ApplicationController.textAnonymous": "Anonymous",
"DE.ApplicationView.txtDownload": "Download",
"DE.ApplicationView.txtDownloadDocx": "Download as docx",
"DE.ApplicationView.txtDownloadPdf": "Download as pdf",

View file

@ -361,7 +361,10 @@ define([
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -434,6 +437,7 @@ define([
var _user = new Asc.asc_CUserInfo();
_user.put_Id(this.appOptions.user.id);
_user.put_FullName(this.appOptions.user.fullname);
_user.put_IsAnonymousUser(!!this.appOptions.user.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -26,6 +26,8 @@
"List Paragraph": "List Paragraph",
"footnote text": "Footnote Text"
},
"textGuest": "Guest",
"textAnonymous": "Anonymous",
"leavePageText": "You have unsaved changes in this document. Click 'Stay on this Page' to await the autosave of the document. Click 'Leave this Page' to discard all the unsaved changes.",
"titleLicenseExp": "License expired",
"warnLicenseExp": "Your license has expired. Please update your license and refresh the page.",

View file

@ -74,12 +74,14 @@ class MainController extends Component {
};
const loadConfig = data => {
const _t = this._t;
EditorUIController.isSupportEditFeature();
console.log('load config');
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
this.props.storeAppOptions.setConfigOptions(this.editorConfig);
this.props.storeAppOptions.setConfigOptions(this.editorConfig, _t);
this.editorConfig.lang && this.api.asc_setLocale(this.editorConfig.lang);
@ -109,6 +111,7 @@ class MainController extends Component {
const _user = new Asc.asc_CUserInfo();
_user.put_Id(_userOptions.id);
_user.put_FullName(_userOptions.fullname);
_user.put_IsAnonymousUser(_userOptions.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -1,4 +1,5 @@
import {makeObservable, action, observable} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeAppOptions {
constructor() {
@ -48,9 +49,19 @@ export class storeAppOptions {
}
config = {};
setConfigOptions (config) {
setConfigOptions (config, _t) {
this.config = config;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
this.customization = config.customization;
this.canRenameAnonymous = !((typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') && (this.customization.anonymous.request===false));
this.guestName = (typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') &&
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
config.user = this.user;
this.isDesktopApp = config.targetApp == 'desktop';
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
this.canOpenRecent = config.recent !== undefined && !this.isDesktopApp;
@ -64,7 +75,6 @@ export class storeAppOptions {
this.mergeFolderUrl = config.mergeFolderUrl;
this.canAnalytics = false;
this.canRequestClose = config.canRequestClose;
this.customization = config.customization;
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
this.canBack = this.canBackToFolder === true;

View file

@ -305,6 +305,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -347,6 +347,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -57,6 +57,10 @@ PE.ApplicationController = new(function(){
return;
}
common.localStorage.setId('text');
common.localStorage.setKeysFilter('pe-,asc.presentation');
common.localStorage.sync();
// Handlers
// -------------------------
@ -90,7 +94,19 @@ PE.ApplicationController = new(function(){
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)),
guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') &&
(typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ?
common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest,
value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null,
user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous,
common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
user.anonymous && common.localStorage.setItem("guest-id", user.id);
_user.put_Id(user.id);
_user.put_FullName(user.fullname);
_user.put_IsAnonymousUser(user.anonymous);
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
@ -625,6 +641,9 @@ PE.ApplicationController = new(function(){
if (api) api.asc_runAutostartMacroses();
}
function onBeforeUnload () {
common.localStorage.save();
}
// Helpers
// -------------------------
@ -646,7 +665,8 @@ PE.ApplicationController = new(function(){
$(window).resize(function(){
onDocumentResize();
});
window.onbeforeunload = onBeforeUnload;
api = new Asc.asc_docs_api({
'id-view' : 'editor_sdk',
'embedded' : true
@ -691,6 +711,8 @@ PE.ApplicationController = new(function(){
textLoadingDocument: 'Loading presentation',
txtClose: 'Close',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.',
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.'
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.',
textGuest: 'Guest',
textAnonymous: 'Anonymous'
}
})();

View file

@ -23,6 +23,8 @@
"PE.ApplicationController.unknownErrorText": "Unknown error.",
"PE.ApplicationController.unsupportedBrowserErrorText": "Your browser is not supported.",
"PE.ApplicationController.waitText": "Please, wait...",
"PE.ApplicationController.textGuest": "Guest",
"PE.ApplicationController.textAnonymous": "Anonymous",
"PE.ApplicationView.txtDownload": "Download",
"PE.ApplicationView.txtEmbed": "Embed",
"PE.ApplicationView.txtFileLocation": "Open file location",

View file

@ -322,7 +322,10 @@ define([
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -393,6 +396,7 @@ define([
var _user = new Asc.asc_CUserInfo();
_user.put_Id(this.appOptions.user.id);
_user.put_FullName(this.appOptions.user.fullname);
_user.put_IsAnonymousUser(!!this.appOptions.user.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -22,6 +22,8 @@
"Table": "Table",
"Slide title": "Slide title"
},
"textGuest": "Guest",
"textAnonymous": "Anonymous",
"closeButtonText": "Close File",
"advDRMOptions": "Protected File",
"advDRMPassword": "Password",

View file

@ -70,13 +70,15 @@ class MainController extends Component {
};
const loadConfig = data => {
const _t = this._t;
EditorUIController.isSupportEditFeature();
console.log('load config');
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
this.props.storeAppOptions.setConfigOptions(this.editorConfig);
this.props.storeAppOptions.setConfigOptions(this.editorConfig, _t);
this.editorConfig.lang && this.api.asc_setLocale(this.editorConfig.lang);
@ -104,6 +106,7 @@ class MainController extends Component {
const _userOptions = this.props.storeAppOptions.user;
_user.put_Id(_userOptions.id);
_user.put_FullName(_userOptions.fullname);
_user.put_IsAnonymousUser(_userOptions.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -1,4 +1,5 @@
import {action, observable, makeObservable} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeAppOptions {
constructor() {
@ -30,9 +31,19 @@ export class storeAppOptions {
this.isDocReady = value;
}
setConfigOptions (config) {
setConfigOptions (config, _t) {
this.config = config;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
this.customization = config.customization;
this.canRenameAnonymous = !((typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') && (this.customization.anonymous.request===false));
this.guestName = (typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') &&
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
config.user = this.user;
this.isDesktopApp = config.targetApp == 'desktop';
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
this.canOpenRecent = config.recent !== undefined && !this.isDesktopApp;
@ -46,7 +57,6 @@ export class storeAppOptions {
this.mergeFolderUrl = config.mergeFolderUrl;
this.canAnalytics = false;
this.canRequestClose = config.canRequestClose;
this.customization = config.customization;
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
this.canBack = this.canBackToFolder === true;

View file

@ -281,6 +281,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -349,6 +349,7 @@
<script type="text/javascript" src="../../common/locale.js"></script>
<script type="text/javascript" src="../../common/Gateway.js"></script>
<script type="text/javascript" src="../../common/Analytics.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/LocalStorage.js"></script>
<script type="text/javascript" src="../../common/embed/lib/util/utils.js"></script>
<script type="text/javascript" src="../../common/embed/lib/view/modals.js"></script>
<script type="text/javascript" src="../../common/embed/lib/controller/modals.js"></script>

View file

@ -59,6 +59,9 @@ SSE.ApplicationController = new(function(){
return;
}
common.localStorage.setId('text');
common.localStorage.setKeysFilter('sse-,asc.table');
common.localStorage.sync();
// Handlers
// -------------------------
@ -93,7 +96,19 @@ SSE.ApplicationController = new(function(){
var _permissions = $.extend({}, docConfig.permissions),
docInfo = new Asc.asc_CDocInfo(),
_user = new Asc.asc_CUserInfo();
_user.put_Id(config.user && config.user.id ? config.user.id : ('uid-' + Date.now()));
var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)),
guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') &&
(typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ?
common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest,
value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null,
user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous,
common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
user.anonymous && common.localStorage.setItem("guest-id", user.id);
_user.put_Id(user.id);
_user.put_FullName(user.fullname);
_user.put_IsAnonymousUser(user.anonymous);
docInfo.put_Id(docConfig.key);
docInfo.put_Url(docConfig.url);
@ -580,6 +595,9 @@ SSE.ApplicationController = new(function(){
if (api) api.asc_runAutostartMacroses();
}
function onBeforeUnload () {
common.localStorage.save();
}
// Helpers
// -------------------------
@ -599,7 +617,8 @@ SSE.ApplicationController = new(function(){
$(window).resize(function(){
onDocumentResize();
});
window.onbeforeunload = onBeforeUnload;
api = new Asc.spreadsheet_api({
'id-view': 'editor_sdk',
'embedded' : true
@ -643,6 +662,8 @@ SSE.ApplicationController = new(function(){
textLoadingDocument: 'Loading spreadsheet',
txtClose: 'Close',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.',
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.'
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.',
textGuest: 'Guest',
textAnonymous: 'Anonymous'
}
})();

View file

@ -23,6 +23,8 @@
"SSE.ApplicationController.unknownErrorText": "Unknown error.",
"SSE.ApplicationController.unsupportedBrowserErrorText": "Your browser is not supported.",
"SSE.ApplicationController.waitText": "Please, wait...",
"SSE.ApplicationController.textGuest": "Guest",
"SSE.ApplicationController.textAnonymous": "Anonymous",
"SSE.ApplicationView.txtDownload": "Download",
"SSE.ApplicationView.txtEmbed": "Embed",
"SSE.ApplicationView.txtFileLocation": "Open file location",

View file

@ -356,7 +356,10 @@ define([
Common.Utils.InternalSettings.set("save-guest-username", !!value);
}
this.editorConfig.user =
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
@ -458,6 +461,7 @@ define([
var _user = new Asc.asc_CUserInfo();
_user.put_Id(this.appOptions.user.id);
_user.put_FullName(this.appOptions.user.fullname);
_user.put_IsAnonymousUser(!!this.appOptions.user.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -143,6 +143,7 @@ class MainController extends Component {
_user.put_Id(_userOptions.id);
_user.put_FullName(_userOptions.fullname);
_user.put_IsAnonymousUser(_userOptions.anonymous);
docInfo = new Asc.asc_CDocInfo();
docInfo.put_Id(data.doc.key);

View file

@ -1,4 +1,5 @@
import {action, observable, makeObservable} from 'mobx';
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
export class storeAppOptions {
constructor() {
@ -38,9 +39,10 @@ export class storeAppOptions {
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
const value = this.canRenameAnonymous ? Common.localStorage.getItem("guest-username") : null;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous);
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
config.user = this.user;
this.isDesktopApp = config.targetApp == 'desktop';
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
@ -58,7 +60,6 @@ export class storeAppOptions {
this.mergeFolderUrl = config.mergeFolderUrl;
this.canAnalytics = false;
this.canRequestClose = config.canRequestClose;
this.customization = config.customization;
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
this.canBack = this.canBackToFolder === true;

View file

@ -409,6 +409,7 @@
"../apps/common/locale.js",
"../apps/common/Gateway.js",
"../apps/common/Analytics.js",
"../apps/common/embed/lib/util/LocalStorage.js",
"../apps/common/embed/lib/util/utils.js",
"../apps/common/embed/lib/view/modals.js",
"../apps/common/embed/lib/controller/modals.js",

View file

@ -413,6 +413,7 @@
"../apps/common/locale.js",
"../apps/common/Gateway.js",
"../apps/common/Analytics.js",
"../apps/common/embed/lib/util/LocalStorage.js",
"../apps/common/embed/lib/util/utils.js",
"../apps/common/embed/lib/view/modals.js",
"../apps/common/embed/lib/controller/modals.js",

View file

@ -426,6 +426,7 @@
"../apps/common/locale.js",
"../apps/common/Gateway.js",
"../apps/common/Analytics.js",
"../apps/common/embed/lib/util/LocalStorage.js",
"../apps/common/embed/lib/util/utils.js",
"../apps/common/embed/lib/view/modals.js",
"../apps/common/embed/lib/controller/modals.js",