Aktualisierung der GroupOfUser-, User- und UserRep-Controller. Aktualisieren Sie Agular-Referenzen und entfernen Sie Konsolenprotokolle.
This commit is contained in:
@@ -59,7 +59,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return Ok(await _service.HasGroup(username, groupname));
|
||||
return await _service.HasGroup(username, groupname).ThenAsync(Ok, (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using DigitalData.UserManager.Application.DTOs.User;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.UserRep;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
@@ -26,14 +27,12 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.ReadAllAsync(withUser, withRepGroup, withRightGroup, withRepUser, userId);
|
||||
|
||||
if (result.IsSuccess)
|
||||
return await _service.ReadAllAsync(withUser, withRepGroup, withRightGroup, withRepUser, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
_logger.LogNotice(n);
|
||||
return NotFound();
|
||||
});
|
||||
|
||||
return NotFound(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Observable, of } from 'rxjs';
|
||||
import { AuthenticationService } from '../services/authentication.service'; // Adjust the path as necessary
|
||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { LoginComponent } from '../login/login.component';
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType } from '@generic-ui/ngx-grid';
|
||||
import Swal from 'sweetalert2';
|
||||
import { GroupService } from 'src/app/services/group.service';
|
||||
import { forkJoin, of } from 'rxjs';
|
||||
import { GroupService } from '../../services/group.service';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { catchError, finalize } from 'rxjs/operators';
|
||||
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
||||
import { DirGroupService } from '../../services/dir-group.service';
|
||||
import { DirGroup } from '../../models/user-management.api.models';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-dir-import',
|
||||
@@ -40,15 +42,12 @@ export class GroupDirImportComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
addSelectedGroups() {
|
||||
let requests = [];
|
||||
let requests = new Array<Observable<DirGroup | null>>();
|
||||
let numAdded: number = 0;
|
||||
for (let row of this.dirGroups.selectedRows) {
|
||||
// Create an Observable for each request and add it to the requests array
|
||||
requests.push(
|
||||
this.gService.createByDir({ samaccountname: row?.source?.samaccountname }).pipe(
|
||||
catchError((err) => {
|
||||
console.log(err);
|
||||
// In case of error, return a 'null' observable for this request, so it doesn't affect other requests
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
@@ -72,13 +71,9 @@ export class GroupDirImportComponent implements OnInit, AfterViewInit {
|
||||
})
|
||||
).subscribe({
|
||||
next: (results) => {
|
||||
// Increment numAdded for each successful request
|
||||
// You can increment numAdded for each result that is not null
|
||||
numAdded += results.filter(result => result !== null).length;
|
||||
},
|
||||
error: (err) => {
|
||||
// You may need to handle any potential errors here
|
||||
console.log('An error occurred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AfterViewInit, Component, Inject, Input, OnDestroy, OnInit, ViewChild,
|
||||
import { ApiService } from '../../../services/user-management.api.service';
|
||||
import { GuiColumn, GuiColumnMenu, GuiSorting, GuiRowDetail, GuiPaging, GuiPagingDisplay, GuiSearching, GuiCellEdit, GuiInfoPanel, GuiTitlePanel, GuiRowSelection, GuiSelectedRow, GuiGridComponent, GuiGridApi, GuiTheme } from '@generic-ui/ngx-grid';
|
||||
import { Subscription } from 'rxjs/internal/Subscription';
|
||||
import { ColorModeService, Theme } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService, Theme } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-base-table',
|
||||
@@ -154,8 +154,7 @@ export class BaseTableComponent<TModel, TApiService extends ApiService<TModel>>
|
||||
this.source = response;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => console.error('Error fetching users:', error)
|
||||
error: (error) => {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { DirGroupService } from 'src/app/services/dir-group.service';
|
||||
import { DirGroup } from 'src/app/models/user-management.api.models';
|
||||
import { DirGroupService } from '../../../services/dir-group.service';
|
||||
import { DirGroup } from '../../../models/user-management.api.models';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dir-group-table',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { DirUser } from 'src/app/models/user-management.api.models';
|
||||
import { DirUserService } from 'src/app/services/dir-user.service';
|
||||
import { DirUser } from '../../../models/user-management.api.models';
|
||||
import { DirUserService } from '../../../services/dir-user.service';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid/gui/grid/src/core/api/gui.grid.public-api';
|
||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dir-user-table',
|
||||
@@ -21,7 +21,7 @@ export class DirUserTableComponent extends BaseTableComponent<DirUser, DirUserSe
|
||||
this.source = response;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error: any) => console.error('Error fetching users:', error)
|
||||
error: (error: any) => {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { GroupService } from '../../../services/group.service';
|
||||
import { Group } from '../../../models/user-management.api.models';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-table',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { GroupOfUserService } from '../../../services/group-of-user.service';
|
||||
import { GroupOfUser } from '../../../models/user-management.api.models';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-user-table',
|
||||
@@ -22,7 +22,7 @@ export class GroupUserTableComponent extends BaseTableComponent<GroupOfUser, Gro
|
||||
next: (response) => {
|
||||
this.source = response;
|
||||
},
|
||||
error: (error) => console.error('Error fetching users:', error)
|
||||
error: (error) => {}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { Module } from '../../../models/user-management.api.models';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { ModuleService } from '../../../services/module.service'
|
||||
import { ColorModeService } from 'src/app/services/color-mode.service';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-module-table',
|
||||
|
||||
@@ -19,11 +19,11 @@ export class UserRepTableComponent extends BaseTableComponent<UserRep, UserRepSe
|
||||
|
||||
override fetchData(userId?: number): void {
|
||||
this.service.getAll(false, true, true, true, userId).subscribe({
|
||||
next: (response: any) => {
|
||||
next: (response: UserRep[]) => {
|
||||
this.source = response;
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error: any) => console.error('Error fetching users:', error)
|
||||
error: (error: any) => {}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,11 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
||||
mosService: ModuleOfUserService;
|
||||
gosService: GroupOfUserService;
|
||||
|
||||
constructor(mosService: ModuleOfUserService, gosService: GroupOfUserService, service: UserService, @Inject('USER_TABLE_COLUMNS') columns: Array<GuiColumn>, cModeService: ColorModeService) {
|
||||
constructor(mosService: ModuleOfUserService,
|
||||
gosService: GroupOfUserService,
|
||||
service: UserService,
|
||||
@Inject('USER_TABLE_COLUMNS') columns: Array<GuiColumn>,
|
||||
cModeService: ColorModeService) {
|
||||
super(service, columns, cModeService)
|
||||
this.mosService = mosService;
|
||||
this.gosService = gosService;
|
||||
@@ -28,7 +32,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
||||
next: (users) => {
|
||||
this.source = users;
|
||||
},
|
||||
error: (error) => console.error('Error fetching users:', error)
|
||||
error: (error) => {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +41,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
||||
next: (users) => {
|
||||
this.source = users;
|
||||
},
|
||||
error: (error) => console.error('Error fetching users:', error)
|
||||
error: (error) => {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,13 +68,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
||||
|
||||
try {
|
||||
const responses = await Promise.all(deletionPromises);
|
||||
responses.forEach(response => {
|
||||
if (!response?.isSuccess) {
|
||||
console.error(response?.messages);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error deleting module of users:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,13 +79,7 @@ export class UserTableComponent extends BaseTableComponent<User, UserService> {
|
||||
|
||||
try {
|
||||
const responses = await Promise.all(deletionPromises);
|
||||
responses.forEach(response => {
|
||||
if (!response?.isSuccess) {
|
||||
console.error(response?.messages);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error deleting group of users:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
import { AfterViewInit, Component, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { GuiRowSelection, GuiRowSelectionMode, GuiRowSelectionType, GuiSelectedRow } from '@generic-ui/ngx-grid';
|
||||
import Swal from 'sweetalert2';
|
||||
import { GroupService } from 'src/app/services/group.service';
|
||||
import { forkJoin, of } from 'rxjs';
|
||||
import { GroupService } from '../../services/group.service';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { catchError, finalize } from 'rxjs/operators';
|
||||
import { DirGroupTableComponent } from '../tables/dir-group-table/dir-group-table.component';
|
||||
import { DirUserTableComponent } from '../tables/dir-user-table/dir-user-table.component';
|
||||
import { UserService } from 'src/app/services/user.service';
|
||||
import { UserService } from '../../services/user.service';
|
||||
import {User} from '../../models/user-management.api.models'
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-group-dir-import',
|
||||
@@ -43,10 +44,9 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
addSelectedUsers() {
|
||||
let requests = [];
|
||||
let requests = new Array<Observable<User | null>>();
|
||||
let numAdded: number = 0;
|
||||
for (let row of this.dirUsers.selectedRows) {
|
||||
console.log(row)
|
||||
// Create an Observable for each request and add it to the requests array
|
||||
requests.push(
|
||||
this.uService.create({
|
||||
@@ -56,8 +56,6 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
||||
name: row.source?.sn?.[0],
|
||||
}).pipe(
|
||||
catchError((err) => {
|
||||
console.log('An error occurred', err);
|
||||
// In case of error, return a 'null' observable for this request, so it doesn't affect other requests
|
||||
return of(null);
|
||||
})
|
||||
)
|
||||
@@ -81,13 +79,9 @@ export class UserGroupDirImportComponent implements OnInit, AfterViewInit {
|
||||
})
|
||||
).subscribe({
|
||||
next: (results) => {
|
||||
// Increment numAdded for each successful request
|
||||
// You can increment numAdded for each result that is not null
|
||||
numAdded += results.filter(result => result !== null).length;
|
||||
},
|
||||
error: (err) => {
|
||||
// You may need to handle any potential errors here
|
||||
console.log('An error occurred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { GuiColumn, GuiSelectedRow } from '@generic-ui/ngx-grid/gui/grid/src/cor
|
||||
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
||||
import { UserRepTableComponent } from '../tables/user-rep-table/user-rep-table.component';
|
||||
import { GroupTableComponent } from '../tables/group-table/group-table.component';
|
||||
import { UserRepService } from 'src/app/services/user-representation.service';
|
||||
import { UserRepService } from '../../services/user-representation.service';
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -12,12 +12,9 @@ export class UserComponent {
|
||||
cellEditing: GuiCellEdit = {
|
||||
enabled: true,
|
||||
rowEdit: (value: any, item: any, index: number) => {
|
||||
console.log("rowEdit", value, item, index)
|
||||
console.log(this.userTable.selectedRows)
|
||||
return Boolean(index % 2);
|
||||
},
|
||||
cellEdit: (value: any, item: any, index: number) => {
|
||||
console.log("cellEdit", value, item, index)
|
||||
return Boolean(index % 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,3 @@ export interface DirUser {
|
||||
mail?: string;
|
||||
addedWho?: string;
|
||||
}
|
||||
|
||||
export interface AuthCheckDto {
|
||||
isAuthenticated: boolean;
|
||||
}
|
||||
@@ -60,7 +60,6 @@ export class NavMenuComponent {
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
console.error("unexpected err happend", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { AuthCheckDto } from '../models/user-management.api.models';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Router } from '@angular/router';
|
||||
import Swal from 'sweetalert2';
|
||||
|
||||
@@ -9,15 +8,20 @@ import Swal from 'sweetalert2';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthenticationService {
|
||||
constructor(private router: Router, private http: HttpClient, @Inject('LOGIN_URL') private loginUrl: string, @Inject('LOGOUT_URL') private logoutUrl: string, @Inject('LOGIN_CHECK_URL') private checkUrl: string) { }
|
||||
constructor(
|
||||
private router: Router,
|
||||
private http: HttpClient,
|
||||
@Inject('LOGIN_URL') private loginUrl: string,
|
||||
@Inject('LOGOUT_URL') private logoutUrl: string,
|
||||
@Inject('LOGIN_CHECK_URL') private checkUrl: string) { }
|
||||
|
||||
isAuthenticated(): Observable<boolean> {
|
||||
return new Observable(observer => {
|
||||
this.http.get<AuthCheckDto>(this.checkUrl, { withCredentials: true })
|
||||
this.http.get<boolean>(this.checkUrl, { withCredentials: true })
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
_isLogedIn = response.isAuthenticated;
|
||||
observer.next(response.isAuthenticated)
|
||||
_isLogedIn = response;
|
||||
observer.next(response)
|
||||
},
|
||||
error: (error) => {
|
||||
this.showErrorAlert()
|
||||
@@ -54,11 +58,9 @@ export class AuthenticationService {
|
||||
this.http.post<any>(this.logoutUrl, {}, { withCredentials: true })
|
||||
.subscribe({
|
||||
next: (response) => {
|
||||
if (response.ok) {
|
||||
this.router.navigate(['/']);
|
||||
_isLogedIn = false;
|
||||
observer.next(response)
|
||||
}
|
||||
},
|
||||
error: (error) => observer.error(error),
|
||||
complete: () => observer.complete()
|
||||
|
||||
@@ -23,7 +23,6 @@ export class UserService extends ApiService<User> {
|
||||
}
|
||||
|
||||
createByDir(createModel: DirUser): Observable<DirUser> {
|
||||
console.log(createModel)
|
||||
return this.http.post<DirUser>(`${this.baseUrl}/byDir`, createModel, { withCredentials: true });
|
||||
}
|
||||
}
|
||||
@@ -184,4 +184,4 @@ if (environment.production) {
|
||||
}
|
||||
|
||||
platformBrowserDynamic(providers).bootstrapModule(AppModule)
|
||||
.catch(err => console.log(err));
|
||||
.catch(err => {});
|
||||
|
||||
Reference in New Issue
Block a user