load item view cipher

This commit is contained in:
Kyle Spearrin 2018-01-24 00:06:05 -05:00
parent 5703782a0f
commit b16ae24d58
7 changed files with 28 additions and 16 deletions

View File

@ -14,7 +14,7 @@ export class FallbackSrcDirective {
constructor(private el: ElementRef) { constructor(private el: ElementRef) {
} }
@HostListener('error') OnError() { @HostListener('error') onError() {
this.el.nativeElement.src = this.appFallbackSrc; this.el.nativeElement.src = this.appFallbackSrc;
} }
} }

View File

@ -10,7 +10,7 @@
<div class="content"> <div class="content">
<div class="list"> <div class="list">
<div class="list-section" style="padding-top: 0; padding-bottom: 0;"> <div class="list-section" style="padding-top: 0; padding-bottom: 0;">
<a *ngFor="let cipher of ciphers" appStopClick (click)="viewCipher(cipher)" <a *ngFor="let cipher of ciphers" appStopClick (click)="cipherClicked(cipher)"
href="#" class="list-section-item condensed" title="View Item"> href="#" class="list-section-item condensed" title="View Item">
<app-vault-icon [cipher]="cipher"></app-vault-icon> <app-vault-icon [cipher]="cipher"></app-vault-icon>
<span class="text"> <span class="text">

View File

@ -2,8 +2,10 @@ import * as template from './ciphers.component.html';
import { import {
Component, Component,
EventEmitter,
Input, Input,
OnChanges, OnChanges,
Output,
} from '@angular/core'; } from '@angular/core';
@Component({ @Component({
@ -12,6 +14,7 @@ import {
}) })
export class CiphersComponent implements OnChanges { export class CiphersComponent implements OnChanges {
@Input() ciphers: any[]; @Input() ciphers: any[];
@Output() onCipherClicked = new EventEmitter<any>();
constructor() { constructor() {
@ -21,7 +24,7 @@ export class CiphersComponent implements OnChanges {
} }
viewCipher(cipher: any) { cipherClicked(cipher: any) {
console.log(cipher.id); this.onCipherClicked.emit(cipher);
} }
} }

View File

@ -1,5 +1,5 @@
<div id="vault"> <div id="vault">
<app-vault-groupings id="groupings"></app-vault-groupings> <app-vault-groupings id="groupings"></app-vault-groupings>
<app-vault-ciphers id="items" [ciphers]="ciphers"></app-vault-ciphers> <app-vault-ciphers id="items" [ciphers]="ciphers" (onCipherClicked)="viewCipher($event)"></app-vault-ciphers>
<app-vault-view id="details" [cipherId]="null"></app-vault-view> <app-vault-view id="details" *ngIf="cipher && details === 'view'" [cipherId]="cipher.id"></app-vault-view>
</div> </div>

View File

@ -13,12 +13,18 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
}) })
export class VaultComponent implements OnInit { export class VaultComponent implements OnInit {
ciphers: any[]; ciphers: any[];
cipher: any;
details: string;
constructor(private cipherService: CipherService) { constructor(private cipherService: CipherService) {
} }
async ngOnInit() { async ngOnInit() {
this.ciphers = await this.cipherService.getAllDecrypted(); this.ciphers = await this.cipherService.getAllDecrypted();
} }
viewCipher(cipher: any) {
this.cipher = cipher;
this.details = 'view';
}
} }

View File

@ -4,22 +4,22 @@
<div class="box-header"> <div class="box-header">
Item Information Item Information
</div> </div>
<div class="box-content"> <div class="box-content" *ngIf="cipher">
<div class="box-content-row"> <div class="box-content-row">
<span class="row-label">Name</span> <span class="row-label">Name</span>
Google {{cipher.name}}
</div> </div>
<div class="box-content-row"> <div class="box-content-row">
<span class="row-label">URI</span> <span class="row-label">URI</span>
https://google.com {{cipher.login.uri}}
</div> </div>
<div class="box-content-row"> <div class="box-content-row">
<span class="row-label">Username</span> <span class="row-label">Username</span>
hello@bitwarden.com {{cipher.login.username}}
</div> </div>
<div class="box-content-row"> <div class="box-content-row">
<span class="row-label">Password</span> <span class="row-label">Password</span>
JKsiuhfLKJDOsudfhjksdfjk {{cipher.login.password}}
</div> </div>
</div> </div>
<div class="box-footer"> <div class="box-footer">

View File

@ -6,18 +6,21 @@ import {
OnChanges, OnChanges,
} from '@angular/core'; } from '@angular/core';
import { CipherService } from 'jslib/abstractions/cipher.service';
@Component({ @Component({
selector: 'app-vault-view', selector: 'app-vault-view',
template: template, template: template,
}) })
export class ViewComponent implements OnChanges { export class ViewComponent implements OnChanges {
@Input() cipherId: string; @Input() cipherId: string;
cipher: any;
constructor() { constructor(private cipherService: CipherService) {
} }
ngOnChanges() { async ngOnChanges() {
const cipher = await this.cipherService.get(this.cipherId);
this.cipher = await cipher.decrypt();
} }
} }