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/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 9ece5dbc1..57498e42f 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_isAnonymous(!!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..917975818 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_isAnonymous(_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/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 3988c9b9d..811d3291a 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_isAnonymous(!!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..fc53f13e9 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_isAnonymous(_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/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9f861a970..46acd6c8d 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_isAnonymous(!!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..1c6e137e0 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_isAnonymous(_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;