zitadel/console/src/app/services/admin.service.ts
Max Peintner 124988e2d2
feat(console): organization overview table, table, org context filtering, fix grpc error log, cleanup pipes (#796)
* chore(deps-dev): bump @angular/cli from 10.0.8 to 10.1.3 in /console (#785)

Bumps [@angular/cli](https://github.com/angular/angular-cli) from 10.0.8 to 10.1.3.
- [Release notes](https://github.com/angular/angular-cli/releases)
- [Commits](https://github.com/angular/angular-cli/compare/v10.0.8...v10.1.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @angular-devkit/build-angular in /console (#784)

Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.1000.8 to 0.1001.3.
- [Release notes](https://github.com/angular/angular-cli/releases)
- [Commits](https://github.com/angular/angular-cli/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Peintner <max@caos.ch>

* chore(deps-dev): bump @angular/language-service in /console (#783)

Bumps [@angular/language-service](https://github.com/angular/angular/tree/HEAD/packages/language-service) from 10.1.0 to 10.1.3.
- [Release notes](https://github.com/angular/angular/releases)
- [Changelog](https://github.com/angular/angular/blob/master/CHANGELOG.md)
- [Commits](https://github.com/angular/angular/commits/10.1.3/packages/language-service)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump stylelint from 13.7.1 to 13.7.2 in /console (#782)

Bumps [stylelint](https://github.com/stylelint/stylelint) from 13.7.1 to 13.7.2.
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/13.7.1...13.7.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump karma from 5.2.1 to 5.2.3 in /console (#781)

Bumps [karma](https://github.com/karma-runner/karma) from 5.2.1 to 5.2.3.
- [Release notes](https://github.com/karma-runner/karma/releases)
- [Changelog](https://github.com/karma-runner/karma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/karma-runner/karma/compare/v5.2.1...v5.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump moment from 2.27.0 to 2.29.0 in /console (#780)

Bumps [moment](https://github.com/moment/moment) from 2.27.0 to 2.29.0.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.27.0...2.29.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/node from 14.6.4 to 14.11.2 in /console (#778)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.6.4 to 14.11.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump prettier from 2.1.1 to 2.1.2 in /console (#757)

Bumps [prettier](https://github.com/prettier/prettier) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.1...2.1.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump ts-protoc-gen from 0.12.0 to 0.13.0 in /console (#737)

Bumps [ts-protoc-gen](https://github.com/improbable-eng/ts-protoc-gen) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/improbable-eng/ts-protoc-gen/releases)
- [Changelog](https://github.com/improbable-eng/ts-protoc-gen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/improbable-eng/ts-protoc-gen/compare/0.12.0...0.13.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump jasmine-spec-reporter in /console (#762)

Bumps [jasmine-spec-reporter](https://github.com/bcaudan/jasmine-spec-reporter) from 5.0.2 to 6.0.0.
- [Release notes](https://github.com/bcaudan/jasmine-spec-reporter/releases)
- [Changelog](https://github.com/bcaudan/jasmine-spec-reporter/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bcaudan/jasmine-spec-reporter/compare/v5.0.2...v6.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Peintner <max@caos.ch>

* fix: package

* change html lang to translation lang

* disable detail view org idp

* catch errorcode 16 in auth response interceptor

* new icons

* refactor pipes, idp table config

* fix router guard

* lint

* allowed commonjs deps

* Update console/src/assets/i18n/en.json

Co-authored-by: Florian Forster <florian@caos.ch>

* Update console/src/assets/i18n/de.json

Co-authored-by: Florian Forster <florian@caos.ch>

* clear table warning

* org overview table, header filter

* toolbar filter

* user table filter

* fix org filter themed color, reject error

* org context filter

* button cleanup

* commonjs deps, remove a11y module

* replace progressbar with spinner

* dynamic user, org filter

* ts lint, scss lint

* cleanup table, row highlighting

* lint

* fix i18n description, refresh idp list in login p

* remove async from grpc services, fix external idp

* remove external idp

* fix theme toggle

* change iam policy header i18n

* sticky action columns

* lint

* add i18n filter to user, remove unused org code

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Florian Forster <florian@caos.ch>
2020-10-01 15:53:43 +02:00

278 lines
7.8 KiB
TypeScript

import { Injectable } from '@angular/core';
import { Empty } from 'google-protobuf/google/protobuf/empty_pb';
import {
AddIamMemberRequest,
ChangeIamMemberRequest,
CreateHumanRequest,
CreateOrgRequest,
CreateUserRequest,
DefaultLoginPolicy,
DefaultLoginPolicyView,
FailedEventID,
FailedEvents,
IamMember,
IamMemberRoles,
IamMemberSearchQuery,
IamMemberSearchRequest,
IamMemberSearchResponse,
Idp,
IdpID,
IdpProviderID,
IdpProviderSearchRequest,
IdpProviderSearchResponse,
IdpSearchQuery,
IdpSearchRequest,
IdpSearchResponse,
IdpView,
OidcIdpConfig,
OidcIdpConfigCreate,
OidcIdpConfigUpdate,
OrgIamPolicy,
OrgIamPolicyID,
OrgIamPolicyRequest,
OrgSetUpRequest,
OrgSetUpResponse,
RemoveIamMemberRequest,
ViewID,
Views,
} from '../proto/generated/admin_pb';
import { IdpUpdate } from '../proto/generated/management_pb';
import { GrpcService } from './grpc.service';
@Injectable({
providedIn: 'root',
})
export class AdminService {
constructor(private readonly grpcService: GrpcService) { }
public SetUpOrg(
createOrgRequest: CreateOrgRequest,
humanRequest: CreateHumanRequest,
): Promise<OrgSetUpResponse> {
const req: OrgSetUpRequest = new OrgSetUpRequest();
const userReq: CreateUserRequest = new CreateUserRequest();
userReq.setHuman(humanRequest);
req.setOrg(createOrgRequest);
req.setUser(userReq);
return this.grpcService.admin.setUpOrg(req);
}
public GetIamMemberRoles(): Promise<IamMemberRoles> {
const req = new Empty();
return this.grpcService.admin.getIamMemberRoles(req);
}
public GetViews(): Promise<Views> {
const req = new Empty();
return this.grpcService.admin.getViews(req);
}
public GetFailedEvents(): Promise<FailedEvents> {
const req = new Empty();
return this.grpcService.admin.getFailedEvents(req);
}
public ClearView(viewname: string, db: string): Promise<Empty> {
const req: ViewID = new ViewID();
req.setDatabase(db);
req.setViewName(viewname);
return this.grpcService.admin.clearView(req);
}
public RemoveFailedEvent(viewname: string, db: string, sequence: number): Promise<Empty> {
const req: FailedEventID = new FailedEventID();
req.setDatabase(db);
req.setViewName(viewname);
req.setFailedSequence(sequence);
return this.grpcService.admin.removeFailedEvent(req);
}
public GetDefaultLoginPolicy(
): Promise<DefaultLoginPolicyView> {
const req = new Empty();
return this.grpcService.admin.getDefaultLoginPolicy(req);
}
public UpdateDefaultLoginPolicy(req: DefaultLoginPolicy): Promise<DefaultLoginPolicy> {
return this.grpcService.admin.updateDefaultLoginPolicy(req);
}
public AddIdpProviderToDefaultLoginPolicy(configId: string): Promise<IdpProviderID> {
const req = new IdpProviderID();
req.setIdpConfigId(configId);
return this.grpcService.admin.addIdpProviderToDefaultLoginPolicy(req);
}
public RemoveIdpProviderFromDefaultLoginPolicy(configId: string): Promise<Empty> {
const req = new IdpProviderID();
req.setIdpConfigId(configId);
return this.grpcService.admin.removeIdpProviderFromDefaultLoginPolicy(req);
}
public GetDefaultLoginPolicyIdpProviders(limit?: number, offset?: number): Promise<IdpProviderSearchResponse> {
const req = new IdpProviderSearchRequest();
if (limit) {
req.setLimit(limit);
}
if (offset) {
req.setOffset(offset);
}
return this.grpcService.admin.getDefaultLoginPolicyIdpProviders(req);
}
public SearchIdps(
limit?: number,
offset?: number,
queryList?: IdpSearchQuery[],
): Promise<IdpSearchResponse> {
const req = new IdpSearchRequest();
if (limit) {
req.setLimit(limit);
}
if (offset) {
req.setOffset(offset);
}
if (queryList) {
req.setQueriesList(queryList);
}
return this.grpcService.admin.searchIdps(req);
}
public IdpByID(
id: string,
): Promise<IdpView> {
const req = new IdpID();
req.setId(id);
return this.grpcService.admin.idpByID(req);
}
public UpdateIdp(
req: IdpUpdate,
): Promise<Idp> {
return this.grpcService.admin.updateIdpConfig(req);
}
public CreateOidcIdp(
req: OidcIdpConfigCreate,
): Promise<Idp> {
return this.grpcService.admin.createOidcIdp(req);
}
public UpdateOidcIdpConfig(
req: OidcIdpConfigUpdate,
): Promise<OidcIdpConfig> {
return this.grpcService.admin.updateOidcIdpConfig(req);
}
public RemoveIdpConfig(
id: string,
): Promise<Empty> {
const req = new IdpID;
req.setId(id);
return this.grpcService.admin.removeIdpConfig(req);
}
public DeactivateIdpConfig(
id: string,
): Promise<Empty> {
const req = new IdpID;
req.setId(id);
return this.grpcService.admin.deactivateIdpConfig(req);
}
public ReactivateIdpConfig(
id: string,
): Promise<Empty> {
const req = new IdpID;
req.setId(id);
return this.grpcService.admin.reactivateIdpConfig(req);
}
public SearchIamMembers(
limit: number,
offset: number,
queryList?: IamMemberSearchQuery[],
): Promise<IamMemberSearchResponse> {
const req = new IamMemberSearchRequest();
req.setLimit(limit);
req.setOffset(offset);
if (queryList) {
req.setQueriesList(queryList);
}
return this.grpcService.admin.searchIamMembers(req);
}
public RemoveIamMember(
userId: string,
): Promise<Empty> {
const req = new RemoveIamMemberRequest();
req.setUserId(userId);
return this.grpcService.admin.removeIamMember(req);
}
public AddIamMember(
userId: string,
rolesList: string[],
): Promise<IamMember> {
const req = new AddIamMemberRequest();
req.setUserId(userId);
req.setRolesList(rolesList);
return this.grpcService.admin.addIamMember(req);
}
public ChangeIamMember(
userId: string,
rolesList: string[],
): Promise<IamMember> {
const req = new ChangeIamMemberRequest();
req.setUserId(userId);
req.setRolesList(rolesList);
return this.grpcService.admin.changeIamMember(req);
}
public GetOrgIamPolicy(orgId: string): Promise<OrgIamPolicy> {
const req = new OrgIamPolicyID();
req.setOrgId(orgId);
return this.grpcService.admin.getOrgIamPolicy(req);
}
public CreateOrgIamPolicy(
orgId: string,
description: string,
userLoginMustBeDomain: boolean): Promise<OrgIamPolicy> {
const req = new OrgIamPolicyRequest();
req.setOrgId(orgId);
req.setDescription(description);
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
return this.grpcService.admin.createOrgIamPolicy(req);
}
public UpdateOrgIamPolicy(
orgId: string,
description: string,
userLoginMustBeDomain: boolean): Promise<OrgIamPolicy> {
const req = new OrgIamPolicyRequest();
req.setOrgId(orgId);
req.setDescription(description);
req.setUserLoginMustBeDomain(userLoginMustBeDomain);
return this.grpcService.admin.updateOrgIamPolicy(req);
}
public deleteOrgIamPolicy(
orgId: string,
): Promise<Empty> {
const req = new OrgIamPolicyID();
req.setOrgId(orgId);
return this.grpcService.admin.deleteOrgIamPolicy(req);
}
}