mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Boolean isStandalonePage injected
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, Injector, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { AuthMethodModel } from '../../core/auth/models/auth-method.model';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
||||
import { CoreState } from '../../core/core.reducers';
|
||||
import { InjectedAuthMethodModel } from './injectedAuthMethodModel/injectedAuthMethodModel';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-log-in',
|
||||
templateUrl: './log-in.component.html',
|
||||
styleUrls: ['./log-in.component.scss']
|
||||
})
|
||||
export class LogInComponent implements OnInit {
|
||||
export class LogInComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* The authentication methods data
|
||||
* @type {AuthMethodModel[]}
|
||||
*/
|
||||
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
||||
|
||||
private authMethods: AuthMethodModel[];
|
||||
|
||||
private injectedAuthMethods: InjectedAuthMethodModel[];
|
||||
|
||||
@Input() isStandalonePage: boolean;
|
||||
|
||||
/**
|
||||
@@ -30,13 +35,22 @@ export class LogInComponent implements OnInit {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public loading: Observable<boolean>;
|
||||
private subscription: Subscription;
|
||||
|
||||
constructor( private store: Store<CoreState>) {
|
||||
constructor(private store: Store<CoreState>) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.authMethodData = this.store.pipe(select(getAuthenticationMethods));
|
||||
|
||||
this.subscription = this.authMethodData.subscribe((methods) => this.authMethods = methods);
|
||||
this.injectedAuthMethods = new Array<InjectedAuthMethodModel>();
|
||||
// tslint:disable-next-line:forin
|
||||
for (const index in this.authMethods) {
|
||||
const injectedAuthMethod = new InjectedAuthMethodModel(this.authMethods[index].authMethodType, this.authMethods[index].location, this.isStandalonePage);
|
||||
this.injectedAuthMethods.push(injectedAuthMethod);
|
||||
}
|
||||
|
||||
// set loading
|
||||
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||
|
||||
@@ -44,4 +58,8 @@ export class LogInComponent implements OnInit {
|
||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user