aril 1.2.48 → 1.2.50

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 (138) hide show
  1. package/boot/base/src/aril-title-strategy.d.ts +21 -2
  2. package/boot/config/apps/src/interfaces.d.ts +14 -0
  3. package/esm2022/boot/base/src/aril-title-strategy.mjs +50 -3
  4. package/esm2022/boot/bridge/index.mjs +1 -1
  5. package/esm2022/boot/bridge/src/mfe-bridge.mjs +1 -1
  6. package/esm2022/boot/bridge/src/provide-mfe-bridge.mjs +1 -1
  7. package/esm2022/boot/config/api/index.mjs +1 -1
  8. package/esm2022/boot/config/apps/src/apps.service.mjs +1 -1
  9. package/esm2022/boot/config/apps/src/auth.guard.mjs +1 -1
  10. package/esm2022/boot/config/apps/src/interfaces.mjs +1 -1
  11. package/esm2022/boot/config/apps/src/route-permissions.mjs +1 -1
  12. package/esm2022/boot/config/plugins/src/getNgZone.mjs +1 -1
  13. package/esm2022/boot/config/plugins/src/interfaces.mjs +1 -1
  14. package/esm2022/boot/config/plugins/src/plugins.service.mjs +1 -1
  15. package/esm2022/boot/config/translate/primeng/i18n/tr.mjs +1 -1
  16. package/esm2022/boot/host/src/app.component.mjs +1 -1
  17. package/esm2022/boot/mfe/src/app.component.mjs +13 -13
  18. package/esm2022/boot/mfe/src/bootstrap.mjs +1 -1
  19. package/esm2022/boot/pages/index.mjs +1 -1
  20. package/esm2022/boot/pages/src/forbidden.component.mjs +51 -51
  21. package/esm2022/boot/pages/src/notFound.component.mjs +47 -47
  22. package/esm2022/http/lib/enums.mjs +1 -1
  23. package/esm2022/http/src/serviceBase.mjs +1 -1
  24. package/esm2022/http/src/serviceStateMethods.mjs +1 -1
  25. package/esm2022/keycloak/src/auth.interceptor.mjs +1 -1
  26. package/esm2022/provider/src/prodiveHostRouter.mjs +1 -1
  27. package/esm2022/provider/src/provideHostKeycloak.mjs +1 -1
  28. package/esm2022/superset/index.mjs +1 -1
  29. package/esm2022/theme/layout/app/breadcrumb/app.breadcrumb.component.mjs +1 -1
  30. package/esm2022/theme/layout/app/expandableMenu/expandable-menu.component.mjs +16 -8
  31. package/esm2022/theme/layout/app/general-search/general-search.component.mjs +1 -1
  32. package/esm2022/theme/layout/app/site-map/site-map-sidebar.component.mjs +1 -1
  33. package/esm2022/theme/layout/app/static-sidebar/static-sidebar.component.mjs +19 -11
  34. package/esm2022/theme/layout/index.mjs +1 -1
  35. package/esm2022/theme/layout/service/interfaces/enum.mjs +1 -1
  36. package/esm2022/theme/layout/service/menu-action-confirm.mjs +73 -0
  37. package/esm2022/theme/layout/service/selection-group.service.mjs +1 -1
  38. package/esm2022/ui/autoComplete/src/auto-complete.component.mjs +1 -1
  39. package/esm2022/ui/button/src/button.component.mjs +1 -1
  40. package/esm2022/ui/chip/src/chip.component.mjs +1 -1
  41. package/esm2022/ui/form/src/form-submit-button.component.mjs +3 -3
  42. package/esm2022/ui/table/src/table.component.mjs +3 -3
  43. package/esm2022/ui/table-expand/src/table.component.mjs +3 -3
  44. package/esm2022/ui/treeTable/src/tree-table.component.mjs +1 -1
  45. package/esm2022/ui-business/assetPicker/index.mjs +1 -1
  46. package/esm2022/ui-business/assetPicker/src/asset-picker.component.mjs +3 -3
  47. package/esm2022/ui-business/detailed-overlay-panel/src/detailed-overlay-panel.component.mjs +3 -3
  48. package/esm2022/ui-business/enumPicker/src/interface.mjs +1 -1
  49. package/esm2022/ui-business/multiAssetPicker/index.mjs +1 -1
  50. package/esm2022/ui-business/multiAssetPicker/src/multi-asset-picker.component.mjs +3 -3
  51. package/esm2022/ui-business/pdf-preview-modal/index.mjs +1 -1
  52. package/esm2022/ui-business/pdf-preview-modal/src/open-pdf-preview.mjs +1 -1
  53. package/esm2022/ui-business/pdf-preview-modal/src/pdf-preview-modal.component.mjs +27 -27
  54. package/esm2022/ui-business/ref-value/src/ref-value.component.mjs +3 -3
  55. package/esm2022/ui-business/trace-drawer/index.mjs +1 -1
  56. package/esm2022/ui-business/trace-drawer/src/app-log.service.mjs +1 -1
  57. package/esm2022/ui-business/trace-drawer/src/trace-log.service.mjs +1 -1
  58. package/esm2022/ui-business/trace-id/index.mjs +1 -1
  59. package/esm2022/ui-business/trace-id/src/trace-id.component.mjs +3 -3
  60. package/esm2022/util/activity/index.mjs +1 -1
  61. package/esm2022/util/activity/src/activity.constants.mjs +1 -1
  62. package/esm2022/util/activity/src/activity.service.mjs +1 -1
  63. package/esm2022/util/activity/src/activity.types.mjs +1 -1
  64. package/esm2022/util/directives/src/detail-page-customization/detail-page-customization.directive.mjs +1 -1
  65. package/esm2022/util/pipes/src/translate-json/translate-json.pipe.mjs +1 -1
  66. package/fesm2022/{aril-app.component-YBy2gyza.mjs → aril-app.component-BUjucZ0J.mjs} +13 -13
  67. package/fesm2022/aril-app.component-BUjucZ0J.mjs.map +1 -0
  68. package/fesm2022/aril-boot-base.mjs +49 -2
  69. package/fesm2022/aril-boot-base.mjs.map +1 -1
  70. package/fesm2022/aril-boot-bridge.mjs.map +1 -1
  71. package/fesm2022/aril-boot-config-apps.mjs.map +1 -1
  72. package/fesm2022/aril-boot-config-plugins.mjs.map +1 -1
  73. package/fesm2022/aril-boot-config-translate.mjs.map +1 -1
  74. package/fesm2022/aril-boot-host.mjs.map +1 -1
  75. package/fesm2022/{aril-boot-mfe-app.component-GbZAGlTf.mjs → aril-boot-mfe-app.component-D1w8I2ug.mjs} +14 -14
  76. package/fesm2022/aril-boot-mfe-app.component-D1w8I2ug.mjs.map +1 -0
  77. package/fesm2022/{aril-boot-mfe-aril-boot-mfe-I5xT2fQx.mjs → aril-boot-mfe-aril-boot-mfe-JHrhKvhU.mjs} +2 -2
  78. package/fesm2022/aril-boot-mfe-aril-boot-mfe-JHrhKvhU.mjs.map +1 -0
  79. package/fesm2022/aril-boot-mfe.mjs +1 -1
  80. package/fesm2022/aril-boot-pages.mjs +96 -96
  81. package/fesm2022/aril-boot-pages.mjs.map +1 -1
  82. package/fesm2022/aril-http.mjs.map +1 -1
  83. package/fesm2022/aril-keycloak.mjs.map +1 -1
  84. package/fesm2022/aril-provider.mjs.map +1 -1
  85. package/fesm2022/aril-theme-layout.mjs +113 -28
  86. package/fesm2022/aril-theme-layout.mjs.map +1 -1
  87. package/fesm2022/aril-ui-autoComplete.mjs.map +1 -1
  88. package/fesm2022/aril-ui-business-assetPicker.mjs +2 -2
  89. package/fesm2022/aril-ui-business-assetPicker.mjs.map +1 -1
  90. package/fesm2022/aril-ui-business-detailed-overlay-panel.mjs +2 -2
  91. package/fesm2022/aril-ui-business-detailed-overlay-panel.mjs.map +1 -1
  92. package/fesm2022/aril-ui-business-multiAssetPicker.mjs +2 -2
  93. package/fesm2022/aril-ui-business-multiAssetPicker.mjs.map +1 -1
  94. package/fesm2022/aril-ui-business-pdf-preview-modal.mjs +26 -26
  95. package/fesm2022/aril-ui-business-pdf-preview-modal.mjs.map +1 -1
  96. package/fesm2022/aril-ui-business-ref-value.mjs +2 -2
  97. package/fesm2022/aril-ui-business-ref-value.mjs.map +1 -1
  98. package/fesm2022/aril-ui-business-trace-drawer.mjs.map +1 -1
  99. package/fesm2022/aril-ui-business-trace-id.mjs +2 -2
  100. package/fesm2022/aril-ui-business-trace-id.mjs.map +1 -1
  101. package/fesm2022/aril-ui-button.mjs.map +1 -1
  102. package/fesm2022/aril-ui-chip.mjs.map +1 -1
  103. package/fesm2022/aril-ui-form.mjs +2 -2
  104. package/fesm2022/aril-ui-form.mjs.map +1 -1
  105. package/fesm2022/aril-ui-table-expand.mjs +2 -2
  106. package/fesm2022/aril-ui-table-expand.mjs.map +1 -1
  107. package/fesm2022/aril-ui-table.mjs +2 -2
  108. package/fesm2022/aril-ui-table.mjs.map +1 -1
  109. package/fesm2022/aril-ui-treeTable.mjs.map +1 -1
  110. package/fesm2022/aril-util-activity.mjs.map +1 -1
  111. package/fesm2022/aril-util-directives.mjs.map +1 -1
  112. package/fesm2022/aril-util-pipes.mjs.map +1 -1
  113. package/fesm2022/aril.mjs +1 -1
  114. package/fesm2022/aril.mjs.map +1 -1
  115. package/package.json +201 -201
  116. package/theme/layout/app/breadcrumb/app.breadcrumb.component.ts +127 -127
  117. package/theme/layout/app/expandableMenu/expandable-menu.component.d.ts +4 -1
  118. package/theme/layout/app/expandableMenu/expandable-menu.component.html +137 -137
  119. package/theme/layout/app/expandableMenu/expandable-menu.component.ts +387 -373
  120. package/theme/layout/app/general-search/general-search.component.ts +93 -93
  121. package/theme/layout/app/site-map/site-map-sidebar.component.ts +195 -195
  122. package/theme/layout/app/static-sidebar/static-sidebar.component.d.ts +4 -1
  123. package/theme/layout/app/static-sidebar/static-sidebar.component.html +162 -162
  124. package/theme/layout/app/static-sidebar/static-sidebar.component.ts +357 -343
  125. package/theme/layout/index.ts +9 -9
  126. package/theme/layout/service/interfaces/enum.ts +19 -19
  127. package/theme/layout/service/menu-action-confirm.d.ts +15 -0
  128. package/theme/layout/service/menu-action-confirm.ts +112 -0
  129. package/theme/layout/service/selection-group.service.ts +144 -144
  130. package/theme/styles/layout/_fonts.scss +81 -81
  131. package/theme/styles/theme/base/components/input/_inputtext.scss +104 -104
  132. package/theme/styles/theme/base/components/overlay/_sidebar.scss +27 -27
  133. package/theme/styles/theme/base/components/panel/_stepper.scss +205 -205
  134. package/theme/styles/theme/dark/_variables.scss +933 -933
  135. package/theme/styles/theme/light/_variables.scss +940 -940
  136. package/fesm2022/aril-app.component-YBy2gyza.mjs.map +0 -1
  137. package/fesm2022/aril-boot-mfe-app.component-GbZAGlTf.mjs.map +0 -1
  138. package/fesm2022/aril-boot-mfe-aril-boot-mfe-I5xT2fQx.mjs.map +0 -1
