1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

move ciphers, groupings, and search pipe to jslib

This commit is contained in:
Kyle Spearrin
2018-04-05 11:12:00 -04:00
parent a0ca51dda4
commit 22f0f97cda
3 changed files with 195 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
import {
EventEmitter,
Input,
Output,
} from '@angular/core';
import { CipherService } from '../../abstractions/cipher.service';
import { CipherView } from '../../models/view/cipherView';
export class CiphersComponent {
@Input() activeCipherId: string = null;
@Output() onCipherClicked = new EventEmitter<CipherView>();
@Output() onCipherRightClicked = new EventEmitter<CipherView>();
@Output() onAddCipher = new EventEmitter();
@Output() onAddCipherOptions = new EventEmitter();
loaded: boolean = false;
ciphers: CipherView[] = [];
searchText: string;
searchPlaceholder: string = null;
private filter: (cipher: CipherView) => boolean = null;
constructor(protected cipherService: CipherService) { }
async load(filter: (cipher: CipherView) => boolean = null) {
this.filter = filter;
const ciphers = await this.cipherService.getAllDecrypted();
if (this.filter == null) {
this.ciphers = ciphers;
} else {
this.ciphers = ciphers.filter(this.filter);
}
this.loaded = true;
}
async refresh() {
this.loaded = false;
this.ciphers = [];
await this.load(this.filter);
}
selectCipher(cipher: CipherView) {
this.onCipherClicked.emit(cipher);
}
rightClickCipher(cipher: CipherView) {
this.onCipherRightClicked.emit(cipher);
}
addCipher() {
this.onAddCipher.emit();
}
addCipherOptions() {
this.onAddCipherOptions.emit();
}
}