mirror of
https://github.com/bitwarden/browser
synced 2025-12-24 12:13:39 +00:00
* migrate browser to generator libraries * migrate cli to generator libraries * migrate desktop to generator libraries * migrate angular library to generator libraries * migrate web to generator libraries
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { Component, NgZone } from "@angular/core";
|
|
import { ActivatedRoute } from "@angular/router";
|
|
|
|
import { GeneratorComponent as BaseGeneratorComponent } from "@bitwarden/angular/tools/generator/components/generator.component";
|
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
import { DialogService, ToastService } from "@bitwarden/components";
|
|
import {
|
|
PasswordGenerationServiceAbstraction,
|
|
UsernameGenerationServiceAbstraction,
|
|
} from "@bitwarden/generator-legacy";
|
|
|
|
import { PasswordGeneratorHistoryComponent } from "./password-generator-history.component";
|
|
|
|
@Component({
|
|
selector: "app-generator",
|
|
templateUrl: "generator.component.html",
|
|
})
|
|
export class GeneratorComponent extends BaseGeneratorComponent {
|
|
constructor(
|
|
passwordGenerationService: PasswordGenerationServiceAbstraction,
|
|
usernameGenerationService: UsernameGenerationServiceAbstraction,
|
|
accountService: AccountService,
|
|
platformUtilsService: PlatformUtilsService,
|
|
i18nService: I18nService,
|
|
logService: LogService,
|
|
route: ActivatedRoute,
|
|
ngZone: NgZone,
|
|
private dialogService: DialogService,
|
|
toastService: ToastService,
|
|
) {
|
|
super(
|
|
passwordGenerationService,
|
|
usernameGenerationService,
|
|
platformUtilsService,
|
|
accountService,
|
|
i18nService,
|
|
logService,
|
|
route,
|
|
ngZone,
|
|
window,
|
|
toastService,
|
|
);
|
|
if (platformUtilsService.isSelfHost()) {
|
|
// Allow only valid email forwarders for self host
|
|
this.forwardOptions = this.forwardOptions.filter((forwarder) => forwarder.validForSelfHosted);
|
|
}
|
|
}
|
|
|
|
get isSelfHosted(): boolean {
|
|
return this.platformUtilsService.isSelfHost();
|
|
}
|
|
|
|
async history() {
|
|
this.dialogService.open(PasswordGeneratorHistoryComponent);
|
|
}
|
|
|
|
lengthChanged() {
|
|
document.getElementById("length").focus();
|
|
}
|
|
|
|
minNumberChanged() {
|
|
document.getElementById("min-number").focus();
|
|
}
|
|
|
|
minSpecialChanged() {
|
|
document.getElementById("min-special").focus();
|
|
}
|
|
}
|