diff --git a/apps/common/embed/lib/util/LocalStorage.js b/apps/common/embed/lib/util/LocalStorage.js
new file mode 100644
index 000000000..be30d339c
--- /dev/null
+++ b/apps/common/embed/lib/util/LocalStorage.js
@@ -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
+ };
+})();
diff --git a/apps/common/embed/lib/util/utils.js b/apps/common/embed/lib/util/utils.js
index 0ad2ed91e..8676bb859 100644
--- a/apps/common/embed/lib/util/utils.js
+++ b/apps/common/embed/lib/util/utils.js
@@ -74,6 +74,16 @@
},
htmlEncode: function(value) {
return $('
').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;
}
};
})();
diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js
index d9f186d37..7d41f09ff 100644
--- a/apps/common/main/lib/util/utils.js
+++ b/apps/common/main/lib/util/utils.js
@@ -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;
diff --git a/apps/documenteditor/embed/index.html b/apps/documenteditor/embed/index.html
index 7a0b2fb5f..fe9d9a3a9 100644
--- a/apps/documenteditor/embed/index.html
+++ b/apps/documenteditor/embed/index.html
@@ -255,6 +255,7 @@
+
diff --git a/apps/documenteditor/embed/index_loader.html b/apps/documenteditor/embed/index_loader.html
index 1d4885581..842ca9611 100644
--- a/apps/documenteditor/embed/index_loader.html
+++ b/apps/documenteditor/embed/index_loader.html
@@ -349,6 +349,7 @@
+
diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js
index 992531f0d..b51279b9e 100644
--- a/apps/documenteditor/embed/js/ApplicationController.js
+++ b/apps/documenteditor/embed/js/ApplicationController.js
@@ -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: 'Form submitted successfully
Click to close the tip.',
errorSubmit: 'Submit failed.',
- errorEditingDownloadas: 'An error occurred during the work with the document.
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.
Use the \'Download as...\' option to save the file backup copy to your computer hard drive.',
+ textGuest: 'Guest',
+ textAnonymous: 'Anonymous'
}
})();
\ No newline at end of file
diff --git a/apps/documenteditor/embed/locale/en.json b/apps/documenteditor/embed/locale/en.json
index f9b6baf64..b1eab25e5 100644
--- a/apps/documenteditor/embed/locale/en.json
+++ b/apps/documenteditor/embed/locale/en.json
@@ -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",
diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js
index 9ece5dbc1..ae3ba4a75 100644
--- a/apps/documenteditor/main/app/controller/Main.js
+++ b/apps/documenteditor/main/app/controller/Main.js
@@ -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);
diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json
index 6bd1dfcf8..eb22ff811 100644
--- a/apps/documenteditor/mobile/locale/en.json
+++ b/apps/documenteditor/mobile/locale/en.json
@@ -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.",
diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx
index 67b4f8607..161971b67 100644
--- a/apps/documenteditor/mobile/src/controller/Main.jsx
+++ b/apps/documenteditor/mobile/src/controller/Main.jsx
@@ -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);
diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js
index 15160ce54..d22f062ce 100644
--- a/apps/documenteditor/mobile/src/store/appOptions.js
+++ b/apps/documenteditor/mobile/src/store/appOptions.js
@@ -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;
diff --git a/apps/presentationeditor/embed/index.html b/apps/presentationeditor/embed/index.html
index 0f58d02a3..b0baf0920 100644
--- a/apps/presentationeditor/embed/index.html
+++ b/apps/presentationeditor/embed/index.html
@@ -305,6 +305,7 @@
+
diff --git a/apps/presentationeditor/embed/index_loader.html b/apps/presentationeditor/embed/index_loader.html
index 0d98ea98c..5d725ac73 100644
--- a/apps/presentationeditor/embed/index_loader.html
+++ b/apps/presentationeditor/embed/index_loader.html
@@ -347,6 +347,7 @@
+
diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js
index 8982ccd8b..6f4ca8d87 100644
--- a/apps/presentationeditor/embed/js/ApplicationController.js
+++ b/apps/presentationeditor/embed/js/ApplicationController.js
@@ -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.
Please contact your Document Server administrator for details.',
- errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
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.
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'
}
})();
diff --git a/apps/presentationeditor/embed/locale/en.json b/apps/presentationeditor/embed/locale/en.json
index 8c5855861..3e45dc89b 100644
--- a/apps/presentationeditor/embed/locale/en.json
+++ b/apps/presentationeditor/embed/locale/en.json
@@ -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",
diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js
index 3988c9b9d..6326bf485 100644
--- a/apps/presentationeditor/main/app/controller/Main.js
+++ b/apps/presentationeditor/main/app/controller/Main.js
@@ -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);
diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json
index 768aafced..c83fb611a 100644
--- a/apps/presentationeditor/mobile/locale/en.json
+++ b/apps/presentationeditor/mobile/locale/en.json
@@ -22,6 +22,8 @@
"Table": "Table",
"Slide title": "Slide title"
},
+ "textGuest": "Guest",
+ "textAnonymous": "Anonymous",
"closeButtonText": "Close File",
"advDRMOptions": "Protected File",
"advDRMPassword": "Password",
diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx
index f7aa2b066..e34fed388 100644
--- a/apps/presentationeditor/mobile/src/controller/Main.jsx
+++ b/apps/presentationeditor/mobile/src/controller/Main.jsx
@@ -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);
diff --git a/apps/presentationeditor/mobile/src/store/appOptions.js b/apps/presentationeditor/mobile/src/store/appOptions.js
index ce71648ec..0cb3fc7cd 100644
--- a/apps/presentationeditor/mobile/src/store/appOptions.js
+++ b/apps/presentationeditor/mobile/src/store/appOptions.js
@@ -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;
diff --git a/apps/spreadsheeteditor/embed/index.html b/apps/spreadsheeteditor/embed/index.html
index 2ba2a765a..a7eb4880a 100644
--- a/apps/spreadsheeteditor/embed/index.html
+++ b/apps/spreadsheeteditor/embed/index.html
@@ -281,6 +281,7 @@
+
diff --git a/apps/spreadsheeteditor/embed/index_loader.html b/apps/spreadsheeteditor/embed/index_loader.html
index 3d44aeda2..f703fe302 100644
--- a/apps/spreadsheeteditor/embed/index_loader.html
+++ b/apps/spreadsheeteditor/embed/index_loader.html
@@ -349,6 +349,7 @@
+
diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js
index 8ad14a075..e2a5a7031 100644
--- a/apps/spreadsheeteditor/embed/js/ApplicationController.js
+++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js
@@ -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.
Please contact your Document Server administrator for details.',
- errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
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.
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'
}
})();
\ No newline at end of file
diff --git a/apps/spreadsheeteditor/embed/locale/en.json b/apps/spreadsheeteditor/embed/locale/en.json
index 101004ce6..1d6011fcc 100644
--- a/apps/spreadsheeteditor/embed/locale/en.json
+++ b/apps/spreadsheeteditor/embed/locale/en.json
@@ -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",
diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js
index 9f861a970..0fdda3bfa 100644
--- a/apps/spreadsheeteditor/main/app/controller/Main.js
+++ b/apps/spreadsheeteditor/main/app/controller/Main.js
@@ -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);
diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx
index 92889cf34..466c4b7be 100644
--- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx
+++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx
@@ -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);
diff --git a/apps/spreadsheeteditor/mobile/src/store/appOptions.js b/apps/spreadsheeteditor/mobile/src/store/appOptions.js
index 24c605a10..33d830d27 100644
--- a/apps/spreadsheeteditor/mobile/src/store/appOptions.js
+++ b/apps/spreadsheeteditor/mobile/src/store/appOptions.js
@@ -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;
diff --git a/build/documenteditor.json b/build/documenteditor.json
index a08360a2a..a1d168912 100644
--- a/build/documenteditor.json
+++ b/build/documenteditor.json
@@ -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",
diff --git a/build/presentationeditor.json b/build/presentationeditor.json
index fd01f1441..f5954e7f7 100644
--- a/build/presentationeditor.json
+++ b/build/presentationeditor.json
@@ -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",
diff --git a/build/spreadsheeteditor.json b/build/spreadsheeteditor.json
index bf9b7ca17..d4270756a 100644
--- a/build/spreadsheeteditor.json
+++ b/build/spreadsheeteditor.json
@@ -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",