-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
151 lines (143 loc) · 5.75 KB
/
app.component.ts
File metadata and controls
151 lines (143 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { Component, inject, isDevMode } from '@angular/core';
import { Link } from '@vality/matez';
import { KeycloakService } from 'keycloak-angular';
import sortBy from 'lodash-es/sortBy';
import { Observable, from } from 'rxjs';
import { map, shareReplay, startWith } from 'rxjs/operators';
import { environment } from '../environments/environment';
import { ROUTING_CONFIG as CLAIMS_ROUTING_CONFIG } from './sections/claims/routing-config';
import { ROUTING_CONFIG as DEPOSITS_ROUTING_CONFIG } from './sections/deposits/routing-config';
import { ROUTING_CONFIG as DOMAIN_ROUTING_CONFIG } from './sections/domain/routing-config';
import { ROUTING_CONFIG as MACHINES_ROUTING_CONFIG } from './sections/machines/routing-config';
import { ROUTING_CONFIG as PAYMENTS_ROUTING_CONFIG } from './sections/payments/routing-config';
import { ROUTING_CONFIG as PARTIES_ROUTING_CONFIG } from './sections/search-parties/routing-config';
import { SHOPS_ROUTING_CONFIG } from './sections/shops';
import { ROUTING_CONFIG as SOURCES_ROUTING_CONFIG } from './sections/sources/routing-config';
import { ROUTING_CONFIG as TERMINALS_ROUTING_CONFIG } from './sections/terminals';
import { ROUTING_CONFIG as TERMS_ROUTING_CONFIG } from './sections/terms/routing-config';
import { ROUTING_CONFIG as WALLETS_ROUTING_CONFIG } from './sections/wallets/routing-config';
import { ROUTING_CONFIG as WITHDRAWALS_ROUTING_CONFIG } from './sections/withdrawals/routing-config';
import { SidenavInfoService } from './shared/components/sidenav-info';
import { AppAuthGuardService, ManagerUiService, Services } from './shared/services';
@Component({
selector: 'cc-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: false,
})
export class AppComponent {
private keycloakService = inject(KeycloakService);
private appAuthGuardService = inject(AppAuthGuardService);
public sidenavInfoService = inject(SidenavInfoService);
public managerUiService = inject(ManagerUiService);
links$: Observable<Link[][]> = from(this.keycloakService.loadUserProfile()).pipe(
startWith(null),
map(() => this.getMenuItemsGroups()),
shareReplay({ refCount: true, bufferSize: 1 }),
);
constructor() {
this.registerConsoleUtils();
}
private registerConsoleUtils() {
Object.assign(window as never as object, {
ccSwitchLogging: () => {
environment.logging = { requests: !environment.logging.requests };
console.log(`Logging ${environment.logging.requests ? 'enabled' : 'disabled'}`);
},
ccGetMyRoles: () => {
console.log(this.keycloakService.getUserRoles(true).sort().join('\n'));
},
});
}
private getMenuItemsGroups() {
const menuItems: (Link & { services: Services[] })[][] = [
[
{
label: 'Domain config',
url: '/domain',
services: DOMAIN_ROUTING_CONFIG.services,
},
...(isDevMode()
? [
{
label: 'Domain config 2',
url: '/domain2',
services: DOMAIN_ROUTING_CONFIG.services,
},
]
: []),
{
label: 'Terminals',
url: '/terminals',
services: TERMINALS_ROUTING_CONFIG.services,
},
{
label: 'Machines',
url: '/machines',
services: MACHINES_ROUTING_CONFIG.services,
},
{
label: 'Sources',
url: '/sources',
services: SOURCES_ROUTING_CONFIG.services,
},
{
label: 'Terms',
url: '/terms',
services: TERMS_ROUTING_CONFIG.services,
},
],
[
{
label: 'Merchants',
url: '/parties',
services: PARTIES_ROUTING_CONFIG.services,
},
{
label: 'Shops',
url: '/shops',
services: SHOPS_ROUTING_CONFIG.services,
},
{
label: 'Wallets',
url: '/wallets',
services: WALLETS_ROUTING_CONFIG.services,
},
{
label: 'Claims',
url: '/claims',
services: CLAIMS_ROUTING_CONFIG.services,
},
],
[
{
label: 'Payments',
url: '/payments',
services: PAYMENTS_ROUTING_CONFIG.services,
},
{
label: 'Chargebacks',
url: '/chargebacks',
services: WALLETS_ROUTING_CONFIG.services,
},
{
label: 'Deposits',
url: '/deposits',
services: DEPOSITS_ROUTING_CONFIG.services,
},
{
label: 'Withdrawals',
url: '/withdrawals',
services: WITHDRAWALS_ROUTING_CONFIG.services,
},
],
];
return menuItems
.map((group) =>
group.filter((item) =>
this.appAuthGuardService.userHasSomeServiceMethods(item.services),
),
)
.map((group) => sortBy(group, 'label'));
}
}