@etsoo/appscript 1.1.44 → 1.1.45
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/cjs/app/CoreApp.d.ts +1 -0
- package/lib/cjs/app/CoreApp.js +31 -28
- package/lib/mjs/app/CoreApp.d.ts +1 -0
- package/lib/mjs/app/CoreApp.js +31 -28
- package/package.json +1 -1
- package/src/app/CoreApp.ts +20 -16
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -278,6 +278,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
278
278
|
* @param name Application name
|
|
279
279
|
*/
|
|
280
280
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
|
|
281
|
+
protected setApi(api: IApi): void;
|
|
281
282
|
/**
|
|
282
283
|
* Alert action result
|
|
283
284
|
* @param result Action result
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -32,38 +32,11 @@ class CoreApp {
|
|
|
32
32
|
* Token refresh count down seed
|
|
33
33
|
*/
|
|
34
34
|
this.refreshCountdownSeed = 0;
|
|
35
|
-
// onRequest, show loading or not, rewrite the property to override default action
|
|
36
|
-
api.onRequest = (data) => {
|
|
37
|
-
if (data.showLoading == null || data.showLoading) {
|
|
38
|
-
notifier.showLoading();
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
// onComplete, hide loading, rewrite the property to override default action
|
|
42
|
-
api.onComplete = (data) => {
|
|
43
|
-
if (data.showLoading == null || data.showLoading) {
|
|
44
|
-
notifier.hideLoading();
|
|
45
|
-
}
|
|
46
|
-
this.lastCalled = true;
|
|
47
|
-
};
|
|
48
|
-
// Global API error handler
|
|
49
|
-
api.onError = (error) => {
|
|
50
|
-
// Error code
|
|
51
|
-
const status = error.response
|
|
52
|
-
? api.transformResponse(error.response).status
|
|
53
|
-
: undefined;
|
|
54
|
-
if (status === 401) {
|
|
55
|
-
// When status is equal to 401, unauthorized, try login
|
|
56
|
-
this.tryLogin();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// Report the error
|
|
60
|
-
notifier.alert(this.formatError(error));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
35
|
this.settings = settings;
|
|
64
36
|
this.api = api;
|
|
65
37
|
this.notifier = notifier;
|
|
66
38
|
this.name = name;
|
|
39
|
+
this.setApi(api);
|
|
67
40
|
const { currentCulture, currentRegion } = settings;
|
|
68
41
|
this.changeCulture(currentCulture);
|
|
69
42
|
this.changeRegion(currentRegion);
|
|
@@ -103,6 +76,36 @@ class CoreApp {
|
|
|
103
76
|
set authorized(value) {
|
|
104
77
|
this._authorized = value;
|
|
105
78
|
}
|
|
79
|
+
setApi(api) {
|
|
80
|
+
// onRequest, show loading or not, rewrite the property to override default action
|
|
81
|
+
api.onRequest = (data) => {
|
|
82
|
+
if (data.showLoading == null || data.showLoading) {
|
|
83
|
+
this.notifier.showLoading();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
// onComplete, hide loading, rewrite the property to override default action
|
|
87
|
+
api.onComplete = (data) => {
|
|
88
|
+
if (data.showLoading == null || data.showLoading) {
|
|
89
|
+
this.notifier.hideLoading();
|
|
90
|
+
}
|
|
91
|
+
this.lastCalled = true;
|
|
92
|
+
};
|
|
93
|
+
// Global API error handler
|
|
94
|
+
api.onError = (error) => {
|
|
95
|
+
// Error code
|
|
96
|
+
const status = error.response
|
|
97
|
+
? api.transformResponse(error.response).status
|
|
98
|
+
: undefined;
|
|
99
|
+
if (status === 401) {
|
|
100
|
+
// When status is equal to 401, unauthorized, try login
|
|
101
|
+
this.tryLogin();
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Report the error
|
|
105
|
+
this.notifier.alert(this.formatError(error));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
106
109
|
/**
|
|
107
110
|
* Alert action result
|
|
108
111
|
* @param result Action result
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -278,6 +278,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
278
278
|
* @param name Application name
|
|
279
279
|
*/
|
|
280
280
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
|
|
281
|
+
protected setApi(api: IApi): void;
|
|
281
282
|
/**
|
|
282
283
|
* Alert action result
|
|
283
284
|
* @param result Action result
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -29,38 +29,11 @@ export class CoreApp {
|
|
|
29
29
|
* Token refresh count down seed
|
|
30
30
|
*/
|
|
31
31
|
this.refreshCountdownSeed = 0;
|
|
32
|
-
// onRequest, show loading or not, rewrite the property to override default action
|
|
33
|
-
api.onRequest = (data) => {
|
|
34
|
-
if (data.showLoading == null || data.showLoading) {
|
|
35
|
-
notifier.showLoading();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
// onComplete, hide loading, rewrite the property to override default action
|
|
39
|
-
api.onComplete = (data) => {
|
|
40
|
-
if (data.showLoading == null || data.showLoading) {
|
|
41
|
-
notifier.hideLoading();
|
|
42
|
-
}
|
|
43
|
-
this.lastCalled = true;
|
|
44
|
-
};
|
|
45
|
-
// Global API error handler
|
|
46
|
-
api.onError = (error) => {
|
|
47
|
-
// Error code
|
|
48
|
-
const status = error.response
|
|
49
|
-
? api.transformResponse(error.response).status
|
|
50
|
-
: undefined;
|
|
51
|
-
if (status === 401) {
|
|
52
|
-
// When status is equal to 401, unauthorized, try login
|
|
53
|
-
this.tryLogin();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// Report the error
|
|
57
|
-
notifier.alert(this.formatError(error));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
32
|
this.settings = settings;
|
|
61
33
|
this.api = api;
|
|
62
34
|
this.notifier = notifier;
|
|
63
35
|
this.name = name;
|
|
36
|
+
this.setApi(api);
|
|
64
37
|
const { currentCulture, currentRegion } = settings;
|
|
65
38
|
this.changeCulture(currentCulture);
|
|
66
39
|
this.changeRegion(currentRegion);
|
|
@@ -100,6 +73,36 @@ export class CoreApp {
|
|
|
100
73
|
set authorized(value) {
|
|
101
74
|
this._authorized = value;
|
|
102
75
|
}
|
|
76
|
+
setApi(api) {
|
|
77
|
+
// onRequest, show loading or not, rewrite the property to override default action
|
|
78
|
+
api.onRequest = (data) => {
|
|
79
|
+
if (data.showLoading == null || data.showLoading) {
|
|
80
|
+
this.notifier.showLoading();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
// onComplete, hide loading, rewrite the property to override default action
|
|
84
|
+
api.onComplete = (data) => {
|
|
85
|
+
if (data.showLoading == null || data.showLoading) {
|
|
86
|
+
this.notifier.hideLoading();
|
|
87
|
+
}
|
|
88
|
+
this.lastCalled = true;
|
|
89
|
+
};
|
|
90
|
+
// Global API error handler
|
|
91
|
+
api.onError = (error) => {
|
|
92
|
+
// Error code
|
|
93
|
+
const status = error.response
|
|
94
|
+
? api.transformResponse(error.response).status
|
|
95
|
+
: undefined;
|
|
96
|
+
if (status === 401) {
|
|
97
|
+
// When status is equal to 401, unauthorized, try login
|
|
98
|
+
this.tryLogin();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Report the error
|
|
102
|
+
this.notifier.alert(this.formatError(error));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
103
106
|
/**
|
|
104
107
|
* Alert action result
|
|
105
108
|
* @param result Action result
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -385,17 +385,34 @@ export abstract class CoreApp<
|
|
|
385
385
|
notifier: INotifier<N, C>,
|
|
386
386
|
name: string
|
|
387
387
|
) {
|
|
388
|
+
this.settings = settings;
|
|
389
|
+
this.api = api;
|
|
390
|
+
this.notifier = notifier;
|
|
391
|
+
this.name = name;
|
|
392
|
+
|
|
393
|
+
this.setApi(api);
|
|
394
|
+
|
|
395
|
+
const { currentCulture, currentRegion } = settings;
|
|
396
|
+
this.changeCulture(currentCulture);
|
|
397
|
+
|
|
398
|
+
this.changeRegion(currentRegion);
|
|
399
|
+
|
|
400
|
+
// Setup callback
|
|
401
|
+
this.setup();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
protected setApi(api: IApi) {
|
|
388
405
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
389
406
|
api.onRequest = (data) => {
|
|
390
407
|
if (data.showLoading == null || data.showLoading) {
|
|
391
|
-
notifier.showLoading();
|
|
408
|
+
this.notifier.showLoading();
|
|
392
409
|
}
|
|
393
410
|
};
|
|
394
411
|
|
|
395
412
|
// onComplete, hide loading, rewrite the property to override default action
|
|
396
413
|
api.onComplete = (data) => {
|
|
397
414
|
if (data.showLoading == null || data.showLoading) {
|
|
398
|
-
notifier.hideLoading();
|
|
415
|
+
this.notifier.hideLoading();
|
|
399
416
|
}
|
|
400
417
|
this.lastCalled = true;
|
|
401
418
|
};
|
|
@@ -412,22 +429,9 @@ export abstract class CoreApp<
|
|
|
412
429
|
this.tryLogin();
|
|
413
430
|
} else {
|
|
414
431
|
// Report the error
|
|
415
|
-
notifier.alert(this.formatError(error));
|
|
432
|
+
this.notifier.alert(this.formatError(error));
|
|
416
433
|
}
|
|
417
434
|
};
|
|
418
|
-
|
|
419
|
-
this.settings = settings;
|
|
420
|
-
this.api = api;
|
|
421
|
-
this.notifier = notifier;
|
|
422
|
-
this.name = name;
|
|
423
|
-
|
|
424
|
-
const { currentCulture, currentRegion } = settings;
|
|
425
|
-
this.changeCulture(currentCulture);
|
|
426
|
-
|
|
427
|
-
this.changeRegion(currentRegion);
|
|
428
|
-
|
|
429
|
-
// Setup callback
|
|
430
|
-
this.setup();
|
|
431
435
|
}
|
|
432
436
|
|
|
433
437
|
/**
|