Skip to content

Commit be34610

Browse files
committed
Store initializer added.
1 parent f8592a7 commit be34610

19 files changed

+312
-231
lines changed

reactjs/package-lock.json

Lines changed: 30 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reactjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@aspnet/signalr": "^1.0.0",
77
"@types/moment": "^2.13.0",
88
"@types/moment-timezone": "^0.5.9",
9+
"@types/recharts": "^1.1.1",
910
"abp-web-resources": "^3.8.2",
1011
"antd": "^3.10.3",
1112
"axios": "^0.18.0",

reactjs/src/App.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import Layout from './scenes/Layout';
55
import Login from './scenes/Login';
66
import { inject } from 'mobx-react';
77
import SignalRAspNetCoreHelper from 'src/lib/signalRAspNetCoreHelper';
8+
import SessionStore from './stores/sessionStore';
9+
import Stores from './stores/storeIdentifier';
810

9-
@inject('SessionStore')
10-
class App extends React.Component<any> {
11+
export interface IAppProps {
12+
sessionStore: SessionStore;
13+
}
14+
15+
@inject(Stores.SessionStore)
16+
class App extends React.Component<IAppProps> {
1117
async componentDidMount() {
12-
await this.props.SessionStore.getCurrentLoginInformations();
18+
await this.props.sessionStore.getCurrentLoginInformations();
1319

14-
if (!!this.props.SessionStore.currentLogin.user && this.props.SessionStore.currentLogin.application.features['SignalR']) {
15-
if (this.props.SessionStore.currentLogin.application.features['SignalR.AspNetCore']) {
20+
if (!!this.props.sessionStore.currentLogin.user && this.props.sessionStore.currentLogin.application.features['SignalR']) {
21+
if (this.props.sessionStore.currentLogin.application.features['SignalR.AspNetCore']) {
1622
SignalRAspNetCoreHelper.initSignalR();
1723
}
1824
}

reactjs/src/components/Router/privateRouter.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
import * as React from "react";
2-
import { Route } from "react-router-dom";
3-
import { observer, inject } from "mobx-react";
4-
import Login from "../../scenes/Login";
1+
import * as React from 'react';
2+
import { Route } from 'react-router-dom';
3+
import { observer, inject } from 'mobx-react';
4+
import Login from '../../scenes/Login';
5+
import Stores from './../../stores/storeIdentifier';
6+
import AuthenticationStore from './../../stores/authenticationStore';
57

6-
export interface IPrivateRouter {
8+
export interface IPrivateRouterProps {
79
component: any;
810
path: string;
911
permission: string;
12+
authenticationStore: AuthenticationStore;
1013
}
1114

12-
@inject("AuthenticationStores")
15+
@inject(Stores.AuthenticationStore)
1316
@observer
14-
class PrivateRouter extends React.Component<any> {
17+
class PrivateRouter extends React.Component<IPrivateRouterProps> {
1518
public render() {
1619
const { component, path } = this.props;
1720

18-
return this.props.AuthenticationStores.isAuthenticated ? (
19-
<Route path={path} component={component} />
20-
) : (
21-
<Route path={path} component={Login} />
22-
);
21+
return this.props.authenticationStore.isAuthenticated ? <Route path={path} component={component} /> : <Route path={path} component={Login} />;
2322
}
2423
}
2524

reactjs/src/components/Router/publicRouter.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import * as React from "react";
2-
import { Route } from "react-router-dom";
3-
import { observer, inject } from "mobx-react";
1+
import * as React from 'react';
2+
import { Route } from 'react-router-dom';
3+
import { observer, inject } from 'mobx-react';
4+
import AuthenticationStore from 'src/stores/authenticationStore';
5+
import Stores from './../../stores/storeIdentifier';
46

5-
export interface IPublicRouter {
7+
export interface IPublicRouterProps {
68
component: any;
79
path: string;
810
permission: string;
11+
authenticationStore: AuthenticationStore;
912
}
1013

11-
@inject("AuthenticationStores")
14+
@inject(Stores.AuthenticationStore)
1215
@observer
13-
class PublicRouter extends React.Component<any> {
16+
class PublicRouter extends React.Component<IPublicRouterProps> {
1417
public render() {
1518
const { component, path } = this.props;
1619

17-
return this.props.AuthenticationStores.isAuthenticated ? (
18-
<Route path={path} component={component} />
19-
) : (
20-
<Route path={path} component={component} />
21-
);
20+
return this.props.authenticationStore.isAuthenticated ? <Route path={path} component={component} /> : <Route path={path} component={component} />;
2221
}
2322
}
2423

reactjs/src/index.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,13 @@ import './index.css';
44
import appInitializer from './appInitializer';
55
import registerServiceWorker from './registerServiceWorker';
66
import App from './App';
7-
import AuthenticationStores from './stores/authenticationStore';
87
import { Provider } from 'mobx-react';
98
import { HashRouter } from 'react-router-dom';
10-
import RoleStores from './stores/roleStore';
11-
import TenantStores from './stores/tenantStore';
12-
import UserStores from './stores/userStore';
13-
import SessionStore from './stores/sessionStore';
9+
import initializeStores from './stores/storeInitializer';
1410

1511
appInitializer();
1612

17-
const stores = {
18-
AuthenticationStores,
19-
RoleStores,
20-
TenantStores,
21-
UserStores,
22-
SessionStore,
23-
};
13+
const stores = initializeStores();
2414

2515
ReactDOM.render(
2616
<Provider {...stores}>

reactjs/src/scenes/Login/index.tsx

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
import { Form, Col, Input, Icon, Row, Checkbox, Button, Card } from "antd";
2-
import * as React from "react";
3-
import { inject, observer } from "mobx-react";
4-
import { withRouter } from "react-router";
1+
import { Form, Col, Input, Icon, Row, Checkbox, Button, Card } from 'antd';
2+
import * as React from 'react';
3+
import { inject, observer } from 'mobx-react';
4+
import { withRouter } from 'react-router';
55
// import { withRouter } from "react-router-dom";
6+
import AuthenticationStore from 'src/stores/authenticationStore';
7+
import Stores from './../../stores/storeIdentifier';
8+
import { FormComponentProps } from 'antd/lib/form';
69

710
const FormItem = Form.Item;
811
const group = {
912
height: 19,
10-
fontFamily: "Nunito",
13+
fontFamily: 'Nunito',
1114
fontSize: 14,
1215
fontWeight: 500,
13-
fontStyle: "normal",
14-
fontStretch: "normal",
15-
lineHeight: "normal",
16-
letterSpacing: "normal",
17-
color: "#818181",
16+
fontStyle: 'normal',
17+
fontStretch: 'normal',
18+
lineHeight: 'normal',
19+
letterSpacing: 'normal',
20+
color: '#818181',
1821
marginLeft: 0,
19-
marginTop: 20
22+
marginTop: 20,
2023
}; // TODO: CSS dosyasına taşınması gerekiyor.
2124

22-
@inject("AuthenticationStores")
25+
export interface ILoginProps extends FormComponentProps {
26+
authenticationStore: AuthenticationStore;
27+
item: any;
28+
}
29+
30+
@inject(Stores.AuthenticationStore)
2331
@observer
24-
class Login extends React.Component<any, any> {
25-
constructor(props: any) {
32+
class Login extends React.Component<ILoginProps, any> {
33+
constructor(props: ILoginProps) {
2634
super(props);
2735
}
2836
state = { rememberMe: true };
@@ -38,8 +46,7 @@ class Login extends React.Component<any, any> {
3846
e.preventDefault();
3947
this.props.form.validateFields((err: any, values: any) => {
4048
if (!err) {
41-
42-
this.props.AuthenticationStores.Login(values).then(console.log("TRUE"));
49+
this.props.authenticationStore.login(values);
4350
}
4451
});
4552
};
@@ -57,66 +64,49 @@ class Login extends React.Component<any, any> {
5764
xl={{ span: 4, offset: 10 }}
5865
xxl={{ span: 4, offset: 10 }}
5966
>
60-
<div style={group}>{"Tenant Name"}</div>
67+
<div style={group}>{'Tenant Name'}</div>
6168

6269
<Form className="login-form" onSubmit={this.handleSubmit}>
6370
{!this.props.item ? (
6471
<FormItem>
65-
{getFieldDecorator("TENANT NAME", {
72+
{getFieldDecorator('TENANT NAME', {
6673
rules: [
6774
{
6875
required: true,
69-
message: "Tenant name is required."
70-
}
71-
]
72-
})(
73-
<Input
74-
prefix={
75-
<Icon
76-
type="user"
77-
style={{ color: "rgba(0,0,0,.25)" }}
78-
/>
79-
}
80-
placeholder=""
81-
size="large"
82-
/>
83-
)}
76+
message: 'Tenant name is required.',
77+
},
78+
],
79+
})(<Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="" size="large" />)}
8480
</FormItem>
8581
) : (
86-
""
82+
''
8783
)}
8884

89-
<div style={group}>{"Mail"}</div>
85+
<div style={group}>{'Mail'}</div>
9086
<FormItem>
91-
{getFieldDecorator("mail", {
87+
{getFieldDecorator('mail', {
9288
rules: [
9389
{
9490
required: true,
95-
message: "User Name is required."
96-
}
97-
]
91+
message: 'User Name is required.',
92+
},
93+
],
9894
})(
9995
<Input
100-
prefix={
101-
<Icon type="user" style={{ color: "rgba(0,0,0,.25)" }} />
102-
}
96+
prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
10397
placeholder=""
10498
size="large"
10599
// onChange={}
106100
/>
107101
)}
108102
</FormItem>
109-
<div style={group}>{"Password"}</div>
103+
<div style={group}>{'Password'}</div>
110104
<FormItem>
111-
{getFieldDecorator("password", {
112-
rules: [
113-
{ required: true, message: "Password is is required." }
114-
]
105+
{getFieldDecorator('password', {
106+
rules: [{ required: true, message: 'Password is is required.' }],
115107
})(
116108
<Input
117-
prefix={
118-
<Icon type="lock" style={{ color: "rgba(0,0,0,.25)" }} />
119-
}
109+
prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
120110
type="password"
121111
placeholder=""
122112
size="large"
@@ -125,17 +115,14 @@ class Login extends React.Component<any, any> {
125115
)}
126116
</FormItem>
127117
<Row>
128-
<div style={{ margin: "0px 0px 10px 15px " }}>
129-
<Checkbox
130-
checked={this.state.rememberMe}
131-
onChange={this.rememberMeCheck}
132-
/>
133-
{"RememberMe"}
118+
<div style={{ margin: '0px 0px 10px 15px ' }}>
119+
<Checkbox checked={this.state.rememberMe} onChange={this.rememberMeCheck} />
120+
{'RememberMe'}
134121
</div>
135122
</Row>
136123
<Row>
137124
<Col span={14} push={4}>
138-
<Button htmlType={"submit"}>Login</Button>
125+
<Button htmlType={'submit'}>Login</Button>
139126
</Col>
140127
</Row>
141128
<Row>

0 commit comments

Comments
 (0)