1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +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

@@ -17,6 +17,7 @@ import { Router } from '@angular/router';
import { ModalComponent } from './modal.component';
import { PremiumComponent } from './accounts/premium.component';
import { SettingsComponent } from './accounts/settings.component';
import { ToasterService } from 'angular2-toaster';
@@ -49,10 +50,12 @@ const BroadcasterSubscriptionId = 'AppComponent';
template: `
<toaster-container [toasterconfig]="toasterConfig"></toaster-container>
<ng-template #settings></ng-template>
<ng-template #premium></ng-template>
<router-outlet></router-outlet>`,
})
export class AppComponent implements OnInit {
@ViewChild('settings', { read: ViewContainerRef }) settingsRef: ViewContainerRef;
@ViewChild('premium', { read: ViewContainerRef }) premiumRef: ViewContainerRef;
toasterConfig: ToasterConfig = new ToasterConfig({
showCloseButton: true,
@@ -113,6 +116,9 @@ export class AppComponent implements OnInit {
case 'openSettings':
this.openSettings();
break;
case 'openPremium':
this.openPremium();
break;
default:
}
});
@@ -177,4 +183,18 @@ export class AppComponent implements OnInit {
this.modal = null;
});
}
private openPremium() {
if (this.modal != null) {
this.modal.close();
}
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
this.modal = this.premiumRef.createComponent(factory).instance;
const childComponent = this.modal.show<PremiumComponent>(PremiumComponent, this.premiumRef);
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
}
}