1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

self host builds

This commit is contained in:
Kyle Spearrin
2018-06-30 14:14:52 -04:00
parent d509637623
commit c5d575b9b6
6 changed files with 123 additions and 92 deletions

2
jslib

Submodule jslib updated: f5287e29a2...20622db73c

View File

@@ -10,6 +10,10 @@
"build:watch": "webpack-serve --config webpack.config.js", "build:watch": "webpack-serve --config webpack.config.js",
"build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.js", "build:prod": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"build:prod:watch": "cross-env NODE_ENV=production webpack-serve --config webpack.config.js", "build:prod:watch": "cross-env NODE_ENV=production webpack-serve --config webpack.config.js",
"build:selfhost": "cross-env SELF_HOST=true webpack-serve --config webpack.config.js",
"build:selfhost:watch": "cross-env SELF_HOST=true webpack-serve --config webpack.config.js",
"build:selfhost:prod": "cross-env SELF_HOST=true NODE_ENV=production webpack --config webpack.config.js",
"build:selfhost:prod:watch": "cross-env SELF_HOST=true NODE_ENV=production webpack-serve --config webpack.config.js",
"dist": "npm run build:prod && gulp dist", "dist": "npm run build:prod && gulp dist",
"lint": "tslint src/**/*.ts || true", "lint": "tslint src/**/*.ts || true",
"lint:fix": "tslint src/**/*.ts --fix" "lint:fix": "tslint src/**/*.ts --fix"

View File

