mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
move groupings, ciphers, and search pipe to jslib
This commit is contained in:
@@ -1,67 +1,17 @@
|
||||
import * as template from './ciphers.component.html';
|
||||
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
} from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
|
||||
import { CipherView } from 'jslib/models/view/cipherView';
|
||||
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-vault-ciphers',
|
||||
template: template,
|
||||
})
|
||||
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(private 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);
|
||||
}
|
||||
|
||||
cipherClicked(cipher: CipherView) {
|
||||
this.onCipherClicked.emit(cipher);
|
||||
}
|
||||
|
||||
cipherRightClicked(cipher: CipherView) {
|
||||
this.onCipherRightClicked.emit(cipher);
|
||||
}
|
||||
|
||||
addCipher() {
|
||||
this.onAddCipher.emit();
|
||||
}
|
||||
|
||||
addCipherOptions() {
|
||||
this.onAddCipherOptions.emit();
|
||||
export class CiphersComponent extends BaseCiphersComponent {
|
||||
constructor(cipherService: CipherService) {
|
||||
super(cipherService);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user