From a2e1d888039ef113247b5a5181915ebe98fcfa36 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 23 Nov 2020 16:13:30 +0300 Subject: [PATCH 1/7] [DE mobile] Added Document Info --- apps/documenteditor/mobile/locale/en.json | 9 ++- .../mobile/src/controller/Main.jsx | 29 ++++++- .../src/controller/settings/DocumentInfo.jsx | 80 ++++++++++++++++++ .../mobile/src/store/documentInfo.js | 36 +++++++++ .../mobile/src/store/mainStore.js | 4 +- .../mobile/src/view/settings/DocumentInfo.jsx | 81 +++++++++++++++++++ .../mobile/src/view/settings/Settings.jsx | 7 +- 7 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx create mode 100644 apps/documenteditor/mobile/src/store/documentInfo.js create mode 100644 apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 35aae25ff4..6538708700 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -20,7 +20,14 @@ "textTop": "Top", "textBottom": "Bottom", "textLeft": "Left", - "textRight": "Right" + "textRight": "Right", + "textDocumentTitle": "Document Title", + "textOwner": "Owner", + "textUploaded": "Uploaded", + "textStatistic": "Statistic", + "textLastModifiedBy": "Last Modified By", + "textLastModified": "Last Modified", + "textApplication": "Application" }, "Collaboration": { "textEditUser": "Users who are editing the file:" diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 69871530ec..a4759e81ed 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -3,7 +3,7 @@ import React, {Component} from 'react' import {inject} from "mobx-react"; import CollaborationController from '../../../../common/mobile/lib/controller/Collaboration.jsx' -@inject("storeDocumentSettings", "storeFocusObjects", "storeTextSettings", "storeParagraphSettings", "storeTableSettings") +@inject("storeDocumentSettings", "storeFocusObjects", "storeTextSettings", "storeParagraphSettings", "storeTableSettings", "storeDocumentInfo") class MainController extends Component { constructor(props) { super(props) @@ -87,6 +87,12 @@ class MainController extends Component { this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); + // Document Info + + const storeDocumentInfo = this.props.storeDocumentInfo; + + storeDocumentInfo.setDataDoc(data.doc); + // Common.SharedSettings.set('document', data.doc); // if (data.doc) { @@ -238,6 +244,27 @@ class MainController extends Component { storeTableSettings.initTableTemplates(templates); }); + // Document Info + + const storeDocumentInfo = this.props.storeDocumentInfo; + + this.api.asc_registerCallback("asc_onGetDocInfoStart", () => { + console.log("Start"); + storeDocumentInfo.switchIsLoaded(false); + }); + + this.api.asc_registerCallback("asc_onGetDocInfoStop", () => { + console.log("End"); + storeDocumentInfo.switchIsLoaded(true); + }); + + this.api.asc_registerCallback("asc_onDocInfo", (obj) => { + storeDocumentInfo.changeCount(obj); + }); + + // me.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(me.onApiGetDocInfoEnd, me)); + // me.api.asc_registerCallback('asc_onDocumentName', _.bind(me.onApiDocumentName, me)); + } render() { diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx new file mode 100644 index 0000000000..4450394a63 --- /dev/null +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -0,0 +1,80 @@ +import React, { Component } from "react"; +import DocumentInfo from "../../view/settings/DocumentInfo"; + +class DocumentInfoController extends Component { + constructor(props) { + super(props); + } + + getDocProps() { + const api = Common.EditorApi.get(); + if (api) { + let docProps = api.asc_getCoreProps(); + return docProps; + } + } + + getAppProps() { + const api = Common.EditorApi.get(); + if (api) { + const appProps = api.asc_getAppProps(); + console.log(appProps); + if (appProps) { + let appName = + (appProps.asc_getApplication() || "") + + (appProps.asc_getAppVersion() ? " " : "") + + (appProps.asc_getAppVersion() || ""); + return appName; + } + } + } + + getModified() { + const docProps = this.getDocProps(); + if (docProps) { + let valueModified = docProps.asc_getModified(); + console.log(docProps); + if (valueModified) { + return ( + valueModified.toLocaleString(_lang, { + year: "numeric", + month: "2-digit", + day: "2-digit", + }) + + " " + + valueModified.toLocaleTimeString(_lang, { timeStyle: "short" }) + ); + } + } + } + + getModifiedBy() { + const docProps = this.getDocProps(); + if (docProps) { + let valueModifiedBy = docProps.asc_getLastModifiedBy(); + if (valueModifiedBy) { + return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); + } + } + } + + componentDidMount() { + const api = Common.EditorApi.get(); + if (api) { + api.startGetDocInfo(); + } + } + + render() { + return ( + + ); + } +} + +export default DocumentInfoController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/store/documentInfo.js b/apps/documenteditor/mobile/src/store/documentInfo.js new file mode 100644 index 0000000000..4417029983 --- /dev/null +++ b/apps/documenteditor/mobile/src/store/documentInfo.js @@ -0,0 +1,36 @@ +import { action, observable } from "mobx"; + +export class storeDocumentInfo { + @observable infoObj = { + pageCount: 0, + wordsCount: 0, + paragraphCount: 0, + symbolsCount: 0, + symbolsWSCount: 0, + }; + @observable isLoaded = false; + @observable dataDoc; + + @action switchIsLoaded(value) { + this.isLoaded = value; + } + + @action changeCount(obj) { + if (obj) { + if (obj.get_PageCount() > -1) + this.infoObj.pageCount = obj.get_PageCount(); + if (obj.get_WordsCount() > -1) + this.infoObj.wordsCount = obj.get_WordsCount(); + if (obj.get_ParagraphCount() > -1) + this.infoObj.paragraphCount = obj.get_ParagraphCount(); + if (obj.get_SymbolsCount() > -1) + this.infoObj.symbolsCount = obj.get_SymbolsCount(); + if (obj.get_SymbolsWSCount() > -1) + this.infoObj.symbolsWSCount = obj.get_SymbolsWSCount(); + } + } + + @action setDataDoc(obj) { + this.dataDoc = obj; + } +} \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/store/mainStore.js b/apps/documenteditor/mobile/src/store/mainStore.js index 84be5a1276..c6e323d758 100644 --- a/apps/documenteditor/mobile/src/store/mainStore.js +++ b/apps/documenteditor/mobile/src/store/mainStore.js @@ -8,6 +8,7 @@ import {storeShapeSettings} from "./shapeSettings"; import {storeImageSettings} from "./imageSettings"; import {storeTableSettings} from "./tableSettings"; import {storeChartSettings} from "./chartSettings"; +import {storeDocumentInfo} from "./documentInfo"; export const stores = { storeFocusObjects: new storeFocusObjects(), @@ -18,6 +19,7 @@ export const stores = { storeShapeSettings: new storeShapeSettings(), storeChartSettings: new storeChartSettings(), storeImageSettings: new storeImageSettings(), - storeTableSettings: new storeTableSettings() + storeTableSettings: new storeTableSettings(), + storeDocumentInfo: new storeDocumentInfo() }; diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx new file mode 100644 index 0000000000..7150ae6c0b --- /dev/null +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -0,0 +1,81 @@ +import React from "react"; +import { observer, inject } from "mobx-react"; +import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react"; +import { useTranslation } from "react-i18next"; + +const PageDocumentInfo = (props) => { + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const storeInfo = props.storeDocumentInfo; + const dataApp = props.getAppProps(); + const dataModified = props.getModified(); + const dataModifiedBy = props.getModifiedBy(); + const { + pageCount, + paragraphCount, + symbolsCount, + symbolsWSCount, + wordsCount, + } = storeInfo.infoObj; + const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); + const isLoaded = storeInfo.isLoaded; + + if (!isLoaded) { + console.log( + pageCount, + paragraphCount, + symbolsCount, + symbolsWSCount, + wordsCount + ); + return ( + + + {_t.textDocumentTitle} + + + + {_t.textOwner} + + + + {_t.textUploaded} + + + + {_t.textStatistic} + + + + + + + + {dataModified && dataModifiedBy ? ( + + {_t.textLastModified} + + + + {_t.textLastModifiedBy} + + + + + ) : null} + {dataApp ? ( + + {_t.textApplication} + + + + + ) : null} + + ); + } +}; + +const DocumentInfo = inject("storeDocumentInfo")(observer(PageDocumentInfo)); + +export default DocumentInfo; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/Settings.jsx b/apps/documenteditor/mobile/src/view/settings/Settings.jsx index 5fb54ac8b6..4852b981f5 100644 --- a/apps/documenteditor/mobile/src/view/settings/Settings.jsx +++ b/apps/documenteditor/mobile/src/view/settings/Settings.jsx @@ -5,6 +5,7 @@ import {f7} from 'framework7-react'; import {Device} from '../../../../../common/mobile/utils/device'; import DocumentSettingsController from "../../controller/settings/DocumentSettings"; +import DocumentInfoController from "../../controller/settings/DocumentInfo"; import { DocumentFormats, DocumentMargins } from "./DocumentSettings"; const routes = [ @@ -24,6 +25,10 @@ const routes = [ path: '/document-formats/', component: DocumentFormats, }, + { + path: "/document-info/", + component: DocumentInfoController, + } ]; @@ -64,7 +69,7 @@ const SettingsList = withTranslation()(props => { - + From 6242e8c96d3a40f4fd377041d11ef2eb22bf6aa0 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 23 Nov 2020 16:37:06 +0300 Subject: [PATCH 2/7] Edit controller Document Info --- .../mobile/src/controller/settings/DocumentInfo.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 4450394a63..32ea95c373 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -53,7 +53,8 @@ class DocumentInfoController extends Component { if (docProps) { let valueModifiedBy = docProps.asc_getLastModifiedBy(); if (valueModifiedBy) { - return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); + // return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); + return valueModifiedBy; } } } From 12a96c706c9c8e7addbe093e22e83c45c7879cb5 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 23 Nov 2020 17:27:37 +0300 Subject: [PATCH 3/7] [DE mobile] Fix document info settings --- .../mobile/src/controller/settings/DocumentInfo.jsx | 7 +++---- .../mobile/src/view/settings/DocumentInfo.jsx | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 32ea95c373..8b07ba1347 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -36,13 +36,13 @@ class DocumentInfoController extends Component { console.log(docProps); if (valueModified) { return ( - valueModified.toLocaleString(_lang, { + valueModified.toLocaleString('en', { year: "numeric", month: "2-digit", day: "2-digit", }) + " " + - valueModified.toLocaleTimeString(_lang, { timeStyle: "short" }) + valueModified.toLocaleTimeString('en', { timeStyle: "short" }) ); } } @@ -53,8 +53,7 @@ class DocumentInfoController extends Component { if (docProps) { let valueModifiedBy = docProps.asc_getLastModifiedBy(); if (valueModifiedBy) { - // return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); - return valueModifiedBy; + return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); } } } diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 7150ae6c0b..3e7c5cf7e9 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, {Fragment} from "react"; import { observer, inject } from "mobx-react"; import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react"; import { useTranslation } from "react-i18next"; @@ -52,7 +52,7 @@ const PageDocumentInfo = (props) => { {dataModified && dataModifiedBy ? ( - + {_t.textLastModified} @@ -61,15 +61,15 @@ const PageDocumentInfo = (props) => { - + ) : null} {dataApp ? ( - + {_t.textApplication} - + ) : null} ); From b5058e24ec25e49a5f174c8ca59eb11de8eaf864 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 23 Nov 2020 17:38:05 +0300 Subject: [PATCH 4/7] Small edit view Document Info --- .../mobile/src/view/settings/DocumentInfo.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 3e7c5cf7e9..2f3bdc9cee 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -55,11 +55,11 @@ const PageDocumentInfo = (props) => { {_t.textLastModified} - + {_t.textLastModifiedBy} - + ) : null} @@ -67,7 +67,7 @@ const PageDocumentInfo = (props) => { {_t.textApplication} - + ) : null} From 3e706114eb91ccfacf80b7de1ddb0bfe4f33be6a Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 23 Nov 2020 20:20:00 +0300 Subject: [PATCH 5/7] [DE mobile] Added one more event and loading counters --- apps/documenteditor/mobile/locale/en.json | 3 +- .../mobile/src/controller/Main.jsx | 8 +- .../mobile/src/view/settings/DocumentInfo.jsx | 100 ++++++++---------- 3 files changed, 54 insertions(+), 57 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 6538708700..a73e4e0a8b 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -27,7 +27,8 @@ "textStatistic": "Statistic", "textLastModifiedBy": "Last Modified By", "textLastModified": "Last Modified", - "textApplication": "Application" + "textApplication": "Application", + "textLoading": "Loading..." }, "Collaboration": { "textEditUser": "Users who are editing the file:" diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index a4759e81ed..06c1d41643 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -254,7 +254,7 @@ class MainController extends Component { }); this.api.asc_registerCallback("asc_onGetDocInfoStop", () => { - console.log("End"); + console.log("Stop"); storeDocumentInfo.switchIsLoaded(true); }); @@ -262,7 +262,11 @@ class MainController extends Component { storeDocumentInfo.changeCount(obj); }); - // me.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(me.onApiGetDocInfoEnd, me)); + this.api.asc_registerCallback('asc_onGetDocInfoEnd', () => { + console.log('End'); + storeDocumentInfo.switchIsLoaded(true); + }); + // me.api.asc_registerCallback('asc_onDocumentName', _.bind(me.onApiDocumentName, me)); } diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 2f3bdc9cee..63c1ecc38c 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -19,61 +19,53 @@ const PageDocumentInfo = (props) => { } = storeInfo.infoObj; const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); const isLoaded = storeInfo.isLoaded; - - if (!isLoaded) { - console.log( - pageCount, - paragraphCount, - symbolsCount, - symbolsWSCount, - wordsCount + console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount); + + return ( + + + {_t.textDocumentTitle} + + + + {_t.textOwner} + + + + {_t.textUploaded} + + + + {_t.textStatistic} + + + + + + + + {dataModified && dataModifiedBy ? ( + + {_t.textLastModified} + + + + {_t.textLastModifiedBy} + + + + + ) : null} + {dataApp ? ( + + {_t.textApplication} + + + + + ) : null} + ); - return ( - - - {_t.textDocumentTitle} - - - - {_t.textOwner} - - - - {_t.textUploaded} - - - - {_t.textStatistic} - - - - - - - - {dataModified && dataModifiedBy ? ( - - {_t.textLastModified} - - - - {_t.textLastModifiedBy} - - - - - ) : null} - {dataApp ? ( - - {_t.textApplication} - - - - - ) : null} - - ); - } }; const DocumentInfo = inject("storeDocumentInfo")(observer(PageDocumentInfo)); From 0402a93aafc1e85394bb412267fa9c425278ef99 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 24 Nov 2020 13:10:05 +0300 Subject: [PATCH 6/7] [DE mobile] Added author list in Document Info --- apps/documenteditor/mobile/locale/en.json | 3 ++- .../src/controller/settings/DocumentInfo.jsx | 15 +++++++++++++-- .../mobile/src/view/settings/DocumentInfo.jsx | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index a73e4e0a8b..cbd0bb9d25 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -28,7 +28,8 @@ "textLastModifiedBy": "Last Modified By", "textLastModified": "Last Modified", "textApplication": "Application", - "textLoading": "Loading..." + "textLoading": "Loading...", + "textAuthor": "Author" }, "Collaboration": { "textEditUser": "Users who are editing the file:" diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 8b07ba1347..0918d223bc 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -10,6 +10,7 @@ class DocumentInfoController extends Component { const api = Common.EditorApi.get(); if (api) { let docProps = api.asc_getCoreProps(); + // console.log(docProps); return docProps; } } @@ -18,7 +19,7 @@ class DocumentInfoController extends Component { const api = Common.EditorApi.get(); if (api) { const appProps = api.asc_getAppProps(); - console.log(appProps); + // console.log(appProps); if (appProps) { let appName = (appProps.asc_getApplication() || "") + @@ -33,7 +34,7 @@ class DocumentInfoController extends Component { const docProps = this.getDocProps(); if (docProps) { let valueModified = docProps.asc_getModified(); - console.log(docProps); + if (valueModified) { return ( valueModified.toLocaleString('en', { @@ -52,12 +53,21 @@ class DocumentInfoController extends Component { const docProps = this.getDocProps(); if (docProps) { let valueModifiedBy = docProps.asc_getLastModifiedBy(); + if (valueModifiedBy) { return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); } } } + getCreators() { + const docProps = this.getDocProps(); + if(docProps) { + let valueCreators = docProps.asc_getCreator(); + return valueCreators; + } + } + componentDidMount() { const api = Common.EditorApi.get(); if (api) { @@ -72,6 +82,7 @@ class DocumentInfoController extends Component { getModified={this.getModified} getModifiedBy={this.getModifiedBy} getDocProps={this.getDocProps} + getCreators={this.getCreators} /> ); } diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 63c1ecc38c..7be3b80ff7 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -10,6 +10,8 @@ const PageDocumentInfo = (props) => { const dataApp = props.getAppProps(); const dataModified = props.getModified(); const dataModifiedBy = props.getModifiedBy(); + const creators = props.getCreators(); + console.log(creators); const { pageCount, paragraphCount, @@ -64,6 +66,18 @@ const PageDocumentInfo = (props) => { ) : null} + {creators ? ( + + {_t.textAuthor} + + { + creators.split(/\s*[,;]\s*/).map(item => { + return + }) + } + + + ) : null} ); }; From 736412ce236df26d35d4f88547d32d332b881e3f Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Tue, 24 Nov 2020 17:03:21 +0300 Subject: [PATCH 7/7] [DE mobile] Refactoring Document Info --- .../src/controller/settings/DocumentInfo.jsx | 138 ++++++++---------- .../mobile/src/view/settings/DocumentInfo.jsx | 48 +++--- 2 files changed, 86 insertions(+), 100 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx index 0918d223bc..3f75bdcc80 100644 --- a/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/DocumentInfo.jsx @@ -2,90 +2,76 @@ import React, { Component } from "react"; import DocumentInfo from "../../view/settings/DocumentInfo"; class DocumentInfoController extends Component { - constructor(props) { - super(props); - } - - getDocProps() { - const api = Common.EditorApi.get(); - if (api) { - let docProps = api.asc_getCoreProps(); - // console.log(docProps); - return docProps; + constructor(props) { + super(props); + this.docProps = this.getDocProps(); + this.getModified = this.getModified(); + this.getModifiedBy = this.getModifiedBy(); + this.getCreators = this.getCreators(); } - } - getAppProps() { - const api = Common.EditorApi.get(); - if (api) { - const appProps = api.asc_getAppProps(); - // console.log(appProps); - if (appProps) { - let appName = - (appProps.asc_getApplication() || "") + - (appProps.asc_getAppVersion() ? " " : "") + - (appProps.asc_getAppVersion() || ""); - return appName; - } + getDocProps() { + const api = Common.EditorApi.get(); + return api.asc_getCoreProps(); } - } - getModified() { - const docProps = this.getDocProps(); - if (docProps) { - let valueModified = docProps.asc_getModified(); + getAppProps() { + const api = Common.EditorApi.get(); + const appProps = api.asc_getAppProps(); - if (valueModified) { + if (appProps) { + let appName = + (appProps.asc_getApplication() || "") + + (appProps.asc_getAppVersion() ? " " : "") + + (appProps.asc_getAppVersion() || ""); + return appName; + } + } + + getModified() { + let valueModified = this.docProps.asc_getModified(); + + if (valueModified) { + return ( + valueModified.toLocaleString('en', { + year: "numeric", + month: "2-digit", + day: "2-digit", + }) + + " " + + valueModified.toLocaleTimeString('en', { timeStyle: "short" }) + ); + } + } + + getModifiedBy() { + let valueModifiedBy = this.docProps.asc_getLastModifiedBy(); + + if (valueModifiedBy) { + return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); + } + } + + getCreators() { + return this.docProps.asc_getCreator(); + } + + componentDidMount() { + const api = Common.EditorApi.get(); + api.startGetDocInfo(); + } + + render() { return ( - valueModified.toLocaleString('en', { - year: "numeric", - month: "2-digit", - day: "2-digit", - }) + - " " + - valueModified.toLocaleTimeString('en', { timeStyle: "short" }) + ); - } } - } - - getModifiedBy() { - const docProps = this.getDocProps(); - if (docProps) { - let valueModifiedBy = docProps.asc_getLastModifiedBy(); - - if (valueModifiedBy) { - return Common.Utils.UserInfoParser.getParsedName(valueModifiedBy); - } - } - } - - getCreators() { - const docProps = this.getDocProps(); - if(docProps) { - let valueCreators = docProps.asc_getCreator(); - return valueCreators; - } - } - - componentDidMount() { - const api = Common.EditorApi.get(); - if (api) { - api.startGetDocInfo(); - } - } - - render() { - return ( - - ); - } } + export default DocumentInfoController; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx index 7be3b80ff7..69ac1869b3 100644 --- a/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx +++ b/apps/documenteditor/mobile/src/view/settings/DocumentInfo.jsx @@ -4,26 +4,26 @@ import { Page, Navbar, List, ListItem, BlockTitle } from "framework7-react"; import { useTranslation } from "react-i18next"; const PageDocumentInfo = (props) => { - const { t } = useTranslation(); - const _t = t("Settings", { returnObjects: true }); - const storeInfo = props.storeDocumentInfo; - const dataApp = props.getAppProps(); - const dataModified = props.getModified(); - const dataModifiedBy = props.getModifiedBy(); - const creators = props.getCreators(); - console.log(creators); - const { - pageCount, - paragraphCount, - symbolsCount, - symbolsWSCount, - wordsCount, - } = storeInfo.infoObj; - const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); - const isLoaded = storeInfo.isLoaded; - console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount); + const { t } = useTranslation(); + const _t = t("Settings", { returnObjects: true }); + const storeInfo = props.storeDocumentInfo; + const dataApp = props.getAppProps(); + const dataModified = props.getModified; + const dataModifiedBy = props.getModifiedBy; + const creators = props.getCreators; + // console.log(creators); + const { + pageCount, + paragraphCount, + symbolsCount, + symbolsWSCount, + wordsCount, + } = storeInfo.infoObj; + const dataDoc = JSON.parse(JSON.stringify(storeInfo.dataDoc)); + const isLoaded = storeInfo.isLoaded; + // console.log(pageCount, paragraphCount, symbolsCount, symbolsWSCount, wordsCount); - return ( + return ( {_t.textDocumentTitle} @@ -40,11 +40,11 @@ const PageDocumentInfo = (props) => { {_t.textStatistic} - - - - - + + + + + {dataModified && dataModifiedBy ? (