Skip to content

Commit a6b0928

Browse files
committed
Added inversifyJS and Services are modified accordingly
1 parent 02bd202 commit a6b0928

35 files changed

+5092
-172
lines changed

reactjs/.env

Whitespace-only changes.

reactjs/.env.development

Whitespace-only changes.

reactjs/.env.production

Whitespace-only changes.

reactjs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ This framework is designed by utilizing MVC design pattern and layered architect
1414

1515
InversifyJS IoC container is used to ensure dependency inversion. All of services has one interface and one implementation, so mocks can be used easily when writing tests.
1616

17-
![](images/architecture.jpg)
17+
![](_screenshots/architecture.jpg)

reactjs/package-lock.json

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

reactjs/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"abp-web-resources": "^3.8.2",
88
"axios": "^0.18.0",
99
"famfamfam-flags": "^1.0.0",
10+
"inversify": "^5.0.1",
11+
"moment": "^2.22.2",
1012
"react": "^16.5.2",
1113
"react-dom": "^16.5.2",
12-
"react-scripts-ts": "3.1.0"
14+
"react-scripts-ts": "3.1.0",
15+
"reflect-metadata": "^0.1.12"
1316
},
1417
"scripts": {
1518
"start": "react-scripts-ts start",

reactjs/src/components/AbpComponentBase.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
import * as React from "react";
2-
import LocalizationService from "./../services/localization/localization.service";
3-
import PermissionCheckerService from "./../services/auth/permission-checker.service";
2+
import { ILocalizationService } from "src/services/localization/localizationService";
3+
import { IPermissionCheckerService } from "src/services/auth/permissionCheckerService";
44
import AppConsts from "src/lib/appconst";
5+
import { IFeatureCheckerService } from "src/services/features/featureCheckerService";
6+
import { INotifyService } from "src/services/notify/notifyService";
7+
import { ISettingService } from "src/services/settings/settingService";
8+
import { IMessageService } from "src/services/message/messageService";
9+
import { IAbpMultiTenancyService } from "src/services/multiTenancy/abpMultiTenancyService";
10+
import { inject } from "inversify";
11+
import { IAppSessionService } from "src/services/session/appSessionService";
512

613
export abstract class AbpComponentBase extends React.Component {
7-
localization = LocalizationService;
8-
permission = PermissionCheckerService;
914
localizationSourceName = AppConsts.localization.defaultLocalizationSourceName;
1015

16+
localization: ILocalizationService;
17+
permission: IPermissionCheckerService;
18+
feature: IFeatureCheckerService;
19+
notify: INotifyService;
20+
setting: ISettingService;
21+
message: IMessageService;
22+
multiTenancy: IAbpMultiTenancyService;
23+
appSession: IAppSessionService;
24+
// elementRef: ElementRef;
25+
26+
/**
27+
*
28+
*/
29+
constructor() {
30+
super();
31+
}
32+
1133
l(key: string, ...args: any[]): string {
1234
let localizedText = this.localization.localize(
1335
key,

reactjs/src/config/identifiers.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const SERVICE_IDENTIFIER = {
2+
IPermissionCheckerService: Symbol.for("IPermissionCheckerService"),
3+
ITokenService: Symbol.for("ITokenService"),
4+
IFeatureCheckerService: Symbol.for("IFeatureCheckerService"),
5+
ILocalizationService: Symbol.for("ILocalizationService"),
6+
ILogService: Symbol.for("ILogService"),
7+
IMessageService: Symbol.for("IMessageService"),
8+
IAbpMultiTenancyService: Symbol.for("IAbpMultiTenancyService"),
9+
INotifyService: Symbol.for("INotifyService"),
10+
IAbpSessionService: Symbol.for("IAbpSessionService"),
11+
IAppSessionService: Symbol.for("IAppSessionService"),
12+
ISettingService: Symbol.for("ISettingService"),
13+
IUtilsService: Symbol.for("IUtilsService"),
14+
IAbpUserConfigurationService: Symbol.for("IAbpUserConfigurationService")
15+
};
16+
17+
export default SERVICE_IDENTIFIER;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import "reflect-metadata";
2+
import { Container } from "inversify";
3+
import SERVICE_IDENTIFIER from "src/config/identifiers";
4+
import {
5+
IPermissionCheckerService,
6+
PermissionCheckerService
7+
} from "src/services/auth/permissionCheckerService";
8+
import { ITokenService, TokenService } from "./../services/auth/tokenService";
9+
import {
10+
IFeatureCheckerService,
11+
FeatureCheckerService
12+
} from "src/services/features/featureCheckerService";
13+
import {
14+
ILocalizationService,
15+
LocalizationService
16+
} from "./../services/localization/localizationService";
17+
import { ILogService, LogService } from "src/services/log/logService";
18+
import {
19+
IMessageService,
20+
MessageService
21+
} from "./../services/message/messageService";
22+
import {
23+
IAbpMultiTenancyService,
24+
AbpMultiTenancyService
25+
} from "src/services/multiTenancy/abpMultiTenancyService";
26+
import {
27+
INotifyService,
28+
NotifyService
29+
} from "src/services/notify/notifyService";
30+
import {
31+
IAbpSessionService,
32+
AbpSessionService
33+
} from "./../services/session/abpSessionService";
34+
import {
35+
AppSessionService,
36+
IAppSessionService
37+
} from "./../services/session/appSessionService";
38+
import {
39+
ISettingService,
40+
SettingService
41+
} from "src/services/settings/settingService";
42+
import { IUtilsService, UtilsService } from "./../services/utils/utilsService";
43+
import {
44+
IAbpUserConfigurationService,
45+
AbpUserConfigurationService
46+
} from "./../services/abpUserConfigurationService";
47+
48+
let container = new Container();
49+
50+
container
51+
.bind<IPermissionCheckerService>(SERVICE_IDENTIFIER.IPermissionCheckerService)
52+
.to(PermissionCheckerService);
53+
container
54+
.bind<ITokenService>(SERVICE_IDENTIFIER.ITokenService)
55+
.to(TokenService);
56+
container
57+
.bind<IFeatureCheckerService>(SERVICE_IDENTIFIER.IFeatureCheckerService)
58+
.to(FeatureCheckerService);
59+
container
60+
.bind<ILocalizationService>(SERVICE_IDENTIFIER.ILocalizationService)
61+
.to(LocalizationService);
62+
container.bind<ILogService>(SERVICE_IDENTIFIER.ILogService).to(LogService);
63+
container
64+
.bind<IMessageService>(SERVICE_IDENTIFIER.IMessageService)
65+
.to(MessageService);
66+
container
67+
.bind<IAbpMultiTenancyService>(SERVICE_IDENTIFIER.IAbpMultiTenancyService)
68+
.to(AbpMultiTenancyService);
69+
container
70+
.bind<INotifyService>(SERVICE_IDENTIFIER.INotifyService)
71+
.to(NotifyService);
72+
container
73+
.bind<IAbpSessionService>(SERVICE_IDENTIFIER.IAbpSessionService)
74+
.to(AbpSessionService);
75+
container
76+
.bind<IAppSessionService>(SERVICE_IDENTIFIER.IAppSessionService)
77+
.to(AppSessionService);
78+
container
79+
.bind<ISettingService>(SERVICE_IDENTIFIER.ISettingService)
80+
.to(SettingService);
81+
container
82+
.bind<IUtilsService>(SERVICE_IDENTIFIER.IUtilsService)
83+
.to(UtilsService);
84+
container
85+
.bind<IAbpUserConfigurationService>(
86+
SERVICE_IDENTIFIER.IAbpUserConfigurationService
87+
)
88+
.to(AbpUserConfigurationService);
89+
90+
export default container;

0 commit comments

Comments
 (0)