@indice/ng-components 0.2.138-beta → 0.2.139

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.
Files changed (226) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +4 -4
  3. package/karma.conf.js +44 -0
  4. package/ng-package.json +10 -0
  5. package/package.json +18 -9
  6. package/scripts/css-bundle.ts +33 -0
  7. package/src/_styles.css +36 -0
  8. package/src/_tests/utilities.service.spec.ts +16 -0
  9. package/src/assets/styles/avatar-initials.css +37 -0
  10. package/src/assets/styles/base.css +46 -0
  11. package/src/assets/styles/cards.css +71 -0
  12. package/src/assets/styles/collapsible-panel.css +25 -0
  13. package/src/assets/styles/components.css +34 -0
  14. package/src/assets/styles/date-picker.component.css +0 -0
  15. package/src/assets/styles/drop-down-menu.css +50 -0
  16. package/src/assets/styles/form-layout.css +49 -0
  17. package/{_styles.css → src/assets/styles/indice-ng-icons-inline.css} +2286 -3504
  18. package/src/assets/styles/list-view-empty-state.css +0 -0
  19. package/src/assets/styles/list-view.css +64 -0
  20. package/{modal.css → src/assets/styles/modal.css} +157 -157
  21. package/src/assets/styles/model-view-layout.css +45 -0
  22. package/src/assets/styles/nav-links.css +35 -0
  23. package/src/assets/styles/notifications-indicator.component.css +43 -0
  24. package/src/assets/styles/pager.css +29 -0
  25. package/src/assets/styles/shell-layout.css +232 -0
  26. package/src/assets/styles/side-pane.css +46 -0
  27. package/src/assets/styles/side-view-layout.css +58 -0
  28. package/src/assets/styles/toast.css +72 -0
  29. package/src/assets/styles/toggle.css +26 -0
  30. package/src/assets/styles/view-layout.css +58 -0
  31. package/src/lib/controls/avatar-initials/avatar-initials.component.html +3 -0
  32. package/src/lib/controls/avatar-initials/avatar-initials.component.ts +47 -0
  33. package/src/lib/controls/collapsible-panel/collapsible-panel.component.html +15 -0
  34. package/src/lib/controls/collapsible-panel/collapsible-panel.component.ts +16 -0
  35. package/src/lib/controls/date-picker/date-picker.component.html +133 -0
  36. package/src/lib/controls/date-picker/date-picker.component.ts +258 -0
  37. package/src/lib/controls/drop-down-menu/drop-down-menu.component.html +61 -0
  38. package/src/lib/controls/drop-down-menu/drop-down-menu.component.ts +59 -0
  39. package/src/lib/controls/kpi-tile/kpi-tile.component.html +18 -0
  40. package/src/lib/controls/kpi-tile/kpi-tile.component.ts +26 -0
  41. package/src/lib/controls/list-view/list-column.component.ts +10 -0
  42. package/src/lib/controls/list-view/list-details-section.component.ts +8 -0
  43. package/src/lib/controls/list-view/list-tile.component.ts +8 -0
  44. package/src/lib/controls/list-view/list-view-empty-state.component.html +20 -0
  45. package/src/lib/controls/list-view/list-view-empty-state.component.ts +19 -0
  46. package/src/lib/controls/list-view/list-view.component.html +151 -0
  47. package/src/lib/controls/list-view/list-view.component.ts +146 -0
  48. package/src/lib/controls/nav-links-list/nav-links-list.component.html +27 -0
  49. package/src/lib/controls/nav-links-list/nav-links-list.component.ts +25 -0
  50. package/src/lib/controls/notifications-indicator/notifications-indicator.component.html +78 -0
  51. package/src/lib/controls/notifications-indicator/notifications-indicator.component.ts +75 -0
  52. package/src/lib/controls/pager/pager.component.html +33 -0
  53. package/src/lib/controls/pager/pager.component.ts +106 -0
  54. package/src/lib/controls/side-pane/side-pane.component.html +10 -0
  55. package/src/lib/controls/side-pane/side-pane.component.ts +59 -0
  56. package/src/lib/controls/skeleton-loader/skeleton-loader.component.html +112 -0
  57. package/src/lib/controls/skeleton-loader/skeleton-loader.component.ts +20 -0
  58. package/src/lib/controls/toaster/toaster-container.component.html +1 -0
  59. package/src/lib/controls/toaster/toaster-container.component.ts +27 -0
  60. package/src/lib/controls/toaster/toaster.component.html +103 -0
  61. package/src/lib/controls/toaster/toaster.component.ts +26 -0
  62. package/src/lib/controls/toggle/toggle.component.html +15 -0
  63. package/src/lib/controls/toggle/toggle.component.ts +58 -0
  64. package/src/lib/directives/click-outside.directive.ts +196 -0
  65. package/src/lib/directives/dynamic-component-host.directive.ts +7 -0
  66. package/src/lib/directives/screen-size.directive.ts +67 -0
  67. package/src/lib/helpers/base-list.component.ts +204 -0
  68. package/src/lib/icons.ts +39 -0
  69. package/src/lib/layouts/shell/shell-footer/shell-footer.component.html +71 -0
  70. package/src/lib/layouts/shell/shell-footer/shell-footer.component.ts +14 -0
  71. package/src/lib/layouts/shell/shell-header/shell-header.component.html +199 -0
  72. package/src/lib/layouts/shell/shell-header/shell-header.component.ts +111 -0
  73. package/src/lib/layouts/shell/shell-layout/shell-layout.component.html +36 -0
  74. package/src/lib/layouts/shell/shell-layout/shell-layout.component.ts +91 -0
  75. package/src/lib/layouts/views/form-layout/form-layout.component.html +67 -0
  76. package/src/lib/layouts/views/form-layout/form-layout.component.ts +66 -0
  77. package/src/lib/layouts/views/model-view-layout/model-view-layout.component.html +43 -0
  78. package/src/lib/layouts/views/model-view-layout/model-view-layout.component.ts +37 -0
  79. package/src/lib/layouts/views/side-view-layout/side-view-layout.component.html +36 -0
  80. package/src/lib/layouts/views/side-view-layout/side-view-layout.component.ts +67 -0
  81. package/src/lib/layouts/views/view-layout/view-layout.component.html +68 -0
  82. package/src/lib/layouts/views/view-layout/view-layout.component.ts +82 -0
  83. package/src/lib/ng-components.module.ts +135 -0
  84. package/src/lib/pages/auth/auth-callback/auth-callback.component.html +1 -0
  85. package/src/lib/pages/auth/auth-callback/auth-callback.component.ts +22 -0
  86. package/src/lib/pages/auth/auth-renew/auth-renew.component.ts +20 -0
  87. package/src/lib/pages/auth/logged-out/logged-out.component.html +1 -0
  88. package/src/lib/pages/auth/logged-out/logged-out.component.ts +22 -0
  89. package/src/lib/pages/http-status/error/error.component.html +13 -0
  90. package/src/lib/pages/http-status/error/error.component.ts +13 -0
  91. package/src/lib/pages/http-status/page-not-found/page-not-found.component.html +14 -0
  92. package/src/lib/pages/http-status/page-not-found/page-not-found.component.ts +14 -0
  93. package/src/lib/pages/http-status/unauthorized/unauthorized.component.html +15 -0
  94. package/src/lib/pages/http-status/unauthorized/unauthorized.component.ts +11 -0
  95. package/src/lib/pipes/address.pipe.ts +17 -0
  96. package/src/lib/pipes/duration-format.pipe.ts +67 -0
  97. package/src/lib/services/component-loader/component-loader-options.class.ts +31 -0
  98. package/src/lib/services/component-loader/component-loader.class.ts +226 -0
  99. package/src/lib/services/component-loader/component-loader.factory.ts +27 -0
  100. package/src/lib/services/component-loader/content-ref.class.ts +10 -0
  101. package/src/lib/services/interceptors/bad-request.interceptor.ts +34 -0
  102. package/src/lib/services/modal-service/modal-backdrop-component.ts +40 -0
  103. package/src/lib/services/modal-service/modal-container-component.ts +125 -0
  104. package/src/lib/services/modal-service/modal-options.class.ts +92 -0
  105. package/src/lib/services/modal-service/modal-service.ts +237 -0
  106. package/src/lib/services/modal-service/modal-styles.class.ts +11 -0
  107. package/src/lib/services/modal-service/modal.class.ts +45 -0
  108. package/src/lib/services/shell-state-service.service.ts +10 -0
  109. package/src/lib/services/toaster.service.ts +23 -0
  110. package/src/lib/services/utilities.service.ts +40 -0
  111. package/src/lib/tokens.ts +6 -0
  112. package/src/lib/types.ts +210 -0
  113. package/{public-api.d.ts → src/public-api.ts} +60 -43
  114. package/src/test.ts +28 -0
  115. package/tsconfig.lib.json +26 -0
  116. package/tsconfig.lib.prod.json +10 -0
  117. package/tsconfig.spec.json +17 -0
  118. package/tslint.json +17 -0
  119. package/webpack.config.js +36 -0
  120. package/bundles/indice-ng-components.umd.js +0 -3784
  121. package/bundles/indice-ng-components.umd.js.map +0 -1
  122. package/esm2015/indice-ng-components.js +0 -5
  123. package/esm2015/lib/controls/avatar-initials/avatar-initials.component.js +0 -51
  124. package/esm2015/lib/controls/collapsible-panel/collapsible-panel.component.js +0 -23
  125. package/esm2015/lib/controls/date-picker/date-picker.component.js +0 -269
  126. package/esm2015/lib/controls/drop-down-menu/drop-down-menu.component.js +0 -72
  127. package/esm2015/lib/controls/kpi-tile/kpi-tile.component.js +0 -39
  128. package/esm2015/lib/controls/list-view/list-column.component.js +0 -25
  129. package/esm2015/lib/controls/list-view/list-details-section.component.js +0 -17
  130. package/esm2015/lib/controls/list-view/list-tile.component.js +0 -17
  131. package/esm2015/lib/controls/list-view/list-view-empty-state.component.js +0 -32
  132. package/esm2015/lib/controls/list-view/list-view.component.js +0 -186
  133. package/esm2015/lib/controls/pager/pager.component.js +0 -133
  134. package/esm2015/lib/controls/side-pane/side-pane.component.js +0 -76
  135. package/esm2015/lib/controls/skeleton-loader/skeleton-loader.component.js +0 -29
  136. package/esm2015/lib/controls/toaster/toaster-container.component.js +0 -31
  137. package/esm2015/lib/controls/toaster/toaster.component.js +0 -34
  138. package/esm2015/lib/controls/toggle/toggle.component.js +0 -68
  139. package/esm2015/lib/directives/click-outside.directive.js +0 -189
  140. package/esm2015/lib/directives/dynamic-component-host.directive.js +0 -17
  141. package/esm2015/lib/helpers/base-list.component.js +0 -182
  142. package/esm2015/lib/icons.js +0 -32
  143. package/esm2015/lib/layouts/shell/shell-footer/shell-footer.component.js +0 -22
  144. package/esm2015/lib/layouts/shell/shell-header/shell-header.component.js +0 -142
  145. package/esm2015/lib/layouts/shell/shell-layout/shell-layout.component.js +0 -101
  146. package/esm2015/lib/layouts/views/form-layout/form-layout.component.js +0 -86
  147. package/esm2015/lib/layouts/views/model-view-layout/model-view-layout.component.js +0 -55
  148. package/esm2015/lib/layouts/views/side-view-layout/side-view-layout.component.js +0 -101
  149. package/esm2015/lib/layouts/views/view-layout/view-layout.component.js +0 -110
  150. package/esm2015/lib/ng-components.module.js +0 -220
  151. package/esm2015/lib/pages/auth/auth-callback/auth-callback.component.js +0 -34
  152. package/esm2015/lib/pages/auth/auth-renew/auth-renew.component.js +0 -31
  153. package/esm2015/lib/pages/auth/logged-out/logged-out.component.js +0 -32
  154. package/esm2015/lib/pages/http-status/error/error.component.js +0 -20
  155. package/esm2015/lib/pages/http-status/page-not-found/page-not-found.component.js +0 -18
  156. package/esm2015/lib/pages/http-status/unauthorized/unauthorized.component.js +0 -17
  157. package/esm2015/lib/pipes/address.pipe.js +0 -21
  158. package/esm2015/lib/pipes/duration-format.pipe.js +0 -64
  159. package/esm2015/lib/pipes/obs-with-status.pipe.js +0 -26
  160. package/esm2015/lib/services/component-loader/component-loader-options.class.js +0 -8
  161. package/esm2015/lib/services/component-loader/component-loader.class.js +0 -192
  162. package/esm2015/lib/services/component-loader/component-loader.factory.js +0 -32
  163. package/esm2015/lib/services/component-loader/content-ref.class.js +0 -13
  164. package/esm2015/lib/services/modal-service/modal-backdrop-component.js +0 -44
  165. package/esm2015/lib/services/modal-service/modal-container-component.js +0 -128
  166. package/esm2015/lib/services/modal-service/modal-options.class.js +0 -35
  167. package/esm2015/lib/services/modal-service/modal-service.js +0 -220
  168. package/esm2015/lib/services/modal-service/modal-styles.class.js +0 -11
  169. package/esm2015/lib/services/modal-service/modal.class.js +0 -27
  170. package/esm2015/lib/services/toaster.service.js +0 -24
  171. package/esm2015/lib/tokens.js +0 -4
  172. package/esm2015/lib/types.js +0 -114
  173. package/esm2015/public-api.js +0 -53
  174. package/fesm2015/indice-ng-components.js +0 -3247
  175. package/fesm2015/indice-ng-components.js.map +0 -1
  176. package/indice-ng-components.d.ts +0 -5
  177. package/lib/controls/avatar-initials/avatar-initials.component.d.ts +0 -14
  178. package/lib/controls/collapsible-panel/collapsible-panel.component.d.ts +0 -10
  179. package/lib/controls/date-picker/date-picker.component.d.ts +0 -48
  180. package/lib/controls/drop-down-menu/drop-down-menu.component.d.ts +0 -25
  181. package/lib/controls/kpi-tile/kpi-tile.component.d.ts +0 -13
  182. package/lib/controls/list-view/list-column.component.d.ts +0 -9
  183. package/lib/controls/list-view/list-details-section.component.d.ts +0 -7
  184. package/lib/controls/list-view/list-tile.component.d.ts +0 -7
  185. package/lib/controls/list-view/list-view-empty-state.component.d.ts +0 -11
  186. package/lib/controls/list-view/list-view.component.d.ts +0 -55
  187. package/lib/controls/pager/pager.component.d.ts +0 -36
  188. package/lib/controls/side-pane/side-pane.component.d.ts +0 -18
  189. package/lib/controls/skeleton-loader/skeleton-loader.component.d.ts +0 -11
  190. package/lib/controls/toaster/toaster-container.component.d.ts +0 -13
  191. package/lib/controls/toaster/toaster.component.d.ts +0 -15
  192. package/lib/controls/toggle/toggle.component.d.ts +0 -19
  193. package/lib/directives/click-outside.directive.d.ts +0 -40
  194. package/lib/directives/dynamic-component-host.directive.d.ts +0 -9
  195. package/lib/helpers/base-list.component.d.ts +0 -42
  196. package/lib/icons.d.ts +0 -30
  197. package/lib/layouts/shell/shell-footer/shell-footer.component.d.ts +0 -8
  198. package/lib/layouts/shell/shell-header/shell-header.component.d.ts +0 -45
  199. package/lib/layouts/shell/shell-layout/shell-layout.component.d.ts +0 -27
  200. package/lib/layouts/views/form-layout/form-layout.component.d.ts +0 -25
  201. package/lib/layouts/views/model-view-layout/model-view-layout.component.d.ts +0 -25
  202. package/lib/layouts/views/side-view-layout/side-view-layout.component.d.ts +0 -28
  203. package/lib/layouts/views/view-layout/view-layout.component.d.ts +0 -31
  204. package/lib/ng-components.module.d.ts +0 -45
  205. package/lib/pages/auth/auth-callback/auth-callback.component.d.ts +0 -13
  206. package/lib/pages/auth/auth-renew/auth-renew.component.d.ts +0 -12
  207. package/lib/pages/auth/logged-out/logged-out.component.d.ts +0 -12
  208. package/lib/pages/http-status/error/error.component.d.ts +0 -8
  209. package/lib/pages/http-status/page-not-found/page-not-found.component.d.ts +0 -8
  210. package/lib/pages/http-status/unauthorized/unauthorized.component.d.ts +0 -8
  211. package/lib/pipes/address.pipe.d.ts +0 -8
  212. package/lib/pipes/duration-format.pipe.d.ts +0 -8
  213. package/lib/pipes/obs-with-status.pipe.d.ts +0 -13
  214. package/lib/services/component-loader/component-loader-options.class.d.ts +0 -30
  215. package/lib/services/component-loader/component-loader.class.d.ts +0 -92
  216. package/lib/services/component-loader/component-loader.factory.d.ts +0 -24
  217. package/lib/services/component-loader/content-ref.class.d.ts +0 -12
  218. package/lib/services/modal-service/modal-backdrop-component.d.ts +0 -20
  219. package/lib/services/modal-service/modal-container-component.d.ts +0 -33
  220. package/lib/services/modal-service/modal-options.class.d.ts +0 -81
  221. package/lib/services/modal-service/modal-service.d.ts +0 -58
  222. package/lib/services/modal-service/modal-styles.class.d.ts +0 -10
  223. package/lib/services/modal-service/modal.class.d.ts +0 -43
  224. package/lib/services/toaster.service.d.ts +0 -11
  225. package/lib/tokens.d.ts +0 -4
  226. package/lib/types.d.ts +0 -135
