mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* rebase to master; add create access token button * add static method to access-tokens component
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { Component, OnInit } from "@angular/core";
|
|
import { ActivatedRoute } from "@angular/router";
|
|
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
|
|
|
|
import { DialogService } from "@bitwarden/components";
|
|
|
|
import { AccessTokenView } from "../models/view/access-token.view";
|
|
|
|
import { AccessService } from "./access.service";
|
|
import { AccessTokenCreateDialogComponent } from "./dialogs/access-token-create-dialog.component";
|
|
|
|
@Component({
|
|
selector: "sm-access-tokens",
|
|
templateUrl: "./access-tokens.component.html",
|
|
})
|
|
export class AccessTokenComponent implements OnInit {
|
|
accessTokens$: Observable<AccessTokenView[]>;
|
|
|
|
private serviceAccountId: string;
|
|
private organizationId: string;
|
|
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private accessService: AccessService,
|
|
private dialogService: DialogService
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.accessTokens$ = this.accessService.accessToken$.pipe(
|
|
startWith(null),
|
|
combineLatestWith(this.route.params),
|
|
switchMap(async ([_, params]) => {
|
|
this.organizationId = params.organizationId;
|
|
this.serviceAccountId = params.serviceAccountId;
|
|
return await this.getAccessTokens();
|
|
})
|
|
);
|
|
}
|
|
|
|
private async getAccessTokens(): Promise<AccessTokenView[]> {
|
|
return await this.accessService.getAccessTokens(this.organizationId, this.serviceAccountId);
|
|
}
|
|
|
|
protected openNewAccessTokenDialog() {
|
|
AccessTokenCreateDialogComponent.openNewAccessTokenDialog(
|
|
this.dialogService,
|
|
this.serviceAccountId,
|
|
this.organizationId
|
|
);
|
|
}
|
|
}
|