Add TenantGridViewDto and TenantService for tenant data management; refactor ProxyService to PalantirService
This commit is contained in:
parent
bfbe661ee8
commit
30c7c5ea76
@ -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';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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 }> {
|
||||
@ -0,0 +1,7 @@
|
||||
export interface TenantGridViewDto {
|
||||
id: string;
|
||||
isMaster: boolean;
|
||||
name: string;
|
||||
ownerId: string;
|
||||
visibility: string;
|
||||
}
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user