@etsoo/materialui 1.4.58 → 1.4.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/CommonApp.d.ts +5 -2
- package/lib/app/CommonApp.js +8 -3
- package/lib/app/ReactApp.js +8 -4
- package/lib/app/ServiceApp.js +5 -3
- package/package.json +3 -3
- package/src/app/CommonApp.ts +9 -3
- package/src/app/ReactApp.ts +9 -4
- package/src/app/ServiceApp.ts +6 -3
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ import { ReactApp } from "./ReactApp";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class CommonApp<U extends IUser = IUser, P extends IPageData = IPageData, S extends IAppSettings = IAppSettings> extends ReactApp<S, U, P> {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param settings Settings
|
|
12
|
+
* @param name Application name
|
|
13
|
+
* @param debug Debug mode
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
constructor(settings: S, name: string, debug?: boolean);
|
|
13
16
|
/**
|
|
14
17
|
* Init call update fields in local storage
|
|
15
18
|
* @returns Fields
|
package/lib/app/CommonApp.js
CHANGED
|
@@ -6,10 +6,15 @@ import { ReactApp } from "./ReactApp";
|
|
|
6
6
|
*/
|
|
7
7
|
export class CommonApp extends ReactApp {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Constructor
|
|
10
|
+
* @param settings Settings
|
|
11
|
+
* @param name Application name
|
|
12
|
+
* @param debug Debug mode
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
constructor(settings, name, debug = false) {
|
|
15
|
+
super(settings, name, debug);
|
|
16
|
+
// Add persisted fields
|
|
17
|
+
this.persistedFields.push(CoreConstants.FieldUserIdSaved);
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Init call update fields in local storage
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -239,7 +239,7 @@ export class ReactApp extends CoreApp {
|
|
|
239
239
|
// Check status
|
|
240
240
|
const result = await super.tryLogin(data);
|
|
241
241
|
if (!result) {
|
|
242
|
-
onFailure();
|
|
242
|
+
onFailure("ReactAppSuperTryLoginFailed");
|
|
243
243
|
return false;
|
|
244
244
|
}
|
|
245
245
|
// Refresh token
|
|
@@ -250,10 +250,14 @@ export class ReactApp extends CoreApp {
|
|
|
250
250
|
onSuccess?.();
|
|
251
251
|
}
|
|
252
252
|
else if (result === false) {
|
|
253
|
-
onFailure();
|
|
253
|
+
onFailure("ReactAppRefreshTokenFailed");
|
|
254
254
|
}
|
|
255
|
-
else if (result != null && this.tryLoginIgnoreResult(result)) {
|
|
256
|
-
|
|
255
|
+
else if (result != null && !this.tryLoginIgnoreResult(result)) {
|
|
256
|
+
onFailure("ReactAppRefreshTokenFailed: " + JSON.stringify(result));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// Ignore other results
|
|
260
|
+
onFailure("ReactAppRefreshTokenIgnoredFailure: " + JSON.stringify(result));
|
|
257
261
|
return true;
|
|
258
262
|
}
|
|
259
263
|
});
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -38,6 +38,7 @@ export class ServiceApp extends ReactApp {
|
|
|
38
38
|
this.coreEndpoint = coreEndpoint;
|
|
39
39
|
this.coreOrigin = new URL(coreEndpoint.webUrl).origin;
|
|
40
40
|
this.coreApi = this.createApi(coreName, coreEndpoint);
|
|
41
|
+
this.keepLogin = true;
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Load core system UI
|
|
@@ -188,19 +189,20 @@ export class ServiceApp extends ReactApp {
|
|
|
188
189
|
params ??= {};
|
|
189
190
|
let { onFailure, onSuccess, ...rest } = params;
|
|
190
191
|
if (onFailure == null) {
|
|
191
|
-
onFailure = params.onFailure = () => {
|
|
192
|
+
onFailure = params.onFailure = (type) => {
|
|
193
|
+
console.log(`Try login failed: ${type}.`);
|
|
192
194
|
this.toLoginPage(rest);
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
// Check core system token
|
|
196
198
|
const coreToken = this.storage.getData(coreTokenKey);
|
|
197
199
|
if (!coreToken) {
|
|
198
|
-
onFailure();
|
|
200
|
+
onFailure("ServiceAppCoreTokenNoData");
|
|
199
201
|
return false;
|
|
200
202
|
}
|
|
201
203
|
const coreTokenDecrypted = this.decrypt(coreToken);
|
|
202
204
|
if (!coreTokenDecrypted) {
|
|
203
|
-
onFailure();
|
|
205
|
+
onFailure("ServiceAppCoreTokenNoDecryptedData");
|
|
204
206
|
return false;
|
|
205
207
|
}
|
|
206
208
|
params.onSuccess = () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.60",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"@emotion/css": "^11.13.5",
|
|
36
36
|
"@emotion/react": "^11.14.0",
|
|
37
37
|
"@emotion/styled": "^11.14.0",
|
|
38
|
-
"@etsoo/appscript": "^1.5.
|
|
38
|
+
"@etsoo/appscript": "^1.5.84",
|
|
39
39
|
"@etsoo/notificationbase": "^1.1.54",
|
|
40
|
-
"@etsoo/react": "^1.8.
|
|
40
|
+
"@etsoo/react": "^1.8.17",
|
|
41
41
|
"@etsoo/shared": "^1.2.55",
|
|
42
42
|
"@mui/icons-material": "^6.3.1",
|
|
43
43
|
"@mui/material": "^6.3.1",
|
package/src/app/CommonApp.ts
CHANGED
|
@@ -12,10 +12,16 @@ export abstract class CommonApp<
|
|
|
12
12
|
S extends IAppSettings = IAppSettings
|
|
13
13
|
> extends ReactApp<S, U, P> {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Constructor
|
|
16
|
+
* @param settings Settings
|
|
17
|
+
* @param name Application name
|
|
18
|
+
* @param debug Debug mode
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
constructor(settings: S, name: string, debug: boolean = false) {
|
|
21
|
+
super(settings, name, debug);
|
|
22
|
+
|
|
23
|
+
// Add persisted fields
|
|
24
|
+
this.persistedFields.push(CoreConstants.FieldUserIdSaved);
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
/**
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -437,7 +437,7 @@ export class ReactApp<
|
|
|
437
437
|
// Check status
|
|
438
438
|
const result = await super.tryLogin(data);
|
|
439
439
|
if (!result) {
|
|
440
|
-
onFailure();
|
|
440
|
+
onFailure("ReactAppSuperTryLoginFailed");
|
|
441
441
|
return false;
|
|
442
442
|
}
|
|
443
443
|
|
|
@@ -450,9 +450,14 @@ export class ReactApp<
|
|
|
450
450
|
if (result === true) {
|
|
451
451
|
onSuccess?.();
|
|
452
452
|
} else if (result === false) {
|
|
453
|
-
onFailure();
|
|
454
|
-
} else if (result != null && this.tryLoginIgnoreResult(result)) {
|
|
455
|
-
|
|
453
|
+
onFailure("ReactAppRefreshTokenFailed");
|
|
454
|
+
} else if (result != null && !this.tryLoginIgnoreResult(result)) {
|
|
455
|
+
onFailure("ReactAppRefreshTokenFailed: " + JSON.stringify(result));
|
|
456
|
+
} else {
|
|
457
|
+
// Ignore other results
|
|
458
|
+
onFailure(
|
|
459
|
+
"ReactAppRefreshTokenIgnoredFailure: " + JSON.stringify(result)
|
|
460
|
+
);
|
|
456
461
|
return true;
|
|
457
462
|
}
|
|
458
463
|
}
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -66,6 +66,8 @@ export class ServiceApp<
|
|
|
66
66
|
this.coreEndpoint = coreEndpoint;
|
|
67
67
|
this.coreOrigin = new URL(coreEndpoint.webUrl).origin;
|
|
68
68
|
this.coreApi = this.createApi(coreName, coreEndpoint);
|
|
69
|
+
|
|
70
|
+
this.keepLogin = true;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -252,7 +254,8 @@ export class ServiceApp<
|
|
|
252
254
|
let { onFailure, onSuccess, ...rest } = params;
|
|
253
255
|
|
|
254
256
|
if (onFailure == null) {
|
|
255
|
-
onFailure = params.onFailure = () => {
|
|
257
|
+
onFailure = params.onFailure = (type) => {
|
|
258
|
+
console.log(`Try login failed: ${type}.`);
|
|
256
259
|
this.toLoginPage(rest);
|
|
257
260
|
};
|
|
258
261
|
}
|
|
@@ -260,13 +263,13 @@ export class ServiceApp<
|
|
|
260
263
|
// Check core system token
|
|
261
264
|
const coreToken = this.storage.getData<string>(coreTokenKey);
|
|
262
265
|
if (!coreToken) {
|
|
263
|
-
onFailure();
|
|
266
|
+
onFailure("ServiceAppCoreTokenNoData");
|
|
264
267
|
return false;
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
const coreTokenDecrypted = this.decrypt(coreToken);
|
|
268
271
|
if (!coreTokenDecrypted) {
|
|
269
|
-
onFailure();
|
|
272
|
+
onFailure("ServiceAppCoreTokenNoDecryptedData");
|
|
270
273
|
return false;
|
|
271
274
|
}
|
|
272
275
|
|