Merge branch 'feature/virtual-rooms-1.2' of github.com:ONLYOFFICE/AppServer into feature/virtual-rooms-1.2

This commit is contained in:
Timofey Boyko 2022-03-05 16:59:14 +03:00
commit 7d747b9a7b
5 changed files with 238 additions and 54 deletions

View File

@ -38,11 +38,19 @@ export function setPortalPasswordSettings(
});
}
export function setMailDomainSettings(type, domains, inviteUsersAsVisitors) {
export function setMailDomainSettings(data) {
return request({
method: "post",
url: "/settings/maildomainsettings.json",
data: { type, domains, inviteUsersAsVisitors },
data,
});
}
export function setDNSSettings(dnsName, enable) {
return request({
method: "post",
url: "/settings/maildomainsettings.json",
data: { dnsName, enable },
});
}
@ -78,11 +86,18 @@ export function setCookieSettings(lifeTime) {
});
}
export function setLifetimeAuditSettings(loginHistoryLifeTime) {
export function setLifetimeAuditSettings(data) {
return request({
method: "post",
url: "/audit/settings/lifetime.json",
data: { loginHistoryLifeTime },
url: "/security/audit/settings/lifetime.json",
data,
});
}
export function getAuditTrailReport() {
return request({
method: "post",
url: "/security/audit/login/report.json",
});
}

View File

@ -23,6 +23,7 @@
"CompanyNameForCanvasLogo": "Название компании",
"ConfirmEmailSended": "Письмо с подтверждением отправлено {{ownerName}}",
"Customization": "Кастомизация",
"CustomizationDescription": "Этот раздел позволит вам изменить язык всего портала для всех пользователей портала и настроить часовой пояс, также здесь вы можете изменить приветсвенную страницу, DNS, название портала и т.д.",
"CustomTitles": "Пользовательские заголовки",
"CustomTitlesFrom": "От кого",
"CustomTitlesHeader": "Заголовок",

View File

@ -15,7 +15,6 @@ import withCultureNames from "@appserver/common/hoc/withCultureNames";
import LanguageAndTimeZone from "./language-and-time-zone";
import CustomTitles from "./custom-titles";
import PortalRenaming from "./portal-renaming";
import WhiteLabel from "./whitelabel";
import { Base } from "@appserver/components/themes";
import { Consumer } from "@appserver/components/utils/context";
@ -38,6 +37,51 @@ const StyledArrowRightIcon = styled(ArrowRightIcon)`
StyledArrowRightIcon.defaultProps = { theme: Base };
const StyledMobileComponent = styled.div`
.margin-top {
margin-top: 20px;
}
.margin-left {
margin-left: 20px;
}
.settings-block {
margin-bottom: 70px;
}
.field-container-width {
max-width: 500px;
}
.combo-button-label {
max-width: 100%;
}
.category-item-wrapper {
margin-top: 20px;
.category-item-heading {
display: flex;
align-items: center;
margin-bottom: 5px;
}
.category-item-subheader {
font-size: 13px;
font-weight: 600;
margin-bottom: 5px;
}
.category-item-description {
color: #657077;
font-size: 13px;
max-width: 1024px;
}
.inherit-title-link {
margin-right: 7px;
font-size: 19px;
font-weight: 600;
}
.link-text {
margin: 0;
}
}
`;
const StyledComponent = styled.div`
.margin-top {
margin-top: 20px;
@ -59,6 +103,10 @@ const StyledComponent = styled.div`
max-width: 100%;
}
.category-description {
color: #657077;
}
.category-item-wrapper {
/* .category-item-heading {
display: flex;
@ -208,23 +256,111 @@ class Customization extends React.Component {
render() {
const { t, helpUrlCommonSettings, customNames, theme } = this.props;
const { language, timezone } = this.state;
return (
<Consumer>
{(context) => (
<StyledComponent>
<div className="category-item-wrapper">
<LanguageAndTimeZone sectionWidth={context.sectionWidth} />
</div>
<div className="category-item-wrapper">
<CustomTitles sectionWidth={context.sectionWidth} />
</div>
<div className="category-item-wrapper">
<PortalRenaming sectionWidth={context.sectionWidth} />
</div>
<WhiteLabel />
</StyledComponent>
)}
{(context) =>
`${context.sectionWidth}` <= 375 ? (
<StyledMobileComponent>
<div className="category-item-wrapper">
<div className="category-item-heading">
<Link
className="inherit-title-link header"
onClick={this.onClickLink}
truncate={true}
href={combineUrl(
AppServerConfig.proxyURL,
"/settings/common/customization/language-and-time-zone"
)}
>
{t("StudioTimeLanguageSettings")}
</Link>
<StyledArrowRightIcon size="small" color="#333333" />
</div>
<Text className="category-item-description">
{t("LanguageAndTimeZoneSettingsDescription")}
</Text>
<Box marginProp="16px 0 3px 0">
<Link
color={theme.studio.settings.common.linkColorHelp}
target="_blank"
isHovered={true}
href={helpUrlCommonSettings}
>
{t("Common:LearnMore")}
</Link>
</Box>
</div>
<div className="category-item-wrapper">
<div className="category-item-heading">
<Link
truncate={true}
className="inherit-title-link header"
onClick={this.onClickLink}
href={combineUrl(
AppServerConfig.proxyURL,
"/settings/common/customization/custom-titles"
)}
>
{t("CustomTitles")}
</Link>
<StyledArrowRightIcon size="small" color="#333333" />
</div>
<Text className="category-item-description">
{t("CustomTitlesSettingsDescription")}
</Text>
</div>
<div className="category-item-wrapper">
<div className="category-item-heading">
<Link
truncate={true}
className="inherit-title-link header"
onClick={this.onClickLink}
href={combineUrl(
AppServerConfig.proxyURL,
"/settings/common/customization/team-template"
)}
>
{t("TeamTemplate")}
</Link>
<StyledArrowRightIcon size="small" color="#333333" />
</div>
<Box marginProp="4px 0 6px 0">
<Text fontWeight="600">{`${customNames.name}`}</Text>
</Box>
<Text className="category-item-description">
{t("TeamTemplateSettingsDescription")}
</Text>
<Box marginProp="16px 0 0 0">
<Link
color={theme.studio.settings.common.linkColorHelp}
target="_blank"
isHovered={true}
href={helpUrlCommonSettings}
>
{t("Common:LearnMore")}
</Link>
</Box>
</div>
</StyledMobileComponent>
) : (
<StyledComponent>
<div className="category-description">{`${t(
"Settings:CustomizationDescription"
)}`}</div>
<div className="category-item-wrapper">
<LanguageAndTimeZone sectionWidth={context.sectionWidth} />
</div>
<div className="category-item-wrapper">
<CustomTitles sectionWidth={context.sectionWidth} />
</div>
<div className="category-item-wrapper">
<PortalRenaming sectionWidth={context.sectionWidth} />
</div>
</StyledComponent>
)
}
</Consumer>
);
}

View File

@ -9,6 +9,7 @@ import Button from "@appserver/components/button";
import toastr from "@appserver/components/toast/toastr";
import Link from "@appserver/components/link";
import TextInput from "@appserver/components/text-input";
import FileInput from "@appserver/components/file-input";
import { inject, observer } from "mobx-react";
import { Base } from "@appserver/components/themes";
@ -225,24 +226,67 @@ class WhiteLabel extends React.Component {
this.setState({ isCanvasProcessing: false });
};
onSaveImageBase64 = (url) => {
let img = document.createElement("img");
img.src = url;
let key = encodeURIComponent(url),
canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
let ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
return canvas.toDataURL("image/png");
};
onSave = () => {
const { setWhiteLabelSettings } = this.props;
const { logoText, logoUrls } = this.state;
const { logoText } = this.state;
// TODO: Для всех картинок написать логику
let fd = new FormData();
fd.append("logoText", logoText);
// TODO: Переделать с for
for (let i = 0; i < logoUrls.length; i++) {
fd.append(`logo[${i}][key]`, i);
fd.append(`logo[${i}][value]`, logoUrls[i]);
}
let elem = document.getElementById("canvas_logo_1");
let dataURL = elem.toDataURL();
fd.append(`logo[${0}][key]`, 1);
fd.append(`logo[${0}][value]`, dataURL);
// for (let i = 1; i < logoUrls.length; i++) {
// fd.append(`logo[${i}][key]`, i);
// console.log(this.onSaveImageBase64(logoUrls[i]));
// fd.append(`logo[${i}][value]`, this.onSaveImageBase64(logoUrls[i - 1]));
// }
const data = new URLSearchParams(fd);
setWhiteLabelSettings(data);
};
onChangeHandler = (e) => {
const { setWhiteLabelSettings } = this.props;
// TODO: Добавить проверку на размер
let file = e.target.files[0];
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = (e) => {
this.imgsrc = e.target.result;
let fd = new FormData();
fd.append("logoText", "asas");
fd.append(`logo[${0}][key]`, 1);
fd.append(`logo[${0}][value]`, e.target.result);
const data = new URLSearchParams(fd);
setWhiteLabelSettings(data);
};
};
render() {
const { t, theme } = this.props;
const {
@ -328,14 +372,10 @@ class WhiteLabel extends React.Component {
)}
</div>
{isPortalPaid && (
<Link
type="action"
color={theme.studio.settings.common.linkColorHelp}
isHovered
onClick={this.onChangeLogo}
>
{t("ChangeLogoButton")}
</Link>
<FileInput
placeholder={t("ChangeLogoButton")}
onChange={this.onChangeHandler}
/>
)}
</FieldContainer>
@ -367,16 +407,6 @@ class WhiteLabel extends React.Component {
/>
)}
</div>
{isPortalPaid && (
<Link
type="action"
color={theme.studio.settings.common.linkColorHelp}
isHovered
onClick={this.onChangeLogo}
>
{t("ChangeLogoButton")}
</Link>
)}
</FieldContainer>
<FieldContainer
id="fieldContainerLogoFavicon"

View File

@ -216,12 +216,12 @@ class SettingsSetupStore {
const res = await api.portal.setPortalRename(alias);
};
setMailDomainSettings = async (type, domains, inviteUsersAsVisitors) => {
const res = await api.settings.setMailDomainSettings(
type,
domains,
inviteUsersAsVisitors
);
setMailDomainSettings = async (data) => {
const res = await api.settings.setMailDomainSettings(data);
};
setDNSSettings = async (dnsName, enable) => {
const res = await api.settings.setMailDomainSettings(dnsName, enable);
};
setIpRestrictions = async (data) => {
@ -240,10 +240,12 @@ class SettingsSetupStore {
const res = await api.settings.setCookieSettings(lifeTime);
};
setLifetimeAuditSettings = async (loginHistoryLifeTime) => {
const res = await api.settings.setLifetimeAuditSettings(
loginHistoryLifeTime
);
setLifetimeAuditSettings = async (data) => {
const res = await api.settings.setLifetimeAuditSettings(data);
};
getAuditTrailReport = async () => {
const res = await api.settings.getAuditTrailReport();
};
setGreetingTitle = async (greetingTitle) => {