mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-01 11:52:15 +00:00
* cli core * update material * imports * schematics * lint * rm ng-qrcode, ngx-quicklink * replace qr code lib * rm shared module as quicklink is removed * lazy loading imports * rm public * chore(deps): bump @grpc/grpc-js from 1.7.1 to 1.8.0 in /console (#4857) Bumps [@grpc/grpc-js](https://github.com/grpc/grpc-node) from 1.7.1 to 1.8.0. - [Release notes](https://github.com/grpc/grpc-node/releases) - [Commits](https://github.com/grpc/grpc-node/compare/v1.7.1...@grpc/[email protected]) --- updated-dependencies: - dependency-name: "@grpc/grpc-js" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump libphonenumber-js from 1.10.13 to 1.10.15 in /console (#4861) Bumps [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) from 1.10.13 to 1.10.15. - [Release notes](https://gitlab.com/catamphetamine/libphonenumber-js/tags) - [Changelog](https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/CHANGELOG.md) - [Commits](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.10.13...v1.10.15) --- updated-dependencies: - dependency-name: libphonenumber-js dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * rxjs * chore(deps): bump engine.io from 6.2.0 to 6.2.1 in /console (#4734) Bumps [engine.io](https://github.com/socketio/engine.io) from 6.2.0 to 6.2.1. - [Release notes](https://github.com/socketio/engine.io/releases) - [Changelog](https://github.com/socketio/engine.io/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/engine.io/compare/6.2.0...6.2.1) --- updated-dependencies: - dependency-name: engine.io dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * lock * lint * rm comments * tsconfig ES2022 * get rid of polyfills file * use node 18 * rm age policy, legacy components * packages * build beta prerelease * remove pre-release build Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Livio Spring <[email protected]>
157 lines
5.3 KiB
TypeScript
157 lines
5.3 KiB
TypeScript
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
|
import { Component, Input, ViewChild } from '@angular/core';
|
|
import { MatSort, Sort } from '@angular/material/sort';
|
|
import { MatLegacyTableDataSource as MatTableDataSource } from '@angular/material/legacy-table';
|
|
import { Router } from '@angular/router';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
|
import { BehaviorSubject, catchError, finalize, from, map, Observable, of, Subject, switchMap, take, takeUntil } from 'rxjs';
|
|
import { Org, OrgFieldName, OrgQuery, OrgState } from 'src/app/proto/generated/zitadel/org_pb';
|
|
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { PaginatorComponent } from '../paginator/paginator.component';
|
|
|
|
enum OrgListSearchKey {
|
|
NAME = 'NAME',
|
|
}
|
|
|
|
type Request = { limit: number; offset: number; queries: OrgQuery[] };
|
|
|
|
@Component({
|
|
selector: 'cnsl-org-table',
|
|
templateUrl: './org-table.component.html',
|
|
styleUrls: ['./org-table.component.scss'],
|
|
})
|
|
export class OrgTableComponent {
|
|
public orgSearchKey: OrgListSearchKey | undefined = undefined;
|
|
|
|
@ViewChild(PaginatorComponent) public paginator!: PaginatorComponent;
|
|
@ViewChild('input') public filter!: Input;
|
|
|
|
public dataSource: MatTableDataSource<Org.AsObject> = new MatTableDataSource<Org.AsObject>([]);
|
|
public displayedColumns: string[] = ['name', 'state', 'primaryDomain', 'creationDate', 'changeDate'];
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
|
public activeOrg!: Org.AsObject;
|
|
public OrgListSearchKey: any = OrgListSearchKey;
|
|
public initialLimit: number = 20;
|
|
public timestamp: Timestamp.AsObject | undefined = undefined;
|
|
public totalResult: number = 0;
|
|
public filterOpen: boolean = false;
|
|
public OrgState: any = OrgState;
|
|
public copied: string = '';
|
|
@ViewChild(MatSort) public sort!: MatSort;
|
|
|
|
private searchQueries: OrgQuery[] = [];
|
|
private destroy$: Subject<void> = new Subject();
|
|
private requestOrgs$: BehaviorSubject<Request> = new BehaviorSubject<Request>({
|
|
limit: this.initialLimit,
|
|
offset: 0,
|
|
queries: [],
|
|
});
|
|
private requestOrgsObservable$ = this.requestOrgs$.pipe(takeUntil(this.destroy$));
|
|
|
|
constructor(
|
|
private authService: GrpcAuthService,
|
|
private router: Router,
|
|
private toast: ToastService,
|
|
private _liveAnnouncer: LiveAnnouncer,
|
|
private translate: TranslateService,
|
|
) {
|
|
this.requestOrgs$.next({ limit: this.initialLimit, offset: 0, queries: this.searchQueries });
|
|
this.authService.getActiveOrg().then((org) => (this.activeOrg = org));
|
|
|
|
this.requestOrgsObservable$.pipe(switchMap((req) => this.loadOrgs(req))).subscribe((orgs) => {
|
|
this.dataSource = new MatTableDataSource<Org.AsObject>(orgs);
|
|
});
|
|
}
|
|
|
|
public loadOrgs(request: Request): Observable<Org.AsObject[]> {
|
|
this.loadingSubject.next(true);
|
|
|
|
let sortingField: OrgFieldName | undefined = undefined;
|
|
if (this.sort?.active && this.sort?.direction)
|
|
switch (this.sort.active) {
|
|
case 'name':
|
|
sortingField = OrgFieldName.ORG_FIELD_NAME_NAME;
|
|
break;
|
|
}
|
|
|
|
return from(
|
|
this.authService.listMyProjectOrgs(request.limit, request.offset, request.queries, sortingField, this.sort?.direction),
|
|
).pipe(
|
|
map((resp) => {
|
|
this.timestamp = resp.details?.viewTimestamp;
|
|
this.totalResult = resp.details?.totalResult ?? 0;
|
|
return resp.resultList;
|
|
}),
|
|
catchError((error) => {
|
|
this.toast.showError(error);
|
|
return of([]);
|
|
}),
|
|
finalize(() => this.loadingSubject.next(false)),
|
|
);
|
|
}
|
|
|
|
public refresh(): void {
|
|
this.requestOrgs$.next({
|
|
limit: this.paginator.pageSize,
|
|
offset: this.paginator.pageSize * this.paginator.pageIndex,
|
|
queries: this.searchQueries,
|
|
});
|
|
}
|
|
|
|
public sortChange(sortState: Sort) {
|
|
if (sortState.direction && sortState.active) {
|
|
this._liveAnnouncer.announce(`Sorted ${sortState.direction}ending`);
|
|
this.refresh();
|
|
} else {
|
|
this._liveAnnouncer.announce('Sorting cleared');
|
|
}
|
|
}
|
|
|
|
public applySearchQuery(searchQueries: OrgQuery[]): void {
|
|
this.searchQueries = searchQueries;
|
|
this.requestOrgs$.next({
|
|
limit: this.paginator ? this.paginator.pageSize : this.initialLimit,
|
|
offset: this.paginator ? this.paginator.pageSize * this.paginator.pageIndex : 0,
|
|
queries: this.searchQueries,
|
|
});
|
|
}
|
|
|
|
public setFilter(key: OrgListSearchKey): void {
|
|
setTimeout(() => {
|
|
if (this.filter) {
|
|
(this.filter as any).nativeElement.focus();
|
|
}
|
|
}, 100);
|
|
|
|
if (this.orgSearchKey !== key) {
|
|
this.orgSearchKey = key;
|
|
} else {
|
|
this.orgSearchKey = undefined;
|
|
this.refresh();
|
|
}
|
|
}
|
|
|
|
public setAndNavigateToOrg(org: Org.AsObject): void {
|
|
if (org.state !== OrgState.ORG_STATE_REMOVED) {
|
|
this.authService.setActiveOrg(org);
|
|
this.router.navigate(['/org']);
|
|
} else {
|
|
this.translate.get('ORG.TOAST.ORG_WAS_DELETED').subscribe((data) => {
|
|
this.toast.showInfo(data);
|
|
});
|
|
}
|
|
}
|
|
|
|
public changePage(): void {
|
|
this.refresh();
|
|
}
|
|
|
|
public gotoRouterLink(rL: any) {
|
|
this.router.navigate(rL);
|
|
}
|
|
}
|