@@ -1,373 +1,387 @@
1
- import { NgClass } from '@angular/common';
2
- import { HttpClient } from '@angular/common/http';
3
- import { Component, HostListener, OnDestroy, OnInit, Signal } from '@angular/core';
4
- import { toSignal } from '@angular/core/rxjs-interop';
5
- import { NavigationEnd, Router, RouterLink } from '@angular/router';
6
-
7
- import { TooltipModule } from 'primeng/tooltip';
8
-
9
- import { TranslocoService } from '@ngneat/transloco';
10
- import { KeycloakService } from 'keycloak-angular';
11
- import { Subscription, filter } from 'rxjs';
12
-
13
- import { bridge } from 'aril/boot/bridge';
14
- import { PluginMenuItem } from 'aril/boot/config/apps';
15
- import { TranslateJsonPipe } from 'aril/util/pipes';
16
-
17
- import { LayoutService } from '../../service/app.layout.service';
18
- import { AppMenuService } from '../../service/app.menu.service';
19
-
20
- @Component({
21
- standalone: true,
22
- selector: 'app-expandable-menu',
23
- imports: [RouterLink, NgClass, TooltipModule],
24
- templateUrl: 'expandable-menu.component.html',
25
- providers: [TranslateJsonPipe]
26
- })
27
- export class ExpandableMenuComponent implements OnInit, OnDestroy {
28
- activeLang: Signal<string>;
29
- overlayMenuOpenSubscription: Subscription | null = null;
30
- routerSubscription: Subscription | null = null;
31
- username: string;
32
-
33
- cachedMenuItems: PluginMenuItem[] = [];
34
-
35
- selectedMainMenuItem: PluginMenuItem | null = null;
36
-
37
- get sidebarExpanded(): boolean {
38
- return this.layoutService.state.secondarySidebarExpanded;
39
- }
40
-
41
- set sidebarExpanded(value: boolean) {
42
- this.layoutService.setSecondarySidebarExpanded(value);
43
- }
44
-
45
- tooltipText = {
46
- toggleButton: {
47
- expanded: {
48
- tr: 'Menüyü Gizle',
49
- en: 'Hide Menu'
50
- },
51
- collapsed: {
52
- tr: 'Menüyü Göster',
53
- en: 'Show Menu'
54
- }
55
- },
56
- lockButton: {
57
- locked: {
58
- tr: 'Otomatik Kapanmayı Aç',
59
- en: 'Enable Auto-Close'
60
- },
61
- unlocked: {
62
- tr: 'Menüyü Kilitle',
63
- en: 'Lock Menu'
64
- }
65
- }
66
- };
67
-
68
- private readonly MAX_LENGTH = {
69
- main: 8,
70
- secondary: 20,
71
- tertiary: 20
72
- };
73
-
74
- actionLoadingItems = new Set<string>();
75
- private actionSubscription: Subscription | null = null;
76
-
77
- constructor(
78
- private translateJsonPipe: TranslateJsonPipe,
79
- private menuService: AppMenuService,
80
- private router: Router,
81
- private keycloak: KeycloakService,
82
- private translocoService: TranslocoService,
83
- private layoutService: LayoutService,
84
- private http: HttpClient
85
- ) {
86
- this.activeLang = toSignal(this.translocoService.langChanges$, { initialValue: 'tr' });
87
- this.username = this.keycloak.getUsername().charAt(0).toUpperCase();
88
- }
89
-
90
- // Getter for layout service states
91
- get selectedMainItem(): number | null {
92
- return this.layoutService.state.selectedMainItem;
93
- }
94
-
95
- get secondarySidebarExpanded(): boolean {
96
- return this.layoutService.state.secondarySidebarExpanded;
97
- }
98
-
99
- // Check if text is truncated and needs tooltip
100
- isTextTruncated(
101
- label: any,
102
- lang: string | null,
103
- menuType: 'main' | 'secondary' | 'tertiary' | 'nested' = 'secondary'
104
- ): boolean {
105
- if (!label || !lang || !label[lang]) return false;
106
-
107
- const text = label[lang];
108
- const textLength = text.length;
109
- const maxLength = menuType === 'nested' ? this.MAX_LENGTH.tertiary : this.MAX_LENGTH[menuType];
110
- return textLength > maxLength;
111
- }
112
-
113
- // Recursively check if a menu item or its children match the current route
114
- isActiveRoute(menuItem: PluginMenuItem): boolean {
115
- if (!menuItem || !menuItem.routerLink) return false;
116
-
117
- // Get current URL path after the hash
118
- const currentUrl = this.router.url;
119
- const hashUrl = currentUrl.indexOf('#') > -1 ? currentUrl.split('#')[1] : currentUrl;
120
-
121
- // Check for exact match first
122
- if (hashUrl === menuItem.routerLink || hashUrl === '/' + menuItem.routerLink) {
123
- return true;
124
- }
125
-
126
- // Check if current URL starts with the routerLink (handles child routes)
127
- if (
128
- menuItem.routerLink !== '/' &&
129
- (hashUrl.startsWith(menuItem.routerLink + '/') || hashUrl.startsWith('/' + menuItem.routerLink + '/'))
130
- ) {
131
- return true;
132
- }
133
-
134
- // Check child items if they exist
135
- if (menuItem.items && menuItem.items.length > 0) {
136
- return menuItem.items.some((childItem) => this.isActiveRoute(childItem));
137
- }
138
-
139
- return false;
140
- }
141
-
142
- ngOnInit() {
143
- this.updateMenuItems();
144
- this.initializeMenu();
145
- this.updateActiveMenuFromCurrentRoute();
146
-
147
- // Subscribe to route changes to handle secondary sidebar closing
148
- this.routerSubscription = this.router.events
149
- .pipe(filter((event) => event instanceof NavigationEnd))
150
- .subscribe(() => {
151
- // Update active menu based on the new route
152
- this.updateActiveMenuFromCurrentRoute();
153
- });
154
-
155
- // Subscribe to overlay menu open notifications
156
- this.overlayMenuOpenSubscription = this.layoutService.overlayOpen$.subscribe(() => {
157
- if (this.layoutService.state.staticMenuMobileActive) {
158
- this.layoutService.setSecondarySidebarExpanded(true);
159
- }
160
- });
161
- }
162
-
163
- ngOnDestroy() {
164
- if (this.overlayMenuOpenSubscription) {
165
- this.overlayMenuOpenSubscription.unsubscribe();
166
- }
167
-
168
- if (this.routerSubscription) {
169
- this.routerSubscription.unsubscribe();
170
- }
171
-
172
- this.actionSubscription?.unsubscribe();
173
- }
174
-
175
- // Initialize the menu with proper active state
176
- initializeMenu() {
177
- this.layoutService.setSelectedMainItem(null);
178
- this.selectedMainMenuItem = null;
179
- this.layoutService.setSecondarySidebarExpanded(false);
180
- this.updateMenuItems();
181
- }
182
-
183
- updateMenuFromRootKey(index: number): void {
184
- this.updateMenuItems();
185
- const menuItems = this.getMenuItems();
186
-
187
- if (index >= 0 && index < menuItems.length) {
188
- const item = menuItems[index];
189
- if (!item.separator) {
190
- this.layoutService.setSelectedMainItem(index);
191
- this.selectedMainMenuItem = item;
192
- this.layoutService.setSecondarySidebarExpanded(true);
193
- }
194
- }
195
- }
196
-
197
- updateMenuItems(): void {
198
- this.cachedMenuItems = bridge.isHostMode() ? bridge.hostMenuItems() : this.menuService.menuItems();
199
- }
200
-
201
- getMenuItems(): PluginMenuItem[] {
202
- return this.cachedMenuItems;
203
- }
204
-
205
- selectMainItem(index: number, item: PluginMenuItem): void {
206
- // Handle action items at top level
207
- if (item.action && (!item.items || item.items.length === 0)) {
208
- this.onActionItemClick(item);
209
- return;
210
- }
211
-
212
- if (item.routerLink && (!item.items || item.items.length === 0)) {
213
- this.layoutService.setSecondarySidebarExpanded(false);
214
- this.layoutService.setSelectedMainItem(index);
215
- this.selectedMainMenuItem = item;
216
- this.router.navigate([item.routerLink]);
217
- return;
218
- }
219
-
220
- // Handle regular menu items with submenu
221
- if (this.selectedMainItem === index) {
222
- this.layoutService.toggleSecondarySidebar();
223
- } else {
224
- this.layoutService.setSelectedMainItem(index);
225
- this.selectedMainMenuItem = item;
226
-
227
- if (item.items && item.items.length > 0) {
228
- this.layoutService.setSecondarySidebarExpanded(true);
229
- } else {
230
- this.layoutService.setSecondarySidebarExpanded(false);
231
- }
232
- }
233
-
234
- // For mobile devices, ensure the menu stays open
235
- if (this.isMobile()) {
236
- this.layoutService.state.staticMenuMobileActive = true;
237
- }
238
- }
239
-
240
- toggleSecondarySidebar(): void {
241
- this.layoutService.toggleSecondarySidebar();
242
- }
243
-
244
- isMobile(): boolean {
245
- return this.layoutService.isMobile();
246
- }
247
-
248
- // Listen for resize events - now handled more efficiently by layout service
249
- @HostListener('window:resize')
250
- onResize() {
251
- if (!this.isMobile() && this.layoutService.state.staticMenuMobileActive) {
252
- this.layoutService.closeMobileMenu();
253
- }
254
- }
255
-
256
- updateActiveMenuFromCurrentRoute(): void {
257
- const menuItems = this.getMenuItems();
258
-
259
- for (let i = 0; i < menuItems.length; i++) {
260
- const menuItem = menuItems[i];
261
- if (this.isActiveRoute(menuItem)) {
262
- this.layoutService.setSelectedMainItem(i);
263
- this.selectedMainMenuItem = menuItem;
264
-
265
- if (menuItem.items && menuItem.items.length > 0) {
266
- if (!this.isMobile() && !this.secondarySidebarExpanded && !this.layoutService.state.staticMenuMobileActive) {
267
- this.layoutService.setSecondarySidebarExpanded(true);
268
- }
269
- } else {
270
- this.layoutService.setSecondarySidebarExpanded(false);
271
- }
272
- return;
273
- }
274
- }
275
- }
276
-
277
- isHaveSelectedChildItem(item: PluginMenuItem): boolean {
278
- if (!item || !item.items || item.items.length === 0) return false;
279
-
280
- for (const child of item.items) {
281
- if (this.isActiveRoute(child)) {
282
- return true;
283
- }
284
-
285
- if (child.items && child.items.length > 0) {
286
- if (this.isHaveSelectedChildItem(child)) {
287
- return true;
288
- }
289
- }
290
- }
291
-
292
- return false;
293
- }
294
-
295
- getLocalText(text: any): string {
296
- return this.translateJsonPipe.transform(text);
297
- }
298
-
299
- getActionItemKey(item: PluginMenuItem): string {
300
- return item.action?.url + '|' + item.action?.successRoute;
301
- }
302
-
303
- isActionLoading(item: PluginMenuItem): boolean {
304
- return this.actionLoadingItems.has(this.getActionItemKey(item));
305
- }
306
-
307
- onActionItemClick(item: PluginMenuItem, event?: Event): void {
308
- if (event) {
309
- event.preventDefault();
310
- event.stopPropagation();
311
- }
312
-
313
- if (!item.action || this.isActionLoading(item)) return;
314
-
315
- // Cancel any previous action request
316
- this.actionSubscription?.unsubscribe();
317
-
318
- const key = this.getActionItemKey(item);
319
- this.actionLoadingItems.add(key);
320
-
321
- const request$ =
322
- item.action.method === 'GET'
323
- ? this.http.get(item.action.url)
324
- : this.http.post(item.action.url, item.action.body ?? {});
325
-
326
- this.actionSubscription = request$.subscribe({
327
- next: (response: any) => {
328
- this.actionLoadingItems.delete(key);
329
- const route = this.buildSuccessRoute(item.action!, response);
330
- this.router.navigate([route]);
331
- },
332
- error: () => {
333
- this.actionLoadingItems.delete(key);
334
- }
335
- });
336
- }
337
-
338
- private buildSuccessRoute(action: PluginMenuItem['action'], response: any): string {
339
- if (!action?.successRouteResponseKey) return action?.successRoute ?? '/';
340
-
341
- const value = this.getValueByPath(response, action.successRouteResponseKey);
342
- if (value === undefined || value === null) return action.successRoute;
343
-
344
- return `${action.successRoute}/${value}`;
345
- }
346
-
347
- private getValueByPath(obj: any, path: string): any {
348
- if (!obj || !path) return undefined;
349
-
350
- return path.split('.').reduce((current, key) => {
351
- if (current === undefined || current === null) return undefined;
352
-
353
- // Handle array access like 'result[0]'
354
- const arrayMatch = key.match(/^(.+?)\[(\d+)\]$/);
355
- if (arrayMatch) {
356
- const arrayKey = arrayMatch[1];
357
- const index = parseInt(arrayMatch[2], 10);
358
- return current[arrayKey]?.[index];
359
- }
360
-
361
- return current[key];
362
- }, obj);
363
- }
364
-
365
- toggleSidebar() {
366
- // Eğer seçili bir ana menü öğesi varsa ve alt menüleri varsa toggle yapabiliriz
367
- if (this.selectedMainMenuItem && this.selectedMainMenuItem.items && this.selectedMainMenuItem.items.length > 0) {
368
- this.sidebarExpanded = !this.sidebarExpanded;
369
- } else if (this.sidebarExpanded) {
370
- this.sidebarExpanded = false;
371
- }
372
- }
373
- }
1
+ import { NgClass } from '@angular/common';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { Component, HostListener, OnDestroy, OnInit, Signal } from '@angular/core';
4
+ import { toSignal } from '@angular/core/rxjs-interop';
5
+ import { NavigationEnd, Router, RouterLink } from '@angular/router';
6
+
7
+ import { ConfirmationService } from 'primeng/api';
8
+ import { TooltipModule } from 'primeng/tooltip';
9
+
10
+ import { TranslocoService } from '@ngneat/transloco';
11
+ import { KeycloakService } from 'keycloak-angular';
12
+ import { Subscription, filter } from 'rxjs';
13
+
14
+ import { bridge } from 'aril/boot/bridge';
15
+ import { PluginMenuItem } from 'aril/boot/config/apps';
16
+ import { TranslateJsonPipe } from 'aril/util/pipes';
17
+
18
+ import { LayoutService } from '../../service/app.layout.service';
19
+ import { AppMenuService } from '../../service/app.menu.service';
20
+ import { confirmMenuAction, isGetAction } from '../../service/menu-action-confirm';
21
+
22
+ @Component({
23
+ standalone: true,
24
+ selector: 'app-expandable-menu',
25
+ imports: [RouterLink, NgClass, TooltipModule],
26
+ templateUrl: 'expandable-menu.component.html',
27
+ providers: [TranslateJsonPipe]
28
+ })
29
+ export class ExpandableMenuComponent implements OnInit, OnDestroy {
30
+ activeLang: Signal<string>;
31
+ overlayMenuOpenSubscription: Subscription | null = null;
32
+ routerSubscription: Subscription | null = null;
33
+ username: string;
34
+
35
+ cachedMenuItems: PluginMenuItem[] = [];
36
+
37
+ selectedMainMenuItem: PluginMenuItem | null = null;
38
+
39
+ get sidebarExpanded(): boolean {
40
+ return this.layoutService.state.secondarySidebarExpanded;
41
+ }
42
+
43
+ set sidebarExpanded(value: boolean) {
44
+ this.layoutService.setSecondarySidebarExpanded(value);
45
+ }
46
+
47
+ tooltipText = {
48
+ toggleButton: {
49
+ expanded: {
50
+ tr: 'Menüyü Gizle',
51
+ en: 'Hide Menu'
52
+ },
53
+ collapsed: {
54
+ tr: 'Menüyü Göster',
55
+ en: 'Show Menu'
56
+ }
57
+ },
58
+ lockButton: {
59
+ locked: {
60
+ tr: 'Otomatik Kapanmayı Aç',
61
+ en: 'Enable Auto-Close'
62
+ },
63
+ unlocked: {
64
+ tr: 'Menüyü Kilitle',
65
+ en: 'Lock Menu'
66
+ }
67
+ }
68
+ };
69
+
70
+ private readonly MAX_LENGTH = {
71
+ main: 8,
72
+ secondary: 20,
73
+ tertiary: 20
74
+ };
75
+
76
+ actionLoadingItems = new Set<string>();
77
+ private actionSubscription: Subscription | null = null;
78
+
79
+ constructor(
80
+ private translateJsonPipe: TranslateJsonPipe,
81
+ private menuService: AppMenuService,
82
+ private router: Router,
83
+ private keycloak: KeycloakService,
84
+ private translocoService: TranslocoService,
85
+ private layoutService: LayoutService,
86
+ private http: HttpClient,
87
+ private confirmationService: ConfirmationService
88
+ ) {
89
+ this.activeLang = toSignal(this.translocoService.langChanges$, { initialValue: 'tr' });
90
+ this.username = this.keycloak.getUsername().charAt(0).toUpperCase();
91
+ }
92
+
93
+ // Getter for layout service states
94
+ get selectedMainItem(): number | null {
95
+ return this.layoutService.state.selectedMainItem;
96
+ }
97
+
98
+ get secondarySidebarExpanded(): boolean {
99
+ return this.layoutService.state.secondarySidebarExpanded;
100
+ }
101
+
102
+ // Check if text is truncated and needs tooltip
103
+ isTextTruncated(
104
+ label: any,
105
+ lang: string | null,
106
+ menuType: 'main' | 'secondary' | 'tertiary' | 'nested' = 'secondary'
107
+ ): boolean {
108
+ if (!label || !lang || !label[lang]) return false;
109
+
110
+ const text = label[lang];
111
+ const textLength = text.length;
112
+ const maxLength = menuType === 'nested' ? this.MAX_LENGTH.tertiary : this.MAX_LENGTH[menuType];
113
+ return textLength > maxLength;
114
+ }
115
+
116
+ // Recursively check if a menu item or its children match the current route
117
+ isActiveRoute(menuItem: PluginMenuItem): boolean {
118
+ if (!menuItem || !menuItem.routerLink) return false;
119
+
120
+ // Get current URL path after the hash
121
+ const currentUrl = this.router.url;
122
+ const hashUrl = currentUrl.indexOf('#') > -1 ? currentUrl.split('#')[1] : currentUrl;
123
+
124
+ // Check for exact match first
125
+ if (hashUrl === menuItem.routerLink || hashUrl === '/' + menuItem.routerLink) {
126
+ return true;
127
+ }
128
+
129
+ // Check if current URL starts with the routerLink (handles child routes)
130
+ if (
131
+ menuItem.routerLink !== '/' &&
132
+ (hashUrl.startsWith(menuItem.routerLink + '/') || hashUrl.startsWith('/' + menuItem.routerLink + '/'))
133
+ ) {
134
+ return true;
135
+ }
136
+
137
+ // Check child items if they exist
138
+ if (menuItem.items && menuItem.items.length > 0) {
139
+ return menuItem.items.some((childItem) => this.isActiveRoute(childItem));
140
+ }
141
+
142
+ return false;
143
+ }
144
+
145
+ ngOnInit() {
146
+ this.updateMenuItems();
147
+ this.initializeMenu();
148
+ this.updateActiveMenuFromCurrentRoute();
149
+
150
+ // Subscribe to route changes to handle secondary sidebar closing
151
+ this.routerSubscription = this.router.events
152
+ .pipe(filter((event) => event instanceof NavigationEnd))
153
+ .subscribe(() => {
154
+ // Update active menu based on the new route
155
+ this.updateActiveMenuFromCurrentRoute();
156
+ });
157
+
158
+ // Subscribe to overlay menu open notifications
159
+ this.overlayMenuOpenSubscription = this.layoutService.overlayOpen$.subscribe(() => {
160
+ if (this.layoutService.state.staticMenuMobileActive) {
161
+ this.layoutService.setSecondarySidebarExpanded(true);
162
+ }
163
+ });
164
+ }
165
+
166
+ ngOnDestroy() {
167
+ if (this.overlayMenuOpenSubscription) {
168
+ this.overlayMenuOpenSubscription.unsubscribe();
169
+ }
170
+
171
+ if (this.routerSubscription) {
172
+ this.routerSubscription.unsubscribe();
173
+ }
174
+
175
+ this.actionSubscription?.unsubscribe();
176
+ }
177
+
178
+ // Initialize the menu with proper active state
179
+ initializeMenu() {
180
+ this.layoutService.setSelectedMainItem(null);
181
+ this.selectedMainMenuItem = null;
182
+ this.layoutService.setSecondarySidebarExpanded(false);
183
+ this.updateMenuItems();
184
+ }
185
+
186
+ updateMenuFromRootKey(index: number): void {
187
+ this.updateMenuItems();
188
+ const menuItems = this.getMenuItems();
189
+
190
+ if (index >= 0 && index < menuItems.length) {
191
+ const item = menuItems[index];
192
+ if (!item.separator) {
193
+ this.layoutService.setSelectedMainItem(index);
194
+ this.selectedMainMenuItem = item;
195
+ this.layoutService.setSecondarySidebarExpanded(true);
196
+ }
197
+ }
198
+ }
199
+
200
+ updateMenuItems(): void {
201
+ this.cachedMenuItems = bridge.isHostMode() ? bridge.hostMenuItems() : this.menuService.menuItems();
202
+ }
203
+
204
+ getMenuItems(): PluginMenuItem[] {
205
+ return this.cachedMenuItems;
206
+ }
207
+
208
+ selectMainItem(index: number, item: PluginMenuItem): void {
209
+ // Handle action items at top level
210
+ if (item.action && (!item.items || item.items.length === 0)) {
211
+ this.onActionItemClick(item);
212
+ return;
213
+ }
214
+
215
+ if (item.routerLink && (!item.items || item.items.length === 0)) {
216
+ this.layoutService.setSecondarySidebarExpanded(false);
217
+ this.layoutService.setSelectedMainItem(index);
218
+ this.selectedMainMenuItem = item;
219
+ this.router.navigate([item.routerLink]);
220
+ return;
221
+ }
222
+
223
+ // Handle regular menu items with submenu
224
+ if (this.selectedMainItem === index) {
225
+ this.layoutService.toggleSecondarySidebar();
226
+ } else {
227
+ this.layoutService.setSelectedMainItem(index);
228
+ this.selectedMainMenuItem = item;
229
+
230
+ if (item.items && item.items.length > 0) {
231
+ this.layoutService.setSecondarySidebarExpanded(true);
232
+ } else {
233
+ this.layoutService.setSecondarySidebarExpanded(false);
234
+ }
235
+ }
236
+
237
+ // For mobile devices, ensure the menu stays open
238
+ if (this.isMobile()) {
239
+ this.layoutService.state.staticMenuMobileActive = true;
240
+ }
241
+ }
242
+
243
+ toggleSecondarySidebar(): void {
244
+ this.layoutService.toggleSecondarySidebar();
245
+ }
246
+
247
+ isMobile(): boolean {
248
+ return this.layoutService.isMobile();
249
+ }
250
+
251
+ // Listen for resize events - now handled more efficiently by layout service
252
+ @HostListener('window:resize')
253
+ onResize() {
254
+ if (!this.isMobile() && this.layoutService.state.staticMenuMobileActive) {
255
+ this.layoutService.closeMobileMenu();
256
+ }
257
+ }
258
+
259
+ updateActiveMenuFromCurrentRoute(): void {
260
+ const menuItems = this.getMenuItems();
261
+
262
+ for (let i = 0; i < menuItems.length; i++) {
263
+ const menuItem = menuItems[i];
264
+ if (this.isActiveRoute(menuItem)) {
265
+ this.layoutService.setSelectedMainItem(i);
266
+ this.selectedMainMenuItem = menuItem;
267
+
268
+ if (menuItem.items && menuItem.items.length > 0) {
269
+ if (!this.isMobile() && !this.secondarySidebarExpanded && !this.layoutService.state.staticMenuMobileActive) {
270
+ this.layoutService.setSecondarySidebarExpanded(true);
271
+ }
272
+ } else {
273
+ this.layoutService.setSecondarySidebarExpanded(false);
274
+ }
275
+ return;
276
+ }
277
+ }
278
+ }
279
+
280
+ isHaveSelectedChildItem(item: PluginMenuItem): boolean {
281
+ if (!item || !item.items || item.items.length === 0) return false;
282
+
283
+ for (const child of item.items) {
284
+ if (this.isActiveRoute(child)) {
285
+ return true;
286
+ }
287
+
288
+ if (child.items && child.items.length > 0) {
289
+ if (this.isHaveSelectedChildItem(child)) {
290
+ return true;
291
+ }
292
+ }
293
+ }
294
+
295
+ return false;
296
+ }
297
+
298
+ getLocalText(text: any): string {
299
+ return this.translateJsonPipe.transform(text);
300
+ }
301
+
302
+ getActionItemKey(item: PluginMenuItem): string {
303
+ return item.action?.url + '|' + item.action?.successRoute;
304
+ }
305
+
306
+ isActionLoading(item: PluginMenuItem): boolean {
307
+ return this.actionLoadingItems.has(this.getActionItemKey(item));
308
+ }
309
+
310
+ onActionItemClick(item: PluginMenuItem, event?: Event): void {
311
+ if (event) {
312
+ event.preventDefault();
313
+ event.stopPropagation();
314
+ }
315
+
316
+ if (!item.action || this.isActionLoading(item)) return;
317
+
318
+ confirmMenuAction(
319
+ { confirmationService: this.confirmationService, translocoService: this.translocoService },
320
+ item.action,
321
+ this.getLocalText(item.label),
322
+ () => this.runActionItem(item)
323
+ );
324
+ }
325
+
326
+ private runActionItem(item: PluginMenuItem): void {
327
+ if (!item.action) return;
328
+
329
+ // Cancel any previous action request
330
+ this.actionSubscription?.unsubscribe();
331
+
332
+ const key = this.getActionItemKey(item);
333
+ this.actionLoadingItems.add(key);
334
+
335
+ const request$ =
336
+ isGetAction(item.action)
337
+ ? this.http.get(item.action.url)
338
+ : this.http.post(item.action.url, item.action.body ?? {});
339
+
340
+ this.actionSubscription = request$.subscribe({
341
+ next: (response: any) => {
342
+ this.actionLoadingItems.delete(key);
343
+ const route = this.buildSuccessRoute(item.action!, response);
344
+ this.router.navigate([route]);
345
+ },
346
+ error: () => {
347
+ this.actionLoadingItems.delete(key);
348
+ }
349
+ });
350
+ }
351
+
352
+ private buildSuccessRoute(action: PluginMenuItem['action'], response: any): string {
353
+ if (!action?.successRouteResponseKey) return action?.successRoute ?? '/';
354
+
355
+ const value = this.getValueByPath(response, action.successRouteResponseKey);
356
+ if (value === undefined || value === null) return action.successRoute;
357
+
358
+ return `${action.successRoute}/${value}`;
359
+ }
360
+
361
+ private getValueByPath(obj: any, path: string): any {
362
+ if (!obj || !path) return undefined;
363
+
364
+ return path.split('.').reduce((current, key) => {
365
+ if (current === undefined || current === null) return undefined;
366
+
367
+ // Handle array access like 'result[0]'
368
+ const arrayMatch = key.match(/^(.+?)\[(\d+)\]$/);
369
+ if (arrayMatch) {
370
+ const arrayKey = arrayMatch[1];
371
+ const index = parseInt(arrayMatch[2], 10);
372
+ return current[arrayKey]?.[index];
373
+ }
374
+
375
+ return current[key];
376
+ }, obj);
377
+ }
378
+
379
+ toggleSidebar() {
380
+ // Eğer seçili bir ana menü öğesi varsa ve alt menüleri varsa toggle yapabiliriz
381
+ if (this.selectedMainMenuItem && this.selectedMainMenuItem.items && this.selectedMainMenuItem.items.length > 0) {
382
+ this.sidebarExpanded = !this.sidebarExpanded;
383
+ } else if (this.sidebarExpanded) {
384
+ this.sidebarExpanded = false;
385
+ }
386
+ }
387
+ }