feat: Frontend- und Backend-APIs aktualisiert, um Module basierend auf der Benutzerauswahl zu filtern
This commit is contained in:
@@ -7,6 +7,7 @@ import { ColorModeService } from '../../../services/color-mode.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { env } from '../../../../environments/environment';
|
||||
import { ModuleOfUserService } from '../../../services/module-of-user.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -17,7 +18,13 @@ import { env } from '../../../../environments/environment';
|
||||
})
|
||||
export class ModuleTableComponent extends BaseTableComponent<Module, ModuleService> {
|
||||
constructor(
|
||||
service: ModuleService, cModeService: ColorModeService) {
|
||||
service: ModuleService, cModeService: ColorModeService, private mouService: ModuleOfUserService) {
|
||||
super(service, env.columnNames.module, cModeService)
|
||||
}
|
||||
|
||||
fetchDataByUsername(username: string) {
|
||||
this.mouService.getByUsername(username)
|
||||
.then(mou_list => mou_list.map(mou => mou.module))
|
||||
.then(modules => this.source = modules)
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,10 @@ export class UserComponent implements AfterViewInit {
|
||||
this.refreshService.removeAll()
|
||||
this.refreshService.add(() => {
|
||||
this.userTable.fetchData();
|
||||
if (this.sUsername != null){
|
||||
this.groupTable.fetchDataByUsername(this.sUsername);
|
||||
this.moduleTable.fetchDataByUsername(this.sUsername)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,8 +49,10 @@ export class UserComponent implements AfterViewInit {
|
||||
if (rows.length > 0) {
|
||||
this.sUsername = rows[0].source.username;
|
||||
|
||||
if (this.sUsername != null)
|
||||
if (this.sUsername != null){
|
||||
this.groupTable.fetchDataByUsername(this.sUsername);
|
||||
this.moduleTable.fetchDataByUsername(this.sUsername)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ export interface ModuleOfUser {
|
||||
comment?: string;
|
||||
addedWho?: string;
|
||||
changedWho?: string;
|
||||
module?: Module;
|
||||
}
|
||||
|
||||
export interface GroupOfUser {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ModuleOfUser } from '../models/user-management.api.models';
|
||||
import { ApiService } from './user-management.api.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { UrlService } from './url.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -17,4 +17,9 @@ export class ModuleOfUserService extends ApiService<ModuleOfUser> {
|
||||
const url = `${this.baseUrl}?moduleId=${moduleId}&userId=${userId}`;
|
||||
return this.http.delete<any>(url, { withCredentials: true });
|
||||
}
|
||||
|
||||
async getByUsername(username: string): Promise<ModuleOfUser[]> {
|
||||
const url = `${this.baseUrl}?username=${username}`;
|
||||
return await firstValueFrom(this.http.get<ModuleOfUser[]>(url, { withCredentials: true }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user