From 0d3c2f6c5156a2abe86bbd83f4f5d6c491285ced Mon Sep 17 00:00:00 2001 From: flaurens Date: Wed, 27 Jan 2021 09:23:51 +0100 Subject: [PATCH 1/5] refactor(login): set login page as the landing page + redirect to the dashboard --- src/app/app-routing.module.ts | 3 ++- src/app/main/login/login.component.ts | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 60d0737ded..2341718a11 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component'; const routes: Routes = [ { path: '', - component: MainComponent + component: LoginComponent + // component: MainComponent }, { path: 'help', diff --git a/src/app/main/login/login.component.ts b/src/app/main/login/login.component.ts index d4122147bc..830902d192 100644 --- a/src/app/main/login/login.component.ts +++ b/src/app/main/login/login.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; +import { SessionService } from '@dasch-swiss/dsp-ui'; import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service'; @Component({ @@ -15,6 +16,7 @@ export class LoginComponent implements OnInit { constructor (private _titleService: Title, private _route: ActivatedRoute, private _router: Router, + private _session: SessionService, private _componentCommsService: ComponentCommunicationEventService) { // set the page title @@ -26,13 +28,21 @@ export class LoginComponent implements OnInit { ngOnInit() { } - refresh(status: boolean) { + refresh() { + // check if a session is active + if (this._session.getSession()) { + this._router.navigate(['dashboard']); + } + } + + // TO REPLACE THE METHOD ABOVE ONCE WE WILL USE DSP-APP AS A RESEARCH PLATFORM AGAIN + /* refresh(status: boolean) { // go to previous route: if (status) { this._router.navigate([this.returnUrl]); this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true)); } - } + } */ } From 72b09fe6ff28ca518ac0de415f64013b7f42ee56 Mon Sep 17 00:00:00 2001 From: flaurens Date: Wed, 27 Jan 2021 11:35:06 +0100 Subject: [PATCH 2/5] refactor(login): remove argument --- src/app/main/login/login.component.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/main/login/login.component.html b/src/app/main/login/login.component.html index 44148f9c53..046de23531 100644 --- a/src/app/main/login/login.component.html +++ b/src/app/main/login/login.component.html @@ -1,3 +1,4 @@ From 346cb8b0d759458536f33197d8b412fe5c8ba809 Mon Sep 17 00:00:00 2001 From: flaurens Date: Wed, 27 Jan 2021 14:08:08 +0100 Subject: [PATCH 3/5] doc(login): add comment --- src/app/main/login/login.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/main/login/login.component.html b/src/app/main/login/login.component.html index 046de23531..8f4cb462bb 100644 --- a/src/app/main/login/login.component.html +++ b/src/app/main/login/login.component.html @@ -1,4 +1,4 @@ From 27bc05cb9be1bab8e42d16c32ae79fafbba98526 Mon Sep 17 00:00:00 2001 From: flaurens Date: Wed, 27 Jan 2021 16:39:53 +0100 Subject: [PATCH 4/5] refactor(login): reverse previous change in html --- src/app/main/login/login.component.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/main/login/login.component.html b/src/app/main/login/login.component.html index 8f4cb462bb..44148f9c53 100644 --- a/src/app/main/login/login.component.html +++ b/src/app/main/login/login.component.html @@ -1,4 +1,3 @@ From 34e4acf1bc78474e4ff300fce3992b447fc3a02f Mon Sep 17 00:00:00 2001 From: flaurens Date: Wed, 27 Jan 2021 16:40:16 +0100 Subject: [PATCH 5/5] refactor(login): refactor refresh method + clean up --- src/app/main/login/login.component.ts | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/app/main/login/login.component.ts b/src/app/main/login/login.component.ts index 830902d192..431b0884f1 100644 --- a/src/app/main/login/login.component.ts +++ b/src/app/main/login/login.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; import { SessionService } from '@dasch-swiss/dsp-ui'; @@ -9,7 +9,7 @@ import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/m templateUrl: './login.component.html', styleUrls: ['./login.component.scss'] }) -export class LoginComponent implements OnInit { +export class LoginComponent { returnUrl: string; @@ -22,27 +22,17 @@ export class LoginComponent implements OnInit { // set the page title this._titleService.setTitle('Login'); - this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/'; + // this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/'; } - ngOnInit() { - } + refresh(status: boolean) { - refresh() { - // check if a session is active - if (this._session.getSession()) { + // go to the dashboard: + if (status && this._session.getSession()) { this._router.navigate(['dashboard']); - } - } - - // TO REPLACE THE METHOD ABOVE ONCE WE WILL USE DSP-APP AS A RESEARCH PLATFORM AGAIN - /* refresh(status: boolean) { - - // go to previous route: - if (status) { - this._router.navigate([this.returnUrl]); + // go to the previous route: this._router.navigate([this.returnUrl]); this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true)); } - } */ + } }