diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 65ef7a970e..92dccc99b9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -58,6 +58,7 @@ import { AccountComponent as OrgAccountComponent } from './organizations/setting import { AdjustSeatsComponent } from './organizations/settings/adjust-seats.component'; import { ApiKeyComponent as OrgApiKeyComponent } from './organizations/settings/api-key.component'; import { DeleteOrganizationComponent } from './organizations/settings/delete-organization.component'; +import { DownloadLicenseComponent } from './organizations/settings/download-license.component'; import { OrganizationBillingComponent } from './organizations/settings/organization-billing.component'; import { OrganizationSubscriptionComponent } from './organizations/settings/organization-subscription.component'; import { RotateApiKeyComponent as OrgRotateApiKeyComponent } from './organizations/settings/rotate-api-key.component'; @@ -257,6 +258,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); DeleteAccountComponent, DeleteOrganizationComponent, DomainRulesComponent, + DownloadLicenseComponent, ExportComponent, ExposedPasswordsReportComponent, FallbackSrcDirective, diff --git a/src/app/organizations/settings/download-license.component.html b/src/app/organizations/settings/download-license.component.html new file mode 100644 index 0000000000..802413c4ff --- /dev/null +++ b/src/app/organizations/settings/download-license.component.html @@ -0,0 +1,25 @@ +
+
+

{{'downloadLicense' | i18n}}

+
+
+
+ + + + +
+ +
+
+ + +
+
diff --git a/src/app/organizations/settings/download-license.component.ts b/src/app/organizations/settings/download-license.component.ts new file mode 100644 index 0000000000..4e7dbb89f3 --- /dev/null +++ b/src/app/organizations/settings/download-license.component.ts @@ -0,0 +1,43 @@ +import { + Component, + EventEmitter, + Input, + Output, +} from '@angular/core'; + +import { ApiService } from 'jslib/abstractions/api.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; + +@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; + + constructor(private apiService: ApiService, private platformUtilsService: PlatformUtilsService) { } + + async submit() { + if (this.installationId == null || this.installationId === '') { + return; + } + + try { + this.formPromise = this.apiService.getOrganizationLicense(this.organizationId, this.installationId); + const license = await this.formPromise; + const licenseString = JSON.stringify(license, null, 2); + this.platformUtilsService.saveFile(window, licenseString, null, 'bitwarden_organization_license.json'); + this.platformUtilsService.eventTrack('Downloaded License'); + this.onDownloaded.emit(); + } catch { } + } + + cancel() { + this.onCanceled.emit(); + } +} diff --git a/src/app/organizations/settings/organization-subscription.component.html b/src/app/organizations/settings/organization-subscription.component.html index 679b304537..83ec618a23 100644 --- a/src/app/organizations/settings/organization-subscription.component.html +++ b/src/app/organizations/settings/organization-subscription.component.html @@ -88,11 +88,9 @@ - +
+ +

{{'userSeats' | i18n}}

{{'subscriptionUserSeats' | i18n : sub.seats}}

diff --git a/src/app/organizations/settings/organization-subscription.component.ts b/src/app/organizations/settings/organization-subscription.component.ts index f750ea10e4..31451b9753 100644 --- a/src/app/organizations/settings/organization-subscription.component.ts +++ b/src/app/organizations/settings/organization-subscription.component.ts @@ -30,12 +30,12 @@ export class OrganizationSubscriptionComponent implements OnInit { adjustStorageAdd = true; showAdjustStorage = false; showUpdateLicense = false; + showDownloadLicense = false; sub: OrganizationSubscriptionResponse; selfHosted = false; cancelPromise: Promise; reinstatePromise: Promise; - licensePromise: Promise; constructor(private tokenService: TokenService, private apiService: ApiService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, @@ -109,22 +109,12 @@ export class OrganizationSubscriptionComponent implements OnInit { } } - async downloadLicense() { - if (this.loading) { - return; - } + downloadLicense() { + this.showDownloadLicense = !this.showDownloadLicense; + } - const installationId = window.prompt(this.i18nService.t('enterInstallationId')); - if (installationId == null || installationId === '') { - return; - } - - try { - this.licensePromise = this.apiService.getOrganizationLicense(this.organizationId, installationId); - const license = await this.licensePromise; - const licenseString = JSON.stringify(license, null, 2); - this.platformUtilsService.saveFile(window, licenseString, null, 'bitwarden_organization_license.json'); - } catch { } + closeDownloadLicense() { + this.showDownloadLicense = false; } updateLicense() {