2018-06-12 23:33:08 +02:00
|
|
|
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
|
2022-07-12 20:25:18 +02:00
|
|
|
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";
|
2022-07-08 15:40:31 +02:00
|
|
|
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/folderView";
|
2018-06-12 23:33:08 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-vault-bulk-move",
|
|
|
|
templateUrl: "bulk-move.component.html",
|
|
|
|
})
|
|
|
|
export class BulkMoveComponent implements OnInit {
|
|
|
|
@Input() cipherIds: string[] = [];
|
|
|
|
@Output() onMoved = new EventEmitter();
|
|
|
|
|
|
|
|
folderId: string = null;
|
2022-07-12 20:25:18 +02:00
|
|
|
folders$: Observable<FolderView[]>;
|
2018-06-12 23:33:08 +02:00
|
|
|
formPromise: Promise<any>;
|
|
|
|
|
2021-12-07 20:41:45 +01:00
|
|
|
constructor(
|
|
|
|
private cipherService: CipherService,
|
|
|
|
private platformUtilsService: PlatformUtilsService,
|
2021-04-14 23:43:40 +02:00
|
|
|
private i18nService: I18nService,
|
|
|
|
private folderService: FolderService
|
|
|
|
) {}
|
2018-06-12 23:33:08 +02:00
|
|
|
|
|
|
|
async ngOnInit() {
|
2022-07-12 20:25:18 +02:00
|
|
|
this.folders$ = this.folderService.folderViews$;
|
|
|
|
this.folderId = (await firstValueFrom(this.folders$))[0].id;
|
2018-06-12 23:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
this.formPromise = this.cipherService.moveManyWithServer(this.cipherIds, this.folderId);
|
|
|
|
await this.formPromise;
|
|
|
|
this.onMoved.emit();
|
2021-12-07 20:41:45 +01:00
|
|
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("movedItems"));
|
2018-06-12 23:33:08 +02:00
|
|
|
}
|
|
|
|
}
|