bitwarden-estensione-browser/apps/web/src/app/organizations/settings/download-license.component.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-03-20 14:56:50 +01:00
import { Component, EventEmitter, Input, Output } from "@angular/core";
import { ApiService } from "jslib-common/abstractions/api.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
2019-03-20 14:56:50 +01:00
@Component({
selector: "app-download-license",
templateUrl: "download-license.component.html",
})
export class DownloadLicenseComponent {
@Input() organizationId: string;
@Output() onDownloaded = new EventEmitter();
@Output() onCanceled = new EventEmitter();
installationId: string;
formPromise: Promise<any>;
constructor(
private apiService: ApiService,
private platformUtilsService: PlatformUtilsService,
private logService: LogService
) {}
2019-03-20 14:56:50 +01:00
async submit() {
if (this.installationId == null || this.installationId === "") {
return;
}
try {
this.formPromise = this.apiService.getOrganizationLicense(
this.organizationId,
this.installationId
2021-12-17 15:57:11 +01:00
);
2019-03-20 14:56:50 +01:00
const license = await this.formPromise;
const licenseString = JSON.stringify(license, null, 2);
this.platformUtilsService.saveFile(
2021-12-17 15:57:11 +01:00
window,
2019-03-20 14:56:50 +01:00
licenseString,
2021-12-17 15:57:11 +01:00
null,
2019-03-20 14:56:50 +01:00
"bitwarden_organization_license.json"
2021-12-17 15:57:11 +01:00
);
2019-03-20 14:56:50 +01:00
this.onDownloaded.emit();
} catch (e) {
this.logService.error(e);
2019-03-20 14:56:50 +01:00
}
2021-12-17 15:57:11 +01:00
}
cancel() {
2019-03-20 14:56:50 +01:00
this.onCanceled.emit();
2021-12-17 15:57:11 +01:00
}
2019-03-20 14:56:50 +01:00
}