Browse Source

Override plan and success and error message.

pull/95/head
Sebastian Stehle 9 years ago
parent
commit
76913d0b58
  1. 29
      src/Squidex/app/features/settings/pages/plans/plans-page.component.ts
  2. 21
      src/Squidex/app/shell/pages/internal/internal-area.component.ts

29
src/Squidex/app/features/settings/pages/plans/plans-page.component.ts

@ -5,7 +5,9 @@
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import {
ApiUrlConfig,
@ -24,7 +26,9 @@ import {
styleUrls: ['./plans-page.component.scss'],
templateUrl: './plans-page.component.html'
})
export class PlansPageComponent extends AppComponentBase implements OnInit {
export class PlansPageComponent extends AppComponentBase implements OnDestroy, OnInit {
private queryParamsSubscription: Subscription;
private overridePlanId: string;
private version = new Version();
public portalUrl = this.apiUrl.buildUrl('/identity-server/account/portal');
@ -37,11 +41,21 @@ export class PlansPageComponent extends AppComponentBase implements OnInit {
constructor(apps: AppsStoreService, notifications: NotificationService,
private readonly authService: AuthService,
private readonly plansService: PlansService,
private readonly route: ActivatedRoute,
private readonly apiUrl: ApiUrlConfig
) {
super(notifications, apps);
}
public ngOnDestroy() {
this.queryParamsSubscription.unsubscribe();
this.queryParamsSubscription =
this.route.queryParams.subscribe(params => {
this.overridePlanId = params['planId'];
});
}
public ngOnInit() {
this.load();
}
@ -50,7 +64,16 @@ export class PlansPageComponent extends AppComponentBase implements OnInit {
this.appNameOnce()
.switchMap(app => this.plansService.getPlans(app, this.version).retry(2))
.subscribe(dto => {
this.plans = dto;
if (this.overridePlanId) {
this.plans = new AppPlansDto(
this.overridePlanId,
dto.planOwner,
dto.hasPortal,
dto.plans);
} else {
this.plans = dto;
}
this.planOwned = !dto.planOwner || (dto.planOwner === this.authService.user!.id);
if (showInfo) {

21
src/Squidex/app/shell/pages/internal/internal-area.component.ts

@ -6,6 +6,7 @@
*/
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import {
@ -20,15 +21,18 @@ import {
})
export class InternalAreaComponent implements OnInit, OnDestroy {
private notificationsSubscription: Subscription;
private queryParamsSubscription: Subscription;
public notifications: Notification[] = [];
constructor(
private readonly notificationService: NotificationService
private readonly notificationService: NotificationService,
private readonly route: ActivatedRoute
) {
}
public ngOnDestroy() {
this.queryParamsSubscription.unsubscribe();
this.notificationsSubscription.unsubscribe();
}
@ -43,6 +47,21 @@ export class InternalAreaComponent implements OnInit, OnDestroy {
}, notification.displayTime);
}
});
this.queryParamsSubscription =
this.route.queryParams.subscribe(params => {
const successMessage = params['successMessage'];
if (successMessage) {
this.notificationService.notify(Notification.info(successMessage));
}
const errorMessage = params['errorMessage'];
if (errorMessage) {
this.notificationService.notify(Notification.error(errorMessage));
}
});
}
public close(notification: Notification) {

Loading…
Cancel
Save