bitwarden-estensione-browser/src/app/vault/export.component.ts

76 lines
2.8 KiB
TypeScript
Raw Normal View History

2020-11-04 18:09:21 +01:00
import {
Component,
2021-02-03 19:21:22 +01:00
NgZone,
2020-11-04 18:09:21 +01:00
OnInit,
} from '@angular/core';
2018-08-02 05:21:32 +02:00
2021-03-04 22:53:35 +01:00
import * as os from 'os';
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EventService } from 'jslib-common/abstractions/event.service';
import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
2018-08-02 05:21:32 +02:00
import { BroadcasterService } from 'jslib-angular/services/broadcaster.service';
2020-11-04 18:09:21 +01:00
import { ExportComponent as BaseExportComponent } from 'jslib-angular/components/export.component';
2018-08-02 05:21:32 +02:00
2020-11-04 18:09:21 +01:00
const BroadcasterSubscriptionId = 'ExportComponent';
2018-08-02 05:21:32 +02:00
@Component({
selector: 'app-export',
templateUrl: 'export.component.html',
})
2020-11-04 18:09:21 +01:00
export class ExportComponent extends BaseExportComponent implements OnInit {
constructor(cryptoService: CryptoService, i18nService: I18nService,
2019-07-12 23:11:39 +02:00
platformUtilsService: PlatformUtilsService, exportService: ExportService,
eventService: EventService, policyService: PolicyService,
private broadcasterService: BroadcasterService, private ngZone: NgZone,
logService: LogService) {
super(cryptoService, i18nService, platformUtilsService, exportService, eventService,
policyService, window, logService);
2018-08-02 05:21:32 +02:00
}
2020-11-04 18:09:21 +01:00
async ngOnInit() {
super.ngOnInit();
2020-11-04 18:09:21 +01:00
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => {
switch (message.command) {
case 'windowHidden':
this.onWindowHidden();
break;
default:
}
});
});
}
ngOnDestroy() {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
2020-11-04 18:09:21 +01:00
onWindowHidden() {
this.showPassword = false;
}
2021-03-04 22:53:35 +01:00
async warningDialog() {
if (this.encryptedFormat) {
return await this.platformUtilsService.showDialog(
this.i18nService.t('encExportKeyWarningDesc') +
os.EOL + os.EOL +
this.i18nService.t('encExportAccountWarningDesc'),
this.i18nService.t('confirmVaultExport'), this.i18nService.t('exportVault'),
this.i18nService.t('cancel'), 'warning',
true);
} else {
return await this.platformUtilsService.showDialog(
this.i18nService.t('exportWarningDesc'),
this.i18nService.t('confirmVaultExport'), this.i18nService.t('exportVault'),
this.i18nService.t('cancel'), 'warning');
}
}
2018-08-02 05:21:32 +02:00
}