mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-28 12:35:40 +01:00
set generated password from add/edit
This commit is contained in:
parent
ce84e8e428
commit
40c5cfa10b
@ -4,7 +4,6 @@ import {
|
||||
Component,
|
||||
ComponentFactoryResolver,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
Type,
|
||||
@ -17,6 +16,10 @@ import {
|
||||
template: `<ng-template #container></ng-template>`,
|
||||
})
|
||||
export class ModalComponent implements OnDestroy {
|
||||
@Output() onClose = new EventEmitter();
|
||||
@Output() onClosed = new EventEmitter();
|
||||
@Output() onShow = new EventEmitter();
|
||||
@Output() onShown = new EventEmitter();
|
||||
@ViewChild('container', { read: ViewContainerRef }) container: ViewContainerRef;
|
||||
parentContainer: ViewContainerRef = null;
|
||||
fade: boolean = true;
|
||||
@ -29,6 +32,7 @@ export class ModalComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
show<T>(type: Type<T>, parentContainer: ViewContainerRef, fade: boolean = true): T {
|
||||
this.onShow.emit();
|
||||
this.parentContainer = parentContainer;
|
||||
this.fade = fade;
|
||||
|
||||
@ -50,10 +54,13 @@ export class ModalComponent implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
this.onShown.emit();
|
||||
return componentRef.instance;
|
||||
}
|
||||
|
||||
close() {
|
||||
this.onClose.emit();
|
||||
this.onClosed.emit();
|
||||
if (this.parentContainer != null) {
|
||||
this.parentContainer.clear();
|
||||
}
|
||||
|
@ -175,6 +175,11 @@ export class AddEditComponent implements OnChanges {
|
||||
}
|
||||
|
||||
generatePassword() {
|
||||
if (this.cipher.login != null && this.cipher.login.password != null && this.cipher.login.password.length &&
|
||||
!confirm(this.i18nService.t('overwritePasswordConfirmation'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onGeneratePassword.emit();
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="primary" appBlurClick *ngIf="showSelect">
|
||||
<button type="button" class="primary" appBlurClick *ngIf="showSelect" (click)="select()">
|
||||
<i class="fa fa-lg fa-check"></i> {{'select' | i18n}}
|
||||
</button>
|
||||
<button type="button" data-dismiss="modal">{{'close' | i18n}}</button>
|
||||
|
@ -20,6 +20,7 @@ import { UtilsService } from 'jslib/abstractions/utils.service';
|
||||
})
|
||||
export class PasswordGeneratorComponent implements OnInit {
|
||||
@Input() showSelect: boolean = false;
|
||||
@Output() onSelected = new EventEmitter<string>();
|
||||
|
||||
options: any = {};
|
||||
password: string = '-';
|
||||
@ -83,4 +84,9 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||
this.analytics.eventTrack.next({ action: 'Copied Generated Password' });
|
||||
this.utilsService.copyToClipboard(this.password, window.document);
|
||||
}
|
||||
|
||||
select() {
|
||||
this.analytics.eventTrack.next({ action: 'Selected Generated Password' });
|
||||
this.onSelected.emit(this.password);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
import { AddEditComponent } from './add-edit.component';
|
||||
import { CiphersComponent } from './ciphers.component';
|
||||
import { GroupingsComponent } from './groupings.component';
|
||||
import { PasswordGeneratorComponent } from './password-generator.component';
|
||||
@ -31,6 +32,7 @@ import { FolderView } from 'jslib/models/view/folderView';
|
||||
template: template,
|
||||
})
|
||||
export class VaultComponent implements OnInit {
|
||||
@ViewChild(AddEditComponent) addEditComponent: AddEditComponent;
|
||||
@ViewChild(CiphersComponent) ciphersComponent: CiphersComponent;
|
||||
@ViewChild(GroupingsComponent) groupingsComponent: GroupingsComponent;
|
||||
@ViewChild('passwordGenerator', { read: ViewContainerRef }) passwordGeneratorModal: ViewContainerRef;
|
||||
@ -176,7 +178,15 @@ export class VaultComponent implements OnInit {
|
||||
let modal = componentRef.instance as ModalComponent;
|
||||
let childComponent = modal.show<PasswordGeneratorComponent>(PasswordGeneratorComponent,
|
||||
this.passwordGeneratorModal);
|
||||
|
||||
childComponent.showSelect = true;
|
||||
childComponent.onSelected.subscribe((password: string) => {
|
||||
modal.close();
|
||||
if (this.addEditComponent != null && this.addEditComponent.cipher != null &&
|
||||
this.addEditComponent.cipher.login != null) {
|
||||
this.addEditComponent.cipher.login.password = password;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private clearFilters() {
|
||||
|
Loading…
Reference in New Issue
Block a user