1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-09 05:57:40 +02:00
bitwarden-browser/apps/web/src/app/vault/bulk-move.component.ts

41 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-12-17 15:57:11 +01:00
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { firstValueFrom, Observable } from "rxjs";
2018-06-12 23:33:08 +02:00
2022-06-14 17:10:53 +02:00
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
2022-06-14 17:10:53 +02:00
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
import { FolderView } from "@bitwarden/common/models/view/folder.view";
2018-06-12 23:33:08 +02:00
@Component({
2021-12-17 15:57:11 +01:00
selector: "app-vault-bulk-move",
templateUrl: "bulk-move.component.html",
2018-06-12 23:33:08 +02:00
})
export class BulkMoveComponent implements OnInit {
2021-12-17 15:57:11 +01:00
@Input() cipherIds: string[] = [];
@Output() onMoved = new EventEmitter();
2018-06-12 23:33:08 +02:00
2021-12-17 15:57:11 +01:00
folderId: string = null;
folders$: Observable<FolderView[]>;
2021-12-17 15:57:11 +01:00
formPromise: Promise<any>;
2018-06-12 23:33:08 +02:00
2021-12-17 15:57:11 +01:00
constructor(
private cipherService: CipherService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private folderService: FolderService
) {}
2018-06-12 23:33:08 +02:00
2021-12-17 15:57:11 +01:00
async ngOnInit() {
this.folders$ = this.folderService.folderViews$;
this.folderId = (await firstValueFrom(this.folders$))[0].id;
2021-12-17 15:57:11 +01:00
}
2018-06-12 23:33:08 +02:00
2021-12-17 15:57:11 +01:00
async submit() {
this.formPromise = this.cipherService.moveManyWithServer(this.cipherIds, this.folderId);
await this.formPromise;
this.onMoved.emit();
this.platformUtilsService.showToast("success", null, this.i18nService.t("movedItems"));
}
2018-06-12 23:33:08 +02:00
}