adminforth 1.5.4-next.9 → 1.5.5-next.0
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/dist/auth.js +4 -4
- package/dist/auth.js.map +1 -1
- package/dist/dataConnectors/clickhouse.d.ts.map +1 -1
- package/dist/dataConnectors/clickhouse.js +0 -1
- package/dist/dataConnectors/clickhouse.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -13
- package/dist/index.js.map +1 -1
- package/dist/modules/codeInjector.d.ts.map +1 -1
- package/dist/modules/codeInjector.js +7 -5
- package/dist/modules/codeInjector.js.map +1 -1
- package/dist/modules/configValidator.d.ts +11 -5
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +387 -379
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +32 -13
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/socketBroker.d.ts.map +1 -1
- package/dist/modules/socketBroker.js +0 -1
- package/dist/modules/socketBroker.js.map +1 -1
- package/dist/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +2 -3
- package/dist/servers/express.js.map +1 -1
- package/dist/spa/src/App.vue +8 -6
- package/dist/spa/src/afcl/Input.vue +1 -1
- package/dist/spa/src/afcl/Link.vue +9 -1
- package/dist/spa/src/afcl/LinkButton.vue +5 -3
- package/dist/spa/src/afcl/VerticalTabs.vue +1 -1
- package/dist/spa/src/components/AcceptModal.vue +1 -2
- package/dist/spa/src/components/ResourceListTable.vue +4 -3
- package/dist/spa/src/components/SkeleteLoader.vue +5 -10
- package/dist/spa/src/components/ValueRenderer.vue +13 -14
- package/dist/spa/src/spa_types/core.ts +2 -4
- package/dist/spa/src/stores/core.ts +15 -16
- package/dist/spa/src/stores/user.ts +0 -7
- package/dist/spa/src/types/Back.ts +310 -327
- package/dist/spa/src/types/Common.ts +220 -10
- package/dist/spa/src/types/FrontendAPI.ts +5 -4
- package/dist/spa/src/utils.ts +5 -1
- package/dist/spa/src/views/LoginView.vue +6 -1
- package/dist/spa/src/websocket.ts +3 -2
- package/dist/types/Back.d.ts +262 -287
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js +1 -46
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +194 -9
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js +47 -0
- package/dist/types/Common.js.map +1 -1
- package/dist/types/FrontendAPI.d.ts +4 -4
- package/dist/types/FrontendAPI.d.ts.map +1 -1
- package/dist/types/FrontendAPI.js.map +1 -1
- package/package.json +4 -4
|
@@ -7,7 +7,11 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
|
|
|
7
7
|
type AdminUser, type AllowedActionsResolved,
|
|
8
8
|
type AdminForthBulkActionCommon,
|
|
9
9
|
type AdminForthForeignResourceCommon,
|
|
10
|
-
type AdminForthResourceColumnCommon
|
|
10
|
+
type AdminForthResourceColumnCommon,
|
|
11
|
+
AdminForthResourceInputCommon,
|
|
12
|
+
AdminForthComponentDeclarationFull,
|
|
13
|
+
AdminForthConfigMenuItem,
|
|
14
|
+
AnnouncementBadgeResponse
|
|
11
15
|
} from './Common.js';
|
|
12
16
|
|
|
13
17
|
export interface ICodeInjector {
|
|
@@ -282,7 +286,6 @@ export interface IAdminForth {
|
|
|
282
286
|
restApi: IAdminForthRestAPI;
|
|
283
287
|
activatedPlugins: Array<IAdminForthPlugin>;
|
|
284
288
|
|
|
285
|
-
baseUrlSlashed: string;
|
|
286
289
|
|
|
287
290
|
websocket: IWebSocketBroker;
|
|
288
291
|
|
|
@@ -396,160 +399,6 @@ export interface IAdminForthPlugin {
|
|
|
396
399
|
setupEndpoints(server: IHttpServer): void;
|
|
397
400
|
}
|
|
398
401
|
|
|
399
|
-
export enum AdminForthMenuTypes {
|
|
400
|
-
/**
|
|
401
|
-
* HEADING is just a label in the menu.
|
|
402
|
-
* Respect `label` and `icon` property in {@link AdminForthConfigMenuItem}
|
|
403
|
-
*/
|
|
404
|
-
heading = 'heading',
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* GROUP is a group of menu items.
|
|
408
|
-
* Respects `label`, `icon` and `children` properties in {@link AdminForthConfigMenuItem}
|
|
409
|
-
* use @AdminForthMenuTypes.open to set if group is open by default
|
|
410
|
-
*/
|
|
411
|
-
group = 'group',
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* RESOURCE is a link to a resource.
|
|
415
|
-
* Respects `label`, `icon`, `resourceId`, `homepage`, `isStaticRoute` properties in {@link AdminForthConfigMenuItem}
|
|
416
|
-
*/
|
|
417
|
-
resource = 'resource',
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* PAGE is a link to a custom page.
|
|
421
|
-
* Respects `label`, `icon`, `path`, `component`, `homepage`, `isStaticRoute`, properties in {@link AdminForthConfigMenuItem}
|
|
422
|
-
*
|
|
423
|
-
* Example:
|
|
424
|
-
*
|
|
425
|
-
* ```ts
|
|
426
|
-
* \{
|
|
427
|
-
* type: AdminForthMenuTypes.PAGE,
|
|
428
|
-
* label: 'Custom Page',
|
|
429
|
-
* icon: 'home',
|
|
430
|
-
* path: '/dash',
|
|
431
|
-
* component: '@@/Dashboard.vue',
|
|
432
|
-
* homepage: true,
|
|
433
|
-
* \}
|
|
434
|
-
* ```
|
|
435
|
-
*
|
|
436
|
-
*/
|
|
437
|
-
page = 'page',
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* GAP ads some space between menu items.
|
|
441
|
-
*/
|
|
442
|
-
gap = 'gap',
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* DIVIDER is a divider between menu items.
|
|
446
|
-
*/
|
|
447
|
-
divider = 'divider',
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Menu item which displayed in the left sidebar of the admin panel.
|
|
455
|
-
*/
|
|
456
|
-
export interface AdminForthConfigMenuItem {
|
|
457
|
-
type?: AdminForthMenuTypes | keyof typeof AdminForthMenuTypes,
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Label for menu item which will be displayed in the admin panel.
|
|
461
|
-
*/
|
|
462
|
-
label?: string,
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Icon for menu item which will be displayed in the admin panel.
|
|
466
|
-
* Supports iconify icons in format `<icon set name>:<icon name>`
|
|
467
|
-
* Browse available icons here: https://icon-sets.iconify.design/
|
|
468
|
-
*
|
|
469
|
-
* Example:
|
|
470
|
-
*
|
|
471
|
-
* ```ts
|
|
472
|
-
* icon: 'flowbite:brain-solid',
|
|
473
|
-
* ```
|
|
474
|
-
*
|
|
475
|
-
*/
|
|
476
|
-
icon?: string,
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Path to custom component which will be displayed in the admin panel.
|
|
480
|
-
*
|
|
481
|
-
*/
|
|
482
|
-
path?: string,
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Component to be used for this menu item. Component should be placed in custom folder and referenced with `@@/` prefix.
|
|
486
|
-
* Supported for AdminForthMenuTypes.PAGE only!
|
|
487
|
-
* Example:
|
|
488
|
-
*
|
|
489
|
-
* ```ts
|
|
490
|
-
* component: '@@/Dashboard.vue',
|
|
491
|
-
* ```
|
|
492
|
-
*
|
|
493
|
-
*/
|
|
494
|
-
component?: string,
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Resource ID which will be used to fetch data from.
|
|
498
|
-
* Supported for AdminForthMenuTypes.RESOURCE only!
|
|
499
|
-
*
|
|
500
|
-
*/
|
|
501
|
-
resourceId?: string,
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* If true, group will be open by default after user login to the admin panel.
|
|
505
|
-
* Also will be used to redirect from root path.
|
|
506
|
-
*/
|
|
507
|
-
homepage?: boolean,
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Where Group is open by default
|
|
511
|
-
* Supported for AdminForthMenuTypes.GROUP only!
|
|
512
|
-
*
|
|
513
|
-
*/
|
|
514
|
-
open?: boolean,
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Children menu items which will be displayed in this group.
|
|
518
|
-
* Supported for AdminForthMenuTypes.GROUP only!
|
|
519
|
-
*/
|
|
520
|
-
children?: Array<AdminForthConfigMenuItem>,
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* By default all pages are imported dynamically with lazy import().
|
|
524
|
-
* If you wish to import page statically, set this option to true.
|
|
525
|
-
* Homepage will be imported statically by default. but you can override it with this option.
|
|
526
|
-
*/
|
|
527
|
-
isStaticRoute?: boolean,
|
|
528
|
-
|
|
529
|
-
meta?: {
|
|
530
|
-
title?: string,
|
|
531
|
-
},
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Optional callback which will be called before rendering the menu for each item.
|
|
535
|
-
* You can use it to hide menu items depending on some user
|
|
536
|
-
*/
|
|
537
|
-
visible?: (user: AdminUser) => boolean,
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Optional callback which will be called before rendering the menu for each item.
|
|
541
|
-
* Result of callback if not null will be used as a small badge near the menu item.
|
|
542
|
-
*/
|
|
543
|
-
badge?: string | ((user: AdminUser) => Promise<string>),
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Item id will be automatically generated from hashed resourceId+Path+label
|
|
547
|
-
*/
|
|
548
|
-
_itemId?: string,
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
402
|
|
|
554
403
|
/**
|
|
555
404
|
* Modify query to change how data is fetched from database.
|
|
@@ -647,11 +496,254 @@ export type AdminForthDataSource = {
|
|
|
647
496
|
url: string,
|
|
648
497
|
}
|
|
649
498
|
|
|
499
|
+
type AdminForthPageDeclaration = {
|
|
500
|
+
path: string,
|
|
501
|
+
component: AdminForthComponentDeclaration,
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface AdminForthInputConfigCustomization {
|
|
505
|
+
/**
|
|
506
|
+
* Your app name
|
|
507
|
+
*/
|
|
508
|
+
brandName?: string,
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Whether to show brand name in sidebar
|
|
512
|
+
* default is true
|
|
513
|
+
*/
|
|
514
|
+
showBrandNameInSidebar?: boolean,
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Path to your app logo
|
|
518
|
+
*
|
|
519
|
+
* Example:
|
|
520
|
+
* Place file `logo.svg` to `./custom` folder and set this option:
|
|
521
|
+
*
|
|
522
|
+
* ```ts
|
|
523
|
+
* brandLogo: '@@/logo.svg',
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
*/
|
|
527
|
+
brandLogo?: string,
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Path to your app favicon
|
|
531
|
+
*
|
|
532
|
+
* Example:
|
|
533
|
+
* Place file `favicon.png` to `./custom` folder and set this option:
|
|
534
|
+
*
|
|
535
|
+
* ```ts
|
|
536
|
+
* favicon: '@@/favicon.png',
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
favicon?: string,
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* DayJS format string for all dates in the app.
|
|
543
|
+
* Defaulted to 'MMM D, YYYY'
|
|
544
|
+
*/
|
|
545
|
+
datesFormat?: string,
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* DayJS format string for all datetimes in the app.
|
|
549
|
+
* Defaulted to 'HH:mm:ss'
|
|
550
|
+
*/
|
|
551
|
+
timeFormat?: string,
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* HTML title tag value, defaults to brandName
|
|
555
|
+
*/
|
|
556
|
+
title?: string,
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Placeholder for empty fields in lists and show views, by default empty string ''
|
|
560
|
+
*/
|
|
561
|
+
emptyFieldPlaceholder?: {
|
|
562
|
+
show?: string,
|
|
563
|
+
list?: string,
|
|
564
|
+
|
|
565
|
+
} | string,
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Relative or absolute path to custom components directory
|
|
569
|
+
* By default equals `./custom`.
|
|
570
|
+
*
|
|
571
|
+
* Custom .vue files, images, and any other assets placed in this directory can be accessed in AdminForth components and configs with `@@/`.
|
|
572
|
+
*
|
|
573
|
+
* For example if file path is `./custom/comp/my.vue`, you can use it in AdminForth config like this:
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
576
|
+
* components: {
|
|
577
|
+
* show: '@@/comp/my.vue',
|
|
578
|
+
* }
|
|
579
|
+
* ```
|
|
580
|
+
*
|
|
581
|
+
*/
|
|
582
|
+
customComponentsDir?: string,
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Path to custom .ts file which allows to inject custom Vue uses in SPA or add custom imports.
|
|
586
|
+
*
|
|
587
|
+
* Example: Create file: `./custom/vue-uses.ts` with next content:
|
|
588
|
+
*
|
|
589
|
+
* ```ts
|
|
590
|
+
* import HighchartsVue from 'highcharts-vue';
|
|
591
|
+
* // import '@@/custom.scss'; // here is how you can import custom styles
|
|
592
|
+
*
|
|
593
|
+
* export default function (app) {
|
|
594
|
+
* app.use(HighchartsVue);
|
|
595
|
+
* }
|
|
596
|
+
* ```
|
|
597
|
+
*
|
|
598
|
+
* Install HighCharts into custom folder:
|
|
599
|
+
*
|
|
600
|
+
* ```bashcreating rec
|
|
601
|
+
* cd custom
|
|
602
|
+
* npm init -y
|
|
603
|
+
* npm install highcharts highcharts-vue
|
|
604
|
+
* ```
|
|
605
|
+
*
|
|
606
|
+
* And specify vueUsesFile in AdminForth config:
|
|
607
|
+
*
|
|
608
|
+
* ```ts
|
|
609
|
+
* vueUsesFile: '@@/vue-uses.ts',
|
|
610
|
+
* ```
|
|
611
|
+
*
|
|
612
|
+
*/
|
|
613
|
+
vueUsesFile?: string,
|
|
614
|
+
/**
|
|
615
|
+
* Object to redefine default styles for AdminForth components. Use this file as reference for all possible adjustments https://github.com/devforth/adminforth/blob/main/adminforth/modules/styles.ts
|
|
616
|
+
*/
|
|
617
|
+
styles?: Object,
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Description of custom pages which will let register custom pages for custom routes in AdminForth.
|
|
621
|
+
*/
|
|
622
|
+
customPages?: Array<AdminForthPageDeclaration>,
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Function to return custom badge in side bar for users. Can return text or html
|
|
626
|
+
* If function is not passed or returns null, badge will not be shown.
|
|
627
|
+
* Execution is done on admin app load.
|
|
628
|
+
*/
|
|
629
|
+
announcementBadge?: (user: AdminUser) => AnnouncementBadgeResponse,
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Custom panel components or array of components which will be displayed in the login form
|
|
633
|
+
* right after the inputs. Use it to add custom authorization methods like social login or other custom fields e.g. 'reset'
|
|
634
|
+
* password link.
|
|
635
|
+
*/
|
|
636
|
+
loginPageInjections?: {
|
|
637
|
+
underInputs?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Custom panel components or array of components which will be displayed in different parts of the admin panel.
|
|
642
|
+
*/
|
|
643
|
+
globalInjections?: {
|
|
644
|
+
userMenu?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
645
|
+
header?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
646
|
+
sidebar?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
export interface AdminForthResourceInput extends Omit<AdminForthResourceInputCommon, 'columns' | 'hooks' | 'options'> {
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Array of plugins which will be used to modify resource configuration.
|
|
655
|
+
*
|
|
656
|
+
*/
|
|
657
|
+
plugins?: Array<IAdminForthPlugin>,
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Hooks allow you to change the data on different stages of resource lifecycle.
|
|
661
|
+
* Hooks are functions which will be called on backend side (only backend side).
|
|
662
|
+
*/
|
|
663
|
+
hooks?: {
|
|
664
|
+
show?: {
|
|
665
|
+
/**
|
|
666
|
+
* Typical use-cases:
|
|
667
|
+
* - request additional data from database before returning to frontend for soft-join
|
|
668
|
+
*/
|
|
669
|
+
beforeDatasourceRequest?: BeforeDataSourceRequestFunction | Array<BeforeDataSourceRequestFunction>,
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Typical use-cases:
|
|
673
|
+
* - Transform value for some field for record returned from database before returning to frontend (minimize, sanitize, etc)
|
|
674
|
+
* - If some-why you can't use `backendOnly` you can cleanup sensitive fields here
|
|
675
|
+
* - Attach additional data to record before returning to frontend
|
|
676
|
+
*/
|
|
677
|
+
afterDatasourceResponse?: AfterDataSourceResponseFunction | Array<AfterDataSourceResponseFunction>,
|
|
678
|
+
},
|
|
679
|
+
list?: {
|
|
680
|
+
/**
|
|
681
|
+
* Typical use-cases:
|
|
682
|
+
* - add additional filters in addition to what user selected before fetching data from database.
|
|
683
|
+
* - same as hooks.show.beforeDatasourceRequest
|
|
684
|
+
*/
|
|
685
|
+
beforeDatasourceRequest?: BeforeDataSourceRequestFunction | Array<BeforeDataSourceRequestFunction>,
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Typical use-cases:
|
|
689
|
+
* - Same as hooks.show.afterDatasourceResponse but applied for all records returned from database for
|
|
690
|
+
* showing in list view, e.g. add new field to each record in list view
|
|
691
|
+
*/
|
|
692
|
+
afterDatasourceResponse?: AfterDataSourceResponseFunction | Array<AfterDataSourceResponseFunction>,
|
|
693
|
+
},
|
|
694
|
+
create?: {
|
|
695
|
+
/**
|
|
696
|
+
* Typical use-cases:
|
|
697
|
+
* - Validate record before saving to database and interrupt execution if validation failed (`allowedActions.create` should be preferred in most cases)
|
|
698
|
+
* - fill-in adminUser as creator of record
|
|
699
|
+
* - Attach additional data to record before saving to database (mostly fillOnCreate should be used instead)
|
|
700
|
+
*/
|
|
701
|
+
beforeSave?: BeforeSaveFunction | Array<BeforeSaveFunction>,
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Typical use-cases:
|
|
705
|
+
* - Initiate some trigger after record saved to database (e.g sync to another datasource)
|
|
706
|
+
*/
|
|
707
|
+
afterSave?: AfterSaveFunction | Array<AfterSaveFunction>,
|
|
708
|
+
},
|
|
709
|
+
edit?: {
|
|
710
|
+
/**
|
|
711
|
+
* Typical use-cases:
|
|
712
|
+
* - Same as hooks.create.beforeSave but for edit page
|
|
713
|
+
*/
|
|
714
|
+
beforeSave?: BeforeSaveFunction | Array<BeforeSaveFunction>,
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Typical use-cases:
|
|
718
|
+
* - Same as hooks.create.afterSave but for edit page
|
|
719
|
+
*/
|
|
720
|
+
afterSave?: AfterSaveFunction | Array<AfterSaveFunction>,
|
|
721
|
+
},
|
|
722
|
+
delete?: {
|
|
723
|
+
/**
|
|
724
|
+
* Typical use-cases:
|
|
725
|
+
* - Validate that record can be deleted and interrupt execution if validation failed (`allowedActions.delete` should be preferred in most cases)
|
|
726
|
+
*/
|
|
727
|
+
beforeSave?: BeforeSaveFunction | Array<BeforeSaveFunction>,
|
|
728
|
+
/**
|
|
729
|
+
* Typical use-cases:
|
|
730
|
+
* - Initiate some trigger after record deleted from database (e.g sync to another datasource)
|
|
731
|
+
*/
|
|
732
|
+
afterSave?: BeforeSaveFunction | Array<BeforeSaveFunction>,
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
|
|
736
|
+
options?: ResourceOptionsInput,
|
|
737
|
+
|
|
738
|
+
columns: Array<AdminForthResourceColumn>,
|
|
739
|
+
|
|
740
|
+
dataSourceColumns?: Array<AdminForthResourceColumn>,
|
|
741
|
+
}
|
|
650
742
|
|
|
651
743
|
/**
|
|
652
744
|
* Main configuration object for AdminForth
|
|
653
745
|
*/
|
|
654
|
-
export interface
|
|
746
|
+
export interface AdminForthInputConfig {
|
|
655
747
|
|
|
656
748
|
/**
|
|
657
749
|
* Authorization module configuration
|
|
@@ -749,12 +841,13 @@ export interface AdminForthConfig {
|
|
|
749
841
|
*/
|
|
750
842
|
websocketSubscribed?: (topic: string, user: AdminUser) => void,
|
|
751
843
|
},
|
|
844
|
+
|
|
752
845
|
/**
|
|
753
846
|
* Array of resources which will be displayed in the admin panel.
|
|
754
847
|
* Resource represents one table or collection in database.
|
|
755
848
|
* Each resource has its own configuration.
|
|
756
849
|
*/
|
|
757
|
-
resources: Array<
|
|
850
|
+
resources: Array<AdminForthResourceInput>,
|
|
758
851
|
|
|
759
852
|
/**
|
|
760
853
|
* Array of left sidebar menu items which will be displayed in the admin panel.
|
|
@@ -783,160 +876,7 @@ export interface AdminForthConfig {
|
|
|
783
876
|
* Settings which allow you to customize AdminForth
|
|
784
877
|
*
|
|
785
878
|
*/
|
|
786
|
-
customization?:
|
|
787
|
-
/**
|
|
788
|
-
* Your app name
|
|
789
|
-
*/
|
|
790
|
-
brandName?: string,
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* Slug which will be used on tech side e.g. to store cookies separately.
|
|
794
|
-
* Created automatically from brandName if not set.
|
|
795
|
-
*/
|
|
796
|
-
_brandNameSlug?: string,
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* Whether to show brand name in sidebar
|
|
800
|
-
* default is true
|
|
801
|
-
*/
|
|
802
|
-
showBrandNameInSidebar?: boolean,
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Path to your app logo
|
|
806
|
-
*
|
|
807
|
-
* Example:
|
|
808
|
-
* Place file `logo.svg` to `./custom` folder and set this option:
|
|
809
|
-
*
|
|
810
|
-
* ```ts
|
|
811
|
-
* brandLogo: '@@/logo.svg',
|
|
812
|
-
* ```
|
|
813
|
-
*
|
|
814
|
-
*/
|
|
815
|
-
brandLogo?: string,
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Path to your app favicon
|
|
819
|
-
*
|
|
820
|
-
* Example:
|
|
821
|
-
* Place file `favicon.png` to `./custom` folder and set this option:
|
|
822
|
-
*
|
|
823
|
-
* ```ts
|
|
824
|
-
* favicon: '@@/favicon.png',
|
|
825
|
-
* ```
|
|
826
|
-
*/
|
|
827
|
-
favicon?: string,
|
|
828
|
-
|
|
829
|
-
/**
|
|
830
|
-
* DayJS format string for all dates in the app.
|
|
831
|
-
* Defaulted to 'MMM D, YYYY'
|
|
832
|
-
*/
|
|
833
|
-
datesFormat?: string,
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* DayJS format string for all datetimes in the app.
|
|
837
|
-
* Defaulted to 'HH:mm:ss'
|
|
838
|
-
*/
|
|
839
|
-
timeFormat?: string,
|
|
840
|
-
|
|
841
|
-
/**
|
|
842
|
-
* HTML title tag value, defaults to brandName
|
|
843
|
-
*/
|
|
844
|
-
title?: string,
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* Placeholder for empty fields in lists and show views, by default empty string ''
|
|
848
|
-
*/
|
|
849
|
-
emptyFieldPlaceholder?: {
|
|
850
|
-
show?: string,
|
|
851
|
-
list?: string,
|
|
852
|
-
|
|
853
|
-
} | string,
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* Relative or absolute path to custom components directory
|
|
857
|
-
* By default equals `./custom`.
|
|
858
|
-
*
|
|
859
|
-
* Custom .vue files, images, and any other assets placed in this directory can be accessed in AdminForth components and configs with `@@/`.
|
|
860
|
-
*
|
|
861
|
-
* For example if file path is `./custom/comp/my.vue`, you can use it in AdminForth config like this:
|
|
862
|
-
*
|
|
863
|
-
* ```ts
|
|
864
|
-
* components: {
|
|
865
|
-
* show: '@@/comp/my.vue',
|
|
866
|
-
* }
|
|
867
|
-
* ```
|
|
868
|
-
*
|
|
869
|
-
*/
|
|
870
|
-
customComponentsDir?: string,
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Path to custom .ts file which allows to inject custom Vue uses in SPA or add custom imports.
|
|
874
|
-
*
|
|
875
|
-
* Example: Create file: `./custom/vue-uses.ts` with next content:
|
|
876
|
-
*
|
|
877
|
-
* ```ts
|
|
878
|
-
* import HighchartsVue from 'highcharts-vue';
|
|
879
|
-
* // import '@@/custom.scss'; // here is how you can import custom styles
|
|
880
|
-
*
|
|
881
|
-
* export default function (app) {
|
|
882
|
-
* app.use(HighchartsVue);
|
|
883
|
-
* }
|
|
884
|
-
* ```
|
|
885
|
-
*
|
|
886
|
-
* Install HighCharts into custom folder:
|
|
887
|
-
*
|
|
888
|
-
* ```bashcreating rec
|
|
889
|
-
* cd custom
|
|
890
|
-
* npm init -y
|
|
891
|
-
* npm install highcharts highcharts-vue
|
|
892
|
-
* ```
|
|
893
|
-
*
|
|
894
|
-
* And specify vueUsesFile in AdminForth config:
|
|
895
|
-
*
|
|
896
|
-
* ```ts
|
|
897
|
-
* vueUsesFile: '@@/vue-uses.ts',
|
|
898
|
-
* ```
|
|
899
|
-
*
|
|
900
|
-
*/
|
|
901
|
-
vueUsesFile?: string,
|
|
902
|
-
/**
|
|
903
|
-
* Object to redefine default styles for AdminForth components. Use this file as reference for all possible adjustments https://github.com/devforth/adminforth/blob/main/adminforth/modules/styles.ts
|
|
904
|
-
*/
|
|
905
|
-
styles?: Object,
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Description of custom pages which will let register custom pages for custom routes in AdminForth.
|
|
909
|
-
*/
|
|
910
|
-
customPages?: Array<{
|
|
911
|
-
path: string,
|
|
912
|
-
component: AdminForthComponentDeclaration,
|
|
913
|
-
}>,
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* Function to return custom badge in side bar for users. Can return text or html
|
|
917
|
-
* If function is not passed or returns null, badge will not be shown.
|
|
918
|
-
* Execution is done on admin app load.
|
|
919
|
-
*/
|
|
920
|
-
announcementBadge?: (user: AdminUser) => { text?: string, html?: string, closable?: boolean, title?: string } | null,
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Custom panel components or array of components which will be displayed in the login form
|
|
924
|
-
* right after the inputs. Use it to add custom authorization methods like social login or other custom fields e.g. 'reset'
|
|
925
|
-
* password link.
|
|
926
|
-
*/
|
|
927
|
-
loginPageInjections?: {
|
|
928
|
-
underInputs?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* Custom panel components or array of components which will be displayed in different parts of the admin panel.
|
|
933
|
-
*/
|
|
934
|
-
globalInjections?: {
|
|
935
|
-
userMenu?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
936
|
-
header?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
937
|
-
sidebar?: AdminForthComponentDeclaration | Array<AdminForthComponentDeclaration>,
|
|
938
|
-
}
|
|
939
|
-
}
|
|
879
|
+
customization?: AdminForthInputConfigCustomization,
|
|
940
880
|
|
|
941
881
|
/**
|
|
942
882
|
* If you want to Serve AdminForth from a subdirectory, e.g. on example.com/backoffice, you can specify it like:
|
|
@@ -947,17 +887,46 @@ export interface AdminForthConfig {
|
|
|
947
887
|
*
|
|
948
888
|
*/
|
|
949
889
|
baseUrl?: string,
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
/**
|
|
953
|
-
* Whether to show delete confirmation dialog before deleting record.
|
|
954
|
-
* By default it is true.
|
|
955
|
-
*/
|
|
956
|
-
deleteConfirmation?: boolean,
|
|
957
|
-
|
|
958
|
-
|
|
890
|
+
|
|
959
891
|
}
|
|
960
892
|
|
|
893
|
+
|
|
894
|
+
export interface AdminForthConfigCustomization extends Omit<AdminForthInputConfigCustomization, 'loginPageInjections' | 'globalInjections'> {
|
|
895
|
+
brandName: string,
|
|
896
|
+
|
|
897
|
+
dateFormats: string,
|
|
898
|
+
timeFormat: string,
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Slug which will be used on tech side e.g. to store cookies separately.
|
|
902
|
+
* Created automatically from brandName if not set.
|
|
903
|
+
*/
|
|
904
|
+
brandNameSlug: string,
|
|
905
|
+
showBrandNameInSidebar: boolean,
|
|
906
|
+
customPages: Array<AdminForthPageDeclaration>,
|
|
907
|
+
|
|
908
|
+
loginPageInjections: {
|
|
909
|
+
underInputs: Array<AdminForthComponentDeclarationFull>,
|
|
910
|
+
},
|
|
911
|
+
|
|
912
|
+
globalInjections: {
|
|
913
|
+
userMenu: Array<AdminForthComponentDeclarationFull>,
|
|
914
|
+
header: Array<AdminForthComponentDeclarationFull>,
|
|
915
|
+
sidebar: Array<AdminForthComponentDeclarationFull>,
|
|
916
|
+
},
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
export interface AdminForthConfig extends Omit<AdminForthInputConfig, 'customization' | 'resources'> {
|
|
920
|
+
baseUrl: string;
|
|
921
|
+
baseUrlSlashed: string;
|
|
922
|
+
|
|
923
|
+
customization: AdminForthConfigCustomization,
|
|
924
|
+
|
|
925
|
+
resources: Array<AdminForthResource>,
|
|
926
|
+
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
|
|
961
930
|
// define typescript objects which I can instantiate as Filters.EQ(field, value) and they woudl
|
|
962
931
|
// return { field: field, operator: 'eq', value: value }. They should be exported with Filters namespace so I can import Filters from this file
|
|
963
932
|
// and use Filters.EQ(field, value) in my code
|
|
@@ -1051,16 +1020,20 @@ export type AllowedActionValue = boolean | (({adminUser, resource, meta, source,
|
|
|
1051
1020
|
/**
|
|
1052
1021
|
* Object which describes allowed actions for user.
|
|
1053
1022
|
*/
|
|
1054
|
-
export type
|
|
1023
|
+
export type AllowedActionsInput = {
|
|
1055
1024
|
[key in AllowedActionsEnum]?: AllowedActionValue
|
|
1056
1025
|
} & {
|
|
1057
1026
|
all?: AllowedActionValue;
|
|
1058
1027
|
}
|
|
1059
1028
|
|
|
1029
|
+
export type AllowedActions = {
|
|
1030
|
+
[key in AllowedActionsEnum]: AllowedActionValue
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1060
1033
|
/**
|
|
1061
1034
|
* General options for resource.
|
|
1062
1035
|
*/
|
|
1063
|
-
export
|
|
1036
|
+
export interface ResourceOptionsInput extends Omit<AdminForthResourceCommon['options'], 'allowedActions' | 'bulkActions'> {
|
|
1064
1037
|
|
|
1065
1038
|
/**
|
|
1066
1039
|
* Custom bulk actions list. Bulk actions available in list view when user selects multiple records by
|
|
@@ -1084,14 +1057,18 @@ export type ResourceOptions = Omit<AdminForthResourceCommon['options'], 'allowed
|
|
|
1084
1057
|
* ```
|
|
1085
1058
|
*
|
|
1086
1059
|
*/
|
|
1087
|
-
allowedActions?:
|
|
1060
|
+
allowedActions?: AllowedActionsInput,
|
|
1088
1061
|
};
|
|
1089
1062
|
|
|
1063
|
+
export interface ResourceOptions extends Omit<ResourceOptionsInput, 'allowedActions'> {
|
|
1064
|
+
allowedActions: AllowedActions,
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1090
1067
|
/**
|
|
1091
1068
|
* Resource describes one table or collection in database.
|
|
1092
1069
|
* AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
|
|
1093
1070
|
*/
|
|
1094
|
-
export interface AdminForthResource extends Omit<
|
|
1071
|
+
export interface AdminForthResource extends Omit<AdminForthResourceInput, 'options'> {
|
|
1095
1072
|
/**
|
|
1096
1073
|
* Array of plugins which will be used to modify resource configuration.
|
|
1097
1074
|
*
|
|
@@ -1175,11 +1152,17 @@ export interface AdminForthResource extends Omit<AdminForthResourceCommon, 'opti
|
|
|
1175
1152
|
},
|
|
1176
1153
|
},
|
|
1177
1154
|
|
|
1178
|
-
options
|
|
1155
|
+
options: ResourceOptions,
|
|
1179
1156
|
|
|
1180
1157
|
columns: Array<AdminForthResourceColumn>,
|
|
1181
1158
|
|
|
1182
|
-
dataSourceColumns
|
|
1159
|
+
dataSourceColumns: Array<AdminForthResourceColumn>,
|
|
1160
|
+
|
|
1161
|
+
recordLabel: (record: any) => string,
|
|
1162
|
+
|
|
1163
|
+
label: string,
|
|
1164
|
+
|
|
1165
|
+
resourceId: string,
|
|
1183
1166
|
}
|
|
1184
1167
|
|
|
1185
1168
|
export interface AdminForthBulkAction extends AdminForthBulkActionCommon {
|