mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
base cipher report component class
This commit is contained in:
@@ -2,8 +2,6 @@ import {
|
||||
Component,
|
||||
ComponentFactoryResolver,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
} from '@angular/core';
|
||||
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
@@ -12,34 +10,27 @@ import { CipherView } from 'jslib/models/view/cipherView';
|
||||
|
||||
import { CipherType } from 'jslib/enums/cipherType';
|
||||
|
||||
import { ModalComponent } from '../modal.component';
|
||||
import { AddEditComponent } from '../vault/add-edit.component';
|
||||
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
import { CipherReportComponent } from './cipher-report.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-inactive-two-factor-report',
|
||||
templateUrl: 'inactive-two-factor-report.component.html',
|
||||
})
|
||||
export class InactiveTwoFactorReportComponent implements OnInit {
|
||||
@ViewChild('cipherAddEdit', { read: ViewContainerRef }) cipherAddEditModalRef: ViewContainerRef;
|
||||
|
||||
loading = false;
|
||||
hasLoaded = false;
|
||||
export class InactiveTwoFactorReportComponent extends CipherReportComponent implements OnInit {
|
||||
services = new Map<string, string>();
|
||||
cipherDocs = new Map<string, string>();
|
||||
ciphers: CipherView[] = [];
|
||||
|
||||
private modal: ModalComponent = null;
|
||||
|
||||
constructor(private ciphersService: CipherService, private componentFactoryResolver: ComponentFactoryResolver) { }
|
||||
|
||||
async ngOnInit() {
|
||||
await this.load();
|
||||
constructor(private ciphersService: CipherService, componentFactoryResolver: ComponentFactoryResolver) {
|
||||
super(componentFactoryResolver);
|
||||
}
|
||||
|
||||
async load() {
|
||||
this.loading = true;
|
||||
ngOnInit() {
|
||||
this.load();
|
||||
}
|
||||
|
||||
async setCiphers() {
|
||||
try {
|
||||
await this.load2fa();
|
||||
} catch { }
|
||||
@@ -70,35 +61,6 @@ export class InactiveTwoFactorReportComponent implements OnInit {
|
||||
this.ciphers = inactive2faCiphers;
|
||||
this.cipherDocs = docs;
|
||||
}
|
||||
this.loading = false;
|
||||
this.hasLoaded = true;
|
||||
}
|
||||
|
||||
selectCipher(cipher: CipherView) {
|
||||
if (this.modal != null) {
|
||||
this.modal.close();
|
||||
}
|
||||
|
||||
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
||||
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
|
||||
const childComponent = this.modal.show<AddEditComponent>(
|
||||
AddEditComponent, this.cipherAddEditModalRef);
|
||||
|
||||
childComponent.cipherId = cipher == null ? null : cipher.id;
|
||||
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
|
||||
this.modal.close();
|
||||
await this.load();
|
||||
});
|
||||
childComponent.onDeletedCipher.subscribe(async (c: CipherView) => {
|
||||
this.modal.close();
|
||||
await this.load();
|
||||
});
|
||||
|
||||
this.modal.onClosed.subscribe(() => {
|
||||
this.modal = null;
|
||||
});
|
||||
|
||||
return childComponent;
|
||||
}
|
||||
|
||||
private async load2fa() {
|
||||
|
||||
Reference in New Issue
Block a user