mirror of
https://github.com/bitwarden/browser
synced 2026-01-05 01:53:55 +00:00
* Move event.service to it's own folder Move abstractions/event.service to abstractions/event/event.service Move services/event.service to services/event/event.service Fix all the imports * Extract event-upload from event.service Move `uploadEvents` from `EventService` to `EventUploadService` Create event-upload-service-factory Fix wiring up all the dependencies * Remove clearEvents from EventService clearEvents is only related to uploading events and can be moved into EventUploadService Change the logout-method to only call EventUploadService.uploadEvents as that also calls clearEvents internally * Rename EventService to EventCollectionService Rename libs\common\abstraction\event\event.service.ts to libs\common\abstractions\event\event-collection.service.ts Rename libs\common\services\event\event.service.ts to libs\common\services\event\event-collection.service.ts Fix all the imports Fix up service regristration/instantiation Reanme \browser\src\background\service_factories\event-service.factory.ts to \browser\src\background\service_factories\event-collection-service.factory.ts * Move interval to upload events to EventUploadSvc Move the `init()` from event-collection.service to event-upload.service Change call-site in web, desktop, browser
103 lines
3.7 KiB
TypeScript
103 lines
3.7 KiB
TypeScript
import { Component, EventEmitter, Output } from "@angular/core";
|
|
|
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
|
|
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
|
import { OrganizationService } from "@bitwarden/common/abstractions/organization/organization.service.abstraction";
|
|
import { PasswordRepromptService } from "@bitwarden/common/abstractions/passwordReprompt.service";
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
|
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
|
import { TokenService } from "@bitwarden/common/abstractions/token.service";
|
|
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
|
import { CipherView } from "@bitwarden/common/models/view/cipher.view";
|
|
|
|
import { VaultItemsComponent as BaseVaultItemsComponent } from "../../vault/vault-items.component";
|
|
|
|
@Component({
|
|
selector: "app-org-vault-items",
|
|
templateUrl: "../../vault/vault-items.component.html",
|
|
})
|
|
export class VaultItemsComponent extends BaseVaultItemsComponent {
|
|
@Output() onEventsClicked = new EventEmitter<CipherView>();
|
|
|
|
protected allCiphers: CipherView[] = [];
|
|
|
|
constructor(
|
|
searchService: SearchService,
|
|
i18nService: I18nService,
|
|
platformUtilsService: PlatformUtilsService,
|
|
cipherService: CipherService,
|
|
eventCollectionService: EventCollectionService,
|
|
totpService: TotpService,
|
|
passwordRepromptService: PasswordRepromptService,
|
|
logService: LogService,
|
|
stateService: StateService,
|
|
organizationService: OrganizationService,
|
|
tokenService: TokenService,
|
|
private apiService: ApiService
|
|
) {
|
|
super(
|
|
searchService,
|
|
i18nService,
|
|
platformUtilsService,
|
|
cipherService,
|
|
eventCollectionService,
|
|
totpService,
|
|
stateService,
|
|
passwordRepromptService,
|
|
logService,
|
|
organizationService,
|
|
tokenService
|
|
);
|
|
}
|
|
|
|
async load(filter: (cipher: CipherView) => boolean = null, deleted = false) {
|
|
this.deleted = deleted || false;
|
|
if (this.organization.canEditAnyCollection) {
|
|
this.accessEvents = this.organization.useEvents;
|
|
this.allCiphers = await this.cipherService.getAllFromApiForOrganization(this.organization.id);
|
|
} else {
|
|
this.allCiphers = (await this.cipherService.getAllDecrypted()).filter(
|
|
(c) => c.organizationId === this.organization.id
|
|
);
|
|
}
|
|
await this.searchService.indexCiphers(this.organization.id, this.allCiphers);
|
|
await this.applyFilter(filter);
|
|
this.loaded = true;
|
|
}
|
|
|
|
async applyFilter(filter: (cipher: CipherView) => boolean = null) {
|
|
if (this.organization.canViewAllCollections) {
|
|
await super.applyFilter(filter);
|
|
} else {
|
|
const f = (c: CipherView) =>
|
|
c.organizationId === this.organization.id && (filter == null || filter(c));
|
|
await super.applyFilter(f);
|
|
}
|
|
}
|
|
|
|
async search(timeout: number = null) {
|
|
await super.search(timeout, this.allCiphers);
|
|
}
|
|
|
|
events(c: CipherView) {
|
|
this.onEventsClicked.emit(c);
|
|
}
|
|
|
|
protected deleteCipher(id: string) {
|
|
if (!this.organization.canEditAnyCollection) {
|
|
return super.deleteCipher(id, this.deleted);
|
|
}
|
|
return this.deleted
|
|
? this.apiService.deleteCipherAdmin(id)
|
|
: this.apiService.putDeleteCipherAdmin(id);
|
|
}
|
|
|
|
protected showFixOldAttachments(c: CipherView) {
|
|
return this.organization.canEditAnyCollection && c.hasOldAttachments;
|
|
}
|
|
}
|