mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
delete item
This commit is contained in:
@@ -4,20 +4,49 @@ import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnInit,
|
||||
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() ciphers: CipherView[];
|
||||
export class CiphersComponent implements OnInit {
|
||||
@Output() onCipherClicked = new EventEmitter<CipherView>();
|
||||
@Output() onAddCipher = new EventEmitter();
|
||||
|
||||
ciphers: CipherView[] = [];
|
||||
|
||||
constructor(private cipherService: CipherService) {
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
await this.loadCiphers();
|
||||
}
|
||||
|
||||
async refresh() {
|
||||
await this.loadCiphers();
|
||||
}
|
||||
|
||||
updateCipher(cipher: CipherView) {
|
||||
const i = this.ciphers.findIndex((c) => c.id === cipher.id);
|
||||
if (i > -1) {
|
||||
this.ciphers[i] = cipher;
|
||||
}
|
||||
}
|
||||
|
||||
removeCipher(cipherId: string) {
|
||||
const i = this.ciphers.findIndex((c) => c.id === cipherId);
|
||||
if (i > -1) {
|
||||
this.ciphers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
cipherClicked(cipher: CipherView) {
|
||||
this.onCipherClicked.emit(cipher);
|
||||
}
|
||||
@@ -25,4 +54,8 @@ export class CiphersComponent {
|
||||
addCipher() {
|
||||
this.onAddCipher.emit();
|
||||
}
|
||||
|
||||
private async loadCiphers() {
|
||||
this.ciphers = await this.cipherService.getAllDecrypted();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user