diff --git a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts index ce123c686..a87cd7bc3 100644 --- a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts +++ b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.ts @@ -9,8 +9,8 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { Observable, Subscription } from 'rxjs'; import { - AppContext, fadeAnimation, + DialogService, ImmutableArray, ModalView } from 'shared'; @@ -21,9 +21,6 @@ import { EventConsumerDto, EventConsumersService } from './../../services/event- selector: 'sqx-event-consumers-page', styleUrls: ['./event-consumers-page.component.scss'], templateUrl: './event-consumers-page.component.html', - providers: [ - AppContext - ], animations: [ fadeAnimation ] @@ -35,7 +32,8 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { public eventConsumerError = ''; public eventConsumers = ImmutableArray.empty(); - constructor(public readonly ctx: AppContext, + constructor( + private readonly dialogs: DialogService, private readonly eventConsumersService: EventConsumersService ) { } @@ -59,11 +57,11 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { this.eventConsumers = ImmutableArray.of(dtos); if (showInfo) { - this.ctx.notifyInfo('Event Consumers reloaded.'); + this.dialogs.notifyInfo('Event Consumers reloaded.'); } }, error => { if (showError) { - this.ctx.notifyError(error); + this.dialogs.notifyError(error); } }); } @@ -73,7 +71,7 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { .subscribe(() => { this.eventConsumers = this.eventConsumers.replaceBy('name', consumer.start()); }, error => { - this.ctx.notifyError(error); + this.dialogs.notifyError(error); }); } @@ -82,7 +80,7 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { .subscribe(() => { this.eventConsumers = this.eventConsumers.replaceBy('name', consumer.stop()); }, error => { - this.ctx.notifyError(error); + this.dialogs.notifyError(error); }); } @@ -91,7 +89,7 @@ export class EventConsumersPageComponent implements OnDestroy, OnInit { .subscribe(() => { this.eventConsumers = this.eventConsumers.replaceBy('name', consumer.reset()); }, error => { - this.ctx.notifyError(error); + this.dialogs.notifyError(error); }); } diff --git a/src/Squidex/app/features/administration/pages/users/user-page.component.ts b/src/Squidex/app/features/administration/pages/users/user-page.component.ts index d53e135e1..eabe23c0f 100644 --- a/src/Squidex/app/features/administration/pages/users/user-page.component.ts +++ b/src/Squidex/app/features/administration/pages/users/user-page.component.ts @@ -7,10 +7,10 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormBuilder, Validators } from '@angular/forms'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { Subscription } from 'rxjs'; -import { AppContext, ValidatorsEx } from 'shared'; +import { AuthService, ValidatorsEx } from 'shared'; import { UserDto } from './../../services/users.service'; import { UsersState } from './../../state/users.state'; @@ -18,10 +18,7 @@ import { UsersState } from './../../state/users.state'; @Component({ selector: 'sqx-user-page', styleUrls: ['./user-page.component.scss'], - templateUrl: './user-page.component.html', - providers: [ - AppContext - ] + templateUrl: './user-page.component.html' }) export class UserPageComponent implements OnDestroy, OnInit { private selectedUserSubscription: Subscription; @@ -55,10 +52,12 @@ export class UserPageComponent implements OnDestroy, OnInit { public isCurrentUser = false; - constructor(public readonly ctx: AppContext, + constructor( + private readonly authService: AuthService, private readonly formBuilder: FormBuilder, + private readonly route: ActivatedRoute, private readonly router: Router, - private readonly state: UsersState + private readonly usersState: UsersState ) { } @@ -68,7 +67,7 @@ export class UserPageComponent implements OnDestroy, OnInit { public ngOnInit() { this.selectedUserSubscription = - this.state.selectedUser.subscribe(user => this.setupAndPopulateForm(user!)); + this.usersState.selectedUser.subscribe(user => this.setupAndPopulateForm(user!)); } public save() { @@ -80,14 +79,14 @@ export class UserPageComponent implements OnDestroy, OnInit { const requestDto = this.userForm.value; if (!this.user) { - this.state.createUser(requestDto) + this.usersState.createUser(requestDto) .subscribe(user => { this.back(); }, error => { this.resetFormState(error.displayMessage); }); } else { - this.state.updateUser(this.user!, requestDto) + this.usersState.updateUser(this.user!, requestDto) .subscribe(() => { this.resetFormState(); }, error => { @@ -98,13 +97,13 @@ export class UserPageComponent implements OnDestroy, OnInit { } private back() { - this.router.navigate(['../'], { relativeTo: this.ctx.route, replaceUrl: true }); + this.router.navigate(['../'], { relativeTo: this.route, replaceUrl: true }); } private setupAndPopulateForm(user: UserDto | null) { this.user = user; - this.isCurrentUser = user !== null && user.id === this.ctx.userId; + this.isCurrentUser = user !== null && user.id === this.authService.user!.id; this.userForm.controls['password'].setValidators( user ? diff --git a/src/Squidex/app/features/administration/pages/users/users-page.component.html b/src/Squidex/app/features/administration/pages/users/users-page.component.html index d23dbcc26..325fe8cfd 100644 --- a/src/Squidex/app/features/administration/pages/users/users-page.component.html +++ b/src/Squidex/app/features/administration/pages/users/users-page.component.html @@ -56,7 +56,7 @@
- +
@@ -88,7 +88,7 @@ - +