Merge branch 'master' of github.com:ONLYOFFICE/CommunityServer-AspNetCore

This commit is contained in:
Ilya Oleshko 2019-08-05 15:45:29 +03:00
commit db7f179316
21 changed files with 94 additions and 26 deletions

View File

@ -114,6 +114,7 @@ namespace ASC.Api.Core
jsonSerializer.DateParseHandling = DateParseHandling.None;
jsonSerializer.ContractResolver = new ResponseDataContractResolver(props);
jsonSerializer.Serialize(writer, value);
return;
}
serializer.Serialize(writer, value);

View File

@ -1,5 +1,5 @@
import { SubmissionError } from 'redux-form'
import { createUser, updateUser } from '../../../../../../utils/api'
import { createUser, updateUser } from '../../../../../../store/services/api'
function submit (values) {
function successCallback (res) {

View File

@ -2,7 +2,7 @@ import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import Cookies from "universal-cookie";
import setAuthorizationToken from "./utils/setAuthorizationToken";
import setAuthorizationToken from "./store/services/setAuthorizationToken";
import { AUTH_KEY } from "./helpers/constants";
import store from "./store/store";
import "./custom.scss";

View File

@ -1,6 +1,6 @@
import * as api from '../../utils/api';
import { setGroups, setUsers } from '../people/actions';
import setAuthorizationToken from '../../utils/setAuthorizationToken';
import * as api from '../services/api';
import { setGroups } from '../people/actions';
import setAuthorizationToken from '../../store/services/setAuthorizationToken';
import { fetchPeople } from '../people/actions';
export const LOGIN_POST = 'LOGIN_POST';

View File

@ -1,5 +1,5 @@
import * as api from "../../utils/api";
import Filter from "../../helpers/filter";
import * as api from "../services/api";
import Filter from "./filter";
export const SET_GROUPS = 'SET_GROUPS';
export const SET_USERS = 'SET_USERS';

View File

@ -1,4 +1,4 @@
import { toUrlParams } from "../utils/converter";
import { toUrlParams } from "../services/converter";
class Filter {
static getDefault(total = 0) {

View File

@ -8,7 +8,7 @@ import {
SET_FILTER
} from "./actions";
import { isSelected, skipUser, getUsersBySelected } from './selectors';
import Filter from "../../helpers/filter";
import Filter from "./filter";
const initialState = {
users: [],

View File

@ -40,10 +40,18 @@ export function getTreeGroups(groups) {
};
export const getUserStatus = user => {
if (user.status === 1 && user.activationStatus === 1) return "normal";
else if (user.status === 1 && user.activationStatus === 2) return "pending";
else if (user.status === 2) return "disabled";
else return "normal";
if (user.status === 1 && user.activationStatus === 1) {
return "normal";
}
else if (user.status === 1 && (user.activationStatus === 0 || user.activationStatus === 2)) {
return "pending";
}
else if (user.status === 2) {
return "disabled";
}
else {
return "unknown";
}
};
export const getUserRole = user => {

View File

@ -1,4 +1,4 @@
import * as api from "../../utils/api";
import * as api from "../../store/services/api";
import { isMe } from '../auth/selectors';
import { getUserByUserName } from '../people/selectors';

View File

@ -1,7 +1,7 @@
import axios from 'axios';
import * as fakeApi from './fakeApi';
import Filter from '../helpers/filter';
import Filter from '../people/filter';
const PREFIX = 'api';
const VERSION = '2.0';

View File

@ -1,6 +1,6 @@
import axios from 'axios';
import Cookies from 'universal-cookie';
import { AUTH_KEY } from '../helpers/constants';
import { AUTH_KEY } from '../../helpers/constants';
export default function setAuthorizationToken(token) {
const cookies = new Cookies();

View File

@ -6,6 +6,7 @@ using ASC.Api.Core.Middleware;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Common.Web;
using ASC.Core;
using ASC.Data.Reassigns;
using ASC.Data.Storage.Configuration;
@ -120,9 +121,17 @@ namespace ASC.People
Thread.CurrentThread.CurrentCulture = user.GetCulture();
Thread.CurrentThread.CurrentCulture = user.GetCulture();
}
await next.Invoke();
});
app.Use(async (context, next) =>
{
context.Response.RegisterForDispose(new DisposableHttpContext(context));
await next();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
@ -132,7 +141,6 @@ namespace ASC.People
app.UseCSP();
app.UseCm();
app.UseWebItemManager();
app.UseStaticFiles();
}
}

View File

@ -1,10 +1,12 @@
using System.Threading;
using ASC.Api.Core;
using ASC.Api.Core.Core;
using ASC.Api.Core.Middleware;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Common.Web;
using ASC.Core;
using ASC.Data.Reassigns;
using ASC.Data.Storage.Configuration;
@ -115,6 +117,13 @@ namespace ASC.Web.Api
await next.Invoke();
});
app.Use(async (context, next) =>
{
context.Response.RegisterForDispose(new DisposableHttpContext(context));
await next();
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();

View File

@ -28,11 +28,29 @@ class FilterInput extends React.Component {
constructor(props) {
super(props);
function getDefaultFilterData(){
let filterData = props.getFilterData();
let defaultFilterItems = [];
props.defaultFilterData.filterValue.forEach(defaultfilterValue => {
let filterValue = filterData.find(x => (x.key === defaultfilterValue.value && x.group === defaultfilterValue.key));
if(filterValue != undefined){
defaultfilterValue.label = filterValue.label;
defaultfilterValue.groupLabel = filterData.find(x => (x.key === defaultfilterValue.key)).label;
defaultFilterItems.push(defaultfilterValue);
}
});
return defaultFilterItems;
}
this.state = {
sortDirection: false,
sortId: this.props.getSortData().length > 0 ? this.props.getSortData()[0].id : "",
filterValue: [],
searchText: this.props.value
sortDirection: props.defaultFilterData ? props.defaultFilterData.sortDirection == "asc" ? true : false : false,
sortId: props.defaultFilterData ?
this.props.getSortData().findIndex(x => x.id === props.defaultFilterData.sortId) != -1 ? props.defaultFilterData.sortId : "" :
this.props.getSortData().length > 0 ? this.props.getSortData()[0].id : "",
filterValue: props.defaultFilterData ?
getDefaultFilterData() :
[],
searchText: props.defaultFilterData ? props.defaultFilterData.inputValue : this.props.value
};
this.timerId = null;
@ -43,8 +61,18 @@ class FilterInput extends React.Component {
this.onSearch = this.onSearch.bind(this);
this.setFilterTimer = this.setFilterTimer.bind(this);
this.onSearchChanged = this.onSearchChanged.bind(this);
this.getDefaultSelectedIndex = this.getDefaultSelectedIndex.bind(this);
}
getDefaultSelectedIndex(){
const sortData = this.getSortData();
if(sortData.length > 0){
let defaultIndex = sortData.findIndex(x => x.id === this.state.sortId);
return defaultIndex != -1 ? defaultIndex : 0;
}
return 0;
}
getSortData() {
let _this = this;
let d = this.props.getSortData();
@ -110,6 +138,7 @@ class FilterInput extends React.Component {
onSearchClick={this.onSearch}
onChangeFilter={this.onSearch}
value={this.state.searchText}
defaultFilterData={this.state.filterValue}
onChange={this.onSearchChanged}
/>
</StyledSearchInput>
@ -118,6 +147,7 @@ class FilterInput extends React.Component {
options={this.getSortData()}
isDisabled={this.props.isDisabled}
onSelect={this.onClickSortItem}
selectedIndex={this.getDefaultSelectedIndex()}
>
<StyledIconButton {...this.state}>
<IconButton

View File

@ -35,7 +35,7 @@ const getSizeStyle = size => {
}
};
export default function createStyledIcon(Component, displayName, fillPath="*", strokePath="rect") {
export default function createStyledIcon(Component, displayName, fillPath="*", strokePath="*") {
const Icon = ({ isfill, isStroke, color, stroke, fillPath, strokePath, ...props }) => <Component {...props}></Component>;
const StyledIcon = styled(Icon)(

View File

@ -312,8 +312,8 @@ export const CheckIcon = createStyledIcon(
);
export const CheckboxIcon = createStyledIcon(
OrigCheckboxIcon,
"*",
'CheckboxIcon'
'CheckboxIcon',
"rect"
);
export const CheckboxCheckedIcon = createStyledIcon(
OrigCheckboxCheckedIcon,

View File

@ -73,7 +73,7 @@ class SearchInput extends React.Component {
this.minWidth = 190;
this.isUpdateFilter = true;
this.state = {
filterItems: [],
filterItems: props.defaultFilterData ? props.defaultFilterData : [],
openFilterItems: [],
hideFilterItems: []
};
@ -248,6 +248,7 @@ class SearchInput extends React.Component {
componentDidMount() {
window.addEventListener('resize', _.throttle(this.resize), 100);
this.isUpdateFilter = false; this.updateFilter();
}
componentWillUnmount() {
window.removeEventListener('resize', this.resize());

View File

@ -33,5 +33,6 @@ FilterInput description
| `placeholder` | `string` | - | - | - | Placeholder text for the input |
| `size` | `string` | | `base`, `middle`, `big`, `huge`| `base` | Supported size of the input fields. |
| `scale` | `bool` | - | - | - | Indicates the input field has scale |
| `defaultFilterData` | `object` | - | - | - | Default filter data |

View File

@ -7,9 +7,18 @@ import withReadme from 'storybook-readme/with-readme';
import Readme from '../README.md';
import { FilterInput } from 'asc-web-components';
import Section from '../../../.storybook/decorators/section';
import { directive } from '@babel/types';
const sizeOptions = ['base', 'middle', 'big', 'huge'];
const defaultFilterData = {
filterValue: [
{key: "filter-status", value: "filter-status-disabled"}
],
sortDirection: "desc",
sortId: "name",
inputValue: "text"
};
function getData() {
return [
{ key: 'filter-status', group: 'filter-status', label: 'Status', isHeader: true },
@ -55,6 +64,7 @@ storiesOf('Components|Filter', module)
placeholder={text('placeholder', 'Search')}
onFilter={(result) => {console.log(result)}}
value={value}
defaultFilterData={defaultFilterData}
onChange={e => {
set(e.target.value);
}}