create by license moved from update license component
This commit is contained in:
parent
70dbca67e7
commit
738eaa6ca7
|
@ -3,8 +3,18 @@
|
||||||
</div>
|
</div>
|
||||||
<p>{{'newOrganizationDesc' | i18n}}</p>
|
<p>{{'newOrganizationDesc' | i18n}}</p>
|
||||||
<ng-container *ngIf="selfHosted">
|
<ng-container *ngIf="selfHosted">
|
||||||
<p>{{'uploadLicenseFilePremium' | i18n}}</p>
|
<p>{{'uploadLicenseFileOrg' | i18n}}</p>
|
||||||
<app-update-license [user]="true" [create]="true" (onUpdated)="finalizePremium()"></app-update-license>
|
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="file">{{'licenseFile' | i18n}}</label>
|
||||||
|
<input type="file" id="file" class="form-control-file" name="file" required>
|
||||||
|
<small class="form-text text-muted">{{'licenseFileDesc' | i18n : 'bitwarden_organization_license.json'}}</small>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
||||||
|
<i class="fa fa-spinner fa-spin"></i>
|
||||||
|
<span>{{'submit' | i18n}}</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="!selfHosted">
|
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="!selfHosted">
|
||||||
<h2 class="mt-5">{{'generalInformation' | i18n}}</h2>
|
<h2 class="mt-5">{{'generalInformation' | i18n}}</h2>
|
||||||
|
|
|
@ -87,6 +87,17 @@ export class CreateOrganizationComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
let files: FileList = null;
|
||||||
|
if (this.selfHosted) {
|
||||||
|
const fileEl = document.getElementById('file') as HTMLInputElement;
|
||||||
|
files = fileEl.files;
|
||||||
|
if (files == null || files.length === 0) {
|
||||||
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||||
|
this.i18nService.t('selectFile'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let key: string = null;
|
let key: string = null;
|
||||||
let collectionCt: string = null;
|
let collectionCt: string = null;
|
||||||
|
|
||||||
|
@ -96,34 +107,41 @@ export class CreateOrganizationComponent {
|
||||||
return this.cryptoService.encrypt('Default Collection', shareKey[1]);
|
return this.cryptoService.encrypt('Default Collection', shareKey[1]);
|
||||||
}).then((collection) => {
|
}).then((collection) => {
|
||||||
collectionCt = collection.encryptedString;
|
collectionCt = collection.encryptedString;
|
||||||
if (this.plan === 'free') {
|
if (this.selfHosted || this.plan === 'free') {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return this.paymentComponent.createPaymentToken();
|
return this.paymentComponent.createPaymentToken();
|
||||||
}
|
}
|
||||||
}).then((token: string) => {
|
}).then((token: string) => {
|
||||||
const request = new OrganizationCreateRequest();
|
if (this.selfHosted) {
|
||||||
request.key = key;
|
const fd = new FormData();
|
||||||
request.collectionName = collectionCt;
|
fd.append('license', files[0]);
|
||||||
request.name = this.name;
|
fd.append('key', key);
|
||||||
request.billingEmail = this.billingEmail;
|
fd.append('collectionName', collectionCt);
|
||||||
|
return this.apiService.postOrganizationLicense(fd);
|
||||||
if (this.plan === 'free') {
|
|
||||||
request.planType = PlanType.Free;
|
|
||||||
} else {
|
} else {
|
||||||
request.paymentToken = token;
|
const request = new OrganizationCreateRequest();
|
||||||
request.businessName = this.ownedBusiness ? this.businessName : null;
|
request.key = key;
|
||||||
request.additionalSeats = this.additionalSeats;
|
request.collectionName = collectionCt;
|
||||||
request.additionalStorageGb = this.additionalStorage;
|
request.name = this.name;
|
||||||
request.country = this.paymentComponent.getCountry();
|
request.billingEmail = this.billingEmail;
|
||||||
if (this.interval === 'month') {
|
|
||||||
request.planType = this.plans[this.plan].monthPlanType;
|
|
||||||
} else {
|
|
||||||
request.planType = this.plans[this.plan].annualPlanType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.apiService.postOrganization(request);
|
if (this.plan === 'free') {
|
||||||
|
request.planType = PlanType.Free;
|
||||||
|
} else {
|
||||||
|
request.paymentToken = token;
|
||||||
|
request.businessName = this.ownedBusiness ? this.businessName : null;
|
||||||
|
request.additionalSeats = this.additionalSeats;
|
||||||
|
request.additionalStorageGb = this.additionalStorage;
|
||||||
|
request.country = this.paymentComponent.getCountry();
|
||||||
|
if (this.interval === 'month') {
|
||||||
|
request.planType = this.plans[this.plan].monthPlanType;
|
||||||
|
} else {
|
||||||
|
request.planType = this.plans[this.plan].annualPlanType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.apiService.postOrganization(request);
|
||||||
|
}
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return this.finalize(response.id);
|
return this.finalize(response.id);
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,7 +33,17 @@
|
||||||
</app-callout>
|
</app-callout>
|
||||||
<ng-container *ngIf="selfHosted">
|
<ng-container *ngIf="selfHosted">
|
||||||
<p>{{'uploadLicenseFilePremium' | i18n}}</p>
|
<p>{{'uploadLicenseFilePremium' | i18n}}</p>
|
||||||
<app-update-license [user]="true" [create]="true" (onUpdated)="finalizePremium()"></app-update-license>
|
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="file">{{'licenseFile' | i18n}}</label>
|
||||||
|
<input type="file" id="file" class="form-control-file" name="file" required>
|
||||||
|
<small class="form-text text-muted">{{'licenseFileDesc' | i18n : 'bitwarden_premium_license.json'}}</small>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
||||||
|
<i class="fa fa-spinner fa-spin"></i>
|
||||||
|
<span>{{'submit' | i18n}}</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="!selfHosted">
|
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="!selfHosted">
|
||||||
<h2 class="mt-5">{{'addons' | i18n}}</h2>
|
<h2 class="mt-5">{{'addons' | i18n}}</h2>
|
||||||
|
|
|
@ -46,15 +46,34 @@ export class PremiumComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
let files: FileList = null;
|
||||||
|
if (this.selfHosted) {
|
||||||
|
const fileEl = document.getElementById('file') as HTMLInputElement;
|
||||||
|
files = fileEl.files;
|
||||||
|
if (files == null || files.length === 0) {
|
||||||
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||||
|
this.i18nService.t('selectFile'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.formPromise = this.paymentComponent.createPaymentToken().then((token) => {
|
if (this.selfHosted) {
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append('paymentToken', token);
|
fd.append('license', files[0]);
|
||||||
fd.append('additionalStorageGb', (this.additionalStorage || 0).toString());
|
this.formPromise = this.apiService.postAccountLicense(fd).then(() => {
|
||||||
return this.apiService.postPremium(fd);
|
return this.finalizePremium();
|
||||||
}).then(() => {
|
});
|
||||||
return this.finalizePremium();
|
} else {
|
||||||
});
|
this.formPromise = this.paymentComponent.createPaymentToken().then((token) => {
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('paymentToken', token);
|
||||||
|
fd.append('additionalStorageGb', (this.additionalStorage || 0).toString());
|
||||||
|
return this.apiService.postPremium(fd);
|
||||||
|
}).then(() => {
|
||||||
|
return this.finalizePremium();
|
||||||
|
});
|
||||||
|
}
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<i class="fa fa-spinner fa-spin"></i>
|
<i class="fa fa-spinner fa-spin"></i>
|
||||||
<span>{{'submit' | i18n}}</span>
|
<span>{{'submit' | i18n}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-outline-secondary" (click)="cancel()" *ngIf="!create">
|
<button type="button" class="btn btn-outline-secondary" (click)="cancel()">
|
||||||
{{'cancel' | i18n}}
|
{{'cancel' | i18n}}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -10,24 +10,20 @@ import { Angulartics2 } from 'angulartics2';
|
||||||
|
|
||||||
import { ApiService } from 'jslib/abstractions/api.service';
|
import { ApiService } from 'jslib/abstractions/api.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { TokenService } from 'jslib/abstractions/token.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-update-license',
|
selector: 'app-update-license',
|
||||||
templateUrl: 'update-license.component.html',
|
templateUrl: 'update-license.component.html',
|
||||||
})
|
})
|
||||||
export class UpdateLicenseComponent {
|
export class UpdateLicenseComponent {
|
||||||
@Input() create = true;
|
|
||||||
@Input() user = true;
|
@Input() user = true;
|
||||||
@Output() onUpdated = new EventEmitter();
|
@Output() onUpdated = new EventEmitter();
|
||||||
@Output() onCanceled = new EventEmitter();
|
@Output() onCanceled = new EventEmitter();
|
||||||
|
|
||||||
storageAdjustment = 0;
|
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<any>;
|
||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService) { }
|
||||||
private tokenService: TokenService) { }
|
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
const fileEl = document.getElementById('file') as HTMLInputElement;
|
const fileEl = document.getElementById('file') as HTMLInputElement;
|
||||||
|
@ -39,25 +35,18 @@ export class UpdateLicenseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('license', files[0]);
|
||||||
|
|
||||||
if (this.user) {
|
if (this.user) {
|
||||||
const fd = new FormData();
|
this.formPromise = this.apiService.postAccountLicense(fd);
|
||||||
fd.append('license', files[0]);
|
} else {
|
||||||
if (this.create) {
|
// TODO
|
||||||
if (!this.tokenService.getEmailVerified()) {
|
|
||||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
||||||
this.i18nService.t('accountEmailMustBeVerified'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.formPromise = this.apiService.postPremium(fd);
|
|
||||||
} else {
|
|
||||||
this.formPromise = this.apiService.postAccountLicense(fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.formPromise;
|
await this.formPromise;
|
||||||
if (!this.create) {
|
this.analytics.eventTrack.next({ action: 'Updated License' });
|
||||||
this.analytics.eventTrack.next({ action: 'Updated License' });
|
this.toasterService.popAsync('success', null, this.i18nService.t('updatedLicense'));
|
||||||
this.toasterService.popAsync('success', null, this.i18nService.t('updatedLicense'));
|
|
||||||
}
|
|
||||||
this.onUpdated.emit();
|
this.onUpdated.emit();
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<div class="card mt-3" *ngIf="showUpdateLicense">
|
<div class="card mt-3" *ngIf="showUpdateLicense">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="card-body-header">{{'updateLicense' | i18n}}</h3>
|
<h3 class="card-body-header">{{'updateLicense' | i18n}}</h3>
|
||||||
<app-update-license [create]="false" [user]="true" (onUpdated)="closeUpdateLicense(true)" (onCanceled)="closeUpdateLicense(false)"></app-update-license>
|
<app-update-license [user]="true" (onUpdated)="closeUpdateLicense(true)" (onCanceled)="closeUpdateLicense(false)"></app-update-license>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
@ -1452,6 +1452,9 @@
|
||||||
"uploadLicenseFilePremium": {
|
"uploadLicenseFilePremium": {
|
||||||
"message": "To upgrade your account to a premium membership you need to upload a valid license file."
|
"message": "To upgrade your account to a premium membership you need to upload a valid license file."
|
||||||
},
|
},
|
||||||
|
"uploadLicenseFileOrg": {
|
||||||
|
"message": "To create an on-premise hosted organization you need to upload a valid license file."
|
||||||
|
},
|
||||||
"accountEmailMustBeVerified": {
|
"accountEmailMustBeVerified": {
|
||||||
"message": "Your account's email address must be verified."
|
"message": "Your account's email address must be verified."
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue