Web.Client/Server: Settings: added changing greetingTitle
This commit is contained in:
parent
9d114185ad
commit
a153d90082
@ -173,6 +173,56 @@ namespace ASC.Api.Settings
|
||||
return listOfTimezones;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[Read("greetingsettings")]
|
||||
public string GetGreetingSettings()
|
||||
{
|
||||
return Tenant.Name;
|
||||
}
|
||||
|
||||
[Create("greetingsettings")]
|
||||
public object SaveGreetingSettings(GreetingSettingsModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
SecurityContext.DemandPermissions(Tenant, SecutiryConstants.EditPortalSettings);
|
||||
|
||||
Tenant.Name = model.Title;
|
||||
CoreContext.TenantManager.SaveTenant(Tenant);
|
||||
|
||||
MessageService.Send(MessageAction.GreetingSettingsUpdated);
|
||||
|
||||
return new { Status = 1, Message = Resource.SuccessfullySaveGreetingSettingsMessage };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new { Status = 0, Message = e.Message.HtmlEncode() };
|
||||
}
|
||||
}
|
||||
|
||||
[Create("greetingsettings/restore")]
|
||||
public object RestoreGreetingSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
SecurityContext.DemandPermissions(Tenant, SecutiryConstants.EditPortalSettings);
|
||||
|
||||
TenantInfoSettings.Load().RestoreDefaultTenantName();
|
||||
//_tenantInfoSettings.Save();
|
||||
|
||||
return new
|
||||
{
|
||||
Status = 1,
|
||||
Message = Resource.SuccessfullySaveGreetingSettingsMessage,
|
||||
CompanyName = CoreContext.TenantManager.GetCurrentTenant().Name
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new { Status = 0, Message = e.Message.HtmlEncode() };
|
||||
}
|
||||
}
|
||||
|
||||
[Read("recalculatequota")]
|
||||
public void RecalculateQuota()
|
||||
{
|
||||
|
7
web/ASC.Web.Api/Models/GreetingSettingsModel.cs
Normal file
7
web/ASC.Web.Api/Models/GreetingSettingsModel.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace ASC.Web.Api.Models
|
||||
{
|
||||
public class GreetingSettingsModel
|
||||
{
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withTranslation } from 'react-i18next';
|
||||
import { FieldContainer, Text, ComboBox, Loader, Button, toastr, Link } from "asc-web-components";
|
||||
import { FieldContainer, Text, ComboBox, Loader, Button, toastr, Link, TextInput } from "asc-web-components";
|
||||
import { getCultures, setLanguageAndTime, getPortalTimezones } from '../../../../../store/auth/actions';
|
||||
import { getGreetingTitle, setGreetingTitle, restoreGreetingTitle } from '../../../../../store/settings/actions';
|
||||
import styled from 'styled-components';
|
||||
import { Trans } from 'react-i18next';
|
||||
|
||||
@ -27,6 +28,18 @@ const StyledComponent = styled.div`
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.margin-left {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.settings-block {
|
||||
margin-bottom: 70px;
|
||||
}
|
||||
|
||||
.input-width {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.dropdown-item-width {
|
||||
& > div:first-child {
|
||||
div:first-child{
|
||||
@ -40,7 +53,7 @@ class Customization extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const { portalLanguage, portalTimeZoneId, rawCultures, rawTimezones, t } = props;
|
||||
const { portalLanguage, portalTimeZoneId, rawCultures, rawTimezones, t, greetingSettings } = props;
|
||||
const languages = mapCulturesToArray(rawCultures, t);
|
||||
const timezones = mapTimezonesToArray(rawTimezones);
|
||||
|
||||
@ -51,13 +64,20 @@ class Customization extends React.Component {
|
||||
timezone: findSelectedItemByKey(timezones, portalTimeZoneId),
|
||||
languages,
|
||||
language: findSelectedItemByKey(languages, portalLanguage),
|
||||
greetingTitle: greetingSettings,
|
||||
isLoadingGreeting: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
componentDidMount() {
|
||||
const { getCultures, portalLanguage, portalTimeZoneId, t, getPortalTimezones } = this.props;
|
||||
const { timezones, languages } = this.state;
|
||||
const { getCultures, portalLanguage, portalTimeZoneId, t, getPortalTimezones, getGreetingTitle } = this.props;
|
||||
const { timezones, languages, greetingTitle } = this.state;
|
||||
|
||||
if (!greetingTitle.length) {
|
||||
getGreetingTitle()
|
||||
.then(() => this.setState({ greetingTitle: this.props.greetingSettings }));
|
||||
}
|
||||
|
||||
if (!timezones.length && !languages.length) {
|
||||
let languages;
|
||||
@ -99,9 +119,38 @@ class Customization extends React.Component {
|
||||
})
|
||||
}
|
||||
|
||||
onChangeGreetingTitle = (e) => {
|
||||
this.setState({ greetingTitle: e.target.value })
|
||||
};
|
||||
|
||||
onSaveGreetingSettings = () => {
|
||||
const { setGreetingTitle, t } = this.props;
|
||||
this.setState({ isLoadingGreeting: true }, function () {
|
||||
setGreetingTitle(this.state.greetingTitle)
|
||||
.then(() => {
|
||||
this.setState({ isLoadingGreeting: false })
|
||||
toastr.success(t('SuccessfullySaveGreetingSettingsMessage'));
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
onRestoreGreetingSettings = () => {
|
||||
const { restoreGreetingTitle, t } = this.props;
|
||||
this.setState({ isLoadingGreeting: true }, function () {
|
||||
restoreGreetingTitle()
|
||||
.then(() => {
|
||||
this.setState({
|
||||
isLoadingGreeting: false,
|
||||
greetingTitle: this.props.greetingSettings
|
||||
})
|
||||
toastr.success(t('SuccessfullySaveGreetingSettingsMessage'));
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { t, i18n } = this.props;
|
||||
const { isLoadedData, languages, language, isLoading, timezones, timezone } = this.state;
|
||||
const { isLoadedData, languages, language, isLoading, timezones, timezone, greetingTitle, isLoadingGreeting } = this.state;
|
||||
const supportEmail = "documentation@onlyoffice.com";
|
||||
const tooltipLanguage =
|
||||
<Text.Body fontSize={13}>
|
||||
@ -123,54 +172,94 @@ class Customization extends React.Component {
|
||||
<Loader className="pageLoader" type="rombs" size={40} />
|
||||
: <>
|
||||
<StyledComponent>
|
||||
<Text.Body fontSize={16}>{t('StudioTimeLanguageSettings')}</Text.Body>
|
||||
<FieldContainer
|
||||
id='fieldContainerLanguage'
|
||||
className='margin-top'
|
||||
labelText={`${t("Language")}:`}
|
||||
tooltipContent={tooltipLanguage}
|
||||
isVertical={true}>
|
||||
<ComboBox
|
||||
id='comboBoxLanguage'
|
||||
options={languages}
|
||||
selectedOption={language}
|
||||
onSelect={this.onLanguageSelect}
|
||||
isDisabled={isLoading}
|
||||
noBorder={false}
|
||||
scaled={false}
|
||||
scaledOptions={true}
|
||||
// dropDownMaxHeight={300}
|
||||
size='huge'
|
||||
/>
|
||||
</FieldContainer>
|
||||
<div className='settings-block'>
|
||||
<Text.Body fontSize={16}>{t('StudioTimeLanguageSettings')}</Text.Body>
|
||||
<FieldContainer
|
||||
id='fieldContainerLanguage'
|
||||
className='margin-top'
|
||||
labelText={`${t("Language")}:`}
|
||||
tooltipContent={tooltipLanguage}
|
||||
isVertical={true}>
|
||||
<ComboBox
|
||||
id='comboBoxLanguage'
|
||||
options={languages}
|
||||
selectedOption={language}
|
||||
onSelect={this.onLanguageSelect}
|
||||
isDisabled={isLoading}
|
||||
noBorder={false}
|
||||
scaled={false}
|
||||
scaledOptions={true}
|
||||
// dropDownMaxHeight={300}
|
||||
size='huge'
|
||||
/>
|
||||
</FieldContainer>
|
||||
|
||||
<FieldContainer
|
||||
id='fieldContainerTimezone'
|
||||
labelText={`${t("TimeZone")}:`}
|
||||
isVertical={true}>
|
||||
<ComboBox
|
||||
id='comboBoxTimezone'
|
||||
options={timezones}
|
||||
selectedOption={timezone}
|
||||
onSelect={this.onTimezoneSelect}
|
||||
isDisabled={isLoading}
|
||||
noBorder={false}
|
||||
scaled={false}
|
||||
scaledOptions={true}
|
||||
dropDownMaxHeight={300}
|
||||
size='huge'
|
||||
className='dropdown-item-width'
|
||||
<FieldContainer
|
||||
id='fieldContainerTimezone'
|
||||
labelText={`${t("TimeZone")}:`}
|
||||
isVertical={true}>
|
||||
<ComboBox
|
||||
id='comboBoxTimezone'
|
||||
options={timezones}
|
||||
selectedOption={timezone}
|
||||
onSelect={this.onTimezoneSelect}
|
||||
isDisabled={isLoading}
|
||||
noBorder={false}
|
||||
scaled={false}
|
||||
scaledOptions={true}
|
||||
dropDownMaxHeight={300}
|
||||
size='huge'
|
||||
className='dropdown-item-width'
|
||||
/>
|
||||
</FieldContainer>
|
||||
<Button
|
||||
id='btnSaveLngTZ'
|
||||
className='margin-top'
|
||||
primary={true}
|
||||
size='medium'
|
||||
label={t('SaveButton')}
|
||||
isLoading={isLoading}
|
||||
onClick={this.onSaveLngTZSettings}
|
||||
/>
|
||||
</FieldContainer>
|
||||
<Button
|
||||
id='btnSaveLngTZ'
|
||||
className='margin-top'
|
||||
primary={true}
|
||||
size='big'
|
||||
label={t('SaveButton')}
|
||||
isLoading={isLoading}
|
||||
onClick={this.onSaveLngTZSettings}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='settings-block'>
|
||||
<Text.Body fontSize={16}>{t('GreetingSettingsTitle')}</Text.Body>
|
||||
<FieldContainer
|
||||
id='fieldContainerWelcomePage'
|
||||
className='margin-top'
|
||||
labelText={`${t("GreetingTitle")}:`}
|
||||
isVertical={true}>
|
||||
<TextInput
|
||||
className='input-width'
|
||||
scale={true}
|
||||
value={greetingTitle}
|
||||
onChange={this.onChangeGreetingTitle}
|
||||
isDisabled={isLoadingGreeting}
|
||||
/>
|
||||
|
||||
</FieldContainer>
|
||||
|
||||
<Button
|
||||
id='btnSaveGreetingSetting'
|
||||
className='margin-top'
|
||||
primary={true}
|
||||
size='medium'
|
||||
label={t('SaveButton')}
|
||||
isLoading={isLoadingGreeting}
|
||||
onClick={this.onSaveGreetingSettings}
|
||||
/>
|
||||
|
||||
<Button
|
||||
id='btnRestoreToDefault'
|
||||
className='margin-top margin-left'
|
||||
size='medium'
|
||||
label={t('RestoreDefaultButton')}
|
||||
isDisabled={isLoadingGreeting}
|
||||
onClick={this.onRestoreGreetingSettings}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</StyledComponent>
|
||||
|
||||
</>
|
||||
@ -185,7 +274,11 @@ function mapStateToProps(state) {
|
||||
language: state.auth.user.cultureName || state.auth.settings.culture,
|
||||
rawTimezones: state.auth.settings.timezones,
|
||||
rawCultures: state.auth.settings.cultures,
|
||||
greetingSettings: state.settings.greetingSettings,
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, { getCultures, setLanguageAndTime, getPortalTimezones })(withTranslation()(Customization));
|
||||
export default connect(mapStateToProps, {
|
||||
getCultures, setLanguageAndTime, getPortalTimezones,
|
||||
getGreetingTitle, setGreetingTitle, restoreGreetingTitle
|
||||
})(withTranslation()(Customization));
|
||||
|
@ -42,8 +42,12 @@
|
||||
"ThirdPartyAuthorization": "Third Party Authorization",
|
||||
"SmtpSettings": "SMTP Settings",
|
||||
"ManagementCategoryStatistic": "Statistics",
|
||||
"LoadingProcessing": "Loading...",
|
||||
"LoadingDescription": "Please wait...",
|
||||
"LoadingProcessing": "Loading...",
|
||||
"LoadingDescription": "Please wait...",
|
||||
"GreetingSettingsTitle": "Welcome Page Settings",
|
||||
"GreetingTitle": "Title",
|
||||
"RestoreDefaultButton": "Restore to Default",
|
||||
"SuccessfullySaveGreetingSettingsMessage": "Welcome Page settings have been successfully saved",
|
||||
|
||||
|
||||
|
||||
|
@ -42,7 +42,11 @@
|
||||
"SmtpSettings": "Настройки SMTP",
|
||||
"ManagementCategoryStatistic": "Статистика",
|
||||
"LoadingProcessing": "Загрузка...",
|
||||
"LoadingDescription": "Пожалуйста подождите...",
|
||||
"LoadingDescription": "Пожалуйста подождите...",
|
||||
"GreetingSettingsTitle": "Настройки страницы приветствия",
|
||||
"GreetingTitle": "Заголовок",
|
||||
"RestoreDefaultButton": "Настройки по умолчанию",
|
||||
"SuccessfullySaveGreetingSettingsMessage": "Настройки страницы приветствия успешно сохранены",
|
||||
|
||||
|
||||
|
||||
|
@ -89,6 +89,10 @@
|
||||
"DeactivationDeletionPortal",
|
||||
"ThirdPartyAuthorization",
|
||||
"SmtpSettings",
|
||||
"GreetingSettingsTitle",
|
||||
"GreetingTitle",
|
||||
"RestoreDefaultButton",
|
||||
"SuccessfullySaveGreetingSettingsMessage",
|
||||
"Employees"
|
||||
],
|
||||
"FeedResource": [
|
||||
|
@ -167,7 +167,7 @@ export function changeProductAdmin(userId, productId, administrator) {
|
||||
return request({
|
||||
method: "put",
|
||||
url: "/settings/security/administrator",
|
||||
data: {
|
||||
data: {
|
||||
productId,
|
||||
userId,
|
||||
administrator
|
||||
@ -180,4 +180,26 @@ export function getUserById(userId) {
|
||||
method: "get",
|
||||
url: `/people/${userId}`,
|
||||
});
|
||||
}
|
||||
|
||||
export function getGreetingSettings() {
|
||||
return request({
|
||||
method: "get",
|
||||
url: `/settings/greetingsettings.json`,
|
||||
});
|
||||
}
|
||||
|
||||
export function setGreetingSettings(title) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: `/settings/greetingsettings.json`,
|
||||
data: { title }
|
||||
});
|
||||
}
|
||||
|
||||
export function restoreGreetingSettings() {
|
||||
return request({
|
||||
method: "post",
|
||||
url: `/settings/greetingsettings/restore.json`
|
||||
});
|
||||
}
|
@ -3,6 +3,7 @@ import * as api from "../services/api";
|
||||
export const SET_USERS = "SET_USERS";
|
||||
export const SET_ADMINS = "SET_ADMINS";
|
||||
export const SET_OWNER = "SET_OWNER";
|
||||
export const SET_GREETING_SETTINGS = "SET_GREETING_SETTINGS";
|
||||
|
||||
export function setUsers(users) {
|
||||
return {
|
||||
@ -25,6 +26,13 @@ export function setOwner(owner) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setGreetingSettings(title) {
|
||||
return {
|
||||
type: SET_GREETING_SETTINGS,
|
||||
title
|
||||
};
|
||||
}
|
||||
|
||||
export function getListUsers() {
|
||||
return dispatch => {
|
||||
return api.getUserList().then(users => dispatch(setUsers(users)));
|
||||
@ -53,3 +61,28 @@ export function getUserById(userId) {
|
||||
return api.getUserById(userId).then(owner => dispatch(setOwner(owner)));
|
||||
};
|
||||
}
|
||||
|
||||
export function getGreetingTitle() {
|
||||
return dispatch => {
|
||||
return api.getGreetingSettings()
|
||||
.then(greetingTitle => dispatch(setGreetingSettings(greetingTitle)));
|
||||
};
|
||||
}
|
||||
|
||||
export function setGreetingTitle(greetingTitle) {
|
||||
return dispatch => {
|
||||
return api.setGreetingSettings(greetingTitle)
|
||||
.then((res) => {
|
||||
dispatch(setGreetingSettings(greetingTitle))
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function restoreGreetingTitle() {
|
||||
return dispatch => {
|
||||
return api.restoreGreetingSettings()
|
||||
.then((res) => {
|
||||
dispatch(setGreetingSettings(res.companyName))
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { SET_USERS, SET_ADMINS, SET_OWNER } from "./actions";
|
||||
import { SET_USERS, SET_ADMINS, SET_OWNER, SET_GREETING_SETTINGS } from "./actions";
|
||||
|
||||
const initialState = {
|
||||
users: [],
|
||||
admins: [],
|
||||
owner: {}
|
||||
owner: {},
|
||||
greetingSettings: ''
|
||||
};
|
||||
|
||||
const peopleReducer = (state = initialState, action) => {
|
||||
@ -20,6 +21,10 @@ const peopleReducer = (state = initialState, action) => {
|
||||
return Object.assign({}, state, {
|
||||
owner: action.owner
|
||||
});
|
||||
case SET_GREETING_SETTINGS:
|
||||
return Object.assign({}, state, {
|
||||
greetingSettings: action.title
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user