2021-12-16 13:36:21 +01:00
|
|
|
import { Directive, OnInit } from "@angular/core";
|
2018-04-06 04:21:18 +02:00
|
|
|
|
2021-12-16 13:36:21 +01:00
|
|
|
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
|
|
|
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
|
|
|
|
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
|
|
|
import { GeneratedPasswordHistory } from "jslib-common/models/domain/generatedPasswordHistory";
|
2018-04-06 04:21:18 +02:00
|
|
|
|
2021-04-22 21:17:14 +02:00
|
|
|
@Directive()
|
2018-04-06 04:21:18 +02:00
|
|
|
export class PasswordGeneratorHistoryComponent implements OnInit {
|
2021-12-16 13:36:21 +01:00
|
|
|
history: GeneratedPasswordHistory[] = [];
|
2018-04-06 04:21:18 +02:00
|
|
|
|
2021-12-16 13:36:21 +01:00
|
|
|
constructor(
|
|
|
|
protected passwordGenerationService: PasswordGenerationService,
|
|
|
|
protected platformUtilsService: PlatformUtilsService,
|
|
|
|
protected i18nService: I18nService,
|
|
|
|
private win: Window
|
|
|
|
) {}
|
2018-04-06 04:21:18 +02:00
|
|
|
|
2021-12-16 13:36:21 +01:00
|
|
|
async ngOnInit() {
|
|
|
|
this.history = await this.passwordGenerationService.getHistory();
|
|
|
|
}
|
2018-04-06 04:21:18 +02:00
|
|
|
|
2021-12-16 13:36:21 +01:00
|
|
|
clear() {
|
|
|
|
this.history = [];
|
|
|
|
this.passwordGenerationService.clear();
|
|
|
|
}
|
2018-04-06 04:21:18 +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"))
|
|
|
|
);
|
|
|
|
}
|
2018-04-06 04:21:18 +02:00
|
|
|
}
|