bitwarden-estensione-browser/src/popup/generator/password-generator.componen...

51 lines
1.7 KiB
TypeScript
Raw Normal View History

2018-04-09 23:35:16 +02:00
import { Location } from '@angular/common';
2018-04-10 15:38:21 +02:00
import { Component } from '@angular/core';
2018-04-09 23:35:16 +02: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 { StateService } from 'jslib-common/abstractions/state.service';
2018-04-09 23:35:16 +02:00
import { CipherView } from 'jslib-common/models/view/cipherView';
2018-04-09 23:35:16 +02:00
import {
2018-04-11 05:49:46 +02:00
PasswordGeneratorComponent as BasePasswordGeneratorComponent,
} from 'jslib-angular/components/password-generator.component';
2018-04-09 23:35:16 +02:00
@Component({
selector: 'app-password-generator',
templateUrl: 'password-generator.component.html',
})
export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent {
private cipherState: CipherView;
constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, private stateService: StateService,
private location: Location) {
super(passwordGenerationService, platformUtilsService, i18nService, window);
2018-04-09 23:35:16 +02:00
}
async ngOnInit() {
await super.ngOnInit();
const addEditCipherInfo = await this.stateService.get<any>('addEditCipherInfo');
if (addEditCipherInfo != null) {
this.cipherState = addEditCipherInfo.cipher;
}
2018-04-10 15:38:21 +02:00
this.showSelect = this.cipherState != null;
2018-04-09 23:35:16 +02:00
}
select() {
super.select();
this.cipherState.login.password = this.password;
this.close();
}
2019-04-16 04:34:22 +02:00
lengthChanged() {
document.getElementById('length').focus();
}
2018-04-09 23:35:16 +02:00
close() {
this.location.back();
}
}