Files
clients/src/angular/components/premium.component.ts

47 lines
2.0 KiB
TypeScript
Raw Normal View History

2018-04-13 13:19:14 -04:00
import { OnInit } from '@angular/core';
import { ApiService } from '../../abstractions/api.service';
import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { TokenService } from '../../abstractions/token.service';
export class PremiumComponent implements OnInit {
isPremium: boolean = false;
2018-08-31 15:38:40 -04:00
price: number = 10;
2018-04-13 13:19:14 -04:00
refreshPromise: Promise<any>;
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
2018-04-13 13:19:14 -04:00
protected tokenService: TokenService, protected apiService: ApiService) { }
async ngOnInit() {
this.isPremium = this.tokenService.getPremium();
}
async refresh() {
try {
this.refreshPromise = this.apiService.refreshIdentityToken();
await this.refreshPromise;
2018-10-02 23:09:19 -04:00
this.platformUtilsService.showToast('success', null, this.i18nService.t('refreshComplete'));
2018-04-13 13:19:14 -04:00
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.platformUtilsService.eventTrack('Clicked Purchase Premium');
2018-04-13 13:19:14 -04:00
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.platformUtilsService.eventTrack('Clicked Manage Membership');
2018-04-13 13:19:14 -04:00
this.platformUtilsService.launchUri('https://vault.bitwarden.com/#/?premium=manage');
}
}
}