diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2ea1a4a01c..3ed599c835 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -114,6 +114,7 @@ import { DeauthorizeSessionsComponent } from './settings/deauthorize-sessions.co import { DeleteAccountComponent } from './settings/delete-account.component'; import { DomainRulesComponent } from './settings/domain-rules.component'; import { EmergencyAccessAddEditComponent } from './settings/emergency-access-add-edit.component'; +import { EmergencyAccessAttachmentsComponent } from './settings/emergency-access-attachments.component'; import { EmergencyAccessComponent } from './settings/emergency-access.component'; import { EmergencyAccessConfirmComponent } from './settings/emergency-access-confirm.component'; import { EmergencyAccessTakeoverComponent } from './settings/emergency-access-takeover.component'; @@ -304,6 +305,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); DomainRulesComponent, DownloadLicenseComponent, EmergencyAccessAddEditComponent, + EmergencyAccessAttachmentsComponent, EmergencyAccessComponent, EmergencyAccessConfirmComponent, EmergencyAccessTakeoverComponent, @@ -424,6 +426,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); DeleteAccountComponent, DeleteOrganizationComponent, EmergencyAccessAddEditComponent, + EmergencyAccessAttachmentsComponent, EmergencyAccessConfirmComponent, EmergencyAccessTakeoverComponent, EmergencyAddEditComponent, diff --git a/src/app/organizations/vault/attachments.component.ts b/src/app/organizations/vault/attachments.component.ts index 7b470d1db7..de214478cd 100644 --- a/src/app/organizations/vault/attachments.component.ts +++ b/src/app/organizations/vault/attachments.component.ts @@ -20,6 +20,7 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from '../../vault/at templateUrl: '../../vault/attachments.component.html', }) export class AttachmentsComponent extends BaseAttachmentsComponent { + viewOnly = false; organization: Organization; constructor(cipherService: CipherService, i18nService: I18nService, diff --git a/src/app/settings/emergency-access-attachments.component.ts b/src/app/settings/emergency-access-attachments.component.ts new file mode 100644 index 0000000000..8cbbfb1062 --- /dev/null +++ b/src/app/settings/emergency-access-attachments.component.ts @@ -0,0 +1,34 @@ +import { Component } from '@angular/core'; + +import { CipherService } from 'jslib/abstractions/cipher.service'; +import { CryptoService } from 'jslib/abstractions/crypto.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { UserService } from 'jslib/abstractions/user.service'; + +import { AttachmentView } from 'jslib/models/view/attachmentView'; + +import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/components/attachments.component'; + +@Component({ + selector: 'emergency-access-attachments', + templateUrl: '../vault/attachments.component.html', +}) +export class EmergencyAccessAttachmentsComponent extends BaseAttachmentsComponent { + viewOnly = true; + canAccessAttachments = true; + + constructor(cipherService: CipherService, i18nService: I18nService, + cryptoService: CryptoService, userService: UserService, + platformUtilsService: PlatformUtilsService) { + super(cipherService, i18nService, cryptoService, userService, platformUtilsService, window); + } + + protected async init() { + // Do nothing since cipher is already decoded + } + + protected showFixOldAttachments(attachment: AttachmentView) { + return false; + } +} diff --git a/src/app/settings/emergency-access-view.component.html b/src/app/settings/emergency-access-view.component.html index 4b44896b9b..bdb421754c 100644 --- a/src/app/settings/emergency-access-view.component.html +++ b/src/app/settings/emergency-access-view.component.html @@ -23,9 +23,25 @@
{{c.subTitle}} + + + + diff --git a/src/app/settings/emergency-access-view.component.ts b/src/app/settings/emergency-access-view.component.ts index f1313b5419..e8d9517ef6 100644 --- a/src/app/settings/emergency-access-view.component.ts +++ b/src/app/settings/emergency-access-view.component.ts @@ -18,6 +18,7 @@ import { CipherView } from 'jslib/models/view/cipherView'; import { ModalComponent } from '../modal.component'; +import { EmergencyAccessAttachmentsComponent } from './emergency-access-attachments.component'; import { EmergencyAddEditComponent } from './emergency-add-edit.component'; @Component({ @@ -26,6 +27,7 @@ import { EmergencyAddEditComponent } from './emergency-add-edit.component'; }) export class EmergencyAccessViewComponent implements OnInit { @ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef; + @ViewChild('attachments', { read: ViewContainerRef, static: true }) attachmentsModalRef: ViewContainerRef; id: string; ciphers: CipherView[] = []; @@ -72,6 +74,22 @@ export class EmergencyAccessViewComponent implements OnInit { this.ciphers = await this.getAllCiphers(response); } + async viewAttachments(cipher: CipherView) { + 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(EmergencyAccessAttachmentsComponent, this.attachmentsModalRef); + + childComponent.cipher = cipher; + + this.modal.onClosed.subscribe(async () => { + this.modal = null; + }); + } + protected async getAllCiphers(response: EmergencyAccessViewResponse): Promise { const ciphers = response.ciphers; diff --git a/src/app/vault/attachments.component.html b/src/app/vault/attachments.component.html index 279c90dd1d..bff4095bf0 100644 --- a/src/app/vault/attachments.component.html +++ b/src/app/vault/attachments.component.html @@ -35,7 +35,7 @@ {{a.sizeName}} - + diff --git a/src/app/vault/attachments.component.ts b/src/app/vault/attachments.component.ts index 343ee3fee6..109a00a1cf 100644 --- a/src/app/vault/attachments.component.ts +++ b/src/app/vault/attachments.component.ts @@ -15,6 +15,8 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/ templateUrl: 'attachments.component.html', }) export class AttachmentsComponent extends BaseAttachmentsComponent { + viewOnly = false; + constructor(cipherService: CipherService, i18nService: I18nService, cryptoService: CryptoService, userService: UserService, platformUtilsService: PlatformUtilsService) {