@etsoo/appscript 1.2.93 → 1.2.95
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 +7 -6
- package/lib/cjs/app/CoreApp.js +27 -9
- package/lib/cjs/app/IApp.d.ts +13 -5
- package/lib/mjs/app/CoreApp.d.ts +7 -6
- package/lib/mjs/app/CoreApp.js +27 -9
- package/lib/mjs/app/IApp.d.ts +13 -5
- package/package.json +1 -1
- package/src/app/CoreApp.ts +26 -10
- package/src/app/IApp.ts +18 -6
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IActionResult } from '../result/IActionResult';
|
|
|
8
8
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
9
9
|
import { IUser } from '../state/User';
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
|
-
import { IApp, IAppFields, IDetectIPCallback, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
|
+
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
14
14
|
* Core application interface
|
|
@@ -407,14 +407,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
407
407
|
*/
|
|
408
408
|
hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
|
|
409
409
|
/**
|
|
410
|
-
*
|
|
410
|
+
* Navigate to Url or delta
|
|
411
|
+
* @param url Url or delta
|
|
412
|
+
* @param options Options
|
|
411
413
|
*/
|
|
412
|
-
|
|
414
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
413
415
|
/**
|
|
414
|
-
*
|
|
415
|
-
* @param url Url
|
|
416
|
+
* Callback where exit a page
|
|
416
417
|
*/
|
|
417
|
-
|
|
418
|
+
pageExit(): void;
|
|
418
419
|
/**
|
|
419
420
|
* Refresh countdown
|
|
420
421
|
* @param seconds Seconds
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -978,6 +978,31 @@ class CoreApp {
|
|
|
978
978
|
return true;
|
|
979
979
|
return false;
|
|
980
980
|
}
|
|
981
|
+
/**
|
|
982
|
+
* Navigate to Url or delta
|
|
983
|
+
* @param url Url or delta
|
|
984
|
+
* @param options Options
|
|
985
|
+
*/
|
|
986
|
+
navigate(to, options) {
|
|
987
|
+
if (typeof to === 'number') {
|
|
988
|
+
globalThis.history.go(to);
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
const { state, replace = false } = options !== null && options !== void 0 ? options : {};
|
|
992
|
+
if (replace) {
|
|
993
|
+
if (state)
|
|
994
|
+
globalThis.history.replaceState(state, '', to);
|
|
995
|
+
else
|
|
996
|
+
globalThis.location.replace(to);
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
if (state)
|
|
1000
|
+
globalThis.history.pushState(state, '', to);
|
|
1001
|
+
else
|
|
1002
|
+
globalThis.location.assign(to);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
981
1006
|
/**
|
|
982
1007
|
* Callback where exit a page
|
|
983
1008
|
*/
|
|
@@ -985,13 +1010,6 @@ class CoreApp {
|
|
|
985
1010
|
var _a;
|
|
986
1011
|
(_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
|
|
987
1012
|
}
|
|
988
|
-
/**
|
|
989
|
-
* Redirect to the Url
|
|
990
|
-
* @param url Url
|
|
991
|
-
*/
|
|
992
|
-
redirectTo(url) {
|
|
993
|
-
globalThis.location.href = url;
|
|
994
|
-
}
|
|
995
1013
|
/**
|
|
996
1014
|
* Refresh countdown
|
|
997
1015
|
* @param seconds Seconds
|
|
@@ -1089,8 +1107,8 @@ class CoreApp {
|
|
|
1089
1107
|
* @param tryLogin Try to login again
|
|
1090
1108
|
*/
|
|
1091
1109
|
toLoginPage(tryLogin) {
|
|
1092
|
-
const url =
|
|
1093
|
-
this.
|
|
1110
|
+
const url = '/' + (tryLogin ? '' : '?tryLogin=false');
|
|
1111
|
+
this.navigate(url);
|
|
1094
1112
|
}
|
|
1095
1113
|
/**
|
|
1096
1114
|
* Try login, returning false means is loading
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { UserRole } from './UserRole';
|
|
|
13
13
|
export interface IDetectIPCallback {
|
|
14
14
|
(): void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Navigate options
|
|
18
|
+
*/
|
|
19
|
+
export interface NavigateOptions {
|
|
20
|
+
replace?: boolean;
|
|
21
|
+
state?: any;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Refresh token result type
|
|
18
25
|
* true means success, false means failed but no any message
|
|
@@ -335,6 +342,12 @@ export interface IApp {
|
|
|
335
342
|
* @param password Input password
|
|
336
343
|
*/
|
|
337
344
|
isValidPassword(password: string): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Navigate to Url or delta
|
|
347
|
+
* @param url Url or delta
|
|
348
|
+
* @param options Options
|
|
349
|
+
*/
|
|
350
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
338
351
|
/**
|
|
339
352
|
* Callback where exit a page
|
|
340
353
|
*/
|
|
@@ -359,11 +372,6 @@ export interface IApp {
|
|
|
359
372
|
* Persist settings to source when application exit
|
|
360
373
|
*/
|
|
361
374
|
persist(): void;
|
|
362
|
-
/**
|
|
363
|
-
* Redirect to the Url
|
|
364
|
-
* @param url Url
|
|
365
|
-
*/
|
|
366
|
-
redirectTo(url: string): void;
|
|
367
375
|
/**
|
|
368
376
|
* Switch organization
|
|
369
377
|
* @param id Organization id
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { IActionResult } from '../result/IActionResult';
|
|
|
8
8
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
9
9
|
import { IUser } from '../state/User';
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
|
-
import { IApp, IAppFields, IDetectIPCallback, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
|
+
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
14
14
|
* Core application interface
|
|
@@ -407,14 +407,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
407
407
|
*/
|
|
408
408
|
hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
|
|
409
409
|
/**
|
|
410
|
-
*
|
|
410
|
+
* Navigate to Url or delta
|
|
411
|
+
* @param url Url or delta
|
|
412
|
+
* @param options Options
|
|
411
413
|
*/
|
|
412
|
-
|
|
414
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
413
415
|
/**
|
|
414
|
-
*
|
|
415
|
-
* @param url Url
|
|
416
|
+
* Callback where exit a page
|
|
416
417
|
*/
|
|
417
|
-
|
|
418
|
+
pageExit(): void;
|
|
418
419
|
/**
|
|
419
420
|
* Refresh countdown
|
|
420
421
|
* @param seconds Seconds
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -975,6 +975,31 @@ export class CoreApp {
|
|
|
975
975
|
return true;
|
|
976
976
|
return false;
|
|
977
977
|
}
|
|
978
|
+
/**
|
|
979
|
+
* Navigate to Url or delta
|
|
980
|
+
* @param url Url or delta
|
|
981
|
+
* @param options Options
|
|
982
|
+
*/
|
|
983
|
+
navigate(to, options) {
|
|
984
|
+
if (typeof to === 'number') {
|
|
985
|
+
globalThis.history.go(to);
|
|
986
|
+
}
|
|
987
|
+
else {
|
|
988
|
+
const { state, replace = false } = options !== null && options !== void 0 ? options : {};
|
|
989
|
+
if (replace) {
|
|
990
|
+
if (state)
|
|
991
|
+
globalThis.history.replaceState(state, '', to);
|
|
992
|
+
else
|
|
993
|
+
globalThis.location.replace(to);
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
if (state)
|
|
997
|
+
globalThis.history.pushState(state, '', to);
|
|
998
|
+
else
|
|
999
|
+
globalThis.location.assign(to);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
978
1003
|
/**
|
|
979
1004
|
* Callback where exit a page
|
|
980
1005
|
*/
|
|
@@ -982,13 +1007,6 @@ export class CoreApp {
|
|
|
982
1007
|
var _a;
|
|
983
1008
|
(_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
|
|
984
1009
|
}
|
|
985
|
-
/**
|
|
986
|
-
* Redirect to the Url
|
|
987
|
-
* @param url Url
|
|
988
|
-
*/
|
|
989
|
-
redirectTo(url) {
|
|
990
|
-
globalThis.location.href = url;
|
|
991
|
-
}
|
|
992
1010
|
/**
|
|
993
1011
|
* Refresh countdown
|
|
994
1012
|
* @param seconds Seconds
|
|
@@ -1086,8 +1104,8 @@ export class CoreApp {
|
|
|
1086
1104
|
* @param tryLogin Try to login again
|
|
1087
1105
|
*/
|
|
1088
1106
|
toLoginPage(tryLogin) {
|
|
1089
|
-
const url =
|
|
1090
|
-
this.
|
|
1107
|
+
const url = '/' + (tryLogin ? '' : '?tryLogin=false');
|
|
1108
|
+
this.navigate(url);
|
|
1091
1109
|
}
|
|
1092
1110
|
/**
|
|
1093
1111
|
* Try login, returning false means is loading
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ import { UserRole } from './UserRole';
|
|
|
13
13
|
export interface IDetectIPCallback {
|
|
14
14
|
(): void;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Navigate options
|
|
18
|
+
*/
|
|
19
|
+
export interface NavigateOptions {
|
|
20
|
+
replace?: boolean;
|
|
21
|
+
state?: any;
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Refresh token result type
|
|
18
25
|
* true means success, false means failed but no any message
|
|
@@ -335,6 +342,12 @@ export interface IApp {
|
|
|
335
342
|
* @param password Input password
|
|
336
343
|
*/
|
|
337
344
|
isValidPassword(password: string): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Navigate to Url or delta
|
|
347
|
+
* @param url Url or delta
|
|
348
|
+
* @param options Options
|
|
349
|
+
*/
|
|
350
|
+
navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
|
|
338
351
|
/**
|
|
339
352
|
* Callback where exit a page
|
|
340
353
|
*/
|
|
@@ -359,11 +372,6 @@ export interface IApp {
|
|
|
359
372
|
* Persist settings to source when application exit
|
|
360
373
|
*/
|
|
361
374
|
persist(): void;
|
|
362
|
-
/**
|
|
363
|
-
* Redirect to the Url
|
|
364
|
-
* @param url Url
|
|
365
|
-
*/
|
|
366
|
-
redirectTo(url: string): void;
|
|
367
375
|
/**
|
|
368
376
|
* Switch organization
|
|
369
377
|
* @param id Organization id
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
IApp,
|
|
47
47
|
IAppFields,
|
|
48
48
|
IDetectIPCallback,
|
|
49
|
+
NavigateOptions,
|
|
49
50
|
RefreshTokenProps,
|
|
50
51
|
RefreshTokenResult
|
|
51
52
|
} from './IApp';
|
|
@@ -1304,18 +1305,34 @@ export abstract class CoreApp<
|
|
|
1304
1305
|
}
|
|
1305
1306
|
|
|
1306
1307
|
/**
|
|
1307
|
-
*
|
|
1308
|
+
* Navigate to Url or delta
|
|
1309
|
+
* @param url Url or delta
|
|
1310
|
+
* @param options Options
|
|
1308
1311
|
*/
|
|
1309
|
-
|
|
1310
|
-
|
|
1312
|
+
navigate<T extends number | string | URL>(
|
|
1313
|
+
to: T,
|
|
1314
|
+
options?: T extends number ? never : NavigateOptions
|
|
1315
|
+
) {
|
|
1316
|
+
if (typeof to === 'number') {
|
|
1317
|
+
globalThis.history.go(to);
|
|
1318
|
+
} else {
|
|
1319
|
+
const { state, replace = false } = options ?? {};
|
|
1320
|
+
|
|
1321
|
+
if (replace) {
|
|
1322
|
+
if (state) globalThis.history.replaceState(state, '', to);
|
|
1323
|
+
else globalThis.location.replace(to);
|
|
1324
|
+
} else {
|
|
1325
|
+
if (state) globalThis.history.pushState(state, '', to);
|
|
1326
|
+
else globalThis.location.assign(to);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1311
1329
|
}
|
|
1312
1330
|
|
|
1313
1331
|
/**
|
|
1314
|
-
*
|
|
1315
|
-
* @param url Url
|
|
1332
|
+
* Callback where exit a page
|
|
1316
1333
|
*/
|
|
1317
|
-
|
|
1318
|
-
|
|
1334
|
+
pageExit() {
|
|
1335
|
+
this.lastWarning?.dismiss();
|
|
1319
1336
|
}
|
|
1320
1337
|
|
|
1321
1338
|
/**
|
|
@@ -1437,9 +1454,8 @@ export abstract class CoreApp<
|
|
|
1437
1454
|
* @param tryLogin Try to login again
|
|
1438
1455
|
*/
|
|
1439
1456
|
toLoginPage(tryLogin?: boolean) {
|
|
1440
|
-
const url =
|
|
1441
|
-
|
|
1442
|
-
this.redirectTo(url);
|
|
1457
|
+
const url = '/' + (tryLogin ? '' : '?tryLogin=false');
|
|
1458
|
+
this.navigate(url);
|
|
1443
1459
|
}
|
|
1444
1460
|
|
|
1445
1461
|
/**
|
package/src/app/IApp.ts
CHANGED
|
@@ -21,6 +21,14 @@ export interface IDetectIPCallback {
|
|
|
21
21
|
(): void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Navigate options
|
|
26
|
+
*/
|
|
27
|
+
export interface NavigateOptions {
|
|
28
|
+
replace?: boolean;
|
|
29
|
+
state?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
/**
|
|
25
33
|
* Refresh token result type
|
|
26
34
|
* true means success, false means failed but no any message
|
|
@@ -437,6 +445,16 @@ export interface IApp {
|
|
|
437
445
|
*/
|
|
438
446
|
isValidPassword(password: string): boolean;
|
|
439
447
|
|
|
448
|
+
/**
|
|
449
|
+
* Navigate to Url or delta
|
|
450
|
+
* @param url Url or delta
|
|
451
|
+
* @param options Options
|
|
452
|
+
*/
|
|
453
|
+
navigate<T extends number | string | URL>(
|
|
454
|
+
to: T,
|
|
455
|
+
options?: T extends number ? never : NavigateOptions
|
|
456
|
+
): void;
|
|
457
|
+
|
|
440
458
|
/**
|
|
441
459
|
* Callback where exit a page
|
|
442
460
|
*/
|
|
@@ -471,12 +489,6 @@ export interface IApp {
|
|
|
471
489
|
*/
|
|
472
490
|
persist(): void;
|
|
473
491
|
|
|
474
|
-
/**
|
|
475
|
-
* Redirect to the Url
|
|
476
|
-
* @param url Url
|
|
477
|
-
*/
|
|
478
|
-
redirectTo(url: string): void;
|
|
479
|
-
|
|
480
492
|
/**
|
|
481
493
|
* Switch organization
|
|
482
494
|
* @param id Organization id
|