Skip to content

Commit e4f4d4b

Browse files
committed
Merge branch 'master' into pr/561
2 parents d0cee56 + 565f1cd commit e4f4d4b

File tree

41 files changed

+4711
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4711
-524
lines changed

angular/angular.json

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,21 @@
3333
],
3434
"styles": [
3535
"node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
36-
"node_modules/toastr/build/toastr.css",
36+
"node_modules/sweetalert2/dist/sweetalert2.css",
37+
"src/assets/freeze-ui/freeze-ui.css",
3738
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
3839
"node_modules/admin-lte-css-only/css/adminlte.min.css",
3940
"src/shared/core.less"
4041
],
4142
"scripts": [
42-
"node_modules/jquery/dist/jquery.min.js",
4343
"node_modules/moment/min/moment.min.js",
4444
"node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
45-
"node_modules/toastr/toastr.js",
46-
"node_modules/sweetalert/dist/sweetalert.min.js",
47-
"node_modules/block-ui/jquery.blockUI.js",
48-
"node_modules/spin.js/spin.min.js",
49-
"node_modules/spin.js/jquery.spin.js",
45+
"node_modules/sweetalert2/dist/sweetalert2.js",
46+
"src/assets/freeze-ui/freeze-ui.js",
5047
"node_modules/push.js/bin/push.min.js",
5148
"node_modules/abp-web-resources/Abp/Framework/scripts/abp.js",
52-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js",
53-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js",
54-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js",
55-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js",
56-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js",
49+
"src/assets/abp-web-resources/abp.sweet-alert.js",
50+
"src/assets/abp-web-resources/abp.freeze-ui.js",
5751
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js"
5852
]
5953
},
@@ -139,27 +133,21 @@
139133
],
140134
"styles": [
141135
"node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
142-
"node_modules/toastr/build/toastr.css",
136+
"node_modules/sweetalert2/dist/sweetalert2.css",
137+
"src/assets/freeze-ui/freeze-ui.css",
143138
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
144139
"node_modules/admin-lte-css-only/css/adminlte.min.css",
145140
"src/shared/core.less"
146141
],
147142
"scripts": [
148-
"node_modules/jquery/dist/jquery.min.js",
149143
"node_modules/moment/min/moment.min.js",
150144
"node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
151-
"node_modules/toastr/toastr.js",
152-
"node_modules/sweetalert/dist/sweetalert.min.js",
153-
"node_modules/block-ui/jquery.blockUI.js",
154-
"node_modules/spin.js/spin.min.js",
155-
"node_modules/spin.js/jquery.spin.js",
145+
"node_modules/sweetalert2/dist/sweetalert2.js",
146+
"src/assets/freeze-ui/freeze-ui.js",
156147
"node_modules/push.js/bin/push.min.js",
157148
"node_modules/abp-web-resources/Abp/Framework/scripts/abp.js",
158-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.jquery.js",
159-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.toastr.js",
160-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.blockUI.js",
161-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.spin.js",
162-
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.sweet-alert.js",
149+
"src/assets/abp-web-resources/abp.sweet-alert.js",
150+
"src/assets/abp-web-resources/abp.freeze-ui.js",
163151
"node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js"
164152
]
165153
}

