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
|
|
|
|
2021-06-07 19:25:37 +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
|
|
|
|
2021-06-07 19:25:37 +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,
|
2021-06-07 19:25:37 +02:00
|
|
|
} 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;
|
|
|
|
|
2018-10-03 06:21:22 +02:00
|
|
|
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();
|
2019-06-25 03:12:52 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|