1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-10 06:08:34 +02:00
bitwarden-browser/src/app/organizations/vault/attachments.component.ts

48 lines
1.9 KiB
TypeScript
Raw Normal View History

2018-07-05 16:48:51 +02:00
import { Component } from '@angular/core';
import { ApiService } from 'jslib/abstractions/api.service';
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';
2018-08-29 15:31:20 +02:00
import { UserService } from 'jslib/abstractions/user.service';
2018-07-05 16:48:51 +02:00
import { CipherData } from 'jslib/models/data/cipherData';
import { Cipher } from 'jslib/models/domain/cipher';
import { Organization } from 'jslib/models/domain/organization';
2018-07-05 19:14:33 +02:00
import { AttachmentsComponent as BaseAttachmentsComponent } from '../../vault/attachments.component';
2018-07-05 16:48:51 +02:00
@Component({
selector: 'app-org-vault-attachments',
2018-07-05 19:14:33 +02:00
templateUrl: '../../vault/attachments.component.html',
2018-07-05 16:48:51 +02:00
})
export class AttachmentsComponent extends BaseAttachmentsComponent {
organization: Organization;
constructor(cipherService: CipherService, i18nService: I18nService,
2018-08-29 15:31:20 +02:00
cryptoService: CryptoService, userService: UserService,
2018-07-05 16:48:51 +02:00
platformUtilsService: PlatformUtilsService, private apiService: ApiService) {
super(cipherService, i18nService, cryptoService, userService, platformUtilsService);
2018-07-05 16:48:51 +02:00
}
protected async loadCipher() {
if (!this.organization.isAdmin) {
return await super.loadCipher();
}
const response = await this.apiService.getCipherAdmin(this.cipherId);
return new Cipher(new CipherData(response));
}
protected saveCipherAttachment(file: File) {
return this.cipherService.saveAttachmentWithServer(this.cipherDomain, file, this.organization.isAdmin);
}
protected deleteCipherAttachment(attachmentId: string) {
if (!this.organization.isAdmin) {
return super.deleteCipherAttachment(attachmentId);
}
return this.apiService.deleteCipherAttachmentAdmin(this.cipherId, attachmentId);
}
}