Browse Source

AppContext removed

pull/271/head
Sebastian Stehle 8 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();
}
public toggleEditing() {
this.isEditing = !this.isEditing;
}
public addLanguage() {
this.addFallbackLanguage(this.otherLanguage);
}
public toggleEditing() {
this.isEditing = !this.isEditing;
}
public removeFallbackLanguage(language: AppLanguageDto) {
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-panel desiredWidth="50rem">
<div class="panel-header">
<div class="panel-title-row">
<h3 class="panel-title">More</h3>
</div>
<a class="panel-close" sqxParentLink>
<i class="icon-close"></i>
</a>
</div>
<ng-container title>
More
</ng-container>
<div class="panel-main">
<div class="panel-content">
<div class="card border-danger">
<h3 class="card-header">Danger Zone</h3>
<ng-container content>
<div class="card border-danger">
<h3 class="card-header">Danger Zone</h3>
<div class="card-body">
<div class="row">
<div class="col">
<h4>Archive App</h4>
<div class="card-body">
<div class="row">
<div class="col">
<h4>Archive App</h4>
<div>Once you archive an app, there is no going back. Please be certain.</div>
</div>
<div class="col-auto">
<button class="btn btn-danger"
(sqxConfirmClick)="archiveApp()"
confirmTitle="Archive App"
confirmText="Do you really want to archive this app?">
Archive App
</button>
</div>
<div>Once you archive an app, there is no going back. Please be certain.</div>
</div>
<div class="col-auto">
<button class="btn btn-danger"
(sqxConfirmClick)="archiveApp()"
confirmTitle="Archive App"
confirmText="Do you really want to archive this app?">
Archive App
</button>
</div>
</div>
</div>
</div>
</div>
</ng-container>
</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">
<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 {
AppContext,
AppPatternDto,
AppPatternsDto,
AppPatternsService,
HistoryChannelUpdated,
AppsState,
DialogService,
UpdatePatternDto
} from '@app/shared';
@Component({
selector: 'sqx-patterns-page',
styleUrls: ['./patterns-page.component.scss'],
templateUrl: './patterns-page.component.html',
providers: [
AppContext
]
templateUrl: './patterns-page.component.html'
})
export class PatternsPageComponent implements OnInit {
public appPatterns: AppPatternsDto;
constructor(public readonly ctx: AppContext,
constructor(
public readonly appsState: AppsState,
private readonly dialogs: DialogService,
private readonly appPatternsService: AppPatternsService
) {
}
@ -37,40 +36,40 @@ export class PatternsPageComponent implements OnInit {
}
public load() {
this.appPatternsService.getPatterns(this.ctx.appName).retry(2)
this.appPatternsService.getPatterns(this.appsState.appName)
.subscribe(dtos => {
this.updatePatterns(dtos);
}, error => {
this.ctx.notifyError(error);
this.dialogs.notifyError(error);
});
}
public addPattern(pattern: AppPatternDto) {
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 => {
this.updatePatterns(this.appPatterns.addPattern(dto.payload, dto.version));
}, error => {
this.ctx.notifyError(error);
this.dialogs.notifyError(error);
});
}
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 => {
this.updatePatterns(this.appPatterns.updatePattern(pattern.update(update), dto.version));
}, error => {
this.ctx.notifyError(error);
this.dialogs.notifyError(error);
});
}
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 => {
this.updatePatterns(this.appPatterns.deletePattern(pattern, dto.version));
}, error => {
this.ctx.notifyError(error);
this.dialogs.notifyError(error);
});
}
@ -81,7 +80,5 @@ export class PatternsPageComponent implements OnInit {
return a.name.localeCompare(b.name);
}),
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">
<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 { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import {
ApiUrlConfig,
AppContext,
AppPlansDto,
AppsState,
AuthService,
ChangePlanDto,
DialogService,
PlansService
} from '@app/shared';
@Component({
selector: 'sqx-plans-page',
styleUrls: ['./plans-page.component.scss'],
templateUrl: './plans-page.component.html',
providers: [
AppContext
]
templateUrl: './plans-page.component.html'
})
export class PlansPageComponent implements OnDestroy, OnInit {
private queryParamsSubscription: Subscription;
@ -35,9 +35,13 @@ export class PlansPageComponent implements OnDestroy, OnInit {
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 apiUrl: ApiUrlConfig
private readonly route: ActivatedRoute
) {
}
@ -47,7 +51,7 @@ export class PlansPageComponent implements OnDestroy, OnInit {
public ngOnInit() {
this.queryParamsSubscription =
this.ctx.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe(params => {
this.overridePlanId = params['planId'];
});
@ -55,7 +59,7 @@ export class PlansPageComponent implements OnDestroy, OnInit {
}
public load(showInfo = false) {
this.plansService.getPlans(this.ctx.appName)
this.plansService.getPlans(this.appsState.appName)
.subscribe(dto => {
if (this.overridePlanId) {
this.plans = dto.changePlanId(this.overridePlanId);
@ -63,30 +67,31 @@ export class PlansPageComponent implements OnDestroy, OnInit {
this.plans = dto;
}
this.planOwned = !dto.planOwner || (dto.planOwner === this.ctx.userId);
this.planOwned = !dto.planOwner || (dto.planOwner === this.authState.user!.id);
if (showInfo) {
this.ctx.notifyInfo('Plans reloaded.');
this.dialogs.notifyInfo('Plans reloaded.');
}
}, error => {
this.ctx.notifyError(error);
this.dialogs.notifyError(error);
});
}
public changePlan(planId: string) {
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 => {
if (dto.payload.redirectUri && dto.payload.redirectUri.length > 0) {
window.location.href = dto.payload.redirectUri;
} else {
this.plans = this.plans.changePlanId(planId, dto.version);
this.isDisabled = false;
}
}, error => {
this.ctx.notifyError(error);
this.isDisabled = false;
this.dialogs.notifyError(error);
});
}
}

Loading…
Cancel
Save