Browse Source

AppContext removed

pull/271/head
Sebastian Stehle 9 years ago
parent
commit
7f86334cde
  1. 8
      src/Squidex/app/features/settings/pages/languages/language.component.ts
  2. 48
      src/Squidex/app/features/settings/pages/more/more-page.component.html
  3. 2
      src/Squidex/app/features/settings/pages/patterns/patterns-page.component.html
  4. 31
      src/Squidex/app/features/settings/pages/patterns/patterns-page.component.ts
  5. 2
      src/Squidex/app/features/settings/pages/plans/plans-page.component.html
  6. 37
      src/Squidex/app/features/settings/pages/plans/plans-page.component.ts

8
src/Squidex/app/features/settings/pages/languages/language.component.ts

@ -77,14 +77,14 @@ export class LanguageComponent implements OnInit, OnChanges, OnDestroy {
this.resetEditForm(); this.resetEditForm();
} }
public toggleEditing() {
this.isEditing = !this.isEditing;
}
public addLanguage() { public addLanguage() {
this.addFallbackLanguage(this.otherLanguage); this.addFallbackLanguage(this.otherLanguage);
} }
public toggleEditing() {
this.isEditing = !this.isEditing;
}
public removeFallbackLanguage(language: AppLanguageDto) { public removeFallbackLanguage(language: AppLanguageDto) {
this.fallbackLanguages.splice(this.fallbackLanguages.indexOf(language), 1); this.fallbackLanguages.splice(this.fallbackLanguages.indexOf(language), 1);

48
src/Squidex/app/features/settings/pages/more/more-page.component.html

@ -1,39 +1,31 @@
<sqx-title message="{app} | More | Settings" parameter1="app" [value1]="appsState.appName"></sqx-title> <sqx-title message="{app} | More | Settings" parameter1="app" [value1]="appsState.appName"></sqx-title>
<sqx-panel desiredWidth="50rem"> <sqx-panel desiredWidth="50rem">
<div class="panel-header"> <ng-container title>
<div class="panel-title-row"> More
<h3 class="panel-title">More</h3> </ng-container>
</div>
<a class="panel-close" sqxParentLink>
<i class="icon-close"></i>
</a>
</div>
<div class="panel-main"> <ng-container content>
<div class="panel-content"> <div class="card border-danger">
<div class="card border-danger"> <h3 class="card-header">Danger Zone</h3>
<h3 class="card-header">Danger Zone</h3>
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h4>Archive App</h4> <h4>Archive App</h4>
<div>Once you archive an app, there is no going back. Please be certain.</div> <div>Once you archive an app, there is no going back. Please be certain.</div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button class="btn btn-danger" <button class="btn btn-danger"
(sqxConfirmClick)="archiveApp()" (sqxConfirmClick)="archiveApp()"
confirmTitle="Archive App" confirmTitle="Archive App"
confirmText="Do you really want to archive this app?"> confirmText="Do you really want to archive this app?">
Archive App Archive App
</button> </button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </ng-container>
</sqx-panel> </sqx-panel>

2
src/Squidex/app/features/settings/pages/patterns/patterns-page.component.html

@ -1,4 +1,4 @@
<sqx-title message="{app} | Patterns | Settings" parameter1="app" [value1]="ctx.appName"></sqx-title> <sqx-title message="{app} | Patterns | Settings" parameter1="app" [value1]="appsState.appName"></sqx-title>
<sqx-panel desiredWidth="60rem"> <sqx-panel desiredWidth="60rem">
<ng-container title> <ng-container title>

31
src/Squidex/app/features/settings/pages/patterns/patterns-page.component.ts

@ -8,26 +8,25 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { import {
AppContext,
AppPatternDto, AppPatternDto,
AppPatternsDto, AppPatternsDto,
AppPatternsService, AppPatternsService,
HistoryChannelUpdated, AppsState,
DialogService,
UpdatePatternDto UpdatePatternDto
} from '@app/shared'; } from '@app/shared';
@Component({ @Component({
selector: 'sqx-patterns-page', selector: 'sqx-patterns-page',
styleUrls: ['./patterns-page.component.scss'], styleUrls: ['./patterns-page.component.scss'],
templateUrl: './patterns-page.component.html', templateUrl: './patterns-page.component.html'
providers: [
AppContext
]
}) })
export class PatternsPageComponent implements OnInit { export class PatternsPageComponent implements OnInit {
public appPatterns: AppPatternsDto; public appPatterns: AppPatternsDto;
constructor(public readonly ctx: AppContext, constructor(
public readonly appsState: AppsState,
private readonly dialogs: DialogService,
private readonly appPatternsService: AppPatternsService private readonly appPatternsService: AppPatternsService
) { ) {
} }
@ -37,40 +36,40 @@ export class PatternsPageComponent implements OnInit {
} }
public load() { public load() {
this.appPatternsService.getPatterns(this.ctx.appName).retry(2) this.appPatternsService.getPatterns(this.appsState.appName)
.subscribe(dtos => { .subscribe(dtos => {
this.updatePatterns(dtos); this.updatePatterns(dtos);
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
}); });
} }
public addPattern(pattern: AppPatternDto) { public addPattern(pattern: AppPatternDto) {
const requestDto = new UpdatePatternDto(pattern.name, pattern.pattern, pattern.message); const requestDto = new UpdatePatternDto(pattern.name, pattern.pattern, pattern.message);
this.appPatternsService.postPattern(this.ctx.appName, requestDto, this.appPatterns.version) this.appPatternsService.postPattern(this.appsState.appName, requestDto, this.appPatterns.version)
.subscribe(dto => { .subscribe(dto => {
this.updatePatterns(this.appPatterns.addPattern(dto.payload, dto.version)); this.updatePatterns(this.appPatterns.addPattern(dto.payload, dto.version));
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
}); });
} }
public updatePattern(pattern: AppPatternDto, update: UpdatePatternDto) { public updatePattern(pattern: AppPatternDto, update: UpdatePatternDto) {
this.appPatternsService.putPattern(this.ctx.appName, pattern.patternId, update, this.appPatterns.version) this.appPatternsService.putPattern(this.appsState.appName, pattern.patternId, update, this.appPatterns.version)
.subscribe(dto => { .subscribe(dto => {
this.updatePatterns(this.appPatterns.updatePattern(pattern.update(update), dto.version)); this.updatePatterns(this.appPatterns.updatePattern(pattern.update(update), dto.version));
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
}); });
} }
public removePattern(pattern: AppPatternDto) { public removePattern(pattern: AppPatternDto) {
this.appPatternsService.deletePattern(this.ctx.appName, pattern.patternId, this.appPatterns.version) this.appPatternsService.deletePattern(this.appsState.appName, pattern.patternId, this.appPatterns.version)
.subscribe(dto => { .subscribe(dto => {
this.updatePatterns(this.appPatterns.deletePattern(pattern, dto.version)); this.updatePatterns(this.appPatterns.deletePattern(pattern, dto.version));
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
}); });
} }
@ -81,7 +80,5 @@ export class PatternsPageComponent implements OnInit {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}), }),
patterns.version); patterns.version);
this.ctx.bus.emit(new HistoryChannelUpdated());
} }
} }

