1
0
mirror of https://github.com/bitwarden/desktop synced 2025-12-22 11:13:17 +00:00
Files
desktop/src/app/vault/ciphers.component.ts
2018-01-31 17:20:27 -05:00

53 lines
1.3 KiB
TypeScript

import * as template from './ciphers.component.html';
import {
Component,
EventEmitter,
Input,
Output,
} from '@angular/core';
import { CipherView } from 'jslib/models/view/cipherView';
import { CipherService } from 'jslib/abstractions/cipher.service';
@Component({
selector: 'app-vault-ciphers',
template: template,
})
export class CiphersComponent {
@Input() activeCipherId: string = null;
@Output() onCipherClicked = new EventEmitter<CipherView>();
@Output() onAddCipher = new EventEmitter();
ciphers: CipherView[] = [];
searchText: string;
searchPlaceholder: string = null;
private filter: (cipher: CipherView) => boolean = null;
constructor(private cipherService: CipherService) {}
async load(filter: (cipher: CipherView) => boolean = null) {
this.filter = filter;
let ciphers = await this.cipherService.getAllDecrypted();
if (this.filter == null) {
this.ciphers = ciphers;
} else {
this.ciphers = ciphers.filter(this.filter);
}
}
async refresh() {
await this.load(this.filter);
}
cipherClicked(cipher: CipherView) {
this.onCipherClicked.emit(cipher);
}
addCipher() {
this.onAddCipher.emit();
}
}