feat: RefreshService zu UserRepresentationComponent hinzugefügt und integriert
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Inject, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, Inject, ViewChild } from '@angular/core';
|
||||||
import { GuiColumn, GuiSelectedRow } from '@generic-ui/ngx-grid/gui/grid/src/core/api/gui.grid.public-api';
|
import { GuiColumn, GuiSelectedRow } from '@generic-ui/ngx-grid/gui/grid/src/core/api/gui.grid.public-api';
|
||||||
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
import { UserTableComponent } from '../tables/user-table/user-table.component';
|
||||||
import { UserRepTableComponent } from '../tables/user-rep-table/user-rep-table.component';
|
import { UserRepTableComponent } from '../tables/user-rep-table/user-rep-table.component';
|
||||||
@@ -7,6 +7,7 @@ import { UserRepService } from '../../services/user-representation.service';
|
|||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { MatTabsModule, MatTabGroup } from '@angular/material/tabs';
|
import { MatTabsModule, MatTabGroup } from '@angular/material/tabs';
|
||||||
import { env } from '../../../environments/environment';
|
import { env } from '../../../environments/environment';
|
||||||
|
import { RefreshService } from '../../services/refresh.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -15,7 +16,7 @@ import { env } from '../../../environments/environment';
|
|||||||
templateUrl: './user-representation.component.html',
|
templateUrl: './user-representation.component.html',
|
||||||
styleUrl: './user-representation.component.css'
|
styleUrl: './user-representation.component.css'
|
||||||
})
|
})
|
||||||
export class UserRepresentationComponent {
|
export class UserRepresentationComponent implements AfterViewInit {
|
||||||
|
|
||||||
useRepLabel: string = "";
|
useRepLabel: string = "";
|
||||||
groupRepCols: Array<GuiColumn>;
|
groupRepCols: Array<GuiColumn>;
|
||||||
@@ -25,16 +26,25 @@ export class UserRepresentationComponent {
|
|||||||
slRepGroupId: null | number = null;
|
slRepGroupId: null | number = null;
|
||||||
slRightGroupId: null | number = null;
|
slRightGroupId: null | number = null;
|
||||||
slUserRepId: null | number = null;
|
slUserRepId: null | number = null;
|
||||||
userRepService: UserRepService
|
|
||||||
|
|
||||||
initWithoutData = () => { }
|
initWithoutData = () => { }
|
||||||
|
|
||||||
constructor(userRepService: UserRepService) {
|
constructor(private userRepService: UserRepService, private refreshService: RefreshService) {
|
||||||
this.groupRepCols = env.columnNames.group.representative;
|
this.groupRepCols = env.columnNames.group.representative;
|
||||||
this.groupRightColumns = env.columnNames.group.right;
|
this.groupRightColumns = env.columnNames.group.right;
|
||||||
this.userRepService = userRepService;
|
this.userRepService = userRepService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
this.refreshService.removeAll();
|
||||||
|
this.refreshService.add(() => {
|
||||||
|
this.users.fetchData();
|
||||||
|
this.repUsers.fetchData();
|
||||||
|
this.repGroups.fetchData();
|
||||||
|
this.rightGroups.fetchData();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@ViewChild("users") users!: UserTableComponent;
|
@ViewChild("users") users!: UserTableComponent;
|
||||||
@ViewChild("repUsers") repUsers!: UserTableComponent;
|
@ViewChild("repUsers") repUsers!: UserTableComponent;
|
||||||
@ViewChild("repGroups") repGroups!: GroupTableComponent;
|
@ViewChild("repGroups") repGroups!: GroupTableComponent;
|
||||||
@@ -96,11 +106,10 @@ export class UserRepresentationComponent {
|
|||||||
this.userReps.fetchData(this.slUserId)
|
this.userReps.fetchData(this.slUserId)
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
const errorMessage = error?.error || "Es ist ein unerwarteter Fehler aufgetreten.";
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
icon: "error",
|
icon: "error",
|
||||||
title: "Oops...",
|
title: "Oops...",
|
||||||
text: `${errorMessage}\nBitte versuchen Sie es später noch einmal.`,
|
text: `Bitte versuchen Sie es später noch einmal.`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user