Add support for viewing attachments in emergency access (#814)
This commit is contained in:
parent
986f27294a
commit
5010736ca3
|
@ -114,6 +114,7 @@ import { DeauthorizeSessionsComponent } from './settings/deauthorize-sessions.co
|
||||||
import { DeleteAccountComponent } from './settings/delete-account.component';
|
import { DeleteAccountComponent } from './settings/delete-account.component';
|
||||||
import { DomainRulesComponent } from './settings/domain-rules.component';
|
import { DomainRulesComponent } from './settings/domain-rules.component';
|
||||||
import { EmergencyAccessAddEditComponent } from './settings/emergency-access-add-edit.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 { EmergencyAccessComponent } from './settings/emergency-access.component';
|
||||||
import { EmergencyAccessConfirmComponent } from './settings/emergency-access-confirm.component';
|
import { EmergencyAccessConfirmComponent } from './settings/emergency-access-confirm.component';
|
||||||
import { EmergencyAccessTakeoverComponent } from './settings/emergency-access-takeover.component';
|
import { EmergencyAccessTakeoverComponent } from './settings/emergency-access-takeover.component';
|
||||||
|
@ -304,6 +305,7 @@ registerLocaleData(localeZhTw, 'zh-TW');
|
||||||
DomainRulesComponent,
|
DomainRulesComponent,
|
||||||
DownloadLicenseComponent,
|
DownloadLicenseComponent,
|
||||||
EmergencyAccessAddEditComponent,
|
EmergencyAccessAddEditComponent,
|
||||||
|
EmergencyAccessAttachmentsComponent,
|
||||||
EmergencyAccessComponent,
|
EmergencyAccessComponent,
|
||||||
EmergencyAccessConfirmComponent,
|
EmergencyAccessConfirmComponent,
|
||||||
EmergencyAccessTakeoverComponent,
|
EmergencyAccessTakeoverComponent,
|
||||||
|
@ -424,6 +426,7 @@ registerLocaleData(localeZhTw, 'zh-TW');
|
||||||
DeleteAccountComponent,
|
DeleteAccountComponent,
|
||||||
DeleteOrganizationComponent,
|
DeleteOrganizationComponent,
|
||||||
EmergencyAccessAddEditComponent,
|
EmergencyAccessAddEditComponent,
|
||||||
|
EmergencyAccessAttachmentsComponent,
|
||||||
EmergencyAccessConfirmComponent,
|
EmergencyAccessConfirmComponent,
|
||||||
EmergencyAccessTakeoverComponent,
|
EmergencyAccessTakeoverComponent,
|
||||||
EmergencyAddEditComponent,
|
EmergencyAddEditComponent,
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from '../../vault/at
|
||||||
templateUrl: '../../vault/attachments.component.html',
|
templateUrl: '../../vault/attachments.component.html',
|
||||||
})
|
})
|
||||||
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||||
|
viewOnly = false;
|
||||||
organization: Organization;
|
organization: Organization;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, i18nService: I18nService,
|
constructor(cipherService: CipherService, i18nService: I18nService,
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,9 +23,25 @@
|
||||||
<br>
|
<br>
|
||||||
<small>{{c.subTitle}}</small>
|
<small>{{c.subTitle}}</small>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="table-list-options">
|
||||||
|
<div class="dropdown" appListDropdown *ngIf="c.hasAttachments">
|
||||||
|
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="dropdownMenuButton"
|
||||||
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||||
|
appA11yTitle="{{'options' | i18n}}">
|
||||||
|
<i class="fa fa-cog fa-lg" aria-hidden="true"></i>
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
|
||||||
|
<a class="dropdown-item" href="#" appStopClick (click)="viewAttachments(c)">
|
||||||
|
<i class="fa fa-fw fa-paperclip" aria-hidden="true"></i>
|
||||||
|
{{'attachments' | i18n}}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #cipherAddEdit></ng-template>
|
<ng-template #cipherAddEdit></ng-template>
|
||||||
|
<ng-template #attachments></ng-template>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { CipherView } from 'jslib/models/view/cipherView';
|
||||||
|
|
||||||
import { ModalComponent } from '../modal.component';
|
import { ModalComponent } from '../modal.component';
|
||||||
|
|
||||||
|
import { EmergencyAccessAttachmentsComponent } from './emergency-access-attachments.component';
|
||||||
import { EmergencyAddEditComponent } from './emergency-add-edit.component';
|
import { EmergencyAddEditComponent } from './emergency-add-edit.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -26,6 +27,7 @@ import { EmergencyAddEditComponent } from './emergency-add-edit.component';
|
||||||
})
|
})
|
||||||
export class EmergencyAccessViewComponent implements OnInit {
|
export class EmergencyAccessViewComponent implements OnInit {
|
||||||
@ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef;
|
@ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef;
|
||||||
|
@ViewChild('attachments', { read: ViewContainerRef, static: true }) attachmentsModalRef: ViewContainerRef;
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
ciphers: CipherView[] = [];
|
ciphers: CipherView[] = [];
|
||||||
|
@ -72,6 +74,22 @@ export class EmergencyAccessViewComponent implements OnInit {
|
||||||
this.ciphers = await this.getAllCiphers(response);
|
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>(EmergencyAccessAttachmentsComponent, this.attachmentsModalRef);
|
||||||
|
|
||||||
|
childComponent.cipher = cipher;
|
||||||
|
|
||||||
|
this.modal.onClosed.subscribe(async () => {
|
||||||
|
this.modal = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected async getAllCiphers(response: EmergencyAccessViewResponse): Promise<CipherView[]> {
|
protected async getAllCiphers(response: EmergencyAccessViewResponse): Promise<CipherView[]> {
|
||||||
const ciphers = response.ciphers;
|
const ciphers = response.ciphers;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
<small>{{a.sizeName}}</small>
|
<small>{{a.sizeName}}</small>
|
||||||
</td>
|
</td>
|
||||||
<td class="table-list-options">
|
<td class="table-list-options" *ngIf="!viewOnly">
|
||||||
<button class="btn btn-outline-danger" type="button" appStopClick
|
<button class="btn btn-outline-danger" type="button" appStopClick
|
||||||
appA11yTitle="{{'delete' | i18n}}" (click)="delete(a)" #deleteBtn
|
appA11yTitle="{{'delete' | i18n}}" (click)="delete(a)" #deleteBtn
|
||||||
[appApiAction]="deletePromises[a.id]" [disabled]="deleteBtn.loading">
|
[appApiAction]="deletePromises[a.id]" [disabled]="deleteBtn.loading">
|
||||||
|
@ -48,13 +48,15 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h3>{{'newAttachment' | i18n}}</h3>
|
<div *ngIf="!viewOnly">
|
||||||
<label for="file" class="sr-only">{{'file' | i18n}}</label>
|
<h3>{{'newAttachment' | i18n}}</h3>
|
||||||
<input type="file" id="file" class="form-control-file" name="file" required>
|
<label for="file" class="sr-only">{{'file' | i18n}}</label>
|
||||||
<small class="form-text text-muted">{{'maxFileSize' | i18n}}</small>
|
<input type="file" id="file" class="form-control-file" name="file" required>
|
||||||
|
<small class="form-text text-muted">{{'maxFileSize' | i18n}}</small>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading" *ngIf="!viewOnly">
|
||||||
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
|
<i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
|
||||||
<span>{{'save' | i18n}}</span>
|
<span>{{'save' | i18n}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -15,6 +15,8 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/
|
||||||
templateUrl: 'attachments.component.html',
|
templateUrl: 'attachments.component.html',
|
||||||
})
|
})
|
||||||
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
export class AttachmentsComponent extends BaseAttachmentsComponent {
|
||||||
|
viewOnly = false;
|
||||||
|
|
||||||
constructor(cipherService: CipherService, i18nService: I18nService,
|
constructor(cipherService: CipherService, i18nService: I18nService,
|
||||||
cryptoService: CryptoService, userService: UserService,
|
cryptoService: CryptoService, userService: UserService,
|
||||||
platformUtilsService: PlatformUtilsService) {
|
platformUtilsService: PlatformUtilsService) {
|
||||||
|
|
Loading…
Reference in New Issue