mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 01:18:51 +00:00
* routes, move grid to list comopnent * rename app list component, move to project sub * add owned-project-detail child module * seperate pipes * set password validators only if needed * create org initialize without pwd * no caps * self xss message * fix user table * fix project member paginator * fix project members pagination, user grant pag * move project grants, fix imports * fix owned project detail imports * use pipe and directives * ng content bindings, rem custom schemas * i18n, fix error toast parameter * toast i18n * side background * fix: sequence, add timestamp * audit * fix metanav background * org domain label * cleanup policy component * shorten user grant roles, mk cols visible as bind * move user components, show otp only if available * preload modules * fix password change * fix org create buttons * class css
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import { DataSource } from '@angular/cdk/collections';
|
|
import { BehaviorSubject, from, Observable, of } from 'rxjs';
|
|
import { catchError, finalize, map } from 'rxjs/operators';
|
|
import { Application } from 'src/app/proto/generated/management_pb';
|
|
import { ProjectService } from 'src/app/services/project.service';
|
|
|
|
/**
|
|
* Data source for the ProjectMembers view. This class should
|
|
* encapsulate all logic for fetching and manipulating the displayed data
|
|
* (including sorting, pagination, and filtering).
|
|
*/
|
|
export class ProjectApplicationsDataSource extends DataSource<Application.AsObject> {
|
|
public totalResult: number = 0;
|
|
public appsSubject: BehaviorSubject<Application.AsObject[]> = new BehaviorSubject<Application.AsObject[]>([]);
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
|
|
|
constructor(private projectService: ProjectService) {
|
|
super();
|
|
}
|
|
|
|
public loadApps(projectId: string, pageIndex: number, pageSize: number, sortDirection?: string): void {
|
|
const offset = pageIndex * pageSize;
|
|
|
|
this.loadingSubject.next(true);
|
|
from(this.projectService.SearchApplications(projectId, pageSize, offset)).pipe(
|
|
map(resp => {
|
|
this.totalResult = resp.toObject().totalResult;
|
|
return resp.toObject().resultList;
|
|
}),
|
|
catchError(() => of([])),
|
|
finalize(() => this.loadingSubject.next(false)),
|
|
).subscribe(apps => {
|
|
this.appsSubject.next(apps);
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* Connect this data source to the table. The table will only update when
|
|
* the returned stream emits new items.
|
|
* @returns A stream of the items to be rendered.
|
|
*/
|
|
public connect(): Observable<Application.AsObject[]> {
|
|
return this.appsSubject.asObservable();
|
|
}
|
|
|
|
/**
|
|
* Called when the table is being destroyed. Use this function, to clean up
|
|
* any open connections or free any held resources that were set up during connect.
|
|
*/
|
|
public disconnect(): void {
|
|
this.appsSubject.complete();
|
|
this.loadingSubject.complete();
|
|
}
|
|
}
|