@etsoo/appscript 1.2.67 → 1.2.70

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.
@@ -139,6 +139,12 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
139
139
  * @param culture New culture definition
140
140
  */
141
141
  changeCulture(culture: DataTypes.CultureDefinition): void;
142
+ /**
143
+ * Check the action result is about device invalid
144
+ * @param result Action result
145
+ * @returns true means device is invalid
146
+ */
147
+ checkDeviceResult(result: IActionResult): boolean;
142
148
  /**
143
149
  * Clear cache data
144
150
  */
@@ -533,7 +539,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
533
539
  * @param result Action result
534
540
  * @returns true means device is invalid
535
541
  */
536
- protected checkDeviceResult(result: IActionResult): boolean;
542
+ checkDeviceResult(result: IActionResult): boolean;
537
543
  /**
538
544
  * Init call
539
545
  * @param callback Callback
@@ -727,10 +727,18 @@ class CoreApp {
727
727
  doRefreshTokenResult(result, initCallCallback, silent = false) {
728
728
  if (result === true)
729
729
  return;
730
- if (initCallCallback &&
731
- typeof result === 'object' &&
730
+ if (typeof result === 'object' &&
732
731
  !(result instanceof restclient_1.ApiDataError) &&
733
732
  this.checkDeviceResult(result)) {
733
+ initCallCallback !== null && initCallCallback !== void 0 ? initCallCallback : (initCallCallback = (result) => {
734
+ var _a;
735
+ if (!result)
736
+ return;
737
+ this.notifier.alert((_a = this.get('environmentChanged')) !== null && _a !== void 0 ? _a : 'Environment changed', () => {
738
+ // Reload the page
739
+ history.go(0);
740
+ });
741
+ });
734
742
  this.initCall(initCallCallback, true);
735
743
  return;
736
744
  }
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "Email addresses",
42
42
  "enabled": "Enabled",
43
43
  "entityStatus": "Status",
44
+ "environmentChanged": "The operating environment has changed, please log in again",
44
45
  "etsoo": "ETSOO",
45
46
  "expiry": "Expiry",
46
47
  "failed": "Operation failed",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "电子邮箱",
42
42
  "enabled": "已启用",
43
43
  "entityStatus": "状态",
44
+ "environmentChanged": "运行环境已改变,请重新登录",
44
45
  "etsoo": "亿速思维",
45
46
  "expiry": "到期时间",
46
47
  "failed": "操作失败",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "電子郵箱",
42
42
  "enabled": "已啟用",
43
43
  "entityStatus": "狀態",
44
+ "environmentChanged": "運行環境已改變,請重新登錄",
44
45
  "etsoo": "億速思維",
45
46
  "expiry": "到期時間",
46
47
  "failed": "操作失敗",
@@ -139,6 +139,12 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
139
139
  * @param culture New culture definition
140
140
  */
141
141
  changeCulture(culture: DataTypes.CultureDefinition): void;
142
+ /**
143
+ * Check the action result is about device invalid
144
+ * @param result Action result
145
+ * @returns true means device is invalid
146
+ */
147
+ checkDeviceResult(result: IActionResult): boolean;
142
148
  /**
143
149
  * Clear cache data
144
150
  */
@@ -533,7 +539,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
533
539
  * @param result Action result
534
540
  * @returns true means device is invalid
535
541
  */
