mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Added @Input to the log-in component that indicates whether the component is being used in the standalone login page or the drop-down.
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
<div>
|
||||
<img class="mb-4 login-logo" src="assets/images/dspace-logo.png">
|
||||
<h1 class="h3 mb-0 font-weight-normal">{{"login.form.header" | translate}}</h1>
|
||||
<ds-log-in></ds-log-in>
|
||||
<ds-log-in
|
||||
[isStandalonePage]="true"></ds-log-in>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -3,7 +3,8 @@
|
||||
<div ngbDropdown placement="bottom-right" class="d-inline-block" @fadeInOut>
|
||||
<a href="#" id="dropdownLogin" (click)="$event.preventDefault()" ngbDropdownToggle class="px-1">{{ 'nav.login' | translate }}</a>
|
||||
<div id="loginDropdownMenu" [ngClass]="{'pl-3 pr-3': (loading | async)}" ngbDropdownMenu aria-labelledby="dropdownLogin">
|
||||
<ds-log-in></ds-log-in>
|
||||
<ds-log-in
|
||||
[isStandalonePage]="false"></ds-log-in>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
@@ -58,8 +58,7 @@ describe('LogInComponent', () => {
|
||||
{provide: AuthService, useClass: AuthServiceStub},
|
||||
{provide: APP_BASE_HREF, useValue: '/'},
|
||||
{provide: Router, useClass: RouterStub},
|
||||
{provide: RouteService, useValue: routeServiceStub },
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(900) }
|
||||
{provide: RouteService, useValue: routeServiceStub }
|
||||
],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
@@ -151,6 +150,8 @@ describe('LogInComponent', () => {
|
||||
const authService: AuthService = TestBed.get(AuthService);
|
||||
spyOn(authService, 'setRedirectUrl');
|
||||
|
||||
component.isStandalonePage = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(authService.setRedirectUrl).not.toHaveBeenCalledWith();
|
||||
|
||||
@@ -193,8 +194,7 @@ describe('LogInComponent on small screen', () => {
|
||||
{provide: AuthService, useClass: AuthServiceStub},
|
||||
{provide: APP_BASE_HREF, useValue: '/'},
|
||||
{provide: Router, useClass: RouterStub},
|
||||
{provide: RouteService, useValue: routeServiceStub },
|
||||
{provide: HostWindowService, useValue: new HostWindowServiceStub(300) }
|
||||
{provide: RouteService, useValue: routeServiceStub }
|
||||
],
|
||||
schemas: [
|
||||
CUSTOM_ELEMENTS_SCHEMA
|
||||
@@ -230,6 +230,7 @@ describe('LogInComponent on small screen', () => {
|
||||
it('should set the redirect url on init', () => {
|
||||
const authService: AuthService = TestBed.get(AuthService);
|
||||
spyOn(authService, 'setRedirectUrl');
|
||||
component.isStandalonePage = true;
|
||||
fixture.detectChanges();
|
||||
// set FormControl values
|
||||
component.form.controls.email.setValue('user');
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import {filter, map, pairwise, take, takeUntil, takeWhile, tap} from 'rxjs/operators';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { select, Store } from '@ngrx/store';
|
||||
@@ -86,13 +86,14 @@ export class LogInComponent implements OnDestroy, OnInit {
|
||||
|
||||
private redirectUrl = LOGIN_ROUTE;
|
||||
|
||||
@Input() isStandalonePage: boolean;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {AuthService} authService
|
||||
* @param {FormBuilder} formBuilder
|
||||
* @param {RouteService} routeService
|
||||
* @param {Router} router
|
||||
* @param {HostWindowService} windowService
|
||||
* @param {Store<State>} store
|
||||
*/
|
||||
constructor(
|
||||
@@ -100,7 +101,6 @@ export class LogInComponent implements OnDestroy, OnInit {
|
||||
private formBuilder: FormBuilder,
|
||||
private routeService: RouteService,
|
||||
private router: Router,
|
||||
private windowService: HostWindowService,
|
||||
private store: Store<CoreState>
|
||||
) {
|
||||
}
|
||||
@@ -114,17 +114,14 @@ export class LogInComponent implements OnDestroy, OnInit {
|
||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||
|
||||
// for mobile login, set the redirect url to the previous route
|
||||
this.windowService.isXs().pipe(take(1))
|
||||
.subscribe((isMobile) => {
|
||||
if (isMobile) {
|
||||
this.routeService.getHistory().pipe(
|
||||
take(1)
|
||||
).subscribe((history) => {
|
||||
const previousIndex = history.length - 2;
|
||||
this.setRedirectUrl(history[previousIndex]);
|
||||
});
|
||||
}
|
||||
if (this.isStandalonePage) {
|
||||
this.routeService.getHistory().pipe(
|
||||
take(1)
|
||||
).subscribe((history) => {
|
||||
const previousIndex = history.length - 2;
|
||||
this.setRedirectUrl(history[previousIndex]);
|
||||
});
|
||||
}
|
||||
|
||||
// set formGroup
|
||||
this.form = this.formBuilder.group({
|
||||
|
Reference in New Issue
Block a user