Skip to content
Permalink
Browse files
refactor!: set up the login page as a starting page (DSP-1292) (#370)
* refactor(login): set login page as the landing page + redirect to the dashboard

* refactor(login): remove argument

* doc(login): add comment

* refactor(login): reverse previous change in html

* refactor(login): refactor refresh method + clean up

Co-authored-by: flaurens <flavie.laurens@unibas.ch>
  • Loading branch information
flavens and flaurens committed Jan 28, 2021
1 parent 50b1309 commit 46dfdbba13adff1dc40eb5bb8422a3093b1e8b74
Showing with 11 additions and 10 deletions.
  1. +2 −1 src/app/app-routing.module.ts
  2. +9 −9 src/app/main/login/login.component.ts
@@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component';
const routes: Routes = [
{
path: '',
component: MainComponent
component: LoginComponent
// component: MainComponent
},
{
path: 'help',
@@ -1,36 +1,36 @@
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';
import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
export class LoginComponent {

returnUrl: string;

constructor (private _titleService: Title,
private _route: ActivatedRoute,
private _router: Router,
private _session: SessionService,
private _componentCommsService: ComponentCommunicationEventService) {

// set the page title
this._titleService.setTitle('Login');

this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/';
}

ngOnInit() {
// this.returnUrl = this._route.snapshot.queryParams['returnUrl'] || '/';
}

refresh(status: boolean) {

// go to previous route:
if (status) {
this._router.navigate([this.returnUrl]);
// go to the dashboard:
if (status && this._session.getSession()) {
this._router.navigate(['dashboard']);
// go to the previous route: this._router.navigate([this.returnUrl]);
this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true));
}
}

0 comments on commit 46dfdbb

Please sign in to comment.