536
- protected checkDeviceResult(result: IActionResult): boolean;
542
+ checkDeviceResult(result: IActionResult): boolean;
537
543
  /**
538
544
  * Init call
539
545
  * @param callback Callback
@@ -724,10 +724,18 @@ export class CoreApp {
724
724
  doRefreshTokenResult(result, initCallCallback, silent = false) {
725
725
  if (result === true)
726
726
  return;
727
- if (initCallCallback &&
728
- typeof result === 'object' &&
727
+ if (typeof result === 'object' &&
729
728
  !(result instanceof ApiDataError) &&
730
729
  this.checkDeviceResult(result)) {
730
+ initCallCallback !== null && initCallCallback !== void 0 ? initCallCallback : (initCallCallback = (result) => {
731
+ var _a;
732
+ if (!result)
733
+ return;
734
+ this.notifier.alert((_a = this.get('environmentChanged')) !== null && _a !== void 0 ? _a : 'Environment changed', () => {
735
+ // Reload the page
736
+ history.go(0);
737
+ });
738
+ });
731
739
  this.initCall(initCallCallback, true);
732
740
  return;
733
741
  }
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "Email addresses",
42
42
  "enabled": "Enabled",
43
43
  "entityStatus": "Status",
44
+ "environmentChanged": "The operating environment has changed, please log in again",
44
45
  "etsoo": "ETSOO",
45
46
  "expiry": "Expiry",
46
47
  "failed": "Operation failed",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "电子邮箱",
42
42
  "enabled": "已启用",
43
43
  "entityStatus": "状态",
44
+ "environmentChanged": "运行环境已改变,请重新登录",
44
45
  "etsoo": "亿速思维",
45
46
  "expiry": "到期时间",
46
47
  "failed": "操作失败",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "電子郵箱",
42
42
  "enabled": "已啟用",
43
43
  "entityStatus": "狀態",
44
+ "environmentChanged": "運行環境已改變,請重新登錄",
44
45
  "etsoo": "億速思維",
45
46
  "expiry": "到期時間",
46
47
  "failed": "操作失敗",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.67",
3
+ "version": "1.2.70",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -212,6 +212,13 @@ export interface ICoreApp<
212
212
  */
213
213
  changeCulture(culture: DataTypes.CultureDefinition): void;
214
214
 
215
+ /**
216
+ * Check the action result is about device invalid
217
+ * @param result Action result
218
+ * @returns true means device is invalid
219
+ */
220
+ checkDeviceResult(result: IActionResult): boolean;
221
+
215
222
  /**
216
223
  * Clear cache data
217
224
  */
@@ -901,7 +908,7 @@ export abstract class CoreApp<
901
908
  * @param result Action result
902
909
  * @returns true means device is invalid
903
910
  */
904
- protected checkDeviceResult(result: IActionResult): boolean {
911
+ checkDeviceResult(result: IActionResult): boolean {
905
912
  if (result.type === 'NoValidData' && result.field === 'Device')
906
913
  return true;
907
914
  return false;
@@ -1470,11 +1477,22 @@ export abstract class CoreApp<
1470
1477
  if (result === true) return;
1471
1478
 
1472
1479
  if (
1473
- initCallCallback &&
1474
1480
  typeof result === 'object' &&
1475
1481
  !(result instanceof ApiDataError) &&
1476
1482
  this.checkDeviceResult(result)
1477
1483
  ) {
1484
+ initCallCallback ??= (result) => {
1485
+ if (!result) return;
1486
+ this.notifier.alert(
1487
+ this.get<string>('environmentChanged') ??
1488
+ 'Environment changed',
1489
+ () => {
1490
+ // Reload the page
1491
+ history.go(0);
1492
+ }
1493
+ );
1494
+ };
1495
+
1478
1496
  this.initCall(initCallCallback, true);
1479
1497
  return;
1480
1498
  }
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "Email addresses",
42
42
  "enabled": "Enabled",
43
43
  "entityStatus": "Status",
44
+ "environmentChanged": "The operating environment has changed, please log in again",
44
45
  "etsoo": "ETSOO",
45
46
  "expiry": "Expiry",
46
47
  "failed": "Operation failed",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "电子邮箱",
42
42
  "enabled": "已启用",
43
43
  "entityStatus": "状态",
44
+ "environmentChanged": "运行环境已改变,请重新登录",
44
45
  "etsoo": "亿速思维",
45
46
  "expiry": "到期时间",
46
47
  "failed": "操作失败",
@@ -41,6 +41,7 @@
41
41
  "emailAddresses": "電子郵箱",
42
42
  "enabled": "已啟用",
43
43
  "entityStatus": "狀態",
44
+ "environmentChanged": "運行環境已改變,請重新登錄",
44
45
  "etsoo": "億速思維",
45
46
  "expiry": "到期時間",
46
47
  "failed": "操作失敗",