bitwarden-estensione-browser/angular/src/components/password-history.component.ts

41 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-12-16 13:36:21 +01:00
import { Directive, OnInit } from "@angular/core";
2018-07-30 16:04:20 +02:00
2021-12-16 13:36:21 +01:00
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
2018-07-30 16:04:20 +02:00
2021-12-16 13:36:21 +01:00
import { PasswordHistoryView } from "jslib-common/models/view/passwordHistoryView";
2018-07-30 16:04:20 +02:00
@Directive()
2018-07-30 16:04:20 +02:00
export class PasswordHistoryComponent implements OnInit {
2021-12-16 13:36:21 +01:00
cipherId: string;
history: PasswordHistoryView[] = [];
2018-07-30 16:04:20 +02:00
2021-12-16 13:36:21 +01:00
constructor(
protected cipherService: CipherService,
protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService,
private win: Window
) {}
2018-07-30 16:04:20 +02:00
2021-12-16 13:36:21 +01:00
async ngOnInit() {
await this.init();
}
2018-07-30 16:04:20 +02:00
2021-12-16 13:36:21 +01:00
copy(password: string) {
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast(
"info",
null,
this.i18nService.t("valueCopied", this.i18nService.t("password"))
);
}
2019-03-06 20:31:32 +01:00
2021-12-16 13:36:21 +01:00
protected async init() {
const cipher = await this.cipherService.get(this.cipherId);
const decCipher = await cipher.decrypt();
this.history = decCipher.passwordHistory == null ? [] : decCipher.passwordHistory;
}
2018-07-30 16:04:20 +02:00
}