@@ -0,0 +1,111 @@
1
+ import { AuthService } from '@indice/ng-auth';
2
+ import { Component, OnInit, OnDestroy, Inject, Input } from '@angular/core';
3
+ import { User } from 'oidc-client';
4
+ import { ActivatedRoute, Event, NavigationStart, Router } from '@angular/router';
5
+ import { filter, share } from 'rxjs/operators';
6
+ import { NavLink } from '../../../types';
7
+ import { APP_LINKS, SHELL_CONFIG } from '../../../tokens';
8
+ import { BehaviorSubject, isObservable, observable, Observable, of } from 'rxjs';
9
+ import { Subscription } from 'rxjs';
10
+
11
+ @Component({
12
+ // tslint:disable-next-line:component-selector
13
+ selector: 'lib-shell-header',
14
+ templateUrl: './shell-header.component.html',
15
+ })
16
+ export class ShellHeaderComponent implements OnInit, OnDestroy {
17
+ // tslint:disable-next-line:no-input-rename
18
+ @Input('section-links') sectionLinksPath = 'main';
19
+ // tslint:disable-next-line:no-input-rename
20
+ @Input('profile-menu') profileMenuVisible = true;
21
+ // tslint:disable-next-line:no-input-rename
22
+ @Input('show-userName') showUserNameOnHeader: boolean | undefined = false;
23
+ // tslint:disable-next-line:no-input-rename
24
+ @Input('show-alerts') showAlerts: boolean | undefined = false;
25
+ @Input() langs: string[] | undefined;
26
+ // tslint:disable-next-line:no-input-rename
27
+ @Input('current-lang') currentLang: string | undefined;
28
+ @Input() border = true;
29
+ public sectionLinks: Observable<NavLink[]> = of([]);
30
+ public mobileMenuExpanded = false;
31
+ public userMenuExpanded = false;
32
+ protected routeSubject: Observable<Event>;
33
+ protected routerSub$: Subscription | null = null;
34
+ protected userSub$: Subscription | null = null;
35
+ protected statusSub$: Subscription | null = null;
36
+ public user: User | null = null;
37
+ public avatarName: string | null = null;
38
+ public activeFragment: any | null = null;
39
+
40
+ constructor(
41
+ @Inject(AuthService) protected authService: AuthService,
42
+ @Inject(Router) protected router: Router,
43
+ @Inject(ActivatedRoute) protected route: ActivatedRoute,
44
+ @Inject(SHELL_CONFIG) public config: any,
45
+ @Inject(APP_LINKS) public links: any) {
46
+ this.routeSubject = this.router.events.pipe(filter((event) => event instanceof NavigationStart));
47
+ }
48
+
49
+ ngOnInit(): void {
50
+ this.activeFragment = this.route.fragment.pipe(share());
51
+ this.sectionLinks = this.links[this.sectionLinksPath] as Observable<NavLink[]>;
52
+ this.routerSub$ = this.routeSubject.subscribe((event) => {
53
+ this.mobileMenuExpanded = false;
54
+ this.userMenuExpanded = false;
55
+ });
56
+ this.authService.loadUser().subscribe((user) => {
57
+ this.setCurrentUser(user);
58
+ }, error => {
59
+ console.error(error);
60
+ });
61
+ // Detect user changes and display / or not user info accordingly...
62
+ this.userSub$ = this.authService.user$.subscribe((user: any) => {
63
+ // console.log('ShellHeaderComponent user subscription');
64
+ this.setCurrentUser(user);
65
+ });
66
+ // set current lang if no current value from langs if any
67
+ if (!this.currentLang && this.langs && this.langs.length > 0) {
68
+ this.setCurrentLang(this.langs[0]);
69
+ }
70
+ }
71
+
72
+ ngOnDestroy(): void {
73
+
74
+ if (this.routerSub$) {
75
+ this.routerSub$.unsubscribe();
76
+ }
77
+ // TODO: check authenticated user here before we start polling server status
78
+ if (this.statusSub$) {
79
+ this.statusSub$.unsubscribe();
80
+ }
81
+ if (this.userSub$) {
82
+ this.userSub$.unsubscribe();
83
+ }
84
+ }
85
+
86
+
87
+
88
+ // tslint:disable-next-line:typedef
89
+ public onClickOutside($event: any) {
90
+ this.userMenuExpanded = false;
91
+ }
92
+
93
+ public signin(event: any | null | undefined): void {
94
+ if (event) {
95
+ event.preventDefault();
96
+ }
97
+ this.authService.signinRedirect();
98
+ }
99
+
100
+ private setCurrentUser(user: any): void {
101
+ this.user = user;
102
+ if (this.user && this.user.profile) {
103
+ this.avatarName = `${this.user.profile.given_name?.charAt(0)}${this.user.profile.family_name?.charAt(0)}`.toUpperCase();
104
+ }
105
+ }
106
+
107
+ public setCurrentLang(lang: any): void {
108
+ this.currentLang = lang;
109
+ }
110
+ }
111
+
@@ -0,0 +1,36 @@
1
+ <div *ngIf="loaded" [style.display]="!loaded ? 'none':'block'" class="shell-container active-side-pane">
2
+
3
+ <div class="shell-header-container" *ngIf="activeConfig.showHeader">
4
+ <div [class]="activeConfig.fluid ? 'shell-header-container-inner-fluid' : 'shell-header-container-inner'">
5
+ <ng-container *ngIf="activeConfig.customHeaderComponent">
6
+ <div appDynamicComponentHost ="Header"></div>
7
+ </ng-container>
8
+ <lib-shell-header *ngIf="!activeConfig.customHeaderComponent"
9
+ [langs]="activeConfig.langs"
10
+ [show-userName]="activeConfig.showUserNameOnHeader"
11
+ [show-alerts]="activeConfig.showAlertsOnHeader"></lib-shell-header>
12
+ </div>
13
+ </div>
14
+
15
+ <main [class]="activeConfig.showHeader ? 'shell-content-container' : 'shell-content-container-no-header'">
16
+ <div [class]="activeConfig.fluid ? 'shell-content-container-inner-fluid' : 'shell-content-container-inner'">
17
+ <router-outlet></router-outlet>
18
+ </div>
19
+ </main>
20
+
21
+ <div class="shell-footer-container" *ngIf="activeConfig.showFooter">
22
+ <div [class]="activeConfig.fluid ? 'shell-footer-container-inner-fluid' : 'shell-footer-container-inner'">
23
+ <ng-container *ngIf="activeConfig.customFooterComponent">
24
+ <div appDynamicComponentHost hostName="Footer"></div>
25
+ </ng-container>
26
+ <lib-shell-footer *ngIf="!activeConfig.customFooterComponent"></lib-shell-footer>
27
+ </div>
28
+ </div>
29
+
30
+ <lib-side-pane #rightPane>
31
+ <router-outlet name="rightpane" (activate)="rightPane.onSidePaneActivated($event)" (deactivate)="rightPane.onSidePaneDeactivated($event)"></router-outlet>
32
+ </lib-side-pane>
33
+
34
+ <lib-toaster-container></lib-toaster-container>
35
+
36
+ </div>
@@ -0,0 +1,91 @@
1
+ import { SHELL_CONFIG } from './../../../tokens';
2
+ import { IShellConfig, DefaultShellConfig } from './../../../types';
3
+ import { AfterViewInit, Component, OnInit, OnDestroy, Inject, ViewChildren, QueryList, AfterViewChecked } from '@angular/core';
4
+ import { DOCUMENT, Location } from '@angular/common';
5
+ import { ActivationStart, Router } from '@angular/router';
6
+ import { filter } from 'rxjs/operators';
7
+ import { Subscription, timer } from 'rxjs';
8
+ import { DynamicComponentHostDirective } from '../../../directives/dynamic-component-host.directive';
9
+ import { ComponentLoaderFactory } from '../../../services/component-loader/component-loader.factory';
10
+
11
+ @Component({
12
+ // tslint:disable-next-line:component-selector
13
+ selector: 'lib-shell-layout',
14
+ templateUrl: './shell-layout.component.html',
15
+ })
16
+ export class ShellLayoutComponent implements OnInit, OnDestroy, AfterViewInit, AfterViewChecked {
17
+ @ViewChildren(DynamicComponentHostDirective)
18
+ dynamicComponentHosts: QueryList<DynamicComponentHostDirective> | null = null;
19
+ public showRightPaneSM = false;
20
+ private routerSub$: Subscription | null = null;
21
+ public activeConfig: IShellConfig = new DefaultShellConfig();
22
+ public loaded = false;
23
+ constructor(
24
+ @Inject(DOCUMENT) private document: any,
25
+ private router: Router,
26
+ private location: Location,
27
+ @Inject(SHELL_CONFIG) private config: IShellConfig | null,
28
+ private componentLoaderFactory: ComponentLoaderFactory
29
+ ) {
30
+ if (!config) {
31
+ config = new DefaultShellConfig();
32
+ }
33
+ this.activeConfig = config;
34
+ }
35
+
36
+ ngAfterViewChecked(): void {
37
+ setTimeout(() => { this.loaded = true; }, 200);
38
+ }
39
+
40
+ ngOnInit(): void {
41
+ this.routerSub$ = this.router.events.pipe(filter((event) => event instanceof ActivationStart)).subscribe((e) => {
42
+ // console.log('ShellLayoutComponent ActivationStart', e);
43
+ if ((e as ActivationStart)?.snapshot) {
44
+ // console.log('ShellLayoutComponent ActivationStart snapshot', (e as ActivationStart)?.snapshot);
45
+ if ((e as ActivationStart)?.snapshot?.data) {
46
+ // console.log('ShellLayoutComponent ActivationStart snapshot data', (e as ActivationStart)?.snapshot.data);
47
+ if ((e as ActivationStart)?.snapshot?.data.shell) {
48
+ // console.log('ShellLayoutComponent ActivationStart snapshot data shell params',
49
+ // (e as ActivationStart)?.snapshot.data.shell);
50
+ this.activeConfig = (e as ActivationStart)?.snapshot.data.shell as IShellConfig;
51
+ // console.log('ShellLayoutComponent activeConfig from route: ', this.activeConfig);
52
+ if (this.activeConfig.customHeaderComponent) {
53
+ this.initCustomComponents();
54
+ }
55
+ } else {
56
+ this.activeConfig = this.config ? this.config : new DefaultShellConfig();
57
+ // console.log('ShellLayoutComponent default activeConfig: ', this.activeConfig);
58
+ }
59
+ }
60
+ }
61
+ });
62
+ }
63
+
64
+ ngAfterViewInit(): void {
65
+ this.initCustomComponents();
66
+ }
67
+
68
+ private initCustomComponents(): void {
69
+ if (this.dynamicComponentHosts && this.dynamicComponentHosts.length > 0) {
70
+ this.loadCustomComponent(this.dynamicComponentHosts.find((_) => _.hostName === 'Header'));
71
+ // since you're not using it...
72
+ // this.loadCustomComponent(this.dynamicComponentHosts.find(_ => _.hostName === 'Footer'));
73
+ }
74
+ }
75
+
76
+ ngOnDestroy(): void {
77
+ if (this.routerSub$) {
78
+ this.routerSub$.unsubscribe();
79
+ }
80
+ }
81
+
82
+ private loadCustomComponent(host: DynamicComponentHostDirective | undefined): void {
83
+ if (host) {
84
+ const viewContainerRef = host.viewContainerRef;
85
+ if (viewContainerRef && this.activeConfig.customHeaderComponent) {
86
+ const clf = this.componentLoaderFactory.createLoader(viewContainerRef);
87
+ const headerCompRef = clf.attach(this.activeConfig.customHeaderComponent).to(viewContainerRef.element).show();
88
+ }
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,67 @@
1
+ <div class="form-layout-container">
2
+ <div class="form-header" *ngIf="title || subTitle || actions">
3
+ <div class="form-header-inner">
4
+ <h3 class="form-title">
5
+ {{ title }}
6
+ </h3>
7
+ <p class="form-subtitle">
8
+ {{ subTitle }}
9
+ </p>
10
+ </div>
11
+ <div class="form-header-actions">
12
+ <ng-container *ngFor="let action of actions" [ngSwitch]="action.type">
13
+ <ng-container *ngSwitchCase="'search'">
14
+ <label for="search" class="sr-only">Search</label>
15
+ <div class="search-container">
16
+ <div class="pointer-events-none absolute inset-y-0 left-0 pl-3 flex items-center">
17
+ <!--<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
18
+ <path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
19
+ </svg>-->
20
+ </div>
21
+ <input id="search"
22
+ #search
23
+ class="form-search-input"
24
+ [placeholder]="searchPlaceholder"
25
+ type="search"
26
+ name="search"
27
+ (input)="searchActionType(search.value)">
28
+ </div>
29
+ <button type="button"
30
+ href="#"
31
+ class="btn-form-view-header-search"
32
+ [title]="action.tooltip"
33
+ (click)="searchActionClick(action, search.value)">
34
+ <i [class]="action.icon"></i>
35
+ </button>
36
+ </ng-container>
37
+ <ng-container *ngSwitchCase="'router-link'">
38
+ <button type="button"
39
+ href="#"
40
+ class="ml-1 btn-form-view-header"
41
+ [title]="action.tooltip"
42
+ (click)="routerLinkActionClick(action)">
43
+ <i [class]="action.icon"></i>
44
+ </button>
45
+ </ng-container>
46
+ <ng-container *ngSwitchDefault>
47
+ <button type="button"
48
+ class="ml-1 btn-form-view-header"
49
+ [title]="action.tooltip"
50
+ (click)="emitActionClick(action)">
51
+ <i [class]="action.icon"></i>
52
+ </button>
53
+ </ng-container>
54
+ </ng-container>
55
+ </div>
56
+ </div>
57
+ <div class="form-content-container">
58
+ <div [ngClass]="{'form-content-container-inner': actions}">
59
+ <ng-content></ng-content>
60
+ </div>
61
+ </div>
62
+ <lib-side-pane #formPane (onComplete)="onSidePaneDeactivated($event)">
63
+ <router-outlet name="formRightPane"
64
+ (activate)="formPane.onSidePaneActivated($event)"
65
+ (deactivate)="formPane.onSidePaneDeactivated($event)"></router-outlet>
66
+ </lib-side-pane>
67
+ </div>
@@ -0,0 +1,66 @@
1
+ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { fromEvent } from 'rxjs';
4
+ import { map, filter, debounceTime, distinctUntilChanged } from 'rxjs/operators';
5
+ import { RouterViewAction, ViewAction } from '../../../types';
6
+
7
+ @Component({
8
+ selector: 'lib-form-layout',
9
+ templateUrl: './form-layout.component.html'
10
+ })
11
+ export class FormLayoutComponent implements OnInit {
12
+ // tslint:disable-next-line:no-input-rename
13
+ @ViewChild('search') private searchInput$?: ElementRef;
14
+ @Input() title: string | null = null;
15
+ // tslint:disable-next-line:no-input-rename
16
+ @Input('search-placeholder') searchPlaceholder: string | null = 'αναζήτηση'
17
+ @Input() actions: ViewAction[] | null = null;
18
+ // tslint:disable-next-line:no-input-rename
19
+ @Input('sub-title') subTitle: string | null = null;
20
+ // tslint:disable-next-line:no-output-on-prefix
21
+ @Output() onAction: EventEmitter<ViewAction> = new EventEmitter<ViewAction>();
22
+ // tslint:disable-next-line:no-output-on-prefix
23
+ @Output() onSearch: EventEmitter<string> = new EventEmitter<string>();
24
+ @Output() onComplete: EventEmitter<boolean> = new EventEmitter<boolean>();
25
+
26
+ constructor(private router$: Router) { }
27
+
28
+ ngOnInit(): void {
29
+ if (this.searchInput$?.nativeElement){
30
+ fromEvent(this.searchInput$.nativeElement, 'keyup').pipe(
31
+ map((event: any) => {
32
+ return event.target.value; // Get input value.
33
+ }),
34
+ filter(inputValue => inputValue.length >= 3 || inputValue.length === 0),
35
+ // If character length greater than minimumSearchCharacters setting.
36
+ debounceTime(1000), // Time in milliseconds between key events.
37
+ distinctUntilChanged() // If previous query is different from current.
38
+ ).subscribe();
39
+ }
40
+ }
41
+
42
+ public onSidePaneDeactivated($event: any): void {
43
+ this.onComplete.emit(true);
44
+ }
45
+
46
+ public emitActionClick(action: ViewAction): void {
47
+ this.onAction.emit(action);
48
+ }
49
+
50
+ searchActionClick(action: ViewAction, text: string): void {
51
+ this.onSearch.emit(text);
52
+ }
53
+
54
+ searchActionType(text: string): void {
55
+ this.onSearch.emit(this.searchInput$?.nativeElement.value);
56
+ }
57
+
58
+ public routerLinkActionClick(action: RouterViewAction | any, relative: boolean = false): void {
59
+ if (action.outlet) {
60
+ this.router$.navigate(['', { outlets: { formRightPane: action.link } }]);
61
+ } else {
62
+ this.router$.navigate([action.link]);
63
+ }
64
+ }
65
+
66
+ }
@@ -0,0 +1,43 @@
1
+ <lib-view-layout [title]="title" [meta-items]="metaItems">
2
+ <main class="model-view-container">
3
+ <div class="model-view-container-inner">
4
+ <aside class="model-view-aside">
5
+ <section aria-labelledby="menu" class="details-view-aside-header-section">
6
+ <div class="model-view-aside-header-container">
7
+ <div class="model-view-aside-header-container-inner">
8
+ <ng-content></ng-content>
9
+ </div>
10
+ <!-- menu items -->
11
+ <div class="model-view-menu-container">
12
+ <nav class="model-view-menu-nav">
13
+ <div class="model-view-menu-item">
14
+ <ng-container *ngFor="let section of primary">
15
+ <a href="#"
16
+ [routerLinkActive]="['view-nav-link-active']"
17
+ [routerLink]="section.link"
18
+ class="view-nav-link">
19
+ {{section.text}}
20
+ </a>
21
+ </ng-container>
22
+ </div>
23
+ <div class="model-view-menu-item-far">
24
+ <ng-container *ngFor="let section of secondary">
25
+ <a href="#"
26
+ [routerLinkActive]="['view-nav-link-active']"
27
+ [routerLinkActiveOptions]="{ exact: true }"
28
+ [routerLink]="section.link"
29
+ class="view-nav-link">
30
+ {{section.text}}
31
+ </a>
32
+ </ng-container>
33
+ </div>
34
+ </nav>
35
+ </div>
36
+ </div>
37
+ </section>
38
+ </aside>
39
+ <div class="model-view-details-container">
40
+ <router-outlet></router-outlet>
41
+ </div>
42
+ </div>
43
+ </main>
@@ -0,0 +1,37 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { Location } from '@angular/common';
3
+ import { HeaderMetaItem } from '../../../types';
4
+
5
+ @Component({
6
+ // tslint:disable-next-line:component-selector
7
+ selector: 'lib-model-view-layout',
8
+ templateUrl: './model-view-layout.component.html'
9
+ })
10
+ export class ModelViewLayoutComponent implements OnInit {
11
+ public showRightPaneSM = false;
12
+ @Input() title = 'no title';
13
+ // tslint:disable-next-line:no-input-rename
14
+ @Input('primary-links') primary: { text: string, link: string }[] | null = null;
15
+ // tslint:disable-next-line:no-input-rename
16
+ @Input('secondary-links') secondary: { text: string, link: string }[] | null = null;
17
+ // tslint:disable-next-line:no-input-rename
18
+ @Input('meta-items') metaItems: HeaderMetaItem[] | null = [
19
+ // { key: 'test', icon: Icons.Badges, text: 'βρέθηκαν 200 αποτελέσματα' }
20
+ ];
21
+ constructor( private location: Location) { }
22
+
23
+ ngOnInit(): void {
24
+ }
25
+
26
+ public onSidePaneActivated($event: any): void {
27
+ this.showRightPaneSM = true;
28
+ }
29
+
30
+ public onSidePaneDeactivated($event: any): void {
31
+ this.showRightPaneSM = false;
32
+ }
33
+
34
+ public closeSidePane(): void {
35
+ this.location.back();
36
+ }
37
+ }
@@ -0,0 +1,36 @@
1
+ <div class="side-view-layout-size-box">
2
+ <div class="side-view-layout-container">
3
+ <div class="side-view-layout-container-inner">
4
+ <div class="side-view-layout-header-margins">
5
+ <div class="side-view-layout-header-container">
6
+ <h2 class="side-view-layout-header-title" id="slide-over-title">
7
+ {{title}}
8
+ </h2>
9
+ <div class="side-view-layout-close-button-container">
10
+ <button (click)="emitClose()" class="side-view-layout-close-button">
11
+ <span class="sr-only">Close panel</span>
12
+ <!-- Heroicon name: outline/x -->
13
+ <svg class="side-view-layout-close-button-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
14
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
15
+ </svg>
16
+ </button>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <div class="side-view-layout-content-container">
21
+ <!-- Replace with your content -->
22
+ <ng-content></ng-content>
23
+ <!-- /End replace -->
24
+ </div>
25
+ </div>
26
+ <div *ngIf="showActions" class="side-view-layout-actions-container">
27
+ <button *ngIf="cancelShow" (click)="emitCancel()" type="button" class="side-view-layout-action-button-cancel">
28
+ {{cancelLabel}}
29
+ </button>
30
+ <button *ngIf="okShow" (click)="emitOK()" class="side-view-layout-action-button-submit" [disabled]="disabled">
31
+ {{okLabel}}
32
+ </button>
33
+ </div>
34
+ </div>
35
+ </div>
36
+
@@ -0,0 +1,67 @@
1
+ import { Router } from '@angular/router';
2
+ import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
3
+ import { Location } from '@angular/common';
4
+
5
+ @Component({
6
+ selector: 'lib-side-view-layout',
7
+ templateUrl: './side-view-layout.component.html'
8
+ })
9
+ export class SideViewLayoutComponent implements OnInit {
10
+ @Input() title: string | null = 'Πληροφορίες';
11
+ @Input() showActions = true;
12
+ @Input() disabled = false;
13
+ // tslint:disable-next-line:no-input-rename
14
+ @Input('return-path') returnPath: string | undefined;
15
+ // tslint:disable-next-line:no-input-rename
16
+ @Input('ok-label') okLabel = 'Αποθήκευση';
17
+ // tslint:disable-next-line:no-input-rename
18
+ @Input('ok-show') okShow = true;
19
+ // tslint:disable-next-line:no-input-rename
20
+ @Input('ok-close-dialog') closeOnOk = true;
21
+ // tslint:disable-next-line:no-input-rename
22
+ @Input('cancel-label') cancelLabel = 'Ακύρωση';
23
+ // tslint:disable-next-line:no-input-rename
24
+ @Input('cancel-show') cancelShow = true;
25
+ // tslint:disable-next-line:no-input-rename
26
+ @Input('force-location-back') forceLocationBack = false;
27
+ // @Output() close = new EventEmitter<any>();
28
+ @Output() cancel: EventEmitter<boolean> = new EventEmitter();
29
+ @Output() ok: EventEmitter<boolean> = new EventEmitter();
30
+
31
+ constructor(private location: Location, private router: Router) { }
32
+
33
+ ngOnInit(): void {
34
+ }
35
+
36
+ public closeSidePane(): void {
37
+ if (this.returnPath) {
38
+ this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => this.router.navigateByUrl(this.returnPath || '/'));
39
+ } else {
40
+ if ((this.router.url.split('/(')[0] !== this.router.url) && !this.forceLocationBack) {
41
+ this.router.navigateByUrl(this.router.url.split('/(')[0]);
42
+ } else if ((this.router.url.split('(')[0] !== this.router.url) && !this.forceLocationBack) {
43
+ this.router.navigateByUrl(this.router.url.split('(')[0]);
44
+ } else {
45
+ this.location.back();
46
+ }
47
+ }
48
+ }
49
+
50
+ public emitClose(): void {
51
+ this.cancel.emit(false);
52
+ this.closeSidePane();
53
+ }
54
+
55
+ public emitCancel(): void {
56
+ this.cancel.emit(false);
57
+ this.closeSidePane();
58
+ }
59
+
60
+ public emitOK(): void {
61
+ this.ok.emit(true);
62
+ if (this.closeOnOk) {
63
+ this.closeSidePane();
64
+ }
65
+ }
66
+
67
+ }
@@ -0,0 +1,68 @@
1
+ <header *ngIf="header" class="view-layout-paddings">
2
+
3
+ <div class="view-layout-title-container">
4
+
5
+ <div class="view-layout-title-container-inner">
6
+ <div class="flex items-center">
7
+ <i *ngIf="icon" [class]="icon + ' title-icon'" aria-hidden="true"></i>
8
+ <h1 [class]="busy ? 'view-layout-title-busy' : 'view-layout-title'">{{title}}</h1>
9
+ </div>
10
+ <div *ngIf="metaItems && metaItems.length > 0" class="meta-container">
11
+ <ng-container *ngFor="let meta of metaItems">
12
+ <div class="meta-item-container">
13
+ <i *ngIf="meta.icon" [class]="meta.icon + ' meta-icon'" aria-hidden="true"></i>
14
+ <span class="meta-text">{{meta.text}}</span>
15
+ </div>
16
+ </ng-container>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="flex items-center justify-end">
21
+ <ng-container *ngFor="let action of actions" [ngSwitch]="action.type">
22
+
23
+ <ng-container *ngSwitchCase="'switch-view'">
24
+ <button [disabled]="view === action.param" type="button" href="#" class="ml-1 disabled:opacity-50 btn-view-header" (click)="switchViewActionClick(action)">
25
+ <span class="inline-block relative">
26
+ <i [class]="action.icon"></i>
27
+ <span *ngIf="view === action.param" class="selected-view-indicator"></span>
28
+ </span>
29
+ </button>
30
+ </ng-container>
31
+
32
+ <ng-container *ngSwitchCase="'search'">
33
+ <label for="search" class="sr-only">Search</label>
34
+ <div class="search-container">
35
+ <div class="pointer-events-none absolute inset-y-0 left-0 pl-3 flex items-center">
36
+ <!--<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
37
+ <path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
38
+ </svg>-->
39
+ </div>
40
+ <input id="search" #search class="search-input" [placeholder]="searchPlaceholder"
41
+ type="search" name="search" (input)="searchActionType(search.value)" (onsearch)="handleClear($event)">
42
+ </div>
43
+ <button type="button" href="#" class="btn-view-header rounded-l-none" [title]="action.tooltip" (click)="searchActionClick(action, search.value)">
44
+ <i [class]="action.icon"></i>
45
+ </button>
46
+ </ng-container>
47
+
48
+ <ng-container *ngSwitchCase="'router-link'">
49
+ <button type="button" href="#" class="ml-1 btn-view-header" [title]="action.tooltip" (click)="routerLinkActionClick(action)">
50
+ <i [class]="action.icon"></i>
51
+ </button>
52
+ </ng-container>
53
+
54
+
55
+ <ng-container *ngSwitchDefault>
56
+ <button type="button" class="ml-1 btn-view-header" [title]="action.tooltip" (click)="emitActionClick(action)">
57
+ <i [class]="action.icon"></i>
58
+ </button>
59
+ </ng-container>
60
+ </ng-container>
61
+ </div>
62
+ </div>
63
+ </header>
64
+
65
+ <!-- component -->
66
+ <div [class]="fluid ? 'view-container-fluid' : 'view-container'">
67
+ <ng-content></ng-content>
68
+ </div>