From bbe684d95473d23fba952e63e27d966f75ef9b7b Mon Sep 17 00:00:00 2001 From: NikolayRechkin Date: Fri, 24 Jan 2020 11:03:50 +0300 Subject: [PATCH 1/7] web: components: AvatarEditor. compress picture on client --- web/ASC.Web.Components/package.json | 3 ++- .../src/components/avatar-editor/index.js | 2 +- .../sub-components/avatar-editor-body.js | 23 ++++++++++++++----- web/ASC.Web.Components/yarn.lock | 5 ++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index 7d9754b0f3..4845e911fd 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -120,7 +120,8 @@ "react-tooltip": "^3.11.2", "react-virtualized-auto-sizer": "^1.0.2", "react-window": "^1.8.5", - "react-window-infinite-loader": "^1.0.5" + "react-window-infinite-loader": "^1.0.5", + "resize-image": "^0.1.0" }, "resolutions": { "js-yaml": "3.13.1" diff --git a/web/ASC.Web.Components/src/components/avatar-editor/index.js b/web/ASC.Web.Components/src/components/avatar-editor/index.js index b771822148..77251fa836 100644 --- a/web/ASC.Web.Components/src/components/avatar-editor/index.js +++ b/web/ASC.Web.Components/src/components/avatar-editor/index.js @@ -149,7 +149,7 @@ AvatarEditor.propTypes = { AvatarEditor.defaultProps = { visible: false, - maxSize: 1, //1MB + maxSize: 10, //10MB headerLabel: 'Edit Photo', saveButtonLabel: 'Save', accept: ['image/png', 'image/jpeg'], diff --git a/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js b/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js index 690bb1d128..bac5297153 100644 --- a/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js +++ b/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js @@ -7,7 +7,7 @@ import { default as ASCAvatar } from '../../avatar/index' import accepts from 'attr-accept' import Text from '../../text' import { tablet } from '../../../utils/device'; - +import resizeImage from 'resize-image' const StyledErrorContainer = styled.div` p{ text-align: center @@ -160,11 +160,22 @@ class AvatarEditorBody extends React.Component { this.props.onLoadFileError(2); } onDropAccepted(acceptedFiles) { - this.setState({ - image: acceptedFiles[0], - errorText: null - }); - this.props.onLoadFile(acceptedFiles[0]); + const _this = this; + var fr = new FileReader(); + fr.readAsDataURL(acceptedFiles[0]); + fr.onload = function () { + var img = new Image(); + img.onload= function () { + var canvas = resizeImage.resize2Canvas(img, 1024); + var data = resizeImage.resize(canvas, 1024); + _this.setState({ + image: data, + errorText: null + }); + _this.props.onLoadFile(data); + }; + img.src = fr.result; + }; } deleteImage() { this.setState({ diff --git a/web/ASC.Web.Components/yarn.lock b/web/ASC.Web.Components/yarn.lock index ef6ef92990..b603b9a3e3 100644 --- a/web/ASC.Web.Components/yarn.lock +++ b/web/ASC.Web.Components/yarn.lock @@ -12348,6 +12348,11 @@ reserved-words@^0.1.2: resolved "https://registry.yarnpkg.com/reserved-words/-/reserved-words-0.1.2.tgz#00a0940f98cd501aeaaac316411d9adc52b31ab1" integrity sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE= +resize-image@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/resize-image/-/resize-image-0.1.0.tgz#033d5f499cb7095def7827d48b8046f7e1c5776c" + integrity sha512-78cWCEX/IupMCwKi5Gg5gxjOZKoN6UXinL2eVOB4xzyG2QNjq64z6pJBnyBKg5/BsjEosLz1co5e3DHr99TgFg== + resize-observer-polyfill@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464" From 647c1b0cc0c4e5c26e3dfe7267203243d12e4d8a Mon Sep 17 00:00:00 2001 From: NikolayRechkin Date: Fri, 24 Jan 2020 11:04:17 +0300 Subject: [PATCH 2/7] web: components: bump version --- web/ASC.Web.Components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index c5826324d5..73f5189d04 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -1,6 +1,6 @@ { "name": "asc-web-components", - "version": "1.0.324", + "version": "1.0.325", "description": "Ascensio System SIA component library", "license": "AGPL-3.0", "main": "dist/asc-web-components.js", From d1c5c29fc9513fdfeb6a10bcb062ef6bc7b451ed Mon Sep 17 00:00:00 2001 From: NikolayRechkin Date: Fri, 24 Jan 2020 14:15:09 +0300 Subject: [PATCH 3/7] web: components: AvatarEditor. Send a compressed image to the server --- .../sub-components/avatar-editor-body.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js b/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js index bac5297153..b08881fe5d 100644 --- a/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js +++ b/web/ASC.Web.Components/src/components/avatar-editor/sub-components/avatar-editor-body.js @@ -166,13 +166,18 @@ class AvatarEditorBody extends React.Component { fr.onload = function () { var img = new Image(); img.onload= function () { - var canvas = resizeImage.resize2Canvas(img, 1024); - var data = resizeImage.resize(canvas, 1024); + var canvas = resizeImage.resize2Canvas(img, 1024, 1024); + var data = resizeImage.resize(canvas, 1024, 1024, resizeImage.JPEG); _this.setState({ image: data, errorText: null }); - _this.props.onLoadFile(data); + fetch(data) + .then(res => res.blob()) + .then(blob => { + const file = new File([blob], "File name",{ type: "image/jpg" }) + _this.props.onLoadFile(file); + }) }; img.src = fr.result; }; From 681415627bd27e781160cf11e68c730f06960270 Mon Sep 17 00:00:00 2001 From: NikolayRechkin Date: Fri, 24 Jan 2020 14:16:10 +0300 Subject: [PATCH 4/7] web: components: bump version --- web/ASC.Web.Components/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index 73f5189d04..9b4e0b8577 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -1,6 +1,6 @@ { "name": "asc-web-components", - "version": "1.0.325", + "version": "1.0.326", "description": "Ascensio System SIA component library", "license": "AGPL-3.0", "main": "dist/asc-web-components.js", From 5edc461090ec5211e87943ff4a521a655510d9f0 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Fri, 24 Jan 2020 14:57:05 +0300 Subject: [PATCH 5/7] People.Client: Home: fixed empty screen when go back button clicked from another pages --- products/ASC.People/Client/src/components/pages/Home/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/ASC.People/Client/src/components/pages/Home/index.js b/products/ASC.People/Client/src/components/pages/Home/index.js index 9a1dfd305b..585729e8a4 100644 --- a/products/ASC.People/Client/src/components/pages/Home/index.js +++ b/products/ASC.People/Client/src/components/pages/Home/index.js @@ -154,7 +154,7 @@ const Home = (props) => { } Home.propTypes = { - users: PropTypes.array.isRequired, + users: PropTypes.array, history: PropTypes.object.isRequired, isLoaded: PropTypes.bool }; From 08cb3a2ede4222e83676d55c12e7baf6ff69d47d Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Fri, 24 Jan 2020 14:59:55 +0300 Subject: [PATCH 6/7] ASC.Web.Common: PageLayout: saving the pinned state in local storage --- .../src/components/PageLayout/README.md | 19 ++++++++------- .../src/components/PageLayout/index.js | 23 +++++++++---------- .../components/PageLayout/page-layout.test.js | 6 ++--- web/ASC.Web.Common/src/constants/index.js | 1 + 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/web/ASC.Web.Common/src/components/PageLayout/README.md b/web/ASC.Web.Common/src/components/PageLayout/README.md index 11941acba3..3a1e5e8a58 100644 --- a/web/ASC.Web.Common/src/components/PageLayout/README.md +++ b/web/ASC.Web.Common/src/components/PageLayout/README.md @@ -22,11 +22,14 @@ import { PageLayout } from "asc-web-common"; ### Properties -| Props | Type | Required | Values | Default | Description | -| ------------------- | :----: | :------: | :----: | :-----: | ----------------------------------------- | -| `isBackdropVisible` | `bool` | - | - | `false` | If you need display Backdrop | -| `isNavHoverEnabled` | `bool` | - | - | `true` | If you need hover navigation on Backdrop | -| `isNavOpened` | `bool` | - | - | `false` | If you need display navigation | -| `isAsideVisible` | `bool` | - | - | `false` | If you need display aside | -| `withBodyScroll` | `bool` | - | - | `true` | If you need display scroll inside content | -| `withBodyAutoFocus` | `bool` | - | - | `true` | If you need set focus on content element | \ No newline at end of file +| Props | Type | Required | Values | Default | Description | +| -------------------------- | :----: | :------: | :----: | :-----: | ----------------------------------------- | +| `articleHeaderContent` | `bool` | - | - | - | Article header content | +| `articleMainButtonContent` | `bool` | - | - | - | Article main button content | +| `articleBodyContent` | `bool` | - | - | - | Article body content | +| `sectionHeaderContent` | `bool` | - | - | - | Section header content | +| `sectionFilterContent` | `bool` | - | - | - | Section filter content | +| `sectionBodyContent` | `bool` | - | - | - | Section body content | +| `sectionPagingContent` | `bool` | - | - | - | Section paging content | +| `withBodyScroll` | `bool` | - | - | `true` | If you need display scroll inside content | +| `withBodyAutoFocus` | `bool` | - | - | `false` | If you need set focus on content element | \ No newline at end of file diff --git a/web/ASC.Web.Common/src/components/PageLayout/index.js b/web/ASC.Web.Common/src/components/PageLayout/index.js index 8b4ec77faa..5016ab448a 100644 --- a/web/ASC.Web.Common/src/components/PageLayout/index.js +++ b/web/ASC.Web.Common/src/components/PageLayout/index.js @@ -4,6 +4,7 @@ import { Backdrop } from "asc-web-components"; import { withTranslation } from 'react-i18next'; import i18n from './i18n'; import { connect } from "react-redux"; +import { ARTICLE_PINNED_KEY } from "../../constants"; import Article from "./sub-components/article"; import ArticleHeader from "./sub-components/article-header"; @@ -51,7 +52,8 @@ class PageLayoutComponent extends React.PureComponent { isSectionPagingAvailable = !!props.sectionPagingContent, isSectionBodyAvailable = !!props.sectionBodyContent || isSectionFilterAvailable || isSectionPagingAvailable, isSectionAvailable = isSectionHeaderAvailable || isSectionFilterAvailable || isSectionBodyAvailable || isSectionPagingAvailable || isArticleAvailable, - isBackdropAvailable = isArticleAvailable; + isBackdropAvailable = isArticleAvailable, + isArticleVisibleAndPinned = !!localStorage.getItem(ARTICLE_PINNED_KEY); let newState = { isBackdropAvailable: isBackdropAvailable, @@ -65,9 +67,9 @@ class PageLayoutComponent extends React.PureComponent { isSectionBodyAvailable: isSectionBodyAvailable, isSectionPagingAvailable: isSectionPagingAvailable, - isBackdropVisible: props.isBackdropVisible, - isArticleVisible: props.isArticleVisible, - isArticlePinned: props.isArticlePinned, + isBackdropVisible: false, + isArticleVisible: isArticleVisibleAndPinned, + isArticlePinned: isArticleVisibleAndPinned, articleHeaderContent: props.articleHeaderContent, articleMainButtonContent: props.articleMainButtonContent, @@ -95,6 +97,8 @@ class PageLayoutComponent extends React.PureComponent { isArticlePinned: true, isArticleVisible: true }); + + localStorage.setItem(ARTICLE_PINNED_KEY, true); }; unpinArticle = () => { @@ -103,6 +107,8 @@ class PageLayoutComponent extends React.PureComponent { isArticlePinned: false, isArticleVisible: true }); + + localStorage.removeItem(ARTICLE_PINNED_KEY); }; showArticle = () => { @@ -172,7 +178,7 @@ class PageLayoutComponent extends React.PureComponent { {this.state.isArticleAvailable && ( )} @@ -196,10 +202,6 @@ PageLayout.propTypes = { } PageLayoutComponent.propTypes = { - isBackdropVisible: PropTypes.bool, - isArticleVisible: PropTypes.bool, - isArticlePinned: PropTypes.bool, - articleHeaderContent: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node @@ -235,9 +237,6 @@ PageLayoutComponent.propTypes = { }; PageLayoutComponent.defaultProps = { - isBackdropVisible: false, - isArticleVisible: false, - isArticlePinned: false, withBodyScroll: true, withBodyAutoFocus: false }; diff --git a/web/ASC.Web.Common/src/components/PageLayout/page-layout.test.js b/web/ASC.Web.Common/src/components/PageLayout/page-layout.test.js index 5a50ceee23..e9d96f796a 100644 --- a/web/ASC.Web.Common/src/components/PageLayout/page-layout.test.js +++ b/web/ASC.Web.Common/src/components/PageLayout/page-layout.test.js @@ -3,10 +3,8 @@ import { mount } from 'enzyme'; import PageLayout from '.'; const baseProps = { - isBackdropVisible: false, - isArticleVisible: false, - isArticlePinned: false, - withBodyScroll: true + withBodyScroll: true, + withBodyAutoFocus: false } describe('', () => { diff --git a/web/ASC.Web.Common/src/constants/index.js b/web/ASC.Web.Common/src/constants/index.js index 1080429a31..c279b2f422 100644 --- a/web/ASC.Web.Common/src/constants/index.js +++ b/web/ASC.Web.Common/src/constants/index.js @@ -1,4 +1,5 @@ export const AUTH_KEY = 'asc_auth_key'; +export const ARTICLE_PINNED_KEY = 'asc_article_pinned_key'; /** * Enum for employee activation status. From f776054b359cec8df8df040b264e46bcb06e2191 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Fri, 24 Jan 2020 15:50:02 +0300 Subject: [PATCH 7/7] ASC.Web.Client: Settings: AccessRights: hid modules tab --- .../categories/security/accessRights.js | 23 ++++++++++--------- .../Settings/categories/security/index.js | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js index 6b9b69ddc1..0aa39fd5b0 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/accessRights.js @@ -8,7 +8,7 @@ import { TabContainer } from "asc-web-components"; import OwnerSettings from "./sub-components/owner"; import AdminsSettings from "./sub-components/admins"; -import ModulesSettings from "./sub-components/modules"; +// import ModulesSettings from "./sub-components/modules"; const MainContainer = styled.div` padding-bottom: 16px; @@ -33,9 +33,10 @@ class PureAccessRights extends Component { let selectedTab = 0; if (activeStatus === "admins") { selectedTab = 1; - } else if (activeStatus === "modules") { - selectedTab = 2; } + // else if (activeStatus === "modules") { + // selectedTab = 2; + // } this.state = { selectedTab @@ -54,9 +55,9 @@ class PureAccessRights extends Component { case "1": history.push("/settings/security/accessrights/admins"); break; - case "2": - history.push("/settings/security/accessrights/modules"); - break; + // case "2": + // history.push("/settings/security/accessrights/modules"); + // break; default: break; } @@ -96,11 +97,11 @@ class PureAccessRights extends Component { title: "Admins settings", content: }, - { - key: "2", - title: "Portals settings", - content: - } + // { + // key: "2", + // title: "Portals settings", + // content: + // } ]} diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js index 6b5cc95a37..05ce791c57 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js @@ -23,12 +23,12 @@ const Security = () => { component={AccessRightsSettings} selectedTab={1} /> - + /> */} );