@@ -7,50 +7,63 @@
</h1> </h1>
</div> </div>
<app-premium *ngIf="!premium" (onPremiumPurchased)="load()"></app-premium> <app-premium *ngIf="!premium" (onPremiumPurchased)="load()"></app-premium>
<ng-container *ngIf="premium"> <i class="fa fa-spinner fa-spin text-muted" *ngIf="premium && !firstLoaded && loading"></i>
<i class="fa fa-spinner fa-spin text-muted" *ngIf="!firstLoaded && loading"></i> <ng-container *ngIf="premium && billing">
<ng-container *ngIf="billing"> <app-callout type="warning" title="{{'canceled' | i18n}}" *ngIf="subscription.cancelled">{{'subscriptionCanceled' | i18n}}</app-callout>
<app-callout type="warning" title="{{'canceled' | i18n}}" *ngIf="subscription.cancelled">{{'subscriptionCanceled' | i18n}}</app-callout> <app-callout type="warning" title="{{'pendingCancellation' | i18n}}" *ngIf="subscriptionMarkedForCancel">
<app-callout type="warning" title="{{'pendingCancellation' | i18n}}" *ngIf="subscriptionMarkedForCancel"> <p>{{'subscriptionPendingCanceled' | i18n}}</p>
<p>{{'subscriptionPendingCanceled' | i18n}}</p> <button #reinstateBtn type="button" class="btn btn-outline-secondary btn-submit" (click)="reinstate()" [appApiAction]="reinstatePromise"
<button #reinstateBtn type="button" class="btn btn-outline-secondary btn-submit" (click)="reinstate()" [appApiAction]="reinstatePromise" [disabled]="reinstateBtn.loading">
[disabled]="reinstateBtn.loading"> <i class="fa fa-spinner fa-spin"></i>
<i class="fa fa-spinner fa-spin"></i> <span>{{'reinstateSubscription' | i18n}}</span>
<span>{{'reinstateSubscription' | i18n}}</span> </button>
</button> </app-callout>
</app-callout> <dl *ngIf="selfHosted">
<div class="row"> <dt>{{'expiration' | i18n}}</dt>
<div class="col-4"> <dd *ngIf="billing.expiration">{{billing.expiration | date:'mediumDate'}}</dd>
<dl> <dd *ngIf="!billing.expiration">{{'neverExpires' | i18n}}</dd>
<dt>{{'status' | i18n}}</dt> </dl>
<dd> <div class="row" *ngIf="!selfHosted">
<span class="text-capitalize">{{(subscription && subscription.status) || '-'}}</span> <div class="col-4">
<span class="badge badge-warning" *ngIf="subscriptionMarkedForCancel">{{'pendingCancellation' | i18n}}</span> <dl>
</dd> <dt>{{'status' | i18n}}</dt>
<dt>{{'nextCharge' | i18n}}</dt> <dd>
<dd>{{nextInvoice ? ((nextInvoice.date | date: 'mediumDate') + ', ' + (nextInvoice.amount | currency:'$')) <span class="text-capitalize">{{(subscription && subscription.status) || '-'}}</span>
: '-'}}</dd> <span class="badge badge-warning" *ngIf="subscriptionMarkedForCancel">{{'pendingCancellation' | i18n}}</span>
</dl> </dd>
</div> <dt>{{'nextCharge' | i18n}}</dt>
<div class="col-8"> <dd>{{nextInvoice ? ((nextInvoice.date | date: 'mediumDate') + ', ' + (nextInvoice.amount | currency:'$')) :
<strong class="d-block mb-1">{{'details' | i18n}}</strong> '-'}}</dd>
<table class="table"> </dl>
<tbody>
<tr *ngFor="let i of subscription.items">
<td>
{{i.name}} {{i.quantity > 1 ? '&times;' + i.quantity : ''}} @ {{i.amount | currency:'$'}}
</td>
<td>
{{(i.quantity * i.amount) | currency:'$'}} /{{i.interval | i18n}}
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
<div class="col-8">
<strong class="d-block mb-1">{{'details' | i18n}}</strong>
<table class="table">
<tbody>
<tr *ngFor="let i of subscription.items">
<td>
{{i.name}} {{i.quantity > 1 ? '&times;' + i.quantity : ''}} @ {{i.amount | currency:'$'}}
</td>
<td>
{{(i.quantity * i.amount) | currency:'$'}} /{{i.interval | i18n}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
<ng-container *ngIf="selfHosted">
<button type="button" class="btn btn-outline-secondary" (click)="updateLicense()">
{{'updateLicense' | i18n}}
</button>
<a href="https://vault.bitwarden.com/#/settings/billing" target="_blank" rel="noopener" class="btn btn-outline-secondary">
{{'manageSubscription' | i18n}}
</a>
</ng-container>
<ng-container *ngIf="!selfHosted">
<ng-container *ngIf="!subscription.cancelled || subscriptionMarkedForCancel"> <ng-container *ngIf="!subscription.cancelled || subscriptionMarkedForCancel">
<div class="d-flex"> <div class="d-flex">
<button type="button" class="btn btn-outline-secondary" (click)="license()" *ngIf="!subscription.cancelled"> <button type="button" class="btn btn-outline-secondary" (click)="downloadLicense()" *ngIf="!subscription.cancelled">
{{'downloadLicense' | i18n}} {{'downloadLicense' | i18n}}
</button> </button>
<button #cancelBtn type="button" class="btn btn-outline-danger btn-submit ml-auto" (click)="cancel()" [appApiAction]="cancelPromise" <button #cancelBtn type="button" class="btn btn-outline-danger btn-submit ml-auto" (click)="cancel()" [appApiAction]="cancelPromise"
@@ -60,54 +73,52 @@
</button> </button>
</div> </div>
</ng-container> </ng-container>
<ng-container *ngIf="!selfHosted"> <h2 class="spaced-header">{{'storage' | i18n}}</h2>
<h2 class="spaced-header">{{'storage' | i18n}}</h2> <p>{{'subscriptionStorage' | i18n : billing.maxStorageGb : billing.storageName || '0 MB'}}</p>
<p>{{'subscriptionStorage' | i18n : billing.maxStorageGb : billing.storageName || '0 MB'}}</p> <div class="progress">
<div class="progress"> <div class="progress-bar bg-success" role="progressbar" [ngStyle]="{width: storagePercentage + '%' }" [attr.aria-valuenow]="storagePercentage"
<div class="progress-bar bg-success" role="progressbar" [ngStyle]="{width: storagePercentage + '%' }" [attr.aria-valuenow]="storagePercentage" aria-valuemin="0" aria-valuemax="100">{{(storagePercentage / 100) | percent}}</div>
aria-valuemin="0" aria-valuemax="100">{{(storagePercentage / 100) | percent}}</div> </div>
<ng-container *ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel && paymentSource">
<div class="mt-3">
<ng-container *ngIf="!showAdjustStorage">
<button type="button" class="btn btn-outline-secondary" (click)="adjustStorage(true)">
{{'addStorage' | i18n}}
</button>
<button type="button" class="btn btn-outline-secondary" (click)="adjustStorage(false)">
{{'removeStorage' | i18n}}
</button>
</ng-container>
<app-adjust-storage [storageGbPrice]="4" [add]="adjustStorageAdd" [user]="true" (onAdjusted)="closeStorage(true)" (onCanceled)="closeStorage(false)"
*ngIf="showAdjustStorage"></app-adjust-storage>
</div> </div>
<ng-container *ngIf="subscription && !subscription.cancelled && !subscriptionMarkedForCancel && paymentSource"> </ng-container>
<div class="mt-3"> <h2 class="spaced-header">{{'paymentMethod' | i18n}}</h2>
<ng-container *ngIf="!showAdjustStorage"> <p *ngIf="!paymentSource">{{'noPaymentMethod' | i18n}}</p>
<button type="button" class="btn btn-outline-secondary" (click)="adjustStorage(true)"> <p *ngIf="paymentSource">
{{'addStorage' | i18n}} <i class="fa fa-fw" [ngClass]="{'fa-credit-card': paymentSource.type === paymentMethodType.Card,
</button>
<button type="button" class="btn btn-outline-secondary" (click)="adjustStorage(false)">
{{'removeStorage' | i18n}}
</button>
</ng-container>
<app-adjust-storage [storageGbPrice]="4" [add]="adjustStorageAdd" [user]="true" (onAdjusted)="closeStorage(true)" (onCanceled)="closeStorage(false)"
*ngIf="showAdjustStorage"></app-adjust-storage>
</div>
</ng-container>
<h2 class="spaced-header">{{'paymentMethod' | i18n}}</h2>
<p *ngIf="!paymentSource">{{'noPaymentMethod' | i18n}}</p>
<p *ngIf="paymentSource">
<i class="fa fa-fw" [ngClass]="{'fa-credit-card': paymentSource.type === paymentMethodType.Card,
'fa-university': paymentSource.type === paymentMethodType.BankAccount, 'fa-university': paymentSource.type === paymentMethodType.BankAccount,
'fa-paypal text-primary': paymentSource.type === paymentMethodType.PayPal}"></i> 'fa-paypal text-primary': paymentSource.type === paymentMethodType.PayPal}"></i>
{{paymentSource.description}} {{paymentSource.description}}
</p> </p>
<button type="button" class="btn btn-outline-secondary" (click)="changePayment()" *ngIf="!showAdjustPayment"> <button type="button" class="btn btn-outline-secondary" (click)="changePayment()" *ngIf="!showAdjustPayment">
{{(paymentSource ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}} {{(paymentSource ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}
</button> </button>
<app-adjust-payment [currentType]="paymentSource != null ? paymentSource.type : null" [user]="true" (onAdjusted)="closePayment(true)" <app-adjust-payment [currentType]="paymentSource != null ? paymentSource.type : null" [user]="true" (onAdjusted)="closePayment(true)"
(onCanceled)="closePayment(false)" *ngIf="showAdjustPayment"> (onCanceled)="closePayment(false)" *ngIf="showAdjustPayment">
</app-adjust-payment> </app-adjust-payment>
<h2 class="spaced-header">{{'charges' | i18n}}</h2> <h2 class="spaced-header">{{'charges' | i18n}}</h2>
<p *ngIf="!charges || !charges.length">{{'noCharges' | i18n}}</p> <p *ngIf="!charges || !charges.length">{{'noCharges' | i18n}}</p>
<table class="table mb-2" *ngIf="charges && charges.length"> <table class="table mb-2" *ngIf="charges && charges.length">
<tbody> <tbody>
<tr *ngFor="let c of charges"> <tr *ngFor="let c of charges">
<td>{{c.createdDate | date:'mediumDate'}}</td> <td>{{c.createdDate | date:'mediumDate'}}</td>
<td>{{c.paymentSource ? c.paymentSource.description : '-'}}</td> <td>{{c.paymentSource ? c.paymentSource.description : '-'}}</td>
<td class="text-capitalize">{{c.status}}</td> <td class="text-capitalize">{{c.status}}</td>
<td>{{c.amount | currency:'$'}}</td> <td>{{c.amount | currency:'$'}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<small class="text-muted">* {{'chargesStatement' | i18n : 'BITWARDEN'}}</small> <small class="text-muted">* {{'chargesStatement' | i18n : 'BITWARDEN'}}</small>
</ng-container>
</ng-container> </ng-container>
</ng-container> </ng-container>

View File

@@ -15,8 +15,6 @@ import { TokenService } from 'jslib/abstractions/token.service';
import { PaymentMethodType } from 'jslib/enums/paymentMethodType'; import { PaymentMethodType } from 'jslib/enums/paymentMethodType';
import { AdjustStorageComponent } from './adjust-storage.component';
@Component({ @Component({
selector: 'app-user-billing', selector: 'app-user-billing',
templateUrl: 'user-billing.component.html', templateUrl: 'user-billing.component.html',
@@ -30,13 +28,16 @@ export class UserBillingComponent implements OnInit {
showAdjustPayment = false; showAdjustPayment = false;
billing: BillingResponse; billing: BillingResponse;
paymentMethodType = PaymentMethodType; paymentMethodType = PaymentMethodType;
selfHosted = false;
cancelPromise: Promise<any>; cancelPromise: Promise<any>;
reinstatePromise: Promise<any>; reinstatePromise: Promise<any>;
constructor(private tokenService: TokenService, private apiService: ApiService, constructor(private tokenService: TokenService, private apiService: ApiService,
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService) { } private analytics: Angulartics2, private toasterService: ToasterService) {
this.selfHosted = platformUtilsService.isSelfHost();
}
async ngOnInit() { async ngOnInit() {
await this.load(); await this.load();
@@ -96,7 +97,7 @@ export class UserBillingComponent implements OnInit {
} catch { } } catch { }
} }
license() { downloadLicense() {
if (this.loading) { if (this.loading) {
return; return;
} }
@@ -105,6 +106,12 @@ export class UserBillingComponent implements OnInit {
this.platformUtilsService.saveFile(window, licenseString, null, 'bitwarden_premium_license.json'); this.platformUtilsService.saveFile(window, licenseString, null, 'bitwarden_premium_license.json');
} }
updateLicense() {
if (this.loading) {
return;
}
}
adjustStorage(add: boolean) { adjustStorage(add: boolean) {
this.adjustStorageAdd = add; this.adjustStorageAdd = add;
this.showAdjustStorage = true; this.showAdjustStorage = true;

View File

@@ -180,6 +180,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
return process.env.ENV === 'development'; return process.env.ENV === 'development';
} }
isSelfHost(): boolean {
return process.env.SELF_HOST.toString() === 'true';
}
copyToClipboard(text: string, options?: any): void { copyToClipboard(text: string, options?: any): void {
const doc = options ? options.doc : window.document; const doc = options ? options.doc : window.document;
if ((window as any).clipboardData && (window as any).clipboardData.setData) { if ((window as any).clipboardData && (window as any).clipboardData.setData) {

View File

@@ -13,6 +13,10 @@ if (process.env.NODE_ENV == null) {
} }
const ENV = process.env.ENV = process.env.NODE_ENV; const ENV = process.env.ENV = process.env.NODE_ENV;
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'development';
}
const isVendorModule = (module) => { const isVendorModule = (module) => {
if (!module.context) { if (!module.context) {
return false; return false;
@@ -104,6 +108,7 @@ const plugins = [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
'ENV': JSON.stringify(ENV), 'ENV': JSON.stringify(ENV),
'SELF_HOST': JSON.stringify(process.env.SELF_HOST === 'true' ? true : false),
'APPLICATION_VERSION': JSON.stringify(pjson.version), 'APPLICATION_VERSION': JSON.stringify(pjson.version),
'CACHE_TAG': JSON.stringify(Math.random().toString(36).substring(7)), 'CACHE_TAG': JSON.stringify(Math.random().toString(36).substring(7)),
} }