angular/package.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,19 @@
2323
"@angular/router": "^9.1.4",
2424
"@aspnet/signalr": "^1.1.4",
2525
"@fortawesome/fontawesome-free": "^5.13.0",
26-
"abp-ng2-module": "^6.0.0",
27-
"abp-web-resources": "^5.1.1",
26+
"abp-ng2-module": "^6.2.0",
27+
"abp-web-resources": "^5.3.0",
2828
"admin-lte-css-only": "^3.0.4",
29-
"block-ui": "^2.70.1",
3029
"core-js": "^3.2.1",
3130
"famfamfam-flags": "^1.0.0",
32-
"jquery": "^3.4.1",
33-
"lodash": "^4.17.4",
31+
"lodash-es": "^4.17.15",
3432
"moment": "2.24.0",
3533
"moment-timezone": "^0.5.28",
3634
"ngx-bootstrap": "^5.6.1",
3735
"ngx-pagination": "^5.0.0",
3836
"push.js": "1.0.12",
3937
"rxjs": "^6.4.0",
40-
"spin.js": "^2.3.2",
41-
"sweetalert": "^2.0.8",
42-
"toastr": "^2.1.2",
38+
"sweetalert2": "^9.10.12",
4339
"ts-helpers": "^1.1.2",
4440
"tslib": "^1.10.0",
4541
"web-animations-js": "^2.3.2",
@@ -51,9 +47,7 @@
5147
"@angular/compiler-cli": "^9.1.4",
5248
"@angularclass/hmr": "^2.1.3",
5349
"@types/jasmine": "^3.4.0",
54-
"@types/jquery": "^3.3.37",
55-
"@types/jquery.blockui": "0.0.28",
56-
"@types/lodash": "^4.14.150",
50+
"@types/lodash-es": "^4.17.3",
5751
"@types/moment-timezone": "^0.5.12",
5852
"@types/node": "^13.13.4",
5953
"codelyzer": "^5.1.2",
@@ -73,4 +67,4 @@
7367
"webpack-bundle-analyzer": "^3.7.0"
7468
},
7569
"angular-cli": {}
76-
}
70+
}

angular/src/AppPreBootstrap.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

angular/src/account/layout/account-languages.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ChangeDetectionStrategy
66
} from '@angular/core';
77
import { AppComponentBase } from '@shared/app-component-base';
8-
import * as _ from 'lodash';
8+
import { filter as _filter } from 'lodash-es';
99

