mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-27 06:38:46 +00:00
feat(console): friendly quota exhausted screen (#5790)
* fix: remove access interceptor for console * feat: show dialog on exhausted requests * fix exhausted cookie handling * fix quota exhausted screen * read instance mgmt from environment.json * fix interceptors * don't check cookie on environment.json * fix environment.json path * exclude environment.json from cookie check * remove cookie before loading env * use UTC to delete the cookie * delete cookie before fetching env * simplify cookie handling * lint * review cleanup * use exhausted property from env json * fix bootstrapping * lint * always open mgmt link if present * chore: fetch env json before ng serve * wait for cookie to be removed * fix typo * don't wait for cookie to be set
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Request, StatusCode, UnaryInterceptor, UnaryResponse } from 'grpc-web';
|
||||
import { EnvironmentService } from '../environment.service';
|
||||
import { ExhaustedService } from '../exhausted.service';
|
||||
|
||||
/**
|
||||
* ExhaustedGrpcInterceptor shows the exhausted dialog after receiving a gRPC response status 8.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ExhaustedGrpcInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
|
||||
constructor(private exhaustedSvc: ExhaustedService, private envSvc: EnvironmentService) {}
|
||||
|
||||
public async intercept(
|
||||
request: Request<TReq, TResp>,
|
||||
invoker: (request: Request<TReq, TResp>) => Promise<UnaryResponse<TReq, TResp>>,
|
||||
): Promise<UnaryResponse<TReq, TResp>> {
|
||||
return invoker(request).catch((error: any) => {
|
||||
if (error.code === StatusCode.RESOURCE_EXHAUSTED) {
|
||||
return this.exhaustedSvc
|
||||
.showExhaustedDialog(this.envSvc.env)
|
||||
.toPromise()
|
||||
.then(() => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user