Skip to content

Commit 5f7b0c9

Browse files
committed
Code refactoring.
1 parent e916ca5 commit 5f7b0c9

25 files changed

+254
-197
lines changed

reactjs/src/App.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ import * as React from 'react';
22
import './App.css';
33
import { withRouter, Switch, Route } from 'react-router-dom';
44
import Layout from './scenes/Layout';
5-
65
import Login from './scenes/Login';
7-
class App extends React.Component {
8-
componentDidMount() {}
6+
import { inject } from 'mobx-react';
7+
import SignalRAspNetCoreHelper from 'src/lib/signalRAspNetCoreHelper';
8+
9+
@inject('SessionStore')
10+
class App extends React.Component<any> {
11+
async componentDidMount() {
12+
await this.props.SessionStore.getCurrentLoginInformations();
13+
14+
if (!!this.props.SessionStore.currentLogin.user && this.props.SessionStore.currentLogin.application.features['SignalR']) {
15+
if (this.props.SessionStore.currentLogin.application.features['SignalR.AspNetCore']) {
16+
SignalRAspNetCoreHelper.initSignalR();
17+
}
18+
}
19+
}
20+
921
public render() {
1022
return (
1123
<Switch>

reactjs/src/appInitializer.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as moment from 'moment';
2-
import { initialize } from 'src/services/abpUserConfigurationService';
2+
import abpUserConfigurationService from 'src/services/abpUserConfigurationService';
33
import Utils from 'src/utils/utils';
44

55
export default function init() {
6-
initialize().then(data => {
6+
setLocalization();
7+
8+
abpUserConfigurationService.getAll().then(data => {
79
Utils.extend(true, abp, data.data.result);
810
abp.clock.provider = getCurrentClockProvider(data.data.result.clock.provider);
911

@@ -15,6 +17,13 @@ export default function init() {
1517
});
1618
}
1719

20+
function setLocalization() {
21+
if (!abp.utils.getCookieValue('Abp.Localization.CultureName')) {
22+
let language = navigator.language;
23+
abp.utils.setCookieValue('Abp.Localization.CultureName', language, new Date(new Date().getTime() + 5 * 365 * 86400000), abp.appPath);
24+
}
25+
}
26+
1827
function getCurrentClockProvider(currentProviderName: string): abp.timing.IClockProvider {
1928
if (currentProviderName === 'unspecifiedClockProvider') {
2029
return abp.timing.unspecifiedClockProvider;

reactjs/src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +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/tokenAuthStore';
7+
import AuthenticationStores from './stores/authenticationStore';
88
import { Provider } from 'mobx-react';
99
import { HashRouter } from 'react-router-dom';
1010
import RoleStores from './stores/roleStore';
1111
import TenantStores from './stores/tenantStore';
1212
import UserStores from './stores/userStore';
13+
import SessionStore from './stores/sessionStore';
1314

1415
appInitializer();
1516

@@ -18,6 +19,7 @@ const stores = {
1819
RoleStores,
1920
TenantStores,
2021
UserStores,
22+
SessionStore,
2123
};
2224

2325
ReactDOM.render(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class LoginModel {
2+
userNameOrEmailAddress: string;
3+
password: string;
4+
rememberMe: boolean;
5+
}
6+
7+
export default LoginModel;
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import http from './httpService';
22

3-
export async function initialize() {
4-
const result = await http.get('/AbpUserConfiguration/GetAll');
5-
return result;
3+
class AbpUserConfigurationService {
4+
public async getAll() {
5+
const result = await http.get('/AbpUserConfiguration/GetAll');
6+
return result;
7+
}
68
}
9+
10+
export default new AbpUserConfigurationService();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export interface IsTenantAvaibleInput {
2-
tenancyName: string;
3-
}
2+
tenancyName: string;
3+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export interface IsTenantAvaibleOutput {
2-
state: number;
3-
tenantId: number;
4-
}
2+
state: number;
3+
tenantId: number;
4+
}

reactjs/src/services/dto/entityDto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export interface EntityDto<T = number> {
1+
export class EntityDto<T = number> {
22
id: T;
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export interface PagedResultDto<T> {
22
totalCount: number;
3-
items:T[];
3+
items: T[];
44
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default class ApplicationInfoDto {
2+
version: string;
3+
releaseDate: Date;
4+
features: Feature[] = [];
5+
}
6+
7+
class Feature {
8+
name: string;
9+
included: boolean;
10+
}

0 commit comments

Comments
 (0)