intermediate commit

This commit is contained in:
lotte
2018-08-29 15:12:01 +02:00
parent 2cbe6a6d91
commit 777facf5cd
91 changed files with 1150 additions and 964 deletions

View File

@@ -1,12 +1,15 @@
import { filter, takeWhile, map } from 'rxjs/operators';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { AuthenticateAction, ResetAuthenticationMessagesAction } from '../../core/auth/auth.actions';
import {
AuthenticateAction,
ResetAuthenticationMessagesAction
} from '../../core/auth/auth.actions';
import {
getAuthenticationError,
@@ -99,7 +102,7 @@ export class LogInComponent implements OnDestroy, OnInit {
*/
public ngOnInit() {
// set isAuthenticated
this.isAuthenticated = this.store.select(isAuthenticated);
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
// set formGroup
this.form = this.formBuilder.group({
@@ -108,29 +111,35 @@ export class LogInComponent implements OnDestroy, OnInit {
});
// set error
this.error = this.store.select(getAuthenticationError)
.map((error) => {
this.error = this.store.pipe(select(
getAuthenticationError),
map((error) => {
this.hasError = (isNotEmpty(error));
return error;
});
})
);
// set error
this.message = this.store.select(getAuthenticationInfo)
.map((message) => {
this.message = this.store.pipe(
select(getAuthenticationInfo),
map((message) => {
this.hasMessage = (isNotEmpty(message));
return message;
});
})
);
// set loading
this.loading = this.store.select(isAuthenticationLoading);
this.loading = this.store.pipe(select(isAuthenticationLoading));
// subscribe to success
this.store.select(isAuthenticated)
.takeWhile(() => this.alive)
.filter((authenticated) => authenticated)
this.store.pipe(
select(isAuthenticated),
takeWhile(() => this.alive),
filter((authenticated) => authenticated),)
.subscribe(() => {
this.authService.redirectToPreviousUrl();
});
this.authService.redirectToPreviousUrl();
}
);
}
/**