Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ #63 remove login modal and redirect instead #65

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ShellComponent } from './shell/shell.component';
import { MetaDataState } from './shared/store/meta-data.state';
import { FooterComponent } from './footer/footer.component';
import { MaterialModule } from './shared/material/material.module';
import { RegistrationComponent } from './shared/modals/registration/registration.component';
import { RegistrationModule } from './shared/modals/registration/registration.module';
import { UserRegistrationState } from './shared/store/user-registration.state';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
Expand All @@ -34,8 +33,7 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
HeaderComponent,
AppComponent,
ShellComponent,
FooterComponent,
RegistrationComponent
FooterComponent
],
imports: [

Expand Down Expand Up @@ -66,7 +64,8 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
MaterialModule,
FormsModule,
RegistrationModule,
MatSnackBarModule
MatSnackBarModule,

],
providers: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

</div>
<ng-template #isUnauthorized>
<button mat-raised-button (click)="openModal()">
<button mat-raised-button (click)="login()">
Увійти
</button>
</ng-template>
Expand Down
15 changes: 8 additions & 7 deletions src/app/header/header.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';

import { RegistrationComponent } from '../shared/modals/registration/registration.component';
import { Actions, ofAction, Select, Store } from '@ngxs/store';
import { UserRegistrationState } from '../shared/store/user-registration.state';
import { Observable } from 'rxjs';
import { Logout, CheckAuth, AuthFail } from '../shared/store/user-registration.actions';
import { Logout, CheckAuth, AuthFail, Login } from '../shared/store/user-registration.actions';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';


@Component({
Expand All @@ -26,11 +26,12 @@ export class HeaderComponent implements OnInit {
constructor(private modalDialog: MatDialog,
public store: Store,
private actions$: Actions,
public snackBar: MatSnackBar) {
public snackBar: MatSnackBar,
private router: Router) {
actions$.pipe(
ofAction(AuthFail)
).subscribe(action => {
this.snackBar.open('Check your connection', "Try again!", {
this.snackBar.open('Check your connection', 'Try again!', {
duration: 5000,
panelClass: ['red-snackbar'],
});
Expand All @@ -40,10 +41,10 @@ export class HeaderComponent implements OnInit {
ngOnInit(): void {
this.store.dispatch(new CheckAuth())
}
openModal() {
this.modalDialog.open(RegistrationComponent);
}
logout(): void {
this.store.dispatch(new Logout())
}
login(): void{
this.store.dispatch(new Login())
}
}
12 changes: 0 additions & 12 deletions src/app/shared/modals/registration/registration.component.html

This file was deleted.

18 changes: 0 additions & 18 deletions src/app/shared/modals/registration/registration.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/shared/store/user-registration.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class UserRegistrationState {
@Action(Login)
Login({ dispatch }: StateContext<UserRegistrationStateModel>): void {
this.oidcSecurityService.authorize();
dispatch(new CheckAuth());
}
@Action(Logout)
Logout({ dispatch }: StateContext<UserRegistrationStateModel>): void {
Expand Down