2018-06-05 05:10:41 +02:00
|
|
|
import {
|
2018-08-21 04:21:13 +02:00
|
|
|
ChangeDetectorRef,
|
2018-06-05 05:10:41 +02:00
|
|
|
Component,
|
2018-06-06 23:25:57 +02:00
|
|
|
ComponentFactoryResolver,
|
2018-08-21 04:21:13 +02:00
|
|
|
NgZone,
|
|
|
|
OnDestroy,
|
2018-06-06 23:25:57 +02:00
|
|
|
OnInit,
|
|
|
|
ViewChild,
|
|
|
|
ViewContainerRef,
|
2018-06-05 05:10:41 +02:00
|
|
|
} from '@angular/core';
|
2018-06-06 23:25:57 +02:00
|
|
|
import {
|
|
|
|
ActivatedRoute,
|
|
|
|
Router,
|
|
|
|
} from '@angular/router';
|
2018-06-05 05:10:41 +02:00
|
|
|
|
2018-06-05 19:31:25 +02:00
|
|
|
import { CipherType } from 'jslib/enums/cipherType';
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
import { CipherView } from 'jslib/models/view/cipherView';
|
|
|
|
|
|
|
|
import { ModalComponent } from '../modal.component';
|
|
|
|
|
2018-07-11 17:39:48 +02:00
|
|
|
import { OrganizationsComponent } from '../settings/organizations.component';
|
2018-07-17 23:22:51 +02:00
|
|
|
import { UpdateKeyComponent } from '../settings/update-key.component';
|
2018-06-07 05:23:14 +02:00
|
|
|
import { AddEditComponent } from './add-edit.component';
|
2018-06-06 23:25:57 +02:00
|
|
|
import { AttachmentsComponent } from './attachments.component';
|
|
|
|
import { CiphersComponent } from './ciphers.component';
|
2018-06-12 19:08:47 +02:00
|
|
|
import { CollectionsComponent } from './collections.component';
|
2018-06-06 23:25:57 +02:00
|
|
|
import { FolderAddEditComponent } from './folder-add-edit.component';
|
|
|
|
import { GroupingsComponent } from './groupings.component';
|
2018-06-12 19:08:47 +02:00
|
|
|
import { ShareComponent } from './share.component';
|
2018-06-06 23:25:57 +02:00
|
|
|
|
2018-07-12 23:09:09 +02:00
|
|
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
2018-06-06 23:25:57 +02:00
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
2018-07-18 15:21:23 +02:00
|
|
|
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
2018-07-20 16:44:17 +02:00
|
|
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
2018-06-06 23:25:57 +02:00
|
|
|
import { SyncService } from 'jslib/abstractions/sync.service';
|
2018-07-12 17:34:51 +02:00
|
|
|
import { TokenService } from 'jslib/abstractions/token.service';
|
2018-07-18 15:21:23 +02:00
|
|
|
import { UserService } from 'jslib/abstractions/user.service';
|
2018-06-06 23:25:57 +02:00
|
|
|
|
2018-08-21 04:21:13 +02:00
|
|
|
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
|
|
|
|
|
|
|
|
const BroadcasterSubscriptionId = 'VaultComponent';
|
|
|
|
|
2018-06-05 05:10:41 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'app-vault',
|
|
|
|
templateUrl: 'vault.component.html',
|
|
|
|
})
|
2018-08-21 04:21:13 +02:00
|
|
|
export class VaultComponent implements OnInit, OnDestroy {
|
2020-08-17 16:04:38 +02:00
|
|
|
@ViewChild(GroupingsComponent, { static: true }) groupingsComponent: GroupingsComponent;
|
|
|
|
@ViewChild(CiphersComponent, { static: true }) ciphersComponent: CiphersComponent;
|
|
|
|
@ViewChild(OrganizationsComponent, { static: true }) organizationsComponent: OrganizationsComponent;
|
|
|
|
@ViewChild('attachments', { read: ViewContainerRef, static: true }) attachmentsModalRef: ViewContainerRef;
|
|
|
|
@ViewChild('folderAddEdit', { read: ViewContainerRef, static: true }) folderAddEditModalRef: ViewContainerRef;
|
|
|
|
@ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef;
|
|
|
|
@ViewChild('share', { read: ViewContainerRef, static: true }) shareModalRef: ViewContainerRef;
|
|
|
|
@ViewChild('collections', { read: ViewContainerRef, static: true }) collectionsModalRef: ViewContainerRef;
|
|
|
|
@ViewChild('updateKeyTemplate', { read: ViewContainerRef, static: true }) updateKeyModalRef: ViewContainerRef;
|
2018-06-06 23:25:57 +02:00
|
|
|
|
|
|
|
favorites: boolean = false;
|
|
|
|
type: CipherType = null;
|
|
|
|
folderId: string = null;
|
|
|
|
collectionId: string = null;
|
2018-07-12 17:34:51 +02:00
|
|
|
showVerifyEmail = false;
|
|
|
|
showBrowserOutdated = false;
|
|
|
|
showUpdateKey = false;
|
2018-07-20 16:44:17 +02:00
|
|
|
showPremiumCallout = false;
|
2020-04-08 22:48:30 +02:00
|
|
|
deleted: boolean = false;
|
2021-04-27 18:49:02 +02:00
|
|
|
trashCleanupWarning: string = null;
|
2018-06-06 23:25:57 +02:00
|
|
|
|
2020-08-11 17:30:30 +02:00
|
|
|
modal: ModalComponent = null;
|
2018-06-06 23:25:57 +02:00
|
|
|
|
|
|
|
constructor(private syncService: SyncService, private route: ActivatedRoute,
|
2018-11-30 16:28:46 +01:00
|
|
|
private router: Router, private changeDetectorRef: ChangeDetectorRef,
|
2018-07-12 17:34:51 +02:00
|
|
|
private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver,
|
2018-07-18 15:21:23 +02:00
|
|
|
private tokenService: TokenService, private cryptoService: CryptoService,
|
2018-07-20 16:44:17 +02:00
|
|
|
private messagingService: MessagingService, private userService: UserService,
|
2020-08-11 17:30:30 +02:00
|
|
|
private platformUtilsService: PlatformUtilsService, private broadcasterService: BroadcasterService,
|
|
|
|
private ngZone: NgZone) { }
|
2018-06-06 23:25:57 +02:00
|
|
|
|
|
|
|
async ngOnInit() {
|
2018-07-12 17:34:51 +02:00
|
|
|
this.showVerifyEmail = !(await this.tokenService.getEmailVerified());
|
|
|
|
this.showBrowserOutdated = window.navigator.userAgent.indexOf('MSIE') !== -1;
|
2021-04-27 18:49:02 +02:00
|
|
|
this.trashCleanupWarning = this.i18nService.t(
|
|
|
|
this.platformUtilsService.isSelfHost() ? 'trashCleanupWarningSelfHosted' : 'trashCleanupWarning'
|
|
|
|
);
|
2018-07-12 17:34:51 +02:00
|
|
|
|
2021-02-03 18:41:33 +01:00
|
|
|
const queryParamsSub = this.route.queryParams.subscribe(async params => {
|
2018-06-26 18:03:11 +02:00
|
|
|
await this.syncService.fullSync(false);
|
2018-08-31 23:23:36 +02:00
|
|
|
|
|
|
|
this.showUpdateKey = !(await this.cryptoService.hasEncKey());
|
|
|
|
const canAccessPremium = await this.userService.canAccessPremium();
|
|
|
|
this.showPremiumCallout = !this.showVerifyEmail && !canAccessPremium &&
|
|
|
|
!this.platformUtilsService.isSelfHost();
|
2018-08-21 04:21:13 +02:00
|
|
|
|
2018-07-11 17:39:48 +02:00
|
|
|
await Promise.all([
|
|
|
|
this.groupingsComponent.load(),
|
|
|
|
this.organizationsComponent.load(),
|
|
|
|
]);
|
2018-06-06 23:25:57 +02:00
|
|
|
|
|
|
|
if (params == null) {
|
|
|
|
this.groupingsComponent.selectedAll = true;
|
2019-03-19 17:44:22 +01:00
|
|
|
await this.ciphersComponent.reload();
|
2018-06-06 23:25:57 +02:00
|
|
|
} else {
|
2020-04-08 22:48:30 +02:00
|
|
|
if (params.deleted) {
|
|
|
|
this.groupingsComponent.selectedTrash = true;
|
|
|
|
await this.filterDeleted();
|
|
|
|
} else if (params.favorites) {
|
2018-12-20 16:06:40 +01:00
|
|
|
this.groupingsComponent.selectedFavorites = true;
|
|
|
|
await this.filterFavorites();
|
|
|
|
} else if (params.type) {
|
|
|
|
const t = parseInt(params.type, null);
|
|
|
|
this.groupingsComponent.selectedType = t;
|
|
|
|
await this.filterCipherType(t);
|
|
|
|
} else if (params.folderId) {
|
|
|
|
this.groupingsComponent.selectedFolder = true;
|
|
|
|
this.groupingsComponent.selectedFolderId = params.folderId;
|
|
|
|
await this.filterFolder(params.folderId);
|
|
|
|
} else if (params.collectionId) {
|
|
|
|
this.groupingsComponent.selectedCollectionId = params.collectionId;
|
|
|
|
await this.filterCollection(params.collectionId);
|
|
|
|
} else {
|
|
|
|
this.groupingsComponent.selectedAll = true;
|
2019-03-19 17:44:22 +01:00
|
|
|
await this.ciphersComponent.reload();
|
2018-12-20 16:06:40 +01:00
|
|
|
}
|
2018-06-06 23:25:57 +02:00
|
|
|
}
|
2018-08-31 23:23:36 +02:00
|
|
|
|
|
|
|
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
|
|
|
this.ngZone.run(async () => {
|
|
|
|
switch (message.command) {
|
|
|
|
case 'syncCompleted':
|
|
|
|
if (message.successfully) {
|
|
|
|
await Promise.all([
|
|
|
|
this.groupingsComponent.load(),
|
|
|
|
this.organizationsComponent.load(),
|
|
|
|
this.ciphersComponent.load(this.ciphersComponent.filter),
|
|
|
|
]);
|
|
|
|
this.changeDetectorRef.detectChanges();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2018-12-20 16:06:40 +01:00
|
|
|
|
2019-01-17 05:30:32 +01:00
|
|
|
if (queryParamsSub != null) {
|
|
|
|
queryParamsSub.unsubscribe();
|
|
|
|
}
|
2018-06-06 23:25:57 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-21 04:21:13 +02:00
|
|
|
ngOnDestroy() {
|
|
|
|
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
|
|
|
}
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
async clearGroupingFilters() {
|
2018-07-04 15:55:52 +02:00
|
|
|
this.ciphersComponent.showAddNew = true;
|
2018-06-07 15:05:25 +02:00
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchVault');
|
2019-03-19 17:44:22 +01:00
|
|
|
await this.ciphersComponent.reload();
|
2018-06-06 23:25:57 +02:00
|
|
|
this.clearFilters();
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
|
|
|
async filterFavorites() {
|
2018-07-04 15:55:52 +02:00
|
|
|
this.ciphersComponent.showAddNew = true;
|
2018-06-07 15:05:25 +02:00
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchFavorites');
|
2021-02-03 18:41:33 +01:00
|
|
|
await this.ciphersComponent.reload(c => c.favorite);
|
2018-06-06 23:25:57 +02:00
|
|
|
this.clearFilters();
|
|
|
|
this.favorites = true;
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
2020-04-08 22:48:30 +02:00
|
|
|
async filterDeleted() {
|
|
|
|
this.ciphersComponent.showAddNew = false;
|
|
|
|
this.ciphersComponent.deleted = true;
|
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchTrash');
|
|
|
|
await this.ciphersComponent.reload(null, true);
|
|
|
|
this.clearFilters();
|
|
|
|
this.deleted = true;
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
async filterCipherType(type: CipherType) {
|
2018-07-04 15:55:52 +02:00
|
|
|
this.ciphersComponent.showAddNew = true;
|
2018-06-07 15:05:25 +02:00
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchType');
|
2021-02-03 18:41:33 +01:00
|
|
|
await this.ciphersComponent.reload(c => c.type === type);
|
2018-06-06 23:25:57 +02:00
|
|
|
this.clearFilters();
|
|
|
|
this.type = type;
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
|
|
|
async filterFolder(folderId: string) {
|
2018-07-04 15:55:52 +02:00
|
|
|
this.ciphersComponent.showAddNew = true;
|
2018-06-06 23:25:57 +02:00
|
|
|
folderId = folderId === 'none' ? null : folderId;
|
2018-06-07 15:05:25 +02:00
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchFolder');
|
2021-02-03 18:41:33 +01:00
|
|
|
await this.ciphersComponent.reload(c => c.folderId === folderId);
|
2018-06-06 23:25:57 +02:00
|
|
|
this.clearFilters();
|
|
|
|
this.folderId = folderId == null ? 'none' : folderId;
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
|
|
|
async filterCollection(collectionId: string) {
|
2018-10-22 22:46:48 +02:00
|
|
|
this.ciphersComponent.showAddNew = true;
|
2018-06-07 15:05:25 +02:00
|
|
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
2021-02-03 18:41:33 +01:00
|
|
|
await this.ciphersComponent.reload(c => c.collectionIds != null &&
|
2019-03-19 17:44:22 +01:00
|
|
|
c.collectionIds.indexOf(collectionId) > -1);
|
2018-06-06 23:25:57 +02:00
|
|
|
this.clearFilters();
|
|
|
|
this.collectionId = collectionId;
|
|
|
|
this.go();
|
|
|
|
}
|
|
|
|
|
2018-06-07 05:00:57 +02:00
|
|
|
filterSearchText(searchText: string) {
|
|
|
|
this.ciphersComponent.searchText = searchText;
|
2018-08-13 22:27:17 +02:00
|
|
|
this.ciphersComponent.search(200);
|
2018-06-07 05:00:57 +02:00
|
|
|
}
|
|
|
|
|
2018-07-18 15:21:23 +02:00
|
|
|
async editCipherAttachments(cipher: CipherView) {
|
2018-08-29 15:22:28 +02:00
|
|
|
const canAccessPremium = await this.userService.canAccessPremium();
|
|
|
|
if (cipher.organizationId == null && !canAccessPremium) {
|
2018-07-18 15:21:23 +02:00
|
|
|
this.messagingService.send('premiumRequired');
|
|
|
|
return;
|
|
|
|
} else if (cipher.organizationId != null) {
|
|
|
|
const org = await this.userService.getOrganization(cipher.organizationId);
|
|
|
|
if (org != null && (org.maxStorageGb == null || org.maxStorageGb === 0)) {
|
|
|
|
this.messagingService.send('upgradeOrganization', { organizationId: cipher.organizationId });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
|
|
this.modal = this.attachmentsModalRef.createComponent(factory).instance;
|
|
|
|
const childComponent = this.modal.show<AttachmentsComponent>(AttachmentsComponent, this.attachmentsModalRef);
|
|
|
|
|
|
|
|
childComponent.cipherId = cipher.id;
|
2018-06-09 19:29:30 +02:00
|
|
|
let madeAttachmentChanges = false;
|
|
|
|
childComponent.onUploadedAttachment.subscribe(() => madeAttachmentChanges = true);
|
|
|
|
childComponent.onDeletedAttachment.subscribe(() => madeAttachmentChanges = true);
|
2018-11-14 21:20:17 +01:00
|
|
|
childComponent.onReuploadedAttachment.subscribe(() => madeAttachmentChanges = true);
|
2018-06-06 23:25:57 +02:00
|
|
|
|
2018-06-09 19:29:30 +02:00
|
|
|
this.modal.onClosed.subscribe(async () => {
|
2018-06-06 23:25:57 +02:00
|
|
|
this.modal = null;
|
2018-06-09 19:29:30 +02:00
|
|
|
if (madeAttachmentChanges) {
|
|
|
|
await this.ciphersComponent.refresh();
|
|
|
|
}
|
|
|
|
madeAttachmentChanges = false;
|
2018-06-06 23:25:57 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-12 17:46:11 +02:00
|
|
|
shareCipher(cipher: CipherView) {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
|
|
this.modal = this.shareModalRef.createComponent(factory).instance;
|
|
|
|
const childComponent = this.modal.show<ShareComponent>(ShareComponent, this.shareModalRef);
|
|
|
|
|
|
|
|
childComponent.cipherId = cipher.id;
|
|
|
|
childComponent.onSharedCipher.subscribe(async () => {
|
|
|
|
this.modal.close();
|
|
|
|
await this.ciphersComponent.refresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(async () => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-12 19:08:47 +02:00
|
|
|
editCipherCollections(cipher: CipherView) {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
2018-06-20 22:28:56 +02:00
|
|
|
this.modal = this.collectionsModalRef.createComponent(factory).instance;
|
2018-06-12 19:08:47 +02:00
|
|
|
const childComponent = this.modal.show<CollectionsComponent>(CollectionsComponent, this.collectionsModalRef);
|
|
|
|
|
|
|
|
childComponent.cipherId = cipher.id;
|
|
|
|
childComponent.onSavedCollections.subscribe(async () => {
|
|
|
|
this.modal.close();
|
|
|
|
await this.ciphersComponent.refresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(async () => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
async addFolder() {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
|
|
this.modal = this.folderAddEditModalRef.createComponent(factory).instance;
|
|
|
|
const childComponent = this.modal.show<FolderAddEditComponent>(
|
|
|
|
FolderAddEditComponent, this.folderAddEditModalRef);
|
|
|
|
|
|
|
|
childComponent.folderId = null;
|
2018-06-25 21:20:45 +02:00
|
|
|
childComponent.onSavedFolder.subscribe(async () => {
|
2018-06-06 23:25:57 +02:00
|
|
|
this.modal.close();
|
|
|
|
await this.groupingsComponent.loadFolders();
|
|
|
|
});
|
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async editFolder(folderId: string) {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
|
|
this.modal = this.folderAddEditModalRef.createComponent(factory).instance;
|
|
|
|
const childComponent = this.modal.show<FolderAddEditComponent>(
|
|
|
|
FolderAddEditComponent, this.folderAddEditModalRef);
|
|
|
|
|
|
|
|
childComponent.folderId = folderId;
|
2018-06-25 21:20:45 +02:00
|
|
|
childComponent.onSavedFolder.subscribe(async () => {
|
2018-06-06 23:25:57 +02:00
|
|
|
this.modal.close();
|
|
|
|
await this.groupingsComponent.loadFolders();
|
|
|
|
});
|
2018-06-25 21:20:45 +02:00
|
|
|
childComponent.onDeletedFolder.subscribe(async () => {
|
2018-06-06 23:25:57 +02:00
|
|
|
this.modal.close();
|
|
|
|
await this.groupingsComponent.loadFolders();
|
2018-06-25 21:20:45 +02:00
|
|
|
await this.filterFolder('none');
|
|
|
|
this.groupingsComponent.selectedFolderId = null;
|
2018-06-06 23:25:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-07 05:23:14 +02:00
|
|
|
addCipher() {
|
|
|
|
const component = this.editCipher(null);
|
|
|
|
component.type = this.type;
|
|
|
|
component.folderId = this.folderId === 'none' ? null : this.folderId;
|
2018-10-22 22:46:48 +02:00
|
|
|
if (this.collectionId != null) {
|
2021-02-03 18:41:33 +01:00
|
|
|
const collection = this.groupingsComponent.collections.filter(c => c.id === this.collectionId);
|
2018-10-22 22:46:48 +02:00
|
|
|
if (collection.length > 0) {
|
|
|
|
component.organizationId = collection[0].organizationId;
|
|
|
|
component.collectionIds = [this.collectionId];
|
|
|
|
}
|
|
|
|
}
|
2018-06-07 05:23:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
editCipher(cipher: CipherView) {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
2018-06-12 17:46:11 +02:00
|
|
|
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
|
2018-06-07 05:23:14 +02:00
|
|
|
const childComponent = this.modal.show<AddEditComponent>(
|
2018-06-12 17:46:11 +02:00
|
|
|
AddEditComponent, this.cipherAddEditModalRef);
|
2018-06-07 05:23:14 +02:00
|
|
|
|
|
|
|
childComponent.cipherId = cipher == null ? null : cipher.id;
|
2018-06-08 18:04:03 +02:00
|
|
|
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
|
2018-06-07 05:23:14 +02:00
|
|
|
this.modal.close();
|
2018-06-08 20:56:26 +02:00
|
|
|
await this.ciphersComponent.refresh();
|
2018-06-07 05:23:14 +02:00
|
|
|
});
|
2018-06-08 18:04:03 +02:00
|
|
|
childComponent.onDeletedCipher.subscribe(async (c: CipherView) => {
|
2018-06-07 05:23:14 +02:00
|
|
|
this.modal.close();
|
2018-06-08 20:56:26 +02:00
|
|
|
await this.ciphersComponent.refresh();
|
2018-06-07 05:23:14 +02:00
|
|
|
});
|
2020-04-08 22:48:30 +02:00
|
|
|
childComponent.onRestoredCipher.subscribe(async (c: CipherView) => {
|
|
|
|
this.modal.close();
|
|
|
|
await this.ciphersComponent.refresh();
|
|
|
|
});
|
2018-06-07 05:23:14 +02:00
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
return childComponent;
|
|
|
|
}
|
|
|
|
|
2020-02-10 20:03:36 +01:00
|
|
|
cloneCipher(cipher: CipherView) {
|
|
|
|
const component = this.editCipher(cipher);
|
|
|
|
component.cloneMode = true;
|
|
|
|
}
|
|
|
|
|
2018-07-17 23:22:51 +02:00
|
|
|
updateKey() {
|
|
|
|
if (this.modal != null) {
|
|
|
|
this.modal.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
|
|
this.modal = this.updateKeyModalRef.createComponent(factory).instance;
|
|
|
|
this.modal.show<UpdateKeyComponent>(UpdateKeyComponent, this.updateKeyModalRef);
|
|
|
|
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
|
|
this.modal = null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-06 23:25:57 +02:00
|
|
|
private clearFilters() {
|
|
|
|
this.folderId = null;
|
|
|
|
this.collectionId = null;
|
|
|
|
this.favorites = false;
|
|
|
|
this.type = null;
|
2020-04-08 22:48:30 +02:00
|
|
|
this.deleted = false;
|
2018-06-06 23:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private go(queryParams: any = null) {
|
|
|
|
if (queryParams == null) {
|
|
|
|
queryParams = {
|
|
|
|
favorites: this.favorites ? true : null,
|
|
|
|
type: this.type,
|
|
|
|
folderId: this.folderId,
|
|
|
|
collectionId: this.collectionId,
|
2020-04-08 22:48:30 +02:00
|
|
|
deleted: this.deleted ? true : null,
|
2018-06-06 23:25:57 +02:00
|
|
|
};
|
|
|
|
}
|
2018-06-05 05:10:41 +02:00
|
|
|
|
2018-11-30 16:28:46 +01:00
|
|
|
this.router.navigate([], {
|
|
|
|
relativeTo: this.route,
|
|
|
|
queryParams: queryParams,
|
|
|
|
replaceUrl: true,
|
|
|
|
});
|
2018-06-06 23:25:57 +02:00
|
|
|
}
|
2018-06-05 05:10:41 +02:00
|
|
|
}
|