2021-11-24 15:33:34 +01:00
|
|
|
import {
|
2021-11-22 14:41:40 +01:00
|
|
|
Component,
|
|
|
|
EventEmitter,
|
|
|
|
Output,
|
|
|
|
} from '@angular/core';
|
2018-07-16 18:42:49 +02:00
|
|
|
|
2021-11-09 19:24:26 +01:00
|
|
|
import { Verification } from 'jslib-common/types/verification';
|
|
|
|
|
2021-06-07 20:13:58 +02:00
|
|
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
|
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
2021-10-20 18:30:04 +02:00
|
|
|
import { LogService } from 'jslib-common/abstractions/log.service';
|
2021-12-07 20:41:45 +01:00
|
|
|
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
|
2021-11-09 19:24:26 +01:00
|
|
|
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
|
2018-07-16 18:42:49 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-delete-organization',
|
|
|
|
templateUrl: 'delete-organization.component.html',
|
|
|
|
})
|
|
|
|
export class DeleteOrganizationComponent {
|
|
|
|
organizationId: string;
|
2021-11-22 14:41:40 +01:00
|
|
|
descriptionKey = 'deleteOrganizationDesc';
|
|
|
|
@Output() onSuccess: EventEmitter<any> = new EventEmitter();
|
2018-07-16 18:42:49 +02:00
|
|
|
|
2021-11-09 19:24:26 +01:00
|
|
|
masterPassword: Verification;
|
2018-07-16 18:42:49 +02:00
|
|
|
formPromise: Promise<any>;
|
|
|
|
|
|
|
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
2021-12-07 20:41:45 +01:00
|
|
|
private platformUtilsService: PlatformUtilsService, private userVerificationService: UserVerificationService,
|
2021-11-22 14:41:40 +01:00
|
|
|
private logService: LogService) { }
|
2018-07-16 18:42:49 +02:00
|
|
|
|
|
|
|
async submit() {
|
|
|
|
try {
|
2021-11-17 00:37:36 +01:00
|
|
|
this.formPromise = this.userVerificationService.buildRequest(this.masterPassword)
|
|
|
|
.then(request => this.apiService.deleteOrganization(this.organizationId, request));
|
2018-07-16 18:42:49 +02:00
|
|
|
await this.formPromise;
|
2021-12-07 20:41:45 +01:00
|
|
|
this.platformUtilsService.showToast('success', this.i18nService.t('organizationDeleted'),
|
2018-07-16 18:42:49 +02:00
|
|
|
this.i18nService.t('organizationDeletedDesc'));
|
2021-11-22 14:41:40 +01:00
|
|
|
this.onSuccess.emit();
|
2021-10-20 18:30:04 +02:00
|
|
|
} catch (e) {
|
|
|
|
this.logService.error(e);
|
|
|
|
}
|
2018-07-16 18:42:49 +02:00
|
|
|
}
|
|
|
|
}
|