Add TenantGridViewDto and TenantService for tenant data management; refactor ProxyService to PalantirService

This commit is contained in:
Christian Werner 2025-10-22 02:56:58 +02:00
parent bfbe661ee8
commit 30c7c5ea76
4 changed files with 58 additions and 4 deletions

View File

@ -0,0 +1,14 @@
import {Injectable} from "@angular/core";
import {GandalfClient} from "../gandalf-client";
@Injectable({
providedIn: 'root'
})
export abstract class PalantirService extends GandalfClient {
protected base = '/api/appproxy/q5lBLamL6rKy';
}

View File

@ -1,16 +1,16 @@
import {Injectable} from "@angular/core";
import {GandalfClient} from "../gandalf-client";
import {lastValueFrom, Observable} from "rxjs";
import {PalantirService} from "./palantir.service";
@Injectable({
providedIn: 'root'
})
export class ProxyService extends GandalfClient {
export class SubjectService extends PalantirService {
private base = '/api/appproxy/q5lBLamL6rKy';
protected baseUrl = this.base + '/api/subject';
me$(onError?: (error: any) => void): Observable<{ "name": string }> {
return this.handleRequest(this.http.get<{ "name": string }>(this.base + '/api/subject/me'), onError);
return this.handleRequest(this.http.get<{ "name": string }>(this.baseUrl + '/me'), onError);
}
meAsync(onError?: (error: any) => void): Promise<{ "name": string }> {

View File

@ -0,0 +1,7 @@
export interface TenantGridViewDto {
id: string;
isMaster: boolean;
name: string;
ownerId: string;
visibility: string;
}

View File

@ -0,0 +1,33 @@
import {Injectable} from "@angular/core";
import {lastValueFrom, Observable, of} from "rxjs";
import {PalantirService} from '../palantir.service';
import {TenantGridViewDto} from './dtos/tenant-grid-view-dto';
@Injectable({
providedIn: 'root'
})
export class TenantService extends PalantirService {
protected baseUrl = this.base + '/api/tenant';
tenants$(onError?: (error: any) => void): Observable<TenantGridViewDto[]> {
return this.handleRequest(this.http.get<TenantGridViewDto[]>(this.baseUrl), onError);
}
tenantsAsync(onError?: (error: any) => void): Promise<TenantGridViewDto[]> {
return lastValueFrom(this.tenants$(onError));
}
getTenant$(id: string | null, onError?: (error: any) => void): Observable<TenantGridViewDto | null> {
if (id === null) {
return of(null);
}
return this.handleRequest(this.http.get<TenantGridViewDto | null>(this.baseUrl + `/${id}`), onError);
}
getTenantAsync(id: string | null, onError?: (error: any) => void): Promise<TenantGridViewDto | null> {
return lastValueFrom(this.getTenant$(id, onError));
}
}