|
|
|
@ -25,12 +25,7 @@ export class MenuComponent {
|
|
|
|
showPermissions = false;
|
|
|
|
showPermissions = false;
|
|
|
|
permissions: PermissionNode[] = [];
|
|
|
|
permissions: PermissionNode[] = [];
|
|
|
|
saving = false;
|
|
|
|
saving = false;
|
|
|
|
menuItems = [
|
|
|
|
menuItems: { endpoint: string; checked: boolean }[] = [];
|
|
|
|
{ name: 'accountToAccount', endpoint: URIKey.ACCOUNT_TO_ACCOUNT, checked: true },
|
|
|
|
|
|
|
|
{ name: 'glToGl', endpoint: URIKey.GL_TO_GL, checked: false },
|
|
|
|
|
|
|
|
{ name: 'accountToGl', endpoint: URIKey.ACCOUNT_TO_GL, checked: false },
|
|
|
|
|
|
|
|
{ name: 'glToAccount', endpoint: URIKey.GL_TO_ACCOUNT, checked: false }
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private credentialService: CredentialService,
|
|
|
|
private credentialService: CredentialService,
|
|
|
|
@ -47,7 +42,21 @@ export class MenuComponent {
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ngOnInit() {
|
|
|
|
this.getAllUsers();
|
|
|
|
this.getAllUsers();
|
|
|
|
|
|
|
|
this.loadTransactionEndpoints();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadTransactionEndpoints() {
|
|
|
|
|
|
|
|
this.httpService.requestGET<string[]>(URIKey.TRANSACTION_ENDPOINTS).subscribe((response) => {
|
|
|
|
|
|
|
|
if (!(response instanceof HttpErrorResponse)) {
|
|
|
|
|
|
|
|
this.menuItems = response.map(endpoint => ({
|
|
|
|
|
|
|
|
endpoint,
|
|
|
|
|
|
|
|
checked: false
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defaultPermissions(): Observable<PermissionNode[]> {
|
|
|
|
defaultPermissions(): Observable<PermissionNode[]> {
|
|
|
|
return this.httpService.requestGET<PermissionNode[]>('assets/data/sideMenu.json');
|
|
|
|
return this.httpService.requestGET<PermissionNode[]>('assets/data/sideMenu.json');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -88,17 +97,12 @@ onUserChange() {
|
|
|
|
.filter(p => p.allowed)
|
|
|
|
.filter(p => p.allowed)
|
|
|
|
.map(p => this.normalizeUrl(p.transactionEndpoint)); // ← normalize
|
|
|
|
.map(p => this.normalizeUrl(p.transactionEndpoint)); // ← normalize
|
|
|
|
|
|
|
|
|
|
|
|
this.uriService.canSubscribe.pipe(
|
|
|
|
|
|
|
|
filter(ready => ready === true),
|
|
|
|
|
|
|
|
take(1)
|
|
|
|
|
|
|
|
).subscribe(() => {
|
|
|
|
|
|
|
|
this.menuItems.forEach(item => {
|
|
|
|
this.menuItems.forEach(item => {
|
|
|
|
const resolvedEndpoint = this.normalizeUrl(
|
|
|
|
item.checked = allowedEndpoints.some(allowed =>
|
|
|
|
this.uriService.getURIForRequest(item.endpoint) // ← normalize
|
|
|
|
allowed.endsWith(this.normalizeUrl(item.endpoint))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
item.checked = allowedEndpoints.includes(resolvedEndpoint);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.menuItems.forEach(item => item.checked = false);
|
|
|
|
this.menuItems.forEach(item => item.checked = false);
|
|
|
|
@ -151,7 +155,7 @@ savePermissions() {
|
|
|
|
).subscribe(() => {
|
|
|
|
).subscribe(() => {
|
|
|
|
const transactionEndpoints: string[] = this.menuItems
|
|
|
|
const transactionEndpoints: string[] = this.menuItems
|
|
|
|
.filter(item => item.checked)
|
|
|
|
.filter(item => item.checked)
|
|
|
|
.map(item => this.uriService.getURIForRequest(item.endpoint));
|
|
|
|
.map(item => item.endpoint);
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { userId: selectedUser, transactionEndpoints };
|
|
|
|
const payload = { userId: selectedUser, transactionEndpoints };
|
|
|
|
|
|
|
|
|
|
|
|
|