bitwarden-estensione-browser/src/app/vault/view.component.ts

36 lines
799 B
TypeScript
Raw Normal View History

2018-01-24 04:21:14 +01:00
import * as template from './view.component.html';
import {
Component,
2018-01-24 23:41:57 +01:00
EventEmitter,
2018-01-24 04:21:14 +01:00
Input,
OnChanges,
2018-01-24 23:41:57 +01:00
Output,
2018-01-24 04:21:14 +01:00
} from '@angular/core';
2018-01-24 06:06:05 +01:00
import { CipherService } from 'jslib/abstractions/cipher.service';
2018-01-24 18:20:01 +01:00
import { CipherView } from 'jslib/models/view/cipherView';
2018-01-24 04:21:14 +01:00
@Component({
selector: 'app-vault-view',
template: template,
})
export class ViewComponent implements OnChanges {
@Input() cipherId: string;
2018-01-24 23:41:57 +01:00
@Output() onEditCipher = new EventEmitter<string>();
2018-01-24 18:20:01 +01:00
cipher: CipherView;
2018-01-24 04:21:14 +01:00
2018-01-24 06:06:05 +01:00
constructor(private cipherService: CipherService) {
2018-01-24 04:21:14 +01:00
}
2018-01-24 06:06:05 +01:00
async ngOnChanges() {
const cipher = await this.cipherService.get(this.cipherId);
this.cipher = await cipher.decrypt();
2018-01-24 04:21:14 +01:00
}
2018-01-24 23:41:57 +01:00
edit() {
this.onEditCipher.emit(this.cipher.id);
}
2018-01-24 04:21:14 +01:00
}