1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

menu with messages back to app

This commit is contained in:
Kyle Spearrin
2018-02-08 15:58:47 -05:00
parent 5e8ccd19c5
commit c76b4821c6
10 changed files with 233 additions and 61 deletions

View File

@@ -2,8 +2,10 @@ import * as template from './vault.component.html';
import { Location } from '@angular/common';
import {
ChangeDetectorRef,
Component,
ComponentFactoryResolver,
NgZone,
OnInit,
ViewChild,
ViewContainerRef,
@@ -15,6 +17,8 @@ import {
import { ModalComponent } from '../modal.component';
import { BroadcasterService } from '../services/broadcaster.service';
import { AddEditComponent } from './add-edit.component';
import { AttachmentsComponent } from './attachments.component';
import { CiphersComponent } from './ciphers.component';
@@ -48,12 +52,46 @@ export class VaultComponent implements OnInit {
type: CipherType = null;
folderId: string = null;
collectionId: string = null;
addType: CipherType = null;
constructor(private route: ActivatedRoute, private router: Router, private location: Location,
private componentFactoryResolver: ComponentFactoryResolver, private i18nService: I18nService) {
private componentFactoryResolver: ComponentFactoryResolver, private i18nService: I18nService,
private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef,
private ngZone: NgZone) {
}
async ngOnInit() {
this.broadcasterService.subscribe((message: any) => {
this.ngZone.run(async () => {
let detectChanges = true;
switch (message.command) {
case 'newLogin':
this.addCipher(CipherType.Login);
break;
case 'newCard':
this.addCipher(CipherType.Card);
break;
case 'newIdentity':
this.addCipher(CipherType.Identity);
break;
case 'newSecureNote':
this.addCipher(CipherType.SecureNote);
break;
case 'newFolder':
await this.addFolder();
break;
default:
detectChanges = false;
break;
}
if (detectChanges) {
this.changeDetectorRef.detectChanges();
}
});
});
this.route.queryParams.subscribe(async (params) => {
if (params.cipherId) {
const cipherView = new CipherView();
@@ -108,11 +146,12 @@ export class VaultComponent implements OnInit {
this.go();
}
addCipher() {
addCipher(type: CipherType = null) {
if (this.action === 'add') {
return;
}
this.addType = type;
this.action = 'add';
this.cipherId = null;
this.go();