Skip to content

Commit

Permalink
refactor!: set up the login page as a starting page (DSP-1292) (#370)
Browse files Browse the repository at this point in the history
* 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 46dfdbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/app/app-routing.module.ts
Expand Up @@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component';
const routes: Routes = [
{
path: '',
component: MainComponent
component: LoginComponent
// component: MainComponent
},
{
path: 'help',
Expand Down
18 changes: 9 additions & 9 deletions src/app/main/login/login.component.ts
@@ -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));
}
}
Expand Down

0 comments on commit 46dfdbb

Please sign in to comment.