1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

premium membership component

This commit is contained in:
Kyle Spearrin
2018-02-16 15:03:29 -05:00
parent 54d2742604
commit 830a437f1e
8 changed files with 220 additions and 4 deletions

View File

@@ -0,0 +1,59 @@
import * as template from './premium.component.html';
import {
Component,
OnInit,
} from '@angular/core';
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { ApiService } from 'jslib/abstractions/api.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { TokenService } from 'jslib/abstractions/token.service';
@Component({
selector: 'app-premium',
template: template,
})
export class PremiumComponent implements OnInit {
isPremium: boolean = false;
price: string = '$10';
refreshPromise: Promise<any>;
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
private tokenService: TokenService, private apiService: ApiService) { }
async ngOnInit() {
this.isPremium = !this.tokenService.getPremium();
}
async refresh() {
try {
this.refreshPromise = this.apiService.refreshIdentityToken();
await this.refreshPromise;
this.toasterService.popAsync('success', null, this.i18nService.t('refreshComplete'));
this.isPremium = this.tokenService.getPremium();
} catch { }
}
async purchase() {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumPurchaseAlert'),
this.i18nService.t('premiumPurchase'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) {
this.analytics.eventTrack.next({ action: 'Clicked Purchase Premium' });
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=purchase');
}
}
async manage() {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumManageAlert'),
this.i18nService.t('premiumManage'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
if (confirmed) {
this.analytics.eventTrack.next({ action: 'Clicked Manage Membership' });
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=manage');
}
}
}