1010
@Component({
1111
selector: 'account-languages',
@@ -22,7 +22,7 @@ export class AccountLanguagesComponent extends AppComponentBase
2222
}
2323

2424
ngOnInit() {
25-
this.languages = _.filter(
25+
this.languages = _filter(
2626
this.localization.languages,
2727
(l) => !l.isDisabled
2828
);

angular/src/app-initializer.ts

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
import { Injectable, Injector } from '@angular/core';
2+
import { PlatformLocation, registerLocaleData } from '@angular/common';
3+
import { HttpClient } from '@angular/common/http';
4+
import * as moment from 'moment';
5+
import { filter as _filter, merge as _merge } from 'lodash-es';
6+
import { AppConsts } from '@shared/AppConsts';
7+
import { AppSessionService } from '@shared/session/app-session.service';
8+
import { environment } from './environments/environment';
9+
10+
@Injectable({
11+
providedIn: 'root',
12+
})
13+
export class AppInitializer {
14+
constructor(
15+
private _injector: Injector,
16+
private _platformLocation: PlatformLocation,
17+
private _httpClient: HttpClient
18+
) { }
19+
20+
init(): () => Promise<boolean> {
21+
return () => {
22+
abp.ui.setBusy();
23+
return new Promise<boolean>((resolve, reject) => {
24+
AppConsts.appBaseHref = this.getBaseHref();
25+
const appBaseUrl = this.getDocumentOrigin() + AppConsts.appBaseHref;
26+
this.getApplicationConfig(appBaseUrl, () => {
27+
this.getUserConfiguration(() => {
28+
abp.event.trigger('abp.dynamicScriptsInitialized');
29+
// do not use constructor injection for AppSessionService
30+
const appSessionService = this._injector.get(AppSessionService);
31+
appSessionService.init().then(
32+
(result) => {
33+
abp.ui.clearBusy();
34+
if (this.shouldLoadLocale()) {
35+
const angularLocale = this.convertAbpLocaleToAngularLocale(
36+
abp.localization.currentLanguage.name
37+
);
38+
import(`@angular/common/locales/${angularLocale}.js`).then(
39+
(module) => {
40+
registerLocaleData(module.default);
41+
resolve(result);
42+
},
43+
reject
44+
);
45+
} else {
46+
resolve(result);
47+
}
48+
},
49+
(err) => {
50+
abp.ui.clearBusy();
51+
reject(err);
52+
}
53+
);
54+
});
55+
});
56+
});
57+
};
58+
}
59+
60+
private getBaseHref(): string {
61+
const baseUrl = this._platformLocation.getBaseHrefFromDOM();
62+
if (baseUrl) {
63+
return baseUrl;
64+
}
65+
66+
return '/';
67+
}
68+
69+
private getDocumentOrigin(): string {
70+
if (!document.location.origin) {
71+
const port = document.location.port ? ':' + document.location.port : '';
72+
return (
73+
document.location.protocol + '//' + document.location.hostname + port
74+
);
75+
}
76+
77+
return document.location.origin;
78+
}
79+
80+
private shouldLoadLocale(): boolean {
81+
return (
82+
abp.localization.currentLanguage.name &&
83+
abp.localization.currentLanguage.name !== 'en-US'
84+
);
85+
}
86+
87+
private convertAbpLocaleToAngularLocale(locale: string): string {
88+
if (!AppConsts.localeMappings) {
89+
return locale;
90+
}
91+
92+
const localeMapings = _filter(AppConsts.localeMappings, { from: locale });
93+
if (localeMapings && localeMapings.length) {
94+
return localeMapings[0]['to'];
95+
}
96+
97+
return locale;
98+
}
99+
100+
private getCurrentClockProvider(
101+
currentProviderName: string
102+
): abp.timing.IClockProvider {
103+
if (currentProviderName === 'unspecifiedClockProvider') {
104+
return abp.timing.unspecifiedClockProvider;
105+
}
106+
107+
if (currentProviderName === 'utcClockProvider') {
108+
return abp.timing.utcClockProvider;
109+
}
110+
111+
return abp.timing.localClockProvider;
112+
}
113+
114+
private getUserConfiguration(callback: () => void): void {
115+
const cookieLangValue = abp.utils.getCookieValue(
116+
'Abp.Localization.CultureName'
117+
);
118+
const token = abp.auth.getToken();
119+
120+
const requestHeaders = {
121+
'Abp.TenantId': `${abp.multiTenancy.getTenantIdCookie()}`,
122+
'.AspNetCore.Culture': `c=${cookieLangValue}|uic=${cookieLangValue}`,
123+
};
124+
125+
if (token) {
126+
requestHeaders['Authorization'] = `Bearer ${token}`;
127+
}
128+
129+
this._httpClient
130+
.get<any>(
131+
`${AppConsts.remoteServiceBaseUrl}/AbpUserConfiguration/GetAll`,
132+
{
133+
headers: requestHeaders,
134+
}
135+
)
136+
.subscribe((response) => {
137+
const result = response.result;
138+
139+
_merge(abp, result);
140+
141+
abp.clock.provider = this.getCurrentClockProvider(
142+
result.clock.provider
143+
);
144+
145+
moment.locale(abp.localization.currentLanguage.name);
146+
147+
if (abp.clock.provider.supportsMultipleTimezone) {
148+
moment.tz.setDefault(abp.timing.timeZoneInfo.iana.timeZoneId);
149+
}
150+
151+
callback();
152+
});
153+
}
154+
155+
private getApplicationConfig(appRootUrl: string, callback: () => void) {
156+
this._httpClient
157+
.get<any>(`${appRootUrl}assets/${environment.appConfig}`, {
158+
headers: {
159+
'Abp.TenantId': `${abp.multiTenancy.getTenantIdCookie()}`,
160+
},
161+
})
162+
.subscribe((response) => {
163+
AppConsts.appBaseUrl = response.appBaseUrl;
164+
AppConsts.remoteServiceBaseUrl = response.remoteServiceBaseUrl;
165+
AppConsts.localeMappings = response.localeMappings;
166+
167+
callback();
168+
});
169+
}
170+
}

angular/src/app/layout/header-language-menu.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
UserServiceProxy,
1010
ChangeUserLanguageDto
1111
} from '@shared/service-proxies/service-proxies';
12-
import * as _ from 'lodash';
12+
import { filter as _filter } from 'lodash-es';
1313

1414
@Component({
1515
selector: 'header-language-menu',
@@ -26,7 +26,7 @@ export class HeaderLanguageMenuComponent extends AppComponentBase
2626
}
2727

2828
ngOnInit() {
29-
this.languages = _.filter(
29+
this.languages = _filter(
3030
this.localization.languages,
3131
(l) => !l.isDisabled
3232
);

0 commit comments

Comments
 (0)