2
src/Squidex/app/features/settings/pages/plans/plans-page.component.html

@ -1,4 +1,4 @@
<sqx-title message="{app} | Plans | Settings" parameter1="app" [value1]="ctx.appName"></sqx-title> <sqx-title message="{app} | Plans | Settings" parameter1="app" [value1]="appsState.appName"></sqx-title>
<sqx-panel desiredWidth="61rem"> <sqx-panel desiredWidth="61rem">
<ng-container title> <ng-container title>

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

@ -6,23 +6,23 @@
*/ */
import { Component, OnDestroy, OnInit } from '@angular/core'; import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { import {
ApiUrlConfig, ApiUrlConfig,
AppContext,
AppPlansDto, AppPlansDto,
AppsState,
AuthService,
ChangePlanDto, ChangePlanDto,
DialogService,
PlansService PlansService
} from '@app/shared'; } from '@app/shared';
@Component({ @Component({
selector: 'sqx-plans-page', selector: 'sqx-plans-page',
styleUrls: ['./plans-page.component.scss'], styleUrls: ['./plans-page.component.scss'],
templateUrl: './plans-page.component.html', templateUrl: './plans-page.component.html'
providers: [
AppContext
]
}) })
export class PlansPageComponent implements OnDestroy, OnInit { export class PlansPageComponent implements OnDestroy, OnInit {
private queryParamsSubscription: Subscription; private queryParamsSubscription: Subscription;
@ -35,9 +35,13 @@ export class PlansPageComponent implements OnDestroy, OnInit {
public isDisabled = false; public isDisabled = false;
constructor(public readonly ctx: AppContext, constructor(
public readonly appsState: AppsState,
private readonly apiUrl: ApiUrlConfig,
private readonly authState: AuthService,
private readonly dialogs: DialogService,
private readonly plansService: PlansService, private readonly plansService: PlansService,
private readonly apiUrl: ApiUrlConfig private readonly route: ActivatedRoute
) { ) {
} }
@ -47,7 +51,7 @@ export class PlansPageComponent implements OnDestroy, OnInit {
public ngOnInit() { public ngOnInit() {
this.queryParamsSubscription = this.queryParamsSubscription =
this.ctx.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
this.overridePlanId = params['planId']; this.overridePlanId = params['planId'];
}); });
@ -55,7 +59,7 @@ export class PlansPageComponent implements OnDestroy, OnInit {
} }
public load(showInfo = false) { public load(showInfo = false) {
this.plansService.getPlans(this.ctx.appName) this.plansService.getPlans(this.appsState.appName)
.subscribe(dto => { .subscribe(dto => {
if (this.overridePlanId) { if (this.overridePlanId) {
this.plans = dto.changePlanId(this.overridePlanId); this.plans = dto.changePlanId(this.overridePlanId);
@ -63,30 +67,31 @@ export class PlansPageComponent implements OnDestroy, OnInit {
this.plans = dto; this.plans = dto;
} }
this.planOwned = !dto.planOwner || (dto.planOwner === this.ctx.userId); this.planOwned = !dto.planOwner || (dto.planOwner === this.authState.user!.id);
if (showInfo) { if (showInfo) {
this.ctx.notifyInfo('Plans reloaded.'); this.dialogs.notifyInfo('Plans reloaded.');
} }
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
}); });
} }
public changePlan(planId: string) { public changePlan(planId: string) {
this.isDisabled = true; this.isDisabled = true;
this.plansService.putPlan(this.ctx.appName, new ChangePlanDto(planId), this.plans.version) this.plansService.putPlan(this.appsState.appName, new ChangePlanDto(planId), this.plans.version)
.do(() => {
this.isDisabled = false;
})
.subscribe(dto => { .subscribe(dto => {
if (dto.payload.redirectUri && dto.payload.redirectUri.length > 0) { if (dto.payload.redirectUri && dto.payload.redirectUri.length > 0) {
window.location.href = dto.payload.redirectUri; window.location.href = dto.payload.redirectUri;
} else { } else {
this.plans = this.plans.changePlanId(planId, dto.version); this.plans = this.plans.changePlanId(planId, dto.version);
this.isDisabled = false;
} }
}, error => { }, error => {
this.ctx.notifyError(error); this.dialogs.notifyError(error);
this.isDisabled = false;
}); });
} }
} }

Loading…
